【VC开源代码栏目提醒】:网学会员--在 VC开源代码编辑为广大网友搜集整理了:ErrandEditDlg.cpp绩等信息,祝愿广大网友取得需要的信息,参考学习。
// ErrandEditDlg.cpp : implementation file
//
#include "stdafx.h"
#include "CheckManage.h"
#include "ErrandEditDlg.h"
#include "DepSelDlg.h"
#include "CheckInfo.h"
#include "COMDEF.H"
#include "Columns.h"
#include "Column.h"
#include "_Recordset.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CErrandEditDlg dialog
CErrandEditDlg::CErrandEditDlg(CWnd* pParent /*=NULL*/)
: CDialog(CErrandEditDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CErrandEditDlg)
m_DepName = _T("");
m_memo = _T("");
m_checkdate = _T("");
//}}AFX_DATA_INIT
}
void CErrandEditDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CErrandEditDlg)
DDX_Control(pDX, IDC_ADODC1, m_Adodc);
DDX_Control(pDX, IDC_DATAGRID1, m_Datagrid);
DDX_Text(pDX, IDC_DEPNAME_STATIC, m_DepName);
DDX_Text(pDX, IDC_MEMO_EDIT, m_memo);
DDX_Text(pDX, IDC_CHECKDATE_STATIC, m_checkdate);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CErrandEditDlg, CDialog)
//{{AFX_MSG_MAP(CErrandEditDlg)
ON_BN_CLICKED(IDC_SEL_DEP_BUTTON, OnSelDepButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CErrandEditDlg message handlers
BOOL CErrandEditDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// 修改状态下不用选择部门信息
if(EmpId != "")
GetDlgItem(IDC_SEL_DEP_BUTTON)->EnableWindow(FALSE);
m_checkdate = CheckDate;
UpdateData(FALSE);
RefreshData();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
// 刷新数据
void CErrandEditDlg::RefreshData()
{
UpdateData(TRUE);
//根据部门编号设置SELECT语句
CString cDepId;
cDepId.Format("%d", iDepId);
// 设置SELECT语句
CString cSource = "SELECT EmpId AS 员工编号, Name AS "
" FROM EmpInfo WHERE DepId = " + cDepId;
if(EmpId != "")
cSource += " AND EmpId=" + EmpId;
//刷新ADO Data控件的记录源
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);
}
// 选择部门
void CErrandEditDlg::OnSelDepButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
//打开选择部门对话框
CDepSelDlg dlg;
dlg.DoModal();
//从对话框中读取选择部门的信息
iDepId = dlg.DepId;
m_DepName = dlg.DepName;
UpdateData(FALSE);
//根据选择的部门信息,刷新表格数据
RefreshData();
}
void CErrandEditDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
// 是否选择人员
if(m_Adodc.GetRecordset().GetEof())
{
MessageBox("请选择人员");
return;
}
// 赋值到CCheckInfo对象中
CCheckInfo cur;
cur.CheckDate = CheckDate;
cur.EmpId = atol(m_Datagrid.GetItem(0));
cur.ChuChai = "是";
cur.QuanQin = "否";
cur.BingJia = "否";
cur.ShiJia = "否";
cur.KuangGong = "否";
cur.XiuXi = "否";
cur.ChiDao = "否";
cur.ZaoTui = "否";
cur.Memo = m_memo;
if(EmpId == "")
{
// 在添加时,若人员有出勤记录,则不允许添加
if(cur.HaveEmp(CheckDate, m_Datagrid.GetItem(0)))
{
MessageBox("已经有此员工的出勤信息,不能添加");
return;
}
// 插入记录
cur.SqlInsert();
}
else
{
// 修改CheckInfo表记录
cur.UpdateErrand(cur.CheckDate, m_Datagrid.GetItem(0));
}
CDialog::OnOK();
}
上一篇:
EquipmentDlg.cpp
下一篇:
用于土木工程结构抗震的半主动调谐质量阻尼器