Booking.cpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. // Booking.cpp : implementa tion file
  2. //
  3. #include "stdafx.h"
  4. #include "Booking.h"
  5. #include "UPhoneBox.h"
  6. #include "UPhoneBoxDlg.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. extern BOOL g_bNewBooking;
  13. /////////////////////////////////////////////////////////////////////////////
  14. // Booking dialog
  15. Booking::Booking(CWnd* pParent /*=NULL*/)
  16. : CDialog(Booking::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(Booking)
  19. m_name1 = _T("");
  20. m_name2 = _T("");
  21. m_date = _T("");
  22. m_taketime = _T("");
  23. m_pos = -1;
  24. //}}AFX_DATA_INIT
  25. }
  26. void Booking::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CDialog::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(Booking)
  30. DDX_Control(pDX, IDC_EDITdate, m_dateedit);
  31. DDX_Control(pDX, IDC_COMBO2, m_combodatetime);
  32. DDX_Control(pDX, IDC_COMBO1, m_combotype);
  33. DDX_Text(pDX, IDC_EDITname1, m_name1);
  34. DDX_Text(pDX, IDC_EDITname2, m_name2);
  35. DDX_Text(pDX, IDC_EDITdate, m_date);
  36. DDX_CBString(pDX, IDC_COMBO2, m_taketime);
  37. //}}AFX_DATA_MAP
  38. }
  39. BEGIN_MESSAGE_MAP(Booking, CDialog)
  40. //{{AFX_MSG_MAP(Booking)
  41. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  42. ON_WM_CLOSE()
  43. //}}AFX_MSG_MAP
  44. END_MESSAGE_MAP()
  45. /////////////////////////////////////////////////////////////////////////////
  46. // Booking message handlers
  47. extern int g_nYearpos;
  48. extern BOOL g_bReturned2;
  49. extern CUPhoneBoxDlg *g_pMainWnd;
  50. extern void DataToArray(CArray<CStringArray, CStringArray>*List1array);
  51. BOOL Booking::OnInitDialog()
  52. {
  53. CDialog::OnInitDialog();
  54. // TODO: Add extra initialization here
  55. m_combotype.AddString("预约拍照");
  56. m_combotype.AddString("预约选片");
  57. m_combotype.AddString("预约看设计");
  58. m_combotype.AddString("预约取件");
  59. m_combodatetime.AddString("上午9点");
  60. m_combodatetime.AddString("上午10点");
  61. m_combodatetime.AddString("上午11点");
  62. m_combodatetime.AddString("上午12点");
  63. m_combodatetime.AddString("下午1点");
  64. m_combodatetime.AddString("下午2点");
  65. m_combodatetime.AddString("下午3点");
  66. m_combodatetime.AddString("下午4点");
  67. m_combodatetime.AddString("下午5点");
  68. m_combodatetime.AddString("下午6点");
  69. m_combodatetime.AddString("晚上7点");
  70. m_combodatetime.AddString("晚上8点");
  71. m_combodatetime.AddString("晚上9点");
  72. m_combodatetime.AddString("晚上10点");
  73. g_nYearpos = -1;
  74. if (g_bNewBooking)
  75. {
  76. /* g_sendhead.code[0]=179;
  77. g_sendhead.tabcount=1;
  78. g_sendhead.bsql=0;
  79. g_pMainWnd->ProcessChatMessageRequest2(1);
  80. for(int i=0; i<20; i++)
  81. {
  82. if(g_bReturned2)break;
  83. ::Sleep (500);
  84. }
  85. if(i>=20)
  86. {
  87. nNeedConn2=1;
  88. CDialog::OnCancel ();
  89. return 0;
  90. }
  91. DataToArray(&m_Clientarray);*/
  92. GetListData(179, &m_Clientarray, "", 0, 0);
  93. m_pos = -1;
  94. for (int i = 0; i < m_Clientarray.GetSize(); i++)
  95. {
  96. if (m_id == m_Clientarray.ElementAt(i).ElementAt(0))
  97. {
  98. m_pos = i;
  99. break;
  100. }
  101. }
  102. m_array.Add("");
  103. m_array.Add("");
  104. m_array.Add("");
  105. m_array.Add("");
  106. m_array.Add("");
  107. m_array.Add("");
  108. m_array.Add("");
  109. m_array.Add("");
  110. }
  111. else
  112. {
  113. CArray<CStringArray, CStringArray>List1array;
  114. /* CString filter="id='"+m_id+"'";
  115. g_sendhead.code[0]=53;
  116. g_sendhead.tabcount=1;
  117. g_sendhead.bsql=0;
  118. g_pMainWnd->ProcessChatMessageRequest2(filter);
  119. for(int i=0; i<20; i++)
  120. {
  121. if(g_bReturned2)break;
  122. ::Sleep (500);
  123. }
  124. if(i>=20)
  125. {
  126. nNeedConn2=1;
  127. CDialog::OnCancel ();
  128. return 0;
  129. }
  130. DataToArray(&List1array);*/
  131. GetListData(53, &List1array, m_id, 0, 0);
  132. if (List1array.GetSize())
  133. {
  134. m_array.Add(List1array.ElementAt(0).ElementAt(0)); // 拍照日期;
  135. m_array.Add(List1array.ElementAt(0).ElementAt(1)); // 拍照时间;
  136. m_array.Add(List1array.ElementAt(0).ElementAt(13)); // 选片日期;
  137. m_array.Add(List1array.ElementAt(0).ElementAt(18)); // 选片时间;
  138. m_array.Add(List1array.ElementAt(0).ElementAt(15)); // 取件日期;
  139. m_array.Add(List1array.ElementAt(0).ElementAt(20)); // 取件时间;
  140. m_array.Add(List1array.ElementAt(0).ElementAt(14)); // 看样日期;
  141. m_array.Add(List1array.ElementAt(0).ElementAt(19)); // 看样时间;
  142. }
  143. }
  144. return TRUE; // return TRUE unless you set the focus to a control
  145. // EXCEPTION: OCX Property Pages should return FALSE
  146. }
  147. BOOL CheckDateOK(CString str)
  148. {
  149. if (str.IsEmpty())return 1;
  150. CString tip;
  151. int i;
  152. CString demo = CTime::GetCurrentTime().Format("%Y-%m-%d");
  153. if (str.GetLength() != demo.GetLength())
  154. goto ll;
  155. //2009-01-01
  156. if (str.GetAt(4) != '-')
  157. goto ll;
  158. if (str.GetAt(7) != '-')
  159. goto ll;
  160. for (i = 0; i < str.GetLength(); i++)
  161. {
  162. if (i == 4 || i == 7)continue;
  163. if (str.GetAt(i) < '0' || str.GetAt(i) > '9')
  164. goto ll;
  165. }
  166. return 1;
  167. ll:
  168. tip.Format("日期:%s格式错误!\r\n样板:%s", str, demo);
  169. AfxMessageBox(tip, MB_ICONINFORMATION);
  170. return 0;
  171. }
  172. void Booking::OnOK()
  173. {
  174. // TODO: Add extra validation here
  175. UpdateData();
  176. if (!CheckDateOK(m_date))return;
  177. int pos = m_combotype.GetCurSel();
  178. if (pos == -1)
  179. {
  180. AfxMessageBox("请选择预约内容!");
  181. return;
  182. }
  183. m_array.SetAt(pos * 2, m_date);
  184. m_array.SetAt(pos * 2 + 1, m_taketime);
  185. CString sql;
  186. if (g_bNewBooking && m_pos != -1)
  187. {
  188. CString timestamp;
  189. CTime tm = CTime::GetCurrentTime();
  190. timestamp = tm.Format("%Y%m%d%H%M%S");
  191. int pos2 = m_pos;
  192. CArray<CStringArray, CStringArray>*m_pClientArray = &m_Clientarray;
  193. CString name, phone;
  194. name = m_pClientArray->ElementAt(pos2).ElementAt(1) + " " + m_pClientArray->ElementAt(pos2).ElementAt(2);
  195. if (!m_pClientArray->ElementAt(pos2).ElementAt(3).IsEmpty())
  196. phone = m_pClientArray->ElementAt(pos2).ElementAt(3) + " " + m_pClientArray->ElementAt(pos2).ElementAt(4);
  197. else
  198. phone = m_pClientArray->ElementAt(pos2).ElementAt(4);
  199. CString taoxiname = m_pClientArray->ElementAt(pos2).ElementAt(5);
  200. CString m_taoxijiage = m_pClientArray->ElementAt(pos2).ElementAt(6);
  201. CString m_waiter1 = m_pClientArray->ElementAt(pos2).ElementAt(7);
  202. CString m_waiter2 = m_pClientArray->ElementAt(pos2).ElementAt(8);
  203. CString ren = m_pClientArray->ElementAt(pos2).ElementAt(9);
  204. CString money3 = m_pClientArray->ElementAt(pos2).ElementAt(10);
  205. CString m_id = m_pClientArray->ElementAt(pos2).ElementAt(0);
  206. CString clothescount;
  207. if (!m_pClientArray->ElementAt(pos2).ElementAt(11).IsEmpty())
  208. clothescount = "服装:" + m_pClientArray->ElementAt(pos2).ElementAt(11);
  209. sql.Format("insert into [todaytake]([name],[phone],[time],[type],[price],[waiter1],[waiter2],[receptionist],\
  210. [arrearage],[remark],[clerk],[timestamp],[date],[mode],[arrive],[id])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%s','%s')", \
  211. name, phone, m_taketime, taoxiname, m_taoxijiage, m_waiter1, m_waiter2, ren, money3, clothescount, "电话预约", timestamp, m_date, pos, "未到", m_id);
  212. }
  213. else
  214. {
  215. if (pos == 0)
  216. sql.Format("update dindan set [time2]='%s',[taketime]='%s' where id='%s' ", \
  217. m_date, m_taketime, m_id);
  218. else if (pos == 1)
  219. sql.Format("update dindan set [time4]='%s',[datetime4]='%s' where id='%s' ", \
  220. m_date, m_taketime, m_id);
  221. else if (pos == 2)
  222. sql.Format("update dindan set [time6]='%s',[datetime6]='%s' where id='%s' ", \
  223. m_date, m_taketime, m_id);
  224. else
  225. sql.Format("update dindan set [time5]='%s',[datetime5]='%s' where id='%s' ", \
  226. m_date, m_taketime, m_id);
  227. }
  228. g_sendhead.bsql = 1;
  229. g_nYearpos = -1;
  230. g_pMainWnd->ProcessChatMessageRequest2(sql);
  231. int i ;
  232. for ( i = 0; i < 20; i++)
  233. {
  234. if (g_bReturned2)break;
  235. ::Sleep(500);
  236. }
  237. if (i >= 20)
  238. {
  239. nNeedConn2 = 1;
  240. AfxMessageBox("保存失败!");
  241. return;
  242. }
  243. AfxMessageBox("保存成功!");
  244. // CDialog::OnOK();
  245. }
  246. void Booking::OnSelchangeCombo1()
  247. {
  248. // TODO: Add your control notification handler code here
  249. UpdateData();
  250. int pos = m_combotype.GetCurSel();
  251. if (pos == -1)
  252. {
  253. return;
  254. }
  255. if (m_array.GetSize())
  256. {
  257. m_date = m_array.ElementAt(pos * 2);
  258. m_taketime = m_array.ElementAt(pos * 2 + 1);
  259. UpdateData(0);
  260. }
  261. }
  262. void Booking::OnClose()
  263. {
  264. // TODO: Add your message handler code here and/or call default
  265. DestroyWindow();
  266. // CDialog::OnClose();
  267. }
  268. void Booking::OnCancel()
  269. {
  270. // TODO: Add extra cleanup here
  271. DestroyWindow();
  272. // CDialog::OnCancel();
  273. }