📄 dcheck.cpp
字号:
// DCheck.cpp: implementation of the CDCheck class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MyProject.h"
#include "DCheck.h"
#include "ExternDllHeader.h"
#include "DDLg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CDCheck::CDCheck()
{
}
CDCheck::~CDCheck()
{
}
void CDCheck::Init()
{
this->DrawCheck();
this->SetCaption("销售结款");
this->SetManTitle("经 手 人:");
this->SetNoteIDTitle("结款票号:");
this->SetStoreTitle("销售票号:");
this->SetOperationTitle("客 户:");
this->SetGridHeader("扫描码 , 商品名称 , 规格 , 产地 , 计量单位 , 销售数量 , 销售单价 , 合计金额");
this->SetHeadersWidth("70 , 100 , 60 , 100 , 74 , 74 , 74 , 76");
RxRecordset rst;
CString sSQL;
sSQL.Format("SELECT * FROM 往来单位信息表 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("SELECT a.销售票号,b.全称,a.开票日期 FROM 销售记录表 a INNER JOIN 往来单位信息表 b ON a.客户编号=b.编号 AND 结款否=0");
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;
}
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("0");
this->m_StaSumNumber.SetWindowText("0");
Clear();
CString sNewID;
sNewID=ado.AutoNumber("销售结款表","结款票号","JK",3);
this->m_StaIDValue.SetWindowText(sNewID);
this->m_StaIDValue.Invalidate();
this->Enabled(true);
this->m_EdtOperation.SetFocus();
}
void CDCheck::OnSetfocusEdtman()
{
CString sSQL,sID,sNumber,sMoney,sBigMoney;
m_EdtStore.GetWindowText(sID);
if(sID.IsEmpty())
{
this->m_Grid.m_bReadOnly=true;
return;
}
sSQL.Format("SELECT 条形码,名称 AS 商品名称,规格,产地,计量单位,销售数量,合计金额/销售数量 AS 销售单价, 合计金额 FROM 销售明细表 a INNER JOIN 商品信息表 b ON a.商品条形码=b.条形码 WHERE 销售票号='%s'",sID);
m_Grid.DeleteAllItems();
m_Grid.DeleAllCols();
m_Grid.SetDataBase(sSQL,adCmdText);
sSQL.Format("SELECT * FROM 销售记录表 WHERE 销售票号='%s'",sID);
RxRecordset rst;
rst.Open(sSQL,adCmdText);
sNumber=rst.GetFieldValue("合计数量");
sMoney=rst.GetFieldValue("合计金额");
this->m_StaSumNumber.SetWindowText(sNumber);
this->m_StaTotal.SetWindowText(sMoney);
sBigMoney=MoneyToChineseCode(sMoney);
this->m_StaBigTotal.SetWindowText(sBigMoney);
m_Grid.m_bReadOnly=true;
}
void CDCheck::OnButSave()
{
if(MessageBox("确定要保存吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString sNoPay,CheckTime;
this->m_StaNoPayValue.GetWindowText(sNoPay);
if(atoi(sNoPay)>0)
{
CDDlg dlg;
dlg.DoModal();
CheckTime=dlg.m_Time;
if(CheckTime.IsEmpty())
return;
}
CString sID,sSQL,sCode,sOperation,sDate,sMan,sOPID,sMoney,sPay;
this->m_StaIDValue.GetWindowText(sID);
this->m_EdtOperation.GetWindowText(sOperation);
this->m_EdtStore.GetWindowText(sCode);
this->m_StaDateValue.GetWindowText(sDate);
this->m_EdtMan.GetWindowText(sMan);
sMan=ado.FieldToOtherField("员工信息表","姓名",sMan,"编号",1);
sOPID=ado.FieldToOtherField("操作员信息表","用户名",OP,"操作员编号",1);
this->m_StaTotal.GetWindowText(sMoney);
this->m_EdtPay.GetWindowText(sPay);
if(sOperation.IsEmpty()==true)
{
MessageBox("请输入客户名称!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtOperation.SetFocus();
return;
}
if(sCode.IsEmpty()==true)
{
MessageBox("请输入销售票号!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtStore.SetFocus();
return;
}
if(sMan.IsEmpty()==true)
{
MessageBox("请输入经手人!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtMan.SetFocus();
return;
}
//存入销售结款表
sSQL.Format("INSERT INTO 销售结款表 VALUES('%s','%s','%s',%s,%s,%s,%s)",sID,sCode,sDate,sMoney,sPay,sMan,sOPID);
RxRecordset rst;
rst.Open(sSQL,adCmdText);
//存入销售挂帐表
if(atoi(sNoPay)>0)
{
sSQL.Format("INSERT INTO 销售挂帐表 VALUES('%s','%s','%s',%s,0)",sCode,sDate,CheckTime,sNoPay);
rst.Open(sSQL,adCmdText);
}
//更新销售记录表
sSQL.Format("UPDATE 销售记录表 SET 结款否 =1 WHERE 销售票号='%s'",sCode);
rst.Open(sSQL,adCmdText);
this->Enabled(false);
}
void CDCheck::OnRclickGrid(NMHDR *pNMHDR, LRESULT *pResult)
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -