else }
void CDBaseDlg::OnButcopy() //复制 { }
void CDBaseDlg::OnButundo() //撤消 { }
void CDBaseDlg::OnButsave() //保存 {
if(MessageBox(“确定要保存记录吗?”,”系统提示”,\\ MB_OKCANCEL|MB_ICONQUESTION)!=1)
return; RxRecordset rst;
rst.Open(m_DataBaseName); – 22 –
if(MessageBox(“确定要撤销操作吗?”,”系统提示”,\\ MB_OKCANCEL|MB_ICONQUESTION)!=1)
return; Clear(); Display(); Enabled(false);
Cstring sSmallCaption,sCaption; m_IsAdd=true; Enabled(true); Cstring NewNumber; RxRecordset rst;
sCaption=rst.GetFieldName(0); rst.Open(m_DataBaseName); Cstring sType=rst.GetFieldType(0); if(sType==”字符型”){ } else
sSmallCaption=CharToLetterCode(m_DataBaseName); sSmallCaption=sSmallCaption.Left(2);
rst.Open(sSQL,adCmdText); this->OnCancel();
吉林省明日科技有限公司监制
sSQL.Format(“DELETE FROM %s WHERE %s=%s”,m_DataBaseName,sID,sValue);
NewNumber=ado.AutoNumber(m_DataBaseName,m_Identify,sSmallCaption,m_NumberStyle);
NewNumber=ado.AutoNumber(m_DataBaseName,m_Identify,””,m_NumberStyle);
pEdt[0].SetWindowText(NewNumber); pEdt[1].SetFocus();
//将文本存入数组
Cstring sValue[50],sCaption[50],sType[50]; for(int I=0;I //组成新字符串 Cstring sValueString,str,sFiledString; if(m_IsAdd==true) { } else{ sValueString=””; sFiledString=””; for(I=0;I str=””; str=sValueString; if(sType[I]==”数值型”) else sValueString.Format(“%s,?%s?”,str,sValue[I]); str=””; str=sFiledString; sFiledString.Format(“%s,%s”,str,sCaption[I]); sValueString.Format(“%s,%s”,str,sValue[I]); sType[I]=rst.GetFieldType(i); pEdt[I].GetWindowText(sValue[I]); pSta[I].GetWindowText(sCaption[I]); sCaption[I]=sCaption[I].Left(sCaption[I].GetLength()-1); 吉林省明日科技有限公司监制 if(sValue[I].IsEmpty()==true && rst.IsNull(i)==true){//判断数据表中字段是否允许为空 } if(rst.GetFieldType(i)==”日期型”){ } if(IsTime(sValue[I])==false) { //判断用户输入的日期格式是否正确 } MessageBox(“请输入正确的日期格式,如“1983-06-16”、“83/6/16”等”,\\ pEdt[I].SetFocus(); return; “系统提示”,MB_OK|MB_ICONSTOP); MessageBox(“『”+sCaption[I]+”』 字段不允许为空!”,”系统提示”,\\ MB_OK|MB_ICONSTOP); pEdt[I].SetFocus(); return; – 23 – sValueString=””; } void CDBaseDlg::OnButexit() //退出 { } this->OnCancel(); } sFiledString=sFiledString.Right(sFiledString.GetLength()-1); Cstring sSQL; if(m_IsAdd==true) } if(rst.Open(sSQL,adCmdText)==false) { } this->Enabled(false); this->m_ButCommand[1].SetFocus(); sSQL.Format(“INSERT INTO %s (%s) VALUES(%s)”,\\ for(I=1;I str=””; str=sValueString; if(sType[I]==”数值型”) else sValueString.Format(“%s,%s=%s”,str,sCaption[I],sValue[I]); 吉林省明日科技有限公司监制 sValueString.Format(“%s,%s=?%s?”,str,sCaption[I],sValue[I]); m_DataBaseName,sFiledString,sValueString.Right(sValueString.GetLength()-1)); if(sType[0]==”数值型”) else sSQL.Format(“UPDATE %s SET %s WHERE %s=?%s?”,m_DataBaseName,\\ sValueString.Right(sValueString.GetLength()-1),sCaption[0],sValue[0]); sSQL.Format(“UPDATE %s SET %s WHERE %s=%s”,m_DataBaseName\\ sValueString.Right(sValueString.GetLength()-1),sCaption[0],sValue[0]); else{ MessageBox(“数据保存失败!”,”系统提示”,MB_OK|MB_ICONSTOP); pEdt[1].SetFocus(); return; 4.3 业务类 1.销售结款模块 实现目标 销售结款模块主要完成如下功能: ? – 24 – ? 吉林省明日科技有限公司监制 自动生成结款票号及开票日期。 ? 可以由销售开票单直接生成销售结款单,简化经手人的作业。 ? 提供预计偿还欠款日期设置。 ? 支持数据统计及金额核算功能。 ? 支持合计金额的大小写的转换功能。 ? 支持销售结款单据的打印。 销售结款及打印模块运行界面如图8所示。 图8 销售结款模块运行界面 设计步骤 (1)向项目中添加一个新Dialog资源,资源ID为IDD_OPERATION。从Controls面板上向Dialog资源中添加18个Static、4个Edit、1个ListControl、3个Button控件。IDD_OPERATION对应的类为CDOperation。 (2)与销售结款模块对应的类为CDCheck,它是从业务基类CDOperation直接派生而来。 ? 代码分析 重载父类纯虚函数,进行初始化设置。 ? void CDCheck::Init() { this->DrawCheck(); this->SetCaption(\销售结款\this->SetManTitle(\经 手 人:\this->SetNoteIDTitle(\结款票号:\this->SetStoreTitle(\销售票号:\this->SetOperationTitle(\客 户:\ this->SetGridHeader(\扫描码 , 商品名称 , 规格 , 产地 , 计量单位 , 销售数量 , \\ 销售单价 , 合计金额\ this->SetHeadersWidth(\ – 25 – RxRecordset rst; } CString sSQL; 吉林省明日科技有限公司监制 sSQL.Format(\往来单位信息表 WHERE 类型='客户'\rst.Open(sSQL,adCmdText); m_EdtOperation.Initialize(this->GetParent()); m_EdtOperation.StartUpAssciation=true;//启动联想输入 m_EdtOperation.SetRecordset(rst);//设置数据源 m_EdtOperation.SetSelectField(\全称\rst.Open(\员工信息表\ m_EdtMan.Initialize(this->GetParent()); m_EdtMan.SetRecordset(rst);//设置数据源 m_EdtMan.SetSelectField(\姓名\ sSQL.Format(\销售票号,b.全称,a.开票日期 FROM 销售记录表 a INNER EILJOIN 往来单rst.Open(sSQL,adCmdText); m_EdtStore.StartUpAssciation=true; m_EdtStore.Initialize(this->GetParent()); m_EdtStore.SetRecordset(rst);//设置数据源 m_EdtStore.SetSelectField(\销售票号\m_Grid.m_Edit.PopHide=true; m_Grid.m_Edit.Initialize(this->GetParent()); m_Grid.m_Edit.SetRecordset(rst);//设置数据源 m_Grid.m_Edit.SetSelectField(\仓库名称\m_Grid.m_bReadOnly=true; 位信息表 b ON a.客户编号=b.编号 AND 结款否=0\ 重载父类中“登记”按钮的消息响应函数: void CDCheck::OnButEnrol() { this->m_EdtMan.IsShowing=true; this->m_EdtMan.SetWindowText(\this->m_EdtMan.IsShowing=false; this->m_EdtOperation.IsShowing=true; this->m_EdtOperation.SetWindowText(\this->m_EdtOperation.IsShowing=false; this->m_EdtStore.IsShowing=true; this->m_EdtStore.SetWindowText(\this->m_EdtStore.IsShowing=false; this->m_StaBigTotal.SetWindowText(\零元\this->m_StaTotal.SetWindowText(\this->m_StaSumNumber.SetWindowText(\Clear(); – 26 –