Report2Dlg.cpp
资源名称:SQLVC.rar [点击查看]
上传用户:biney012
上传日期:2022-05-09
资源大小:4592k
文件大小:4k
源码类别:
数据库系统
开发平台:
Visual C++
- // Report2Dlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "Stock.h"
- #include "Report2Dlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CReport2Dlg dialog
- CReport2Dlg::CReport2Dlg(CWnd* pParent /*=NULL*/)
- : CDialog(CReport2Dlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CReport2Dlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- void CReport2Dlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CReport2Dlg)
- 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_DATACOMBO1, m_datacombo1);
- DDX_Control(pDX, IDC_DATACOMBO3, m_datacombo3);
- DDX_Control(pDX, IDC_DATACOMBO2, m_datacombo2);
- DDX_Control(pDX, IDC_DATAGRID1, m_datagrid);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CReport2Dlg, CDialog)
- //{{AFX_MSG_MAP(CReport2Dlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CReport2Dlg message handlers
- void CReport2Dlg::Refresh_Data()
- {
- CString cPid;
- cPid = m_datacombo3.GetBoundText();
- if (cPid == "")
- cPid = "0";
- //生成SELECT语句
- CString cSource;
- cSource = "SELECT r.SiType As 入出库类型, p.Pname As 产品名称, r.Pprice As 产品单价,";
- cSource += " r.Pnum As 产品数量, r.Amount As 总金额, c.Cname As 客户单位, s.Sname As 存放仓库,";
- cSource += " r.EmpName As 经办人, r.OptDate As 入出库日期";
- cSource += " FROM Report2 r, Product p, Client c, Storehouse s";
- cSource += " WHERE r.Pid=p.Pid AND r.Cid=c.Cid AND";
- cSource += " r.Sid=s.Sid AND p.Pid=" + cPid;
- //设置记录源
- m_adodc3.SetRecordSource(cSource);
- m_adodc3.Refresh();
- }
- BOOL CReport2Dlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- Refresh_Data();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- BEGIN_EVENTSINK_MAP(CReport2Dlg, CDialog)
- //{{AFX_EVENTSINK_MAP(CReport2Dlg)
- ON_EVENT(CReport2Dlg, IDC_DATACOMBO1, -600 /* Click */, OnClickDatacombo1, VTS_I2)
- ON_EVENT(CReport2Dlg, IDC_DATACOMBO2, -600 /* Click */, OnClickDatacombo2, VTS_I2)
- ON_EVENT(CReport2Dlg, IDC_DATACOMBO3, -600 /* Click */, OnClickDatacombo3, VTS_I2)
- //}}AFX_EVENTSINK_MAP
- END_EVENTSINK_MAP()
- void CReport2Dlg::OnClickDatacombo1(short Area)
- {
- //读取一级产品类别编号
- CString cUpperId;
- cUpperId = m_datacombo1.GetBoundText();
- if (cUpperId == "")
- cUpperId = "0";
- //设置查询二级产品类型的SELECT语句
- CString cSource;
- cSource = "SELECT * FROM ProType WHERE UpperId=" + cUpperId;
- m_datacombo2.SetText("");
- //设置m_adodc3,从而刷新二级产品类别的列表
- m_adodc2.SetRecordSource(cSource);
- m_adodc2.Refresh();
- //设置产品列表框,因为没有选中二级产品类别,所以要清空产品列表框
- cSource = "SELECT * FROM Product WHERE TypeId=0";
- m_datacombo3.SetText("");
- //设置m_adodc5,从而刷新产品的列表
- m_adodc5.SetRecordSource(cSource);
- m_adodc5.Refresh();
- //刷新库存产品表格
- Refresh_Data();
- }
- void CReport2Dlg::OnClickDatacombo2(short Area)
- {
- //读取二级产品类别编号
- CString cTypeId;
- cTypeId = m_datacombo2.GetBoundText();
- if (cTypeId == "")
- cTypeId = "0";
- //设置查询二级产品类型的SELECT语句
- CString cSource;
- cSource = "SELECT * FROM Product WHERE TypeId=" + cTypeId;
- m_datacombo3.SetText("");
- //设置m_adodc5,从而刷新产品的列表
- m_adodc5.SetRecordSource(cSource);
- m_adodc5.Refresh();
- //刷新库存产品表格
- Refresh_Data();
- }
- void CReport2Dlg::OnClickDatacombo3(short Area)
- {
- Refresh_Data();
- }