📄 dialog_personnel.cpp
字号:
strSQL.Format("select * from PERSONNEL_PLAN where EMP_NO=%d",person_id);
m_planset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
if(m_planset.GetRecordCount()!=0) m_planset.MoveFirst();
i=0;
while(!m_planset.IsEOF())
{
int temp=0;
m_planset.GetFieldValue(temp,varValue);
sprintf(buf,"%d",varValue.m_lVal); m_plan.InsertItem(i,buf);
m_planset.GetFieldValue(1,varValue);
sprintf(buf,"%d",varValue.m_lVal); m_plan.SetItemText(i,1,buf);
m_planset.GetFieldValue(2,varValue);
sprintf(buf,"%d-%d-%d",varValue.m_pdate->year,varValue.m_pdate->month,varValue.m_pdate->day); m_plan.SetItemText(i,2,buf);
m_planset.GetFieldValue(3,varValue);
sprintf(buf,"%d-%d-%d",varValue.m_pdate->year,varValue.m_pdate->month,varValue.m_pdate->day); m_plan.SetItemText(i,3,buf);
m_planset.MoveNext();
i++;
}
}
BOOL CDIALOG_PERSONNEL::OnInitDialog()
{
CDialog::OnInitDialog();
select=-1;
// TODO: Add extra initialization here
m_basic.InsertColumn(0,"员工号");
m_basic.InsertColumn(1,"员工姓名");
m_basic.InsertColumn(2,"所在部门号");
m_basic.InsertColumn(3,"学历");
m_basic.InsertColumn(4,"性别");
m_basic.InsertColumn(5,"生日");
m_basic.InsertColumn(6,"籍贯");
m_basic.InsertColumn(7,"国籍");
m_basic.InsertColumn(8,"民族");
m_basic.InsertColumn(9,"身份证号");
m_basic.InsertColumn(10,"婚姻状况");
m_basic.InsertColumn(11,"健康状况");
m_basic.InsertColumn(12,"参加工作时间");
m_basic.InsertColumn(13,"员工状态");
m_basic.InsertColumn(14,"状态时间");
m_basic.InsertColumn(15,"家庭住址");
m_basic.InsertColumn(16,"联系电话");
m_basic.InsertColumn(17,"Email地址");
m_basic.InsertColumn(18,"工作岗位代号");
RECT rectbasic;
m_basic.GetWindowRect(&rectbasic);
int widbasic = rectbasic.right - rectbasic.left;
m_basic.SetColumnWidth(0,widbasic/8);
m_basic.SetColumnWidth(1,widbasic/8);
m_basic.SetColumnWidth(2,widbasic/8);
m_basic.SetColumnWidth(3,widbasic/8);
m_basic.SetColumnWidth(4,widbasic/8);
m_basic.SetColumnWidth(5,widbasic/8);
m_basic.SetColumnWidth(6,widbasic/8);
m_basic.SetColumnWidth(7,widbasic/8);
m_basic.SetColumnWidth(8,widbasic/8);
m_basic.SetColumnWidth(9,widbasic/8);
m_basic.SetColumnWidth(10,widbasic/8);
m_basic.SetColumnWidth(11,widbasic/8);
m_basic.SetColumnWidth(12,widbasic/8);
m_basic.SetColumnWidth(13,widbasic/8);
m_basic.SetColumnWidth(14,widbasic/8);
m_basic.SetColumnWidth(15,widbasic/8);
m_basic.SetColumnWidth(16,widbasic/8);
m_basic.SetColumnWidth(17,widbasic/8);
m_basic.SetColumnWidth(18,widbasic/8);
m_basic.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_score.InsertColumn(0,"员工号");
m_score.InsertColumn(1,"课程号");
m_score.InsertColumn(2,"上课时间");
m_score.InsertColumn(3,"上课地点");
m_score.InsertColumn(4,"教师号");
m_score.InsertColumn(5,"成绩1");
m_score.InsertColumn(6,"成绩2");
m_score.InsertColumn(7,"教师评语");
m_score.InsertColumn(8,"通过与否");
RECT rectscore;
m_score.GetWindowRect(&rectscore);
int widscore= rectscore.right - rectscore.left;
m_score.SetColumnWidth(0,widscore/8);
m_score.SetColumnWidth(1,widscore/8);
m_score.SetColumnWidth(2,widscore/8);
m_score.SetColumnWidth(3,widscore/8);
m_score.SetColumnWidth(4,widscore/8);
m_score.SetColumnWidth(5,widscore/8);
m_score.SetColumnWidth(6,widscore/8);
m_score.SetColumnWidth(7,widscore/8);
m_score.SetColumnWidth(8,widscore/8);
m_score.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_need.InsertColumn(0,"课程号");
m_need.InsertColumn(1,"课程需要者号");
RECT rectneed;
m_need.GetWindowRect(&rectneed);
int widneed= rectneed.right - rectneed.left;
m_need.SetColumnWidth(0,widneed/2);
m_need.SetColumnWidth(1,widneed/2);
m_need.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_plan.InsertColumn(0,"员工号");
m_plan.InsertColumn(1,"课程号");
m_plan.InsertColumn(2,"课程开始时间");
m_plan.InsertColumn(3,"课程结束时间");
RECT rectplan;
m_plan.GetWindowRect(&rectplan);
int widplan= rectplan.right - rectplan.left;
m_plan.SetColumnWidth(0,widplan/4);
m_plan.SetColumnWidth(1,widplan/4);
m_plan.SetColumnWidth(2,widplan/4);
m_plan.SetColumnWidth(3,widplan/4);
m_plan.SetExtendedStyle(LVS_EX_FULLROWSELECT);
p_query.Format("select * from PERSONNEL");
RefreshData();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDIALOG_PERSONNEL::OnCancel()
{
// TODO: Add extra cleanup here
m_database.Close();
CDialog::OnCancel();
}
void CDIALOG_PERSONNEL::OnButtondel()
{
// TODO: Add your control notification handler code here
int choice=CDialog::GetCheckedRadioButton(IDC_RADIO1,IDC_RADIO4);
if(choice==IDC_RADIO1)
{
int i=m_basic.GetHotItem();
CString strSQL;
if(i==-1){
MessageBox("please choose a record first!");
}
else{
int keyid=atoi(m_basic.GetItemText(i,0));
strSQL.Format("delete from PERSONNEL where EMP_NO=%d",keyid);
m_database.ExecuteSQL(strSQL);
strSQL.Format("delete from PERSONNEL_PLAN where EMP_NO=%d",keyid);
m_database.ExecuteSQL(strSQL);
strSQL.Format("delete from SCORE where EMP_NO=%d",keyid);
m_database.ExecuteSQL(strSQL);
strSQL.Format("delete from COURSE_NEED where COURSE_NEED=%d",keyid);
m_database.ExecuteSQL(strSQL);
m_database.Close();
RefreshData();
}
}
else if(choice==IDC_RADIO2)
{
int i=m_plan.GetSelectionMark();
CString strSQL;
if(i==-1){
MessageBox("please choose a record first!");
}
else{
int keyid=atoi(m_plan.GetItemText(i,1));
strSQL.Format("delete from PERSONNEL_PLAN where COURSE_ID=%d",keyid);
m_database.ExecuteSQL(strSQL);
m_database.Close();
RefreshData();
}
}
else if(choice==IDC_RADIO3)
{
int i=m_need.GetSelectionMark();
CString strSQL;
if(i==-1){
MessageBox("please choose a record first!");
}
else{
int keyid=atoi(m_need.GetItemText(i,0));
strSQL.Format("delete from COURSE_NEED where COURSE_ID=%d",keyid);
m_database.ExecuteSQL(strSQL);
m_database.Close();
RefreshData();
}
}
else if(choice==IDC_RADIO4)
{
int i=m_score.GetSelectionMark();
CString strSQL;
if(i==-1){
MessageBox("please choose a record first!");
}
else{
int keyid=atoi(m_score.GetItemText(i,1));
strSQL.Format("delete from SCORE where COURSE_ID=%d",keyid);
m_database.ExecuteSQL(strSQL);
m_database.Close();
RefreshData();
}
}
else{
MessageBox("please choose a class first!");
}
}
void CDIALOG_PERSONNEL::OnRadio4()
{
// TODO: Add your control notification handler code here
CDialog::CheckRadioButton(IDC_RADIO1,IDC_RADIO4,IDC_RADIO4);
}
void CDIALOG_PERSONNEL::OnReturnList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
*pResult = 0;
}
void CDIALOG_PERSONNEL::OnButtonquery()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString m_realfield;
if(m_field.Compare("员工号")==0)
{
m_realfield.Format("EMP_NO");
p_query.Format("select * from PERSONNEL where %s%s%d",m_realfield,m_relation,atoi(m_content));
}
if(m_field.Compare("员工姓名")==0)
{
m_realfield.Format("EMP_NAME");
p_query.Format("select * from PERSONNEL where %s%s'%s'",m_realfield,m_relation,m_content);
}
if(m_field.Compare("学历")==0)
{
m_realfield.Format("EMP_XL");
p_query.Format("select * from PERSONNEL where %s%s'%s'",m_realfield,m_relation,m_content);
}
if(m_field.Compare("所在部门号")==0)
{
m_realfield.Format("DEPT_ID");
p_query.Format("select * from PERSONNEL where %s%s%d",m_realfield,m_relation,atoi(m_content));
}
if(m_field.Compare("性别")==0)
{
m_realfield.Format("EMP_GENDER");
p_query.Format("select * from PERSONNEL where %s%s'%s'",m_realfield,m_relation,m_content);
}
RefreshData();
}
void CDIALOG_PERSONNEL::OnItemclickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
HD_NOTIFY *phdn = (HD_NOTIFY *) pNMHDR;
// TODO: Add your control notification handler code here
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -