📄 storehousemandlg.cpp
字号:
// StoreHouseManDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Stock.h"
#include "StoreHouseManDlg.h"
#include "StoreHouseEditDlg.h"
#include "Storehouse.h"
#include "COMDEF.H"
#include "Columns.h"
#include "Column.h"
#include "_recordset.h"
#include "StoreIn.h"
#include "TakeOut.h"
#include "ProInStore.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStoreHouseManDlg dialog
CStoreHouseManDlg::CStoreHouseManDlg(CWnd* pParent /*=NULL*/)
: CDialog(CStoreHouseManDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CStoreHouseManDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CStoreHouseManDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStoreHouseManDlg)
DDX_Control(pDX, IDC_DATAGRID1, m_datagrid);
DDX_Control(pDX, IDC_ADODC1, m_adodc);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CStoreHouseManDlg, CDialog)
//{{AFX_MSG_MAP(CStoreHouseManDlg)
ON_BN_CLICKED(IDC_ADD_BUTTON, OnAddButton)
ON_BN_CLICKED(IDC_MODI_BUTTON, OnModiButton)
ON_BN_CLICKED(IDC_DEL_BUTTON, OnDelButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStoreHouseManDlg message handlers
void CStoreHouseManDlg::Refresh_Data()
{
UpdateData(TRUE);
CString cSource;
cSource = "SELECT Sid, Sname AS 仓库单位, Memo AS 备注";
cSource += " FROM Storehouse ORDER BY Sname";
m_adodc.SetRecordSource(cSource);
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(100);
vIndex = long(2);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(420);
}
void CStoreHouseManDlg::OnAddButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
//打开编辑对话框
CStoreHouseEditDlg dlg;
dlg.cSid = "";
if (dlg.DoModal() == IDOK)
Refresh_Data();
}
void CStoreHouseManDlg::OnModiButton()
{
// TODO: Add your control notification handler code here
if (m_adodc.GetRecordset().GetEof())
{
MessageBox("请选择要修改的记录");
return;
}
UpdateData(TRUE);
CStoreHouseEditDlg dlg;
dlg.cSid = m_datagrid.GetItem(0); //记录编号
dlg.m_Sname = m_datagrid.GetItem(1); //仓库名称
dlg.m_Memo = m_datagrid.GetItem(2); //备注信息
if (dlg.DoModal() == IDOK)
Refresh_Data();
}
void CStoreHouseManDlg::OnDelButton()
{
// TODO: Add your control notification handler code here
if (m_adodc.GetRecordset().GetEof())
{
MessageBox("请选择要删除的记录");
return;
}
CString Sid;
Sid = m_datagrid.GetItem(0);
CStoreIn obj;
if (obj.HaveStore(Sid) == 1)
{
MessageBox("此仓库信息出现在入库单中,不能删除");
return;
}
CTakeOut obj1;
if (obj1.HaveStore(Sid) == 1)
{
MessageBox("此仓库信息出现在出库单中,不能删除");
return;
}
CProInStore obj2;
if (obj2.HaveStore(Sid) == 1)
{
MessageBox("此仓库信息出现在库存产品信息中,不能删除");
return;
}
if (MessageBox("是否删除当前记录","请确定", MB_YESNO) == IDYES)
{
CStorehouse sh;
sh.sql_delete(Sid);
Refresh_Data();
}
}
BOOL CStoreHouseManDlg::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
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -