📄 listitemeditdlg.cpp
字号:
// ListItemEditDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CarService.h"
#include "ListItemEditDlg.h"
#include "ListItem.h"
#include "Items.h"
#include "Registration.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CListItemEditDlg dialog
CListItemEditDlg::CListItemEditDlg(CWnd* pParent /*=NULL*/)
: CDialog(CListItemEditDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CListItemEditDlg)
m_Memo = _T("");
m_Sum = 0.0f;
m_Cost = 0.0f;
m_Count = 0.0f;
//}}AFX_DATA_INIT
}
void CListItemEditDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CListItemEditDlg)
DDX_Control(pDX, IDC_ADODC1, m_Adodc);
DDX_Control(pDX, IDC_DATACOMBO1, m_dcoItem);
DDX_Text(pDX, IDC_MEMO_EDIT, m_Memo);
DDX_Text(pDX, IDC_SUM_EDIT, m_Sum);
DDX_Text(pDX, IDC_COST_EDIT, m_Cost);
DDX_Text(pDX, IDC_COUNT_EDIT, m_Count);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CListItemEditDlg, CDialog)
//{{AFX_MSG_MAP(CListItemEditDlg)
ON_EN_CHANGE(IDC_COUNT_EDIT, OnChangeCountEdit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CListItemEditDlg message handlers
BOOL CListItemEditDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
if (cListId == "")
{
m_dcoItem.SetText(cItemName);
UpdateData(FALSE);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CListItemEditDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
if(m_dcoItem.GetText() == "")
{
MessageBox("请选择维修项目名称");
return;
}
//将用户输入的数据赋值到对象litem中,为更新数据库做准备
CListItem litem;
litem.RegId = atol(cRegId);
// 得到当前维修项目信息
litem.ItemId = atol(m_dcoItem.GetBoundText());
litem.ItemCount = m_Count;
litem.ItemSum = m_Sum;
litem.Memo = m_Memo;
//插入数据
litem.SqlInsert();
//转换数据类型
CString strSum;
strSum.Format("%lf",m_Sum);
//更新登记表中对应记录的iCost值
CRegistration reg;
reg.UpdateCost(cRegId,strSum,0,0);
CDialog::OnOK();
}
void CListItemEditDlg::OnChangeCountEdit()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
//修改数量同时,总金额同时修改
UpdateData(TRUE);
m_Sum = m_Count * m_Cost;
UpdateData(FALSE);
}
BEGIN_EVENTSINK_MAP(CListItemEditDlg, CDialog)
//{{AFX_EVENTSINK_MAP(CListItemEditDlg)
ON_EVENT(CListItemEditDlg, IDC_DATACOMBO1, -600 /* Click */, OnClickDatacombo1, VTS_I2)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CListItemEditDlg::OnClickDatacombo1(short Area)
{
// TODO: Add your control notification handler code here
// 当选择项目时,显示项目单价
UpdateData(TRUE);
if (m_dcoItem.GetText() != "")
{
//读取项目信息
CItems cit;
cit.GetInfo(m_dcoItem.GetBoundText());
m_Cost = cit.ItemCost;
m_Sum = m_Cost * m_Count;
UpdateData(FALSE);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -