ProEditDlg.cpp
资源名称:SQLVC.rar [点击查看]
上传用户:biney012
上传日期:2022-05-09
资源大小:4592k
文件大小:2k
源码类别:
数据库系统
开发平台:
Visual C++
- // ProEditDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "Stock.h"
- #include "ProEditDlg.h"
- #include "Product.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CProEditDlg dialog
- CProEditDlg::CProEditDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CProEditDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CProEditDlg)
- m_Alarm = 0;
- m_Phigh = 0;
- m_Plow = 0;
- m_Pname = _T("");
- m_Pprice = 0.0f;
- m_Pstyle = _T("");
- m_Ptype = _T("");
- m_Punit = _T("");
- m_Valid = 0;
- //}}AFX_DATA_INIT
- }
- void CProEditDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CProEditDlg)
- DDX_Text(pDX, IDC_ALARM_EDIT, m_Alarm);
- DDX_Text(pDX, IDC_PHIGH_EDIT, m_Phigh);
- DDX_Text(pDX, IDC_PLOW_EDIT, m_Plow);
- DDX_Text(pDX, IDC_PNAME_EDIT, m_Pname);
- DDX_Text(pDX, IDC_PPRICE_EDIT, m_Pprice);
- DDX_Text(pDX, IDC_PSTYLE_EDIT, m_Pstyle);
- DDX_Text(pDX, IDC_PTYPE_STATIC, m_Ptype);
- DDX_Text(pDX, IDC_PUNIT_EDIT, m_Punit);
- DDX_Text(pDX, IDC_VALID_EDIT, m_Valid);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CProEditDlg, CDialog)
- //{{AFX_MSG_MAP(CProEditDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CProEditDlg message handlers
- void CProEditDlg::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData(TRUE); //将数据读取到成员变量
- if (m_Pname == "")
- {
- MessageBox("请输入产品名称");
- return;
- }
- CProduct pr;
- pr.SetPname(m_Pname); //产品名称
- pr.SetTypeId(iTypeId); //产品类别
- pr.SetPprice(m_Pprice); //参考价格
- pr.SetPstyle(m_Pstyle); //产品规格
- pr.SetPunit(m_Punit); //计量单位
- pr.SetPlow(m_Plow); //数量下限
- pr.SetPhigh(m_Phigh); //数量上限
- pr.SetValid(m_Valid); //有效期
- pr.SetAlarmDays(m_Alarm); //警告期
- if (cPid == "") //表示插入记录
- if (pr.HaveName(m_Pname) == 1)
- {
- MessageBox("当前产品名称已经存在,请重新输入");
- return;
- }
- else
- pr.sql_insert();
- else
- if (m_Pname != cPname && pr.HaveName(m_Pname) == 1)
- {
- MessageBox("当前产品名称已经存在,请重新输入");
- return;
- }
- else
- pr.sql_update(cPid);
- CDialog::OnOK();
- }