CheckManDlg.cpp
资源名称:final.rar [点击查看]
上传用户:fangwenmm
上传日期:2014-06-18
资源大小:6955k
文件大小:5k
源码类别:
企业管理
开发平台:
Visual C++
- // CheckManDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "Stock.h"
- #include "CheckManDlg.h"
- #include "COMDEF.H"
- #include "Columns.h"
- #include "Column.h"
- #include "_recordset.h"
- #include "CheckEditDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CCheckManDlg dialog
- CCheckManDlg::CCheckManDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CCheckManDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CCheckManDlg)
- //}}AFX_DATA_INIT
- }
- void CCheckManDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CCheckManDlg)
- DDX_Control(pDX, IDC_ADODC1, m_adodc1);
- DDX_Control(pDX, IDC_ADODC2, m_adodc2);
- DDX_Control(pDX, IDC_ADODC3, m_adodc3);
- DDX_Control(pDX, IDC_ADODC5, m_adodc5);
- DDX_Control(pDX, IDC_ADODC6, m_adodc6);
- DDX_Control(pDX, IDC_DATAGRID1, m_datagrid);
- DDX_Control(pDX, IDC_PNAME_DATACOMBO, m_Pname);
- DDX_Control(pDX, IDC_PROTYPE1_DATACOMBO, m_ProType1);
- DDX_Control(pDX, IDC_PROTYPE2_DATACOMBO, m_ProType2);
- DDX_Control(pDX, IDC_STOREHOUSE_DATACOMBO, m_Storehouse);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CCheckManDlg, CDialog)
- //{{AFX_MSG_MAP(CCheckManDlg)
- ON_BN_CLICKED(IDC_MODI_BUTTON, OnModiButton)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CCheckManDlg message handlers
- void CCheckManDlg::Refresh_Data()
- {
- CString cPid; //保存当前选择的产品编号
- if (m_Pname.GetBoundText() == "")
- cPid = "0";
- else
- cPid = m_Pname.GetBoundText();
- CString cSid; //保存当前选择的仓库编号
- if (m_Storehouse.GetBoundText() == "")
- cSid = "0";
- else
- cSid = m_Storehouse.GetBoundText();
- //设置SELECT语句
- CString cSource;
- cSource = "SELECT SpId, Pprice As 产品入库单价, Pnum As 库存数量, MakeDate As 生产日期";
- cSource += " FROM ProInStore WHERE Pid=" + cPid + " AND Sid=" + cSid;
- //设置记录源
- m_adodc6.SetRecordSource(cSource);
- m_adodc6.Refresh();
- //设置表格列宽度
- _variant_t vIndex;
- vIndex = long(0);
- m_datagrid.GetColumns().GetItem(vIndex).SetWidth(0);
- vIndex = long(1);
- m_datagrid.GetColumns().GetItem(vIndex).SetWidth(180);
- vIndex = long(2);
- m_datagrid.GetColumns().GetItem(vIndex).SetWidth(180);
- vIndex = long(3);
- m_datagrid.GetColumns().GetItem(vIndex).SetWidth(180);
- }
- BEGIN_EVENTSINK_MAP(CCheckManDlg, CDialog)
- //{{AFX_EVENTSINK_MAP(CCheckManDlg)
- ON_EVENT(CCheckManDlg, IDC_PROTYPE1_DATACOMBO, -600 /* Click */, OnClickProtype1Datacombo, VTS_I2)
- ON_EVENT(CCheckManDlg, IDC_PROTYPE2_DATACOMBO, -600 /* Click */, OnClickProtype2Datacombo, VTS_I2)
- ON_EVENT(CCheckManDlg, IDC_PNAME_DATACOMBO, -600 /* Click */, OnClickPnameDatacombo, VTS_I2)
- ON_EVENT(CCheckManDlg, IDC_STOREHOUSE_DATACOMBO, -600 /* Click */, OnClickStorehouseDatacombo, VTS_I2)
- //}}AFX_EVENTSINK_MAP
- END_EVENTSINK_MAP()
- void CCheckManDlg::OnClickProtype1Datacombo(short Area)
- {
- //读取一级产品类别编号
- CString cUpperId;
- cUpperId = m_ProType1.GetBoundText();
- if (cUpperId == "")
- cUpperId = "0";
- //设置查询二级产品类型的SELECT语句
- CString cSource;
- cSource = "SELECT * FROM ProType WHERE UpperId=" + cUpperId;
- m_ProType2.SetText("");
- //设置m_adodc3,从而刷新二级产品类别的列表
- m_adodc2.SetRecordSource(cSource);
- m_adodc2.Refresh();
- //设置产品列表框,因为没有选中二级产品类别,所以要清空产品列表框
- cSource = "SELECT * FROM Product WHERE TypeId=0";
- m_Pname.SetText("");
- //设置m_adodc3,从而刷新二级产品类别的列表
- m_adodc3.SetRecordSource(cSource);
- m_adodc3.Refresh();
- //刷新库存产品表格
- Refresh_Data();
- }
- BOOL CCheckManDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- //刷新库存产品表格
- Refresh_Data();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CCheckManDlg::OnClickProtype2Datacombo(short Area)
- {
- //读取二级产品类别编号
- CString cTypeId;
- cTypeId = m_ProType2.GetBoundText();
- if (cTypeId == "")
- cTypeId = "0";
- //设置查询二级产品类型的SELECT语句
- CString cSource;
- cSource = "SELECT * FROM Product WHERE TypeId=" + cTypeId;
- m_Pname.SetText("");
- //设置m_adodc3,从而刷新二级产品类别的列表
- m_adodc3.SetRecordSource(cSource);
- m_adodc3.Refresh();
- //刷新库存产品表格
- Refresh_Data();
- }
- void CCheckManDlg::OnClickPnameDatacombo(short Area)
- {
- //刷新库存产品表格
- Refresh_Data();
- }
- void CCheckManDlg::OnClickStorehouseDatacombo(short Area)
- {
- //刷新库存产品表格
- Refresh_Data();
- }
- void CCheckManDlg::OnModiButton()
- {
- // TODO: Add your control notification handler code here
- if (m_adodc6.GetRecordset().GetEof())
- {
- MessageBox("请选择盘点记录");
- return;
- }
- CCheckEditDlg dlg;
- dlg.cSpId = m_datagrid.GetItem(0); //库存记录编号
- dlg.m_Sname = m_Storehouse.GetText(); //仓库名称
- dlg.m_Pname = m_Pname.GetText(); //产品名称
- dlg.m_MakeDate = m_datagrid.GetItem(3); //生产日期
- dlg.m_Price = m_datagrid.GetItem(1); //单价
- dlg.m_OldNum = m_datagrid.GetItem(2); //原数量
- if (dlg.DoModal() == IDOK)
- Refresh_Data();
- }