📄 buyinputform.cpp
字号:
// BuyInputForm.cpp : implementation file
//
#include "stdafx.h"
#include "Store.h"
#include "BuyInputForm.h"
#include "SelectMaterial.h"
#include "Affirm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBuyInputForm dialog
CBuyInputForm::CBuyInputForm(CWnd* pParent /*=NULL*/)
: CDialog(CBuyInputForm::IDD, pParent)
{
//{{AFX_DATA_INIT(CBuyInputForm)
m_formDate = COleDateTime::GetCurrentTime();
m_buyInputFormID = _T("");
m_materialReceiveID = _T("");
m_storeHouse = _T("");
m_provider = _T("");
m_buyDepartment = _T("");
m_buyer = _T("");
m_transportCompany = _T("");
m_transportType = _T("");
m_houseInType = _T("");
m_remark = _T("");
flag=1;
is_search=0;
//}}AFX_DATA_INIT
}
void CBuyInputForm::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBuyInputForm)
DDX_Control(pDX, IDC_houseInType, m_houseInTypeCombo);
DDX_Control(pDX, IDC_transportType, m_transportTypeCombo);
DDX_Control(pDX, IDC_transportComany, m_transportCompanyCombo);
DDX_Control(pDX, IDC_buyer, m_buyerCommbo);
DDX_Control(pDX, IDC_buyDepartment, m_departmentCombo);
DDX_Control(pDX, IDC_provider, m_providerCombo);
DDX_Control(pDX, IDC_storeHouse, m_storeHouseCombo);
DDX_Control(pDX, IDC_materialReceiveID, m_materialReceiveIDCombo);
DDX_Control(pDX, IDC_LIST1, m_list);
DDX_DateTimeCtrl(pDX, IDC_formDate, m_formDate);
DDX_Text(pDX, IDC_buyInputFormID, m_buyInputFormID);
DDX_CBString(pDX, IDC_materialReceiveID, m_materialReceiveID);
DDX_CBString(pDX, IDC_storeHouse, m_storeHouse);
DDX_CBString(pDX, IDC_provider, m_provider);
DDX_CBString(pDX, IDC_buyDepartment, m_buyDepartment);
DDX_CBString(pDX, IDC_buyer, m_buyer);
DDX_CBString(pDX, IDC_transportComany, m_transportCompany);
DDX_CBString(pDX, IDC_transportType, m_transportType);
DDX_CBString(pDX, IDC_houseInType, m_houseInType);
DDX_Text(pDX, IDC_remark, m_remark);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBuyInputForm, CDialog)
//{{AFX_MSG_MAP(CBuyInputForm)
ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList)
ON_BN_CLICKED(IDC_add, OnNew)
ON_BN_CLICKED(IDC_modify, OnModify)
ON_BN_CLICKED(IDC_delete, OnDelete)
ON_BN_CLICKED(IDC_addLine, OnAddLine)
ON_BN_CLICKED(IDC_deleteLine, OnDeleteLine)
ON_BN_CLICKED(IDC_save, OnSave)
ON_BN_CLICKED(IDC_cancelation, OnCancelation)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBuyInputForm message handlers
BOOL CBuyInputForm::OnInitDialog()
{
CDialog::OnInitDialog();
CWnd* tx_buyInputFormID;
tx_buyInputFormID=GetDlgItem(IDC_buyInputFormID);
tx_buyInputFormID->EnableWindow(false);
DWORD style;
style=m_list.GetExStyle();
style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
m_list.SetExtendedStyle(style);
m_list.InsertColumn(0,"物料编号",LVCFMT_LEFT,100);
m_list.InsertColumn(1,"物料名称",LVCFMT_LEFT,100);
m_list.InsertColumn(2,"物料单位",LVCFMT_LEFT,100);
m_list.InsertColumn(3,"物料型号",LVCFMT_LEFT,100);
m_list.InsertColumn(4,"数量",LVCFMT_LEFT,100);
m_list.InsertColumn(5,"单价",LVCFMT_LEFT,100);
m_list.InsertColumn(6,"金额",LVCFMT_LEFT,100);
bt_add=GetDlgItem(IDC_add);
bt_delete=GetDlgItem(IDC_delete);
bt_modify=GetDlgItem(IDC_modify);
bt_addLine=GetDlgItem(IDC_addLine);
bt_deleteLine=GetDlgItem(IDC_deleteLine);
bt_save=GetDlgItem(IDC_save);
bt_cancelation=GetDlgItem(IDC_cancelation);
tx_formDate=GetDlgItem(IDC_formDate);
tx_materialReceiveID=GetDlgItem(IDC_materialReceiveID);
tx_storeHouse=GetDlgItem(IDC_storeHouse);
tx_provider=GetDlgItem(IDC_provider);
tx_buyDepartment=GetDlgItem(IDC_buyDepartment);
tx_buyer=GetDlgItem(IDC_buyer);
tx_transportCompany=GetDlgItem(IDC_transportComany);
tx_transportType=GetDlgItem(IDC_transportType);
tx_houseInType=GetDlgItem(IDC_houseInType);
tx_remark=GetDlgItem(IDC_remark);
CString strSQL;
HRESULT hTRes;
_RecordsetPtr m_pRecordset;
//采购部门
strSQL="select distinct departmentName from department"; //sql查询字符串
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
if (SUCCEEDED(hTRes))
{
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);//打开查询结果记录集
if(SUCCEEDED(hTRes))
{
while(!(m_pRecordset->adoEOF))
{
m_departmentCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("departmentName")));//插入
m_pRecordset->MoveNext();//记录集指针向后移动
}
}
}
m_pRecordset->Close();
//采购员
strSQL="select distinct staffName from staff";
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
while(!(m_pRecordset->adoEOF))
{
m_buyerCommbo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("staffName")));
m_pRecordset->MoveNext();
}
}
m_pRecordset->Close();
//入库类别
strSQL="select distinct houseInTypeName from houseInType";
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
while(!(m_pRecordset->adoEOF))
{
m_houseInTypeCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("houseInTypeName")));
m_pRecordset->MoveNext();
}
}
m_pRecordset->Close();
//供应商
strSQL="select distinct company from client";
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
while(!(m_pRecordset->adoEOF))
{
m_providerCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("company")));
m_pRecordset->MoveNext();
}
}
m_pRecordset->Close();
//仓库名称
strSQL="select distinct storeHouseName from storeHouse";
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
while(!(m_pRecordset->adoEOF))
{
m_storeHouseCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("storeHouseName")));
m_pRecordset->MoveNext();
}
}
m_pRecordset->Close();
//承运单位
strSQL="select distinct transportCompanyName from transportCompany";
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
while(!(m_pRecordset->adoEOF))
{
m_transportCompanyCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("transportCompanyName")));
m_pRecordset->MoveNext();
}
}
m_pRecordset->Close();
//运输方式
strSQL="select distinct transportTypeName from transportType";
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
while(!(m_pRecordset->adoEOF))
{
m_transportTypeCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("transportTypeName")));
m_pRecordset->MoveNext();
}
}
m_pRecordset->Close();
if(is_search==1) //被查询对话框调用
{
bt_add->EnableWindow(true); //添加按钮可用
bt_delete->EnableWindow(true); //删除按钮可用
bt_modify->EnableWindow(true); //修改按钮可用
bt_addLine->EnableWindow(false); //增行按钮不可用
bt_deleteLine->EnableWindow(false); //删行按钮不可用
bt_save->EnableWindow(false); //保存按钮不可用
bt_cancelation->EnableWindow(false); //作废按钮不可用
CString strSQL;
_RecordsetPtr m_pRecordset; //用于创建一个查询记录集
_RecordsetPtr m_pBuyInputFormRecordset;
//构造查询指定采购入库单号的入库单信息的sql语句
strSQL="select * from buyInputForm where buyInputFormID='";
strSQL=strSQL+m_buyInputFormID+"'";
HRESULT hTRes;
hTRes = m_pBuyInputFormRecordset.CreateInstance(_T("ADODB.Recordset"));
hTRes = m_pBuyInputFormRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);//打开查询结果记录集
//将查询结果显示在编辑控件中
if(!(m_pBuyInputFormRecordset->adoEOF))
{
DATE dt;
COleDateTime da;
dt=m_pBuyInputFormRecordset->GetCollect("formDate").date;//制单日期
da=COleDateTime(dt);
m_formDate.SetDate(da.GetYear(),da.GetMonth(),da.GetDay());
m_materialReceiveID = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pBuyInputFormRecordset->GetCollect("materialAcceptFormID"));//收料单号
m_storeHouse = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pBuyInputFormRecordset->GetCollect("storeHouse"));//仓库名称
m_provider = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pBuyInputFormRecordset->GetCollect("provider"));//供应商
m_buyDepartment = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pBuyInputFormRecordset->GetCollect("stockDepartment"));//采购部们
m_buyer = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pBuyInputFormRecordset->GetCollect("buyer"));//采购员
m_transportCompany = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pBuyInputFormRecordset->GetCollect("transportCompany"));//承运单位
m_transportType = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pBuyInputFormRecordset->GetCollect("transportType"));//运输方式
m_houseInType = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pBuyInputFormRecordset->GetCollect("houseInType"));//入库类别
m_remark = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pBuyInputFormRecordset->GetCollect("remark"));//备注
//构造查询指定采购单号的采购单的物料信息的sql语句
strSQL="select * from buyInputFormView where buyInputFormID='";
strSQL=strSQL+m_buyInputFormID+"'";
hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);//打开查询结果记录集
int i=0;
//将查询结果显示在列表框中
while(!(m_pRecordset->adoEOF))
{
m_list.InsertItem(i,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("materialID")));//物料编号
m_list.SetItemText(i,1,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("materialName")));//物料名称
m_list.SetItemText(i,2,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("unit")));//计量单位
m_list.SetItemText(i,3,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("model")));//型号
m_list.SetItemText(i,4,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("num")));//数目
m_list.SetItemText(i,5,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("price")));//单价
m_list.SetItemText(i,6,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("total")));//金额
i++;
m_pRecordset->MoveNext(); //记录集指针向后移动
}
}
//设定所有的编辑控件不可用
tx_formDate->EnableWindow(false);
tx_materialReceiveID->EnableWindow(false);
tx_storeHouse->EnableWindow(false);
tx_provider->EnableWindow(false);
tx_buyDepartment->EnableWindow(false);
tx_buyer->EnableWindow(false);
tx_transportCompany->EnableWindow(false);
tx_transportType->EnableWindow(false);
tx_houseInType->EnableWindow(false);
tx_remark->EnableWindow(false);
}
else //被系统菜单调用
{
//设定按钮控件的可用性
bt_add->EnableWindow(false);
bt_delete->EnableWindow(false);
bt_modify->EnableWindow(false);
bt_addLine->EnableWindow(true);
bt_deleteLine->EnableWindow(true);
bt_save->EnableWindow(true);
bt_cancelation->EnableWindow(true);
//设定除“采购入库单号”外的所有编辑控件可用
tx_formDate->EnableWindow(true);
tx_materialReceiveID->EnableWindow(true);
tx_storeHouse->EnableWindow(true);
tx_provider->EnableWindow(true);
tx_buyDepartment->EnableWindow(true);
tx_buyer->EnableWindow(true);
tx_transportCompany->EnableWindow(true);
tx_transportType->EnableWindow(true);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -