📄 outdate.cpp
字号:
// OutDate.cpp : implementation file
//
#include "stdafx.h"
#include "medicine.h"
#include "OutDate.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
/////////////////////////////////////////////////////////////////////////////
// COutDate dialog
COutDate::COutDate(CWnd* pParent /*=NULL*/)
: CDialog(COutDate::IDD, pParent)
{
//{{AFX_DATA_INIT(COutDate)
m_Day = 0;
//}}AFX_DATA_INIT
}
void COutDate::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COutDate)
DDX_Control(pDX, IDC_ADODC1, m_Adodc);
DDX_Control(pDX, IDC_DATAGRID1, m_DataGrid);
DDX_Text(pDX, IDC_DAY, m_Day);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COutDate, CDialog)
//{{AFX_MSG_MAP(COutDate)
ON_BN_CLICKED(IDC_FIND, OnFind)
ON_BN_CLICKED(IDC_OUTDATEBUTTON, OnOutdateButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COutDate message handlers
int COutDate::DoModal()
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::DoModal();
}
BOOL COutDate::OnInitDialog()
{
CDialog::OnInitDialog();
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 COutDate::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_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(1); //药品名称
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(2); //药品简称
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(3); //售价
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(4); //进价
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(5); //单位
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(6); //库存量
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(7); //VIP折扣(%)
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(8); //生产日期
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(9); //过期日期
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(10); //销售商编号
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(11); //库存下限
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(12); //详细说明
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(100);
}
void COutDate::OnFind()
{
// 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 ";
CTime t = CTime::GetCurrentTime();//设置过期时间
t+=m_Day*24*60*60;
CString cstrTime = t.Format("%Y-%m-%d");
MessageBox(cstrTime);
cSql += " and MediInfo.LastDate>='"+cstrTime+"'";
m_Adodc.SetRecordSource(cSql);
m_Adodc.Refresh();
// 设置列宽度
_variant_t vIndex;
//long将整数转换为_variant_t类型,从而可以在CColumns::GetItem()函数中使用
vIndex = long(0);//药品编号
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(1); //药品名称
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(2); //药品简称
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(3); //售价
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(4); //进价
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(5); //单位
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(6); //库存量
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(7); //VIP折扣(%)
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(8); //生产日期
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(9); //过期日期
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(10); //销售商编号
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(11); //库存下限
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(12); //详细说明
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(100);
}
void COutDate::OnOutdateButton()
{
// TODO: Add your control notification handler code here
// 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 ";
CTime t = CTime::GetCurrentTime();//设置过期时间
CString cstrTime = t.Format("%Y-%m-%d");
cSql += " and MediInfo.LastDate<'"+cstrTime+"'";
m_Adodc.SetRecordSource(cSql);
m_Adodc.Refresh();
// 设置列宽度
_variant_t vIndex;
//long将整数转换为_variant_t类型,从而可以在CColumns::GetItem()函数中使用
vIndex = long(0);//药品编号
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(1); //药品名称
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(2); //药品简称
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(3); //售价
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(4); //进价
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(5); //单位
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(6); //库存量
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(7); //VIP折扣(%)
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(8); //生产日期
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(9); //过期日期
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(10); //销售商编号
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(11); //库存下限
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(60);
vIndex = long(12); //详细说明
m_DataGrid.GetColumns().GetItem(vIndex).SetWidth(100);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -