📄 itemselectiondlg.cpp
字号:
// ItemSelectionDlg.cpp : implementation file
//
#include "stdafx.h"
#include "HosptialMan.h"
#include "ItemSelectionDlg.h"
#include "columns.h"
#include "column.h"
#include "COMDEF.H"
#include "_recordset.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CItemSelectionDlg dialog
CItemSelectionDlg::CItemSelectionDlg(CWnd* pParent /*=NULL*/)
: CDialog(CItemSelectionDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CItemSelectionDlg)
m_ItemName = _T("");
//}}AFX_DATA_INIT
}
void CItemSelectionDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CItemSelectionDlg)
DDX_Control(pDX, IDC_ADODC1, m_Adodc);
DDX_Control(pDX, IDC_DATAGRID1, m_DataGrid);
DDX_Text(pDX, IDC_ITEMNAME_EDIT, m_ItemName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CItemSelectionDlg, CDialog)
//{{AFX_MSG_MAP(CItemSelectionDlg)
ON_BN_CLICKED(IDC_SEARCH_BUTTON, OnSearchButton)
ON_BN_CLICKED(IDC_SEL_BUTTON, OnSelButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CItemSelectionDlg message handlers
void CItemSelectionDlg::RefreshData()
{
// 刷新记录
CString cSql;
cSql = "Select i.ItemId,i.ItemName AS 项目名称,i.UnitId,b.TypeName AS 单位,";
cSql += "i.BuyPrice AS 项目成本,i.SalePrice AS 销售价格,i.Total AS 库存数量 ";
cSql += "From Items i,BaseType b Where b.TypeId=3 AND i.UnitId=b.Id";
// 查询条件是否为空
if(m_ItemName!="")
cSql += " AND i.ItemName Like '%"+m_ItemName+"%'";
// MessageBox(cSql);
m_Adodc.SetRecordSource(cSql);
m_Adodc.Refresh();
// 设置列宽度
_variant_t vIndex;
vIndex = long(0);
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(0);
vIndex = long(1); // 项目名称
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(120);
vIndex = long(2); // 单位
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(0);
vIndex = long(3); // 单位
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(50);
vIndex = long(4); // 项目成本
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(80);
vIndex = long(5); // 销售价格
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(80);
vIndex = long(6); // 库存数量
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(100);
}
void CItemSelectionDlg::OnSearchButton()
{
// TODO: Add your control notification handler code here
RefreshData();
}
BEGIN_EVENTSINK_MAP(CItemSelectionDlg, CDialog)
//{{AFX_EVENTSINK_MAP(CItemSelectionDlg)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CItemSelectionDlg::OnSelButton()
{
if(m_Adodc.GetRecordset().GetEof())
{
MessageBox("请选择收费项目!");
return;
}
Reg_ItemId = m_DataGrid.GetItem(0);
Reg_ItemName = m_DataGrid.GetItem(1);
Reg_ItemUnit = m_DataGrid.GetItem(3);
Reg_ItemSalePrice = m_DataGrid.GetItem(5);
Reg_ItemTotal = m_DataGrid.GetItem(6);
OnOK();
}
BOOL CItemSelectionDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
RefreshData();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -