【VC开源代码栏目提醒】:网学会员为广大网友收集整理了,DistributeEditDlg.cpp,希望对大家有所帮助!
// DistributeEditDlg.cpp : implementation file
//
#include "stdafx.h"
#include "AssetsMan.h"
#include "DistributeEditDlg.h"
#include "AssetsSelectDlg.h"
#include "Distribute.h"
#include "Assets.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDistributeEditDlg dialog
CDistributeEditDlg::CDistributeEditDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDistributeEditDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDistributeEditDlg)
m_assets = _T("");
m_name = _T("");
m_date = COleDateTime::GetCurrentTime();
m_aid = _T("");
//}}AFX_DATA_INIT
}
void CDistributeEditDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDistributeEditDlg)
DDX_Control(pDX, IDC_ADODC1, m_adodc);
DDX_Text(pDX, IDC_ASSETS_EDIT, m_assets);
DDX_Control(pDX, IDC_DATACOMBO1, m_dep);
DDX_Text(pDX, IDC_NAME_EDIT, m_name);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER1, m_date);
DDX_Text(pDX, IDC_AID_EDIT, m_aid);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDistributeEditDlg, CDialog)
//{{AFX_MSG_MAP(CDistributeEditDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDistributeEditDlg message handlers
BOOL CDistributeEditDlg::OnInitDialog()
{
CDialog::OnInitDialog();
if(cAid == "")
{
// 设置添加时间和使用时间为当前日期
CTime t = CTime::GetCurrentTime();
m_date.SetDate(t.GetYear(),t.GetMonth(),t.GetDay());
}
else
{
// 初始化控件
m_dep.SetBoundText(cDepId);
// 日期
COleVariant vtime(cDate);
vtime.ChangeType(VT_DATE);
COleDateTime time4(vtime);
m_date.SetDate(time4.GetYear(),time4.GetMonth(),time4.GetDay());
// 不允许修改已分配的固定资产
GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);
}
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDistributeEditDlg::OnButton1()
{
UpdateData(TRUE);
CAssetsSelectDlg dlg;
dlg.flag = 1;
if(dlg.DoModal() == IDOK)
{
m_assets = dlg.AssetsName;
m_aid = dlg.AssetsId;
UpdateData(FALSE);
}
}
void CDistributeEditDlg::OnOK()
{
UpdateData(TRUE);
if(m_dep.GetBoundText() == "")
{
MessageBox("请选择部门");
return;
}
if(m_aid == "")
{
MessageBox("请选择固定资产");
return;
}
if(m_name == "")
{
MessageBox("请输入负责人");
return;
}
CDistribute dis;
dis.DepId = atoi(m_dep.GetBoundText());
dis.EmpName = m_name;
dis.Aid = m_aid;
dis.CreateDate = m_date.Format("%Y-%m-%d");
if(cAid == "")
dis.sql_Insert();
else
dis.sql_Update(cAid);
CDialog::OnOK();
}
上一篇:
BufferList.pas
下一篇:
探讨江泽民对哲学物质利益观的丰富和发展