?? dialog_personnel.cpp
字號(hào):
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,"員工號(hào)");
m_basic.InsertColumn(1,"員工姓名");
m_basic.InsertColumn(2,"所在部門號(hào)");
m_basic.InsertColumn(3,"學(xué)歷");
m_basic.InsertColumn(4,"性別");
m_basic.InsertColumn(5,"生日");
m_basic.InsertColumn(6,"籍貫");
m_basic.InsertColumn(7,"國(guó)籍");
m_basic.InsertColumn(8,"民族");
m_basic.InsertColumn(9,"身份證號(hào)");
m_basic.InsertColumn(10,"婚姻狀況");
m_basic.InsertColumn(11,"健康狀況");
m_basic.InsertColumn(12,"參加工作時(shí)間");
m_basic.InsertColumn(13,"員工狀態(tài)");
m_basic.InsertColumn(14,"狀態(tài)時(shí)間");
m_basic.InsertColumn(15,"家庭住址");
m_basic.InsertColumn(16,"聯(lián)系電話");
m_basic.InsertColumn(17,"Email地址");
m_basic.InsertColumn(18,"工作崗位代號(hào)");
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,"員工號(hào)");
m_score.InsertColumn(1,"課程號(hào)");
m_score.InsertColumn(2,"上課時(shí)間");
m_score.InsertColumn(3,"上課地點(diǎn)");
m_score.InsertColumn(4,"教師號(hào)");
m_score.InsertColumn(5,"成績(jī)1");
m_score.InsertColumn(6,"成績(jī)2");
m_score.InsertColumn(7,"教師評(píng)語(yǔ)");
m_score.InsertColumn(8,"通過(guò)與否");
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,"課程號(hào)");
m_need.InsertColumn(1,"課程需要者號(hào)");
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,"員工號(hào)");
m_plan.InsertColumn(1,"課程號(hào)");
m_plan.InsertColumn(2,"課程開(kāi)始時(shí)間");
m_plan.InsertColumn(3,"課程結(jié)束時(shí)間");
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("員工號(hào)")==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("學(xué)歷")==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("所在部門號(hào)")==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;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -