📄 selldlg.cpp
字号:
*pResult = 0;
}
//DEL void CSellDlg::OnEditchangeComboClassname()
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL
//DEL }
void CSellDlg::OnSelchangeComboClassname() //在使用此事件时要设置为Drop List
{
// TODO: Add your control notification handler code here
CString strSQL, strClassName;
this->m_sum = "0.00";
UpdateData(FALSE);
GetDlgItemText(IDC_COMBO_CLASSNAME, strClassName);
if(strClassName == "")
{
return;
}
m_price = "0.00";
UpdateData(FALSE);
strSQL.Format("SELECT GoodName FROM _tClass INNER JOIN \
_tGoodsLibrary ON _tClass.ClassID = _tGoodsLibrary.ClassID \
Where _tClass.ClassName = '%s'", strClassName);
m_ds->ExecuteSQL(strSQL);
CString str_tmp1;
int nRecordCount = 0;
nRecordCount = m_ds->GetRecordCount();
m_comboGoodName.ResetContent();
for(int i = 0; i < nRecordCount; i++)
{
str_tmp1 = m_ds->GetAsString("GoodName");
m_comboGoodName.InsertString(i, str_tmp1);
m_ds->MoveNext();
}
}
//DEL void CSellDlg::OnEditchangeComboClassname()
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL
//DEL }
//DEL void CSellDlg::OnSelendokComboClassname()
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL
//DEL }
//DEL void CSellDlg::OnCloseupComboClassname()
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL
//DEL }
//DEL void CSellDlg::OnKillfocusComboClassname()
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL
//DEL
//DEL }
//DEL void CSellDlg::OnKillfocusComboGoodname()
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL
//DEL
//DEL
//DEL
//DEL
//DEL /*
//DEL int nRecordCount = 0;
//DEL nRecordCount = m_ds->GetRecordCount();
//DEL m_comboGoodName.ResetContent();
//DEL for(int i = 0; i < nRecordCount; i++)
//DEL {
//DEL str_tmp1 = m_ds->GetAsString("GoodName");
//DEL m_comboGoodName.InsertString(i, str_tmp1);
//DEL m_ds->MoveNext();
//DEL }
//DEL */
//DEL }
//DEL void CSellDlg::OnSelendcancelComboClassname()
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL
//DEL }
//DEL void CSellDlg::OnEditupdateComboClassname()
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL
//DEL
//DEL }
//DEL void CSellDlg::OnDropdownComboClassname()
//DEL {
//DEL // TODO: Add your control notification handler code here
//DEL
//DEL }
void CSellDlg::OnSelchangeComboGoodname()
{
// TODO: Add your control notification handler code here
this->m_sum = "0.00";
UpdateData(FALSE);
CString strSQL, strGoodName;
GetDlgItemText(IDC_COMBO_GOODNAME, strGoodName);
if(strGoodName == "")
{
return;
}
strSQL.Format("SELECT OutPrice FROM _tGoodsLibrary Where GoodName = '%s'", strGoodName);
m_ds->ExecuteSQL(strSQL);
CString str_tmp1;
str_tmp1 = m_ds->GetAsString("OutPrice");
this->m_price = str_tmp1;
UpdateData(FALSE);
}
void CSellDlg::OnEditchangeComboCustomerid()
{
// TODO: Add your control notification handler code here
//****************程序控制ComboBox的下拉******************
// 要用程序控制ComBoBox的下拉,代码如下:
/*//显示
sendmessage(combobox.handle,CB_SHOWDROPDOWN,1,0);
//隐藏
sendmessage(combobox.handle,CB_SHOWDROPDOWN,0,0);
如果要判断一个Combobox是否正在显示下拉列表,代码如下:
if GetWindowLong(combobox.handle,gwl_style) and cbs_dropdown=cbs_dropdown then ....
*/
CString strSQL, str_tmp1;
int nRecordCount = 0;
CString strInput;
m_listTEMP.ResetContent();
GetDlgItemText(IDC_COMBO_CUSTOMERID,strInput);
strInput += '%';
strSQL.Format("Select * From _tCustomer Where CustomerID like '%s'", strInput);
m_ds->ExecuteSQL(strSQL);
nRecordCount = m_ds->GetRecordCount();
if(nRecordCount >= 1)
{
m_listTEMP.ShowWindow(SW_SHOW);
}
if(nRecordCount <= 0)
{
m_listTEMP.ShowWindow(SW_HIDE);
}
for(int n = 0; n < nRecordCount; n++)
{
str_tmp1 = m_ds->GetAsString("CustomerID");
m_listTEMP.InsertString(n, str_tmp1);
m_ds->MoveNext();
}
}
void CSellDlg::OnKillfocusListTemp()
{
// TODO: Add your control notification handler code here
}
void CSellDlg::OnSelchangeListTemp()
{
// TODO: Add your control notification handler code here
int n = 0;
CString strCurSel, strSQL;
n = m_listTEMP.GetCurSel();
m_listTEMP.GetText(n, strCurSel);
m_comboCustomerID.SetWindowText(strCurSel);
m_listTEMP.ShowWindow(SW_HIDE);
strSQL.Format("Select * From _tCustomer Where CustomerID = '%s'", strCurSel);
m_ds->ExecuteSQL(strSQL);
this->m_customerID = m_ds->GetAsString("CustomerID");
this->m_address = m_ds->GetAsString("Address");
this->m_customerName = m_ds->GetAsString("CustomerName");
this->m_address = m_ds->GetAsString("Address");
this->m_tele = m_ds->GetAsString("TelePhone");
this->m_email = m_ds->GetAsString("E_mail");
this->m_qq = m_ds->GetAsString("QQ");
this->m_inteqral = m_ds->GetAsString("Inteqral");
UpdateData(FALSE);
}
void CSellDlg::OnChangeEditNum()
{
// 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
}
void CSellDlg::OnDeltaposSpinNum(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
// TODO: Add your control notification handler code here
this->m_sum = "0.00";
UpdateData(FALSE);
*pResult = 0;
}
void CSellDlg::OnBtnCalc()
{
// TODO: Add your control notification handler code here
//计算机总金额
UpdateData();
CString str_tmp1;
float fPrice;
fPrice = atof(this->m_price);
str_tmp1.Format("%f", fPrice);
float fNum;
fNum = atof(this->m_num);
str_tmp1.Format("%f", fNum);
float fSumMoney;
fSumMoney = fPrice * fNum;
str_tmp1.Format("%.2f", fSumMoney); //保留小数点后两位
this->m_sum = str_tmp1;
UpdateData(FALSE);
}
void CSellDlg::InitComboBox(CComboBox *combo)
{
//初始化类名ComboBox
CString str_tmp1;
int nRecordCount = 0;
m_ds->ExecuteSQL("Select * From _tClass");
nRecordCount = m_ds->GetRecordCount();
combo->ResetContent();
for(int i = 0; i < nRecordCount; i++)
{
str_tmp1 = m_ds->GetAsString("ClassName");
// m_comboClassName.InsertString(i,str_tmp1);
combo->InsertString(i,str_tmp1);
m_ds->MoveNext();
}
}
void CSellDlg::OnBtnAddcustomer()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString strBtn, strSQL;
GetDlgItemText(IDC_BTN_ADDCUSTOMER, strBtn);
if(strBtn == "新增客户")
{
this->m_comboCustomerID.SetWindowText("");
this->m_comboClassName.SetWindowText("");
SetDlgItemText(IDC_BTN_ADDCUSTOMER,"写入数据库");
((CEdit*)GetDlgItem(IDC_EDIT_ADDRESS))->SetReadOnly(FALSE);
((CEdit*)GetDlgItem(IDC_EDIT_TELE))->SetReadOnly(FALSE);
((CEdit*)GetDlgItem(IDC_EDIT_EMAIL))->SetReadOnly(FALSE);
((CEdit*)GetDlgItem(IDC_EDIT_QQ))->SetReadOnly(FALSE);
UpdateData(FALSE);
// ((CEdit*)GetDlgItem(IDC_EDIT_INTEQRAL))->SetReadOnly(FALSE);
}
else if(strBtn == "写入数据库")
{
if(this->m_customerID == "" || this->m_customerName == "" ||
this->m_address == "" || this->m_tele == "" ||
this->m_email == "")
{
MessageBox("您填写的客户资料不完整,请重试", "系统提示", MB_ICONINFORMATION | MB_OK);
((CEdit*)GetDlgItem(IDC_COMBO_CUSTOMERID))->SetSel(0, -1);
return;
}
strSQL.Format("Insert into _tCustomer(CustomerID, CustomerName, Address, TelePhone, E_mail, QQ) values('%s', '%s', '%s', '%s', '%s', '%s')", this->m_customerID, this->m_customerName, this->m_address, this->m_tele, this->m_email, this->m_qq);
m_ds->ExecuteOther(strSQL);
MessageBox("添加客户成功!!!", "系统提示", MB_ICONINFORMATION | MB_OK);
SetDlgItemText(IDC_BTN_ADDCUSTOMER,"新增客户");
}
}
void CSellDlg::OnDblclkListTemp()
{
// TODO: Add your control notification handler code here
m_listTEMP.ShowWindow(SW_HIDE);
}
BOOL CSellDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYDOWN)
{
if((pMsg->wParam==VK_RETURN)||(pMsg->wParam==VK_ESCAPE))
{
return TRUE;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -