SetLoginTime.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. // SetLoginTime.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "SetLoginTime.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // SetLoginTime dialog
  13. SetLoginTime::SetLoginTime(CWnd* pParent /*=NULL*/)
  14. : CDialog(SetLoginTime::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(SetLoginTime)
  17. m_name = _T("");
  18. m_time1 = _T("");
  19. m_time2 = _T("");
  20. m_time3 = _T("");
  21. m_time4 = _T("");
  22. //}}AFX_DATA_INIT
  23. }
  24. void SetLoginTime::DoDataExchange(CDataExchange* pDX)
  25. {
  26. CDialog::DoDataExchange(pDX);
  27. //{{AFX_DATA_MAP(SetLoginTime)
  28. DDX_Control(pDX, IDC_LIST1, m_List1);
  29. DDX_Text(pDX, IDC_EDIT1, m_name);
  30. DDX_Text(pDX, IDC_EDIT2, m_time1);
  31. DDX_Text(pDX, IDC_EDIT3, m_time2);
  32. DDX_Text(pDX, IDC_EDIT4, m_time3);
  33. DDX_Text(pDX, IDC_EDIT8, m_time4);
  34. //}}AFX_DATA_MAP
  35. }
  36. BEGIN_MESSAGE_MAP(SetLoginTime, CDialog)
  37. //{{AFX_MSG_MAP(SetLoginTime)
  38. ON_BN_CLICKED(IDC_BUTadd, OnBUTadd)
  39. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  40. //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42. /////////////////////////////////////////////////////////////////////////////
  43. // SetLoginTime message handlers
  44. BOOL SetLoginTime::OnInitDialog()
  45. {
  46. CDialog::OnInitDialog();
  47. // TODO: Add extra initialization here
  48. m_List1.SetHeadings("班次名称,90;上班时间,90;下班时间,90;上班时间2,95;下班时间2,95" );
  49. FillGrid();
  50. this->CenterWindow (g_pMainWnd);
  51. return TRUE; // return TRUE unless you set the focus to a control
  52. // EXCEPTION: OCX Property Pages should return FALSE
  53. }
  54. void SetLoginTime::FillGrid()
  55. {
  56. g_sendhead.bsql=0;
  57. g_sendhead.code[0]=97;
  58. g_sendhead.tabcount=1;
  59. g_pMainWnd->ProcessChatMessageRequest2(2);if(g_bSendOK==0)return;
  60. DataToArray(&g_List1array);
  61. m_List1.DeleteAllItems2 ();
  62. int ii=0;
  63. {
  64. m_List1.m_arLabels.SetSize( g_List1array.GetSize (), 1 );
  65. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  66. m_List1.m_arLabels.ElementAt (ii).Copy (g_List1array.ElementAt (ii));
  67. }
  68. m_List1.m_LabelCount=ii;
  69. m_List1.SetItemCountEx (ii);
  70. }
  71. void SetLoginTime::OnBUTadd()
  72. {
  73. // TODO: Add your control notification handler code here
  74. UpdateData();
  75. m_name.TrimLeft ();
  76. m_name.TrimRight ();
  77. if(m_name.IsEmpty ())
  78. {
  79. AfxMessageBox("班次名称不能为空!", MB_ICONINFORMATION);
  80. this->GetDlgItem (IDC_EDIT1)->SetFocus();
  81. return;
  82. }
  83. for(int i=0; i<m_List1.GetItemCount (); i++)
  84. {
  85. if(m_List1.GetItemText (i, 0)==m_name)
  86. {
  87. AfxMessageBox("已有此班次!", MB_ICONINFORMATION);
  88. this->GetDlgItem (IDC_EDIT1)->SetFocus();
  89. return;
  90. }
  91. }
  92. m_time1.TrimLeft ();
  93. m_time1.TrimRight ();
  94. m_time2.TrimLeft ();
  95. m_time2.TrimRight ();
  96. m_time3.TrimLeft ();
  97. m_time3.TrimRight ();
  98. m_time4.TrimLeft ();
  99. m_time4.TrimRight ();
  100. int pos=m_time1.Find (":");
  101. if(pos!=2 || m_time1.GetLength ()!=5)
  102. {
  103. AfxMessageBox("时间格式不对!", MB_ICONINFORMATION);
  104. return;
  105. }
  106. pos=m_time2.Find (":");
  107. if(pos!=2 || m_time2.GetLength ()!=5)
  108. {
  109. AfxMessageBox("时间格式不对!", MB_ICONINFORMATION);
  110. return;
  111. }
  112. if(m_time3!="")
  113. {
  114. pos=m_time3.Find (":");
  115. if(pos!=2 || m_time3.GetLength ()!=5)
  116. {
  117. AfxMessageBox("时间格式不对!", MB_ICONINFORMATION);
  118. return;
  119. }
  120. }
  121. if(m_time4!="")
  122. {
  123. pos=m_time4.Find (":");
  124. if(pos!=2 || m_time4.GetLength ()!=5)
  125. {
  126. AfxMessageBox("时间格式不对!", MB_ICONINFORMATION);
  127. return;
  128. }
  129. }
  130. CString sql;
  131. sql.Format ("insert into lonintimeset (name,time1,time2,time3,time4)values('%s','%s','%s','%s','%s')", m_name,m_time1,m_time2,m_time3,m_time4);
  132. g_sendhead.bsql=1;
  133. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  134. FillGrid();
  135. }
  136. void SetLoginTime::OnBUTdel()
  137. {
  138. // TODO: Add your control notification handler code here
  139. POSITION pos;
  140. pos=m_List1.GetFirstSelectedItemPosition();
  141. if(pos==NULL)
  142. {
  143. AfxMessageBox("请选中您要删除的班次!", MB_ICONINFORMATION);
  144. return;
  145. }
  146. if(AfxMessageBox("确认删除吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  147. int iItem=m_List1.GetNextSelectedItem(pos);
  148. CString name=m_List1.GetItemText (iItem, 0);
  149. CString sql;
  150. sql.Format ("delete from lonintimeset where name='%s'", name);
  151. g_sendhead.bsql=1;
  152. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  153. FillGrid();
  154. }