void CDOutPut::OnBUTEnrol()
{
CTime tDate;
CString cID,cDate;
cID=theApp.AutoNumber("出库信息表","CK",2);
m_StaID.SetWindowText(cID);
tDate=tDate.GetCurrentTime();
cDate=theApp.CTimeToCString(tDate);
m_StaDate.SetWindowText(cDate);
m_ButEnrol.EnableWindow(false);
m_ButSave.EnableWindow(true);
m_ButUndo.EnableWindow(true);
m_ButExit.EnableWindow(false);
m_EdtClient.EnableWindow(true);
m_EdtClient.SetFocus();
}
void CDOutPut::OnBUTSave()
{
int a=MessageBox("确定保存此出库单吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION);
if(a==1)
{
CString cSQL,cStoreNumber,cID,cStore,cWareID,cTime,cProvider,cSum,cMoney,cNum;
int nOP,nStoreNumber,nStoreSum;
m_StaID.GetWindowText(cID);
m_StaDate.GetWindowText(cTime);
m_EdtClient.GetWindowText(cProvider);
m_EdtSum.GetWindowText(cSum);
m_EdtMoney.GetWindowText(cMoney);
nOP=theApp.NumberTOName("用户信息表","用户名",OP);
cSQL.Format("Insert Into 出库信息表 values(''%s'',#%s#,%s,%s,%d)",cID,cTime,cSum,cMoney,nOP);
cnn->Execute((_bstr_t)cSQL,NULL,adCmdText);
for(int r=0;r<m_Grid.GetItemCount()-1;r++)
{
cWareID=theApp.NumberTOName("商品信息表","编号","名称",m_Grid.GetItemText(r,0));
cNum=m_Grid.GetItemText(r,8);
cStore=m_Grid.GetItemText(r,6);
nStoreNumber=theApp.NumberTOName("仓库信息表","名称",cStore);
cSQL.Format("Insert Into 出库明细表 values(''%s'',''%s'',%d,%s)",cID,cWareID,nStoreNumber,cNum);
cnn->Execute((_bstr_t)cSQL,NULL,adCmdText);
//更新仓库信息表
cSQL.Format("SELECT * FROM 库存信息表 WHERE 商品编号=''%s'' and 仓库编号=%d ",cWareID,nStoreNumber);
rst=cnn->Execute((_bstr_t)cSQL,NULL,adCmdText);
if(theApp.GetRecordCount(rst)>0)
{
rst->MoveFirst();
cStoreNumber=(char*)(_bstr_t)rst->GetCollect("库存数量");
nStoreSum=atoi(cStoreNumber)-atoi(cNum);
cSQL.Format("UPDATE 库存信息表 set 库存数量=%d WHERE 商品编号=''%s'' and 仓库编号=%d",nStoreSum,cWareID,nStoreNumber);
cnn->Execute((_bstr_t)cSQL,NULL,adCmdText);
rst->Close();
}
}
m_ButEnrol.EnableWindow(true);
m_ButSave.EnableWindow(false);
m_ButUndo.EnableWindow(false);
m_ButExit.EnableWindow(true);
m_EdtClient.EnableWindow(false);
m_EdtClient.IsPopShow=false;
m_EdtClient.SetWindowText("");
m_Grid.ClearGrid();
this->m_ButEnrol.SetFocus();
}
}
void CDOutPut::OnBUTUndo()
{
int a=MessageBox("确定要撤消操作吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION);
if (a==1)
{
m_ButEnrol.EnableWindow(true);
m_ButSave.EnableWindow(false);
m_ButUndo.EnableWindow(false);
m_ButExit.EnableWindow(true);
m_EdtClient.EnableWindow(false);
m_EdtClient.IsPopShow=false;
m_EdtClient.SetWindowText("");
m_Grid.ClearGrid();
}
}
void CDOutPut::OnBUTExit()
{
this->OnCancel();
}
#if !defined(AFX_DOUTPUT_H__4310B5C1_66D7_11D8_8753_5254AB32C8FB__INCLUDED_)
#define AFX_DOUTPUT_H__4310B5C1_66D7_11D8_8753_5254AB32C8FB__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// DOutPut.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CDOutPut dialog
#include "RxGrid.h"
#include "ExtendEdit.h"
class CDOutPut : public CDialog
{
// Construction
public:
bool IsPopShow;
void ItemChange();
void SetOP(CString cOP);
CDOutPut(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CDOutPut)
enum { IDD = IDD_DIAOutput };
CStatic m_StaID;
CStatic m_StaDate;
CRxGrid m_Grid;
CEdit m_EdtSum;
CEdit m_EdtMoney;
CExtendEdit m_EdtClient;
CButton m_ButUndo;
CButton m_ButSave;
CButton m_ButExit;
CButton m_ButEnrol;
CString OP;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDOutPut)
public:
virtual BOOL DestroyWindow();
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CDOutPut)
virtual void OnOK();
virtual BOOL OnInitDialog();
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg void OnItemchangingList(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnBUTEnrol();
afx_msg void OnBUTSave();
afx_msg void OnBUTUndo();
afx_msg void OnBUTExit();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
bool IsShow;
HBRUSH m_hBrush;
_RecordsetPtr rst;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DOUTPUT_H__4310B5C1_66D7_11D8_8753_5254AB32C8FB__INCLUDED_)
相关热词:VC6.0 商品 库存 管理 信息 系统 源代码 论文
上一篇:ASP+SQL 2000学生选课系统论文-论文