ClientEditDlg.cpp
资源名称:SQLVC.rar [点击查看]
上传用户:biney012
上传日期:2022-05-09
资源大小:4592k
文件大小:3k
源码类别:
数据库系统
开发平台:
Visual C++
- // ClientEditDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "Stock.h"
- #include "ClientEditDlg.h"
- #include "Client.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CClientEditDlg dialog
- CClientEditDlg::CClientEditDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CClientEditDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CClientEditDlg)
- m_Address = _T("");
- m_Cname = _T("");
- m_Contact = _T("");
- m_Fax = _T("");
- m_Memo = _T("");
- m_Phone = _T("");
- m_Postcode = _T("");
- //}}AFX_DATA_INIT
- }
- void CClientEditDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CClientEditDlg)
- DDX_Control(pDX, IDC_CTYPE_COMBO, m_Ctype);
- DDX_Text(pDX, IDC_ADDRESS_EDIT, m_Address);
- DDX_Text(pDX, IDC_CNAME_EDIT, m_Cname);
- DDX_Text(pDX, IDC_CONTACT_EDIT, m_Contact);
- DDX_Text(pDX, IDC_FAX_EDIT, m_Fax);
- DDX_Text(pDX, IDC_MEMO_EDIT, m_Memo);
- DDX_Text(pDX, IDC_PHONE_EDIT, m_Phone);
- DDX_Text(pDX, IDC_POSTCODE_EDIT, m_Postcode);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CClientEditDlg, CDialog)
- //{{AFX_MSG_MAP(CClientEditDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CClientEditDlg message handlers
- BOOL CClientEditDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- m_Ctype.SetCurSel(iCtype - 1);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CClientEditDlg::OnOK()
- {
- // 将用户输入数据读取到成员变量中
- UpdateData(TRUE);
- // 检查用户输入数据的有效性
- if (m_Cname == "")
- {
- MessageBox("请输入客户单位");
- return;
- }
- if (m_Contact == "")
- {
- MessageBox("请输入联系人");
- return;
- }
- //将成员变量赋值到clt对象,并保存到数据库
- CClient clt;
- clt.SetCname(m_Cname); //客户单位
- clt.SetCtype(m_Ctype.GetCurSel() + 1); //客户类型
- clt.SetContact(m_Contact); //联系人
- clt.SetAddress(m_Address); //通信地址
- clt.SetPostcode(m_Postcode); //邮政编码
- clt.SetPhone(m_Phone); //联系电话
- clt.SetFax(m_Fax); //传真电话
- clt.SetMemo(m_Memo); //备注
- if (cCid == "") //插入数据
- if (clt.HaveName(m_Cname) == 1)
- {
- MessageBox(m_Cname);
- MessageBox("当前客户已经存在,请重新输入客户单位");
- return;
- }
- else
- clt.sql_insert();
- else //更新数据
- if (m_Cname != cCname && clt.HaveName(m_Cname) == 1)
- {
- MessageBox("当前客户已经存在,请重新输入客户单位");
- return;
- }
- else
- clt.sql_update(cCid);
- //关闭对话框
- CDialog::OnOK();
- }