📄 medistore.cpp
字号:
// MediStore.cpp : implementation file
//
#include "stdafx.h"
#include "medicine.h"
#include "MediStore.h"
#include "columns.h"
#include "column.h"
#include "COMDEF.H"
#include "_recordset.h"
#include "MainFrame.h"
#include "MediInfo.h"
#include "MediInfoEdit.h"
#include "User.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMediStore dialog
CMediStore::CMediStore(CWnd* pParent /*=NULL*/)
: CDialog(CMediStore::IDD, pParent)
{
//{{AFX_DATA_INIT(CMediStore)
m_ChooseInfo = _T("");
m_InAmout = 0.0f;
m_InDate = 0;
m_InPrice = 0.0f;
m_LastDate = 0;
m_MediNo = _T("");
m_Name = _T("");
m_SalePrice = 0.0f;
m_SalerId = _T("");
m_Unit = _T("");
m_Short = _T("");
//}}AFX_DATA_INIT
}
void CMediStore::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMediStore)
DDX_Control(pDX, IDC_CHOOSECOMB, m_ChooseType);
DDX_Control(pDX, IDC_CHOOSE, m_ExactChoose);
DDX_Control(pDX, IDC_CANCEL, m_CancelButton);
DDX_Control(pDX, IDC_ADODCCHOOSE, m_Adodc);
DDX_Text(pDX, IDC_CHOOSEINFO, m_ChooseInfo);
DDX_Control(pDX, IDC_DATAGRIDCHOOSE, m_DataGridChoose);
DDX_Text(pDX, IDC_INAMOUT, m_InAmout);
DDX_DateTimeCtrl(pDX, IDC_INDATE, m_InDate);
DDX_Text(pDX, IDC_INPRICE, m_InPrice);
DDX_DateTimeCtrl(pDX, IDC_LASTDATE, m_LastDate);
DDX_Text(pDX, IDC_MEDINO, m_MediNo);
DDX_Text(pDX, IDC_NAME, m_Name);
DDX_Text(pDX, IDC_SALEPRICE, m_SalePrice);
DDX_Text(pDX, IDC_SALERID, m_SalerId);
DDX_Text(pDX, IDC_UNIT, m_Unit);
DDX_Text(pDX, IDC_SHORT, m_Short);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMediStore, CDialog)
//{{AFX_MSG_MAP(CMediStore)
ON_BN_CLICKED(IDC_CHOOSE, OnExactChoose)
ON_BN_CLICKED(IDC_SOMECHOOSE, OnSomeChoose)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_NEWSTORE, OnNewStore)
ON_BN_CLICKED(IDC_CHANGE, OnChange)
ON_BN_CLICKED(IDC_CANCEL, OnCancel)
ON_BN_CLICKED(IDC_CHANGEMEDI, OnChangeMedi)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMediStore message handlers
BOOL CMediStore::OnInitDialog()
{
CDialog::OnInitDialog();
CTime t = CTime::GetCurrentTime();
m_InDate = t; //设置购入药品日期为当天
m_LastDate=t; //设置药品过期日期为当天
m_ChooseType.SetCurSel(0);
UpdateData(FALSE);//把变量信息及时更新到控件上
RefreshData();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CMediStore::RefreshData()
{
UpdateData(TRUE);// 将控件上的信息及时更新到对应的变量
CString cSql;
cSql = "select MediStore.MediId as'药品编号',MediInfo.MediName as";
cSql+="'药品名称',MediInfo.Short as'药品简称', MediInfo.MediPrice as ";
cSql+="'售价', MediStore.InPrice as'进价',MediInfo.Unit as'单位', MediStore.InAmout as";
cSql+="'库存量',MediInfo.VipDisc as'VIP折扣(%)', MediStore.InDate as";
cSql+="'生产日期',MediInfo.LastDate as'过期日期',MediStore.SalerId as";
cSql+="'销售商编号',MediInfo.LeastAmout as";//,MediInfo.Short as'药品简码'
cSql+="'库存下限', MediInfo.Detail as";
cSql+="'详细说明'from MediStore,MediInfo where MediStore.MediId=MediInfo.MediId";
m_Adodc.SetRecordSource(cSql);
m_Adodc.Refresh();
// MessageBox(cSql);
m_Adodc.SetRecordSource((LPCTSTR)(_bstr_t)cSql);
m_Adodc.Refresh();
// 设置列宽度
_variant_t vIndex;
//long将整数转换为_variant_t类型,从而可以在CColumns::GetItem()函数中使用
vIndex = long(0);//药品编号
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(1); //药品名称
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(2); //药品简称
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(3); //售价
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(4); //进价
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(5); //单位
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(6); //库存量
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(7); //VIP折扣(%)
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(8); //生产日期
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(9); //过期日期
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(10); //销售商编号
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(11); //库存下限
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(12); //详细说明
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(100);
}
int CMediStore::DoModal()
{
// TODO: Add your specialized code here and/or call the base class
//RefreshData();
return CDialog::DoModal();
}
void CMediStore::OnCancel()
{
// TODO: Add your control notification handler code here
CMainFrame dlg;
EndDialog(1);
//dlg.DoModal();
}
void CMediStore::OnExactChoose()
{
// TODO: Add your control notification handler code here
/*全部
按药名
按药品编号
按销售商编号
按生产日期*/
UpdateData(TRUE);
CString cSql;
cSql = "select MediStore.MediId as'药品编号',MediInfo.MediName as";
cSql+="'药品名称',MediInfo.Short as'药品简称', MediInfo.MediPrice as ";
cSql+="'售价', MediStore.InPrice as'进价',MediInfo.Unit as'单位', MediStore.InAmout as";
cSql+="'库存量',MediInfo.VipDisc as'VIP折扣(%)', MediStore.InDate as";
cSql+="'生产日期',MediInfo.LastDate as'过期日期',MediStore.SalerId as";
cSql+="'销售商编号',MediInfo.LeastAmout as";//,MediInfo.Short as'药品简码'
cSql+="'库存下限', MediInfo.Detail as";
cSql+="'详细说明'from MediStore,MediInfo where MediStore.MediId=MediInfo.MediId";
if(m_ChooseInfo!="")
{
if(m_ChooseType.GetCurSel()==1)
{
cSql += " and MediInfo.MediName ='"+m_ChooseInfo+"'";
}
else if(m_ChooseType.GetCurSel()==2)
{
cSql += " and MediStore.MediId = '"+m_ChooseInfo+"'";
}
else if(m_ChooseType.GetCurSel()==3)
{
cSql += " and MediStore.SalerId = '"+m_ChooseInfo+"'";
}
else if(m_ChooseType.GetCurSel()==4)
{
/*int a,b,c ;
sscanf(m_ChooseInfo.GetBuffer(m_ChooseInfo.GetLength()),"%d-%d-%d",&a,&b,&c);
CTime time(a,b,c,0,0,0);
CTime t;
t.Format(m_ChooseInfo);
CString s;
s.Format(t);*/
cSql += " and MediStore.InDate='"+m_ChooseInfo+"'";
}
}
m_Adodc.SetRecordSource(cSql);
m_Adodc.Refresh();
// 设置列宽度
_variant_t vIndex;
//long将整数转换为_variant_t类型,从而可以在CColumns::GetItem()函数中使用
vIndex = long(0);//药品编号
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(1); //药品名称
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(2); //药品简称
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(3); //售价
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(4); //进价
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(5); //单位
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(6); //库存量
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(7); //VIP折扣(%)
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(8); //生产日期
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(9); //过期日期
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(10); //销售商编号
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(11); //库存下限
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(12); //详细说明
m_DataGridChoose.GetColumns().GetItem(vIndex).SetWidth(100);
}
void CMediStore::OnSomeChoose()
{
// TODO: Add your control notification handler code here
/*全部
按药名
按药品编号
按销售商编号
按生产日期*/
UpdateData(TRUE);
CString cSql;
cSql = "select MediStore.MediId as'药品编号',MediInfo.MediName as";
cSql+="'药品名称',MediInfo.Short as'药品简称', MediInfo.MediPrice as ";
cSql+="'售价', MediStore.InPrice as'进价',MediInfo.Unit as'单位', MediStore.InAmout as";
cSql+="'库存量',MediInfo.VipDisc as'VIP折扣(%)', MediStore.InDate as";
cSql+="'生产日期',MediInfo.LastDate as'过期日期',MediStore.SalerId as";
cSql+="'销售商编号',MediInfo.LeastAmout as";//,MediInfo.Short as'药品简码'
cSql+="'库存下限', MediInfo.Detail as";
cSql+="'详细说明'from MediStore,MediInfo where MediStore.MediId=MediInfo.MediId";
if(m_ChooseInfo!="")
{
if(m_ChooseType.GetCurSel()==1)
{
cSql += " and MediInfo.MediName like '%"+m_ChooseInfo+"%'";
}
else if(m_ChooseType.GetCurSel()==2)
{
cSql += " and MediStore.MediId like '%"+m_ChooseInfo+"%'";
}
else if(m_ChooseType.GetCurSel()==3)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -