AddHospitalClient.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. // AddHospitalClient.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "AddHospitalClient.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // AddHospitalClient dialog
  13. AddHospitalClient::AddHospitalClient(CWnd* pParent /*=NULL*/)
  14. : CDialog(AddHospitalClient::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(AddHospitalClient)
  17. checkmsg = FALSE;
  18. name1 = _T("");
  19. name2 = _T("");
  20. food = _T("");
  21. sex = _T("");
  22. check1 = FALSE;
  23. birthdaytype = 0;
  24. birthday = _T("");
  25. pregnancydays = _T("");
  26. qq = _T("");
  27. date1 = GetTmFromStr(g_date);
  28. no = _T("");
  29. from = _T("");
  30. clerk = _T("");
  31. type = _T("");
  32. hospital = _T("");
  33. remark = _T("");
  34. phone1 = _T("");
  35. phone2 = _T("");
  36. phone3 = _T("");
  37. phone4 = _T("");
  38. phone5 = _T("");
  39. addr1 = _T("");
  40. addr2 = _T("");
  41. addr3 = _T("");
  42. post1 = _T("");
  43. post2 = _T("");
  44. post3 = _T("");
  45. businesstype = _T("");
  46. businessintention = _T("");
  47. bookingdate = GetTmFromStr(g_date);
  48. desaddr = _T("");
  49. businessremark = _T("");
  50. alarmcheck = FALSE;
  51. alarmdate = GetTmFromStr(g_date);
  52. bAdd=1;
  53. //}}AFX_DATA_INIT
  54. }
  55. void AddHospitalClient::DoDataExchange(CDataExchange* pDX)
  56. {
  57. CDialog::DoDataExchange(pDX);
  58. //{{AFX_DATA_MAP(AddHospitalClient)
  59. DDX_Control(pDX, IDC_LIST2, m_List1);
  60. DDX_Control(pDX, IDC_EDITBirthday, m_datectrl);
  61. DDX_Control(pDX, IDC_COMBObusinessintention, businessintentionCombo);
  62. DDX_Control(pDX, IDC_COMBOtype, typeCombo);
  63. DDX_Control(pDX, IDC_COMBOsex, sexCombo);
  64. DDX_Control(pDX, IDC_COMBOhospital, hospitalCombo);
  65. DDX_Control(pDX, IDC_COMBOfrom, fromCombo);
  66. DDX_Control(pDX, IDC_COMBOfood, foodCombo);
  67. DDX_Control(pDX, IDC_COMBOdesaddr, desaddrCombo);
  68. DDX_Control(pDX, IDC_COMBOclerk, clerkCombo);
  69. DDX_Control(pDX, IDC_COMBObusinesstype, businesstypeCombo);
  70. DDX_Check(pDX, IDC_CHECK1, check1);
  71. DDX_Check(pDX, IDC_CHECKalarmcheck, alarmcheck);
  72. DDX_Check(pDX, IDC_CHECKmsg, checkmsg);
  73. DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKERalarmdate, alarmdate);
  74. DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKERbookingdate, bookingdate);
  75. DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKERdate1, date1);
  76. DDX_Text(pDX, IDC_EDITaddr1, addr1);
  77. DDX_Text(pDX, IDC_EDITaddr2, addr2);
  78. DDX_Text(pDX, IDC_EDITaddr3, addr3);
  79. DDX_Text(pDX, IDC_EDITBirthday, birthday);
  80. DDX_Text(pDX, IDC_EDITbusinessremark, businessremark);
  81. DDX_Text(pDX, IDC_EDITname1, name1);
  82. DDX_Text(pDX, IDC_EDITname2, name2);
  83. DDX_Text(pDX, IDC_EDITno, no);
  84. DDX_Text(pDX, IDC_EDITphone1, phone1);
  85. DDX_Text(pDX, IDC_EDITphone2, phone2);
  86. DDX_Text(pDX, IDC_EDITphone3, phone3);
  87. DDX_Text(pDX, IDC_EDITphone4, phone4);
  88. DDX_Text(pDX, IDC_EDITphone5, phone5);
  89. DDX_Text(pDX, IDC_EDITpost1, post1);
  90. DDX_Text(pDX, IDC_EDITpost2, post2);
  91. DDX_Text(pDX, IDC_EDITpost3, post3);
  92. DDX_Text(pDX, IDC_EDITpregnancydays, pregnancydays);
  93. DDX_Text(pDX, IDC_EDITqq, qq);
  94. DDX_Text(pDX, IDC_EDITremark, remark);
  95. DDX_Radio(pDX, IDC_RADIO1, birthdaytype);
  96. //}}AFX_DATA_MAP
  97. }
  98. BEGIN_MESSAGE_MAP(AddHospitalClient, CDialog)
  99. //{{AFX_MSG_MAP(AddHospitalClient)
  100. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  101. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  102. ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
  103. //}}AFX_MSG_MAP
  104. ON_WM_CTLCOLOR()
  105. END_MESSAGE_MAP()
  106. /////////////////////////////////////////////////////////////////////////////
  107. // AddHospitalClient message handlers
  108. extern BOOL CALLBACK EnumChildProc2(HWND hwnd,LPARAM lParam);
  109. BOOL AddHospitalClient::OnInitDialog()
  110. {
  111. CDialog::OnInitDialog();
  112. CRect rc2;
  113. GetWindowRect(rc2);
  114. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  115. g_WidthScale2 = (float)g_rc.Width()/(float)rc2.Width(); // new/Old
  116. g_HeightScale2 = (float)g_rc.Height()/(float)rc2.Height();
  117. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc2,0);
  118. #if defined(VC70) || defined(VC80)
  119. businessintentionCombo.GetWindowRect(rc2);
  120. rc2.bottom += 200;
  121. ScreenToClient(rc2);
  122. businessintentionCombo.MoveWindow(rc2);
  123. typeCombo.GetWindowRect(rc2);
  124. rc2.bottom += 200;
  125. ScreenToClient(rc2);
  126. typeCombo.MoveWindow(rc2);
  127. sexCombo.GetWindowRect(rc2);
  128. rc2.bottom += 200;
  129. ScreenToClient(rc2);
  130. sexCombo.MoveWindow(rc2);
  131. hospitalCombo.GetWindowRect(rc2);
  132. rc2.bottom += 200;
  133. ScreenToClient(rc2);
  134. hospitalCombo.MoveWindow(rc2);
  135. fromCombo.GetWindowRect(rc2);
  136. rc2.bottom += 200;
  137. ScreenToClient(rc2);
  138. fromCombo.MoveWindow(rc2);
  139. foodCombo.GetWindowRect(rc2);
  140. rc2.bottom += 200;
  141. ScreenToClient(rc2);
  142. foodCombo.MoveWindow(rc2);
  143. desaddrCombo.GetWindowRect(rc2);
  144. rc2.bottom += 200;
  145. ScreenToClient(rc2);
  146. desaddrCombo.MoveWindow(rc2);
  147. businesstypeCombo.GetWindowRect(rc2);
  148. rc2.bottom += 200;
  149. ScreenToClient(rc2);
  150. businesstypeCombo.MoveWindow(rc2);
  151. #endif
  152. m_List1.SetHeadings("id,0;业务种类,100;业务意向,100;预约日期,100;上门地址,100;备注,100;是否提醒,100;提醒日期,100" );
  153. // m_List1.LoadColumnInfo (118);
  154. foodCombo.AddString ("母乳");
  155. foodCombo.AddString ("人工");
  156. foodCombo.AddString ("混合");
  157. desaddrCombo.AddString ("自家地址");
  158. desaddrCombo.AddString ("婆家地址");
  159. desaddrCombo.AddString ("娘家地址");
  160. sexCombo.AddString ("男");
  161. sexCombo.AddString ("女");
  162. g_sendhead.bsql=0;
  163. g_sendhead.code[0]=200;
  164. g_sendhead.code[1]=201;
  165. g_sendhead.code[2]=202;
  166. g_sendhead.code[3]=203;
  167. g_sendhead.code[4]=82;
  168. g_sendhead.tabcount=5;
  169. g_pMainWnd->ProcessChatMessageRequest2(3);
  170. if(g_bSendOK==0)
  171. {
  172. CDialog::OnCancel ();
  173. return 0;
  174. }
  175. CArray<CStringArray, CStringArray>List1array;
  176. CArray<CStringArray, CStringArray>List2array;
  177. CArray<CStringArray, CStringArray>List3array;
  178. CArray<CStringArray, CStringArray>List4array;
  179. CArray<CStringArray, CStringArray>List5array;
  180. DataToArray(&List1array, &List2array, &List3array, &List4array, &List5array);
  181. int ii = 0;
  182. for( ii=0; ii<List1array.GetSize (); ii++)
  183. businesstypeCombo.AddString ( List1array.ElementAt (ii).ElementAt(0) );
  184. for( ii=0; ii<List2array.GetSize (); ii++)
  185. businessintentionCombo.AddString ( List2array.ElementAt (ii).ElementAt(0) );
  186. for( ii=0; ii<List3array.GetSize (); ii++)
  187. typeCombo.AddString ( List3array.ElementAt (ii).ElementAt(0) );
  188. for( ii=0; ii<List4array.GetSize (); ii++)
  189. hospitalCombo.AddString ( List4array.ElementAt (ii).ElementAt(0) );
  190. for( ii=0; ii<List5array.GetSize (); ii++)
  191. fromCombo.AddString ( List5array.ElementAt (ii).ElementAt(0) );
  192. if(bAdd)
  193. {
  194. if(NewID()==0)
  195. {
  196. CDialog::OnCancel();return 0;
  197. }
  198. }
  199. else
  200. {
  201. SetWindowText("客户资料-修改");
  202. CString filter="id='"+no+"';id='"+no+"'";
  203. g_sendhead.bsql=0;
  204. g_sendhead.code[0]=206;
  205. g_sendhead.code[1]=204;
  206. g_sendhead.tabcount=2;
  207. g_pMainWnd->ProcessChatMessageRequest2(filter);
  208. if(g_bSendOK==0)
  209. {
  210. CDialog::OnCancel();return 0;
  211. }
  212. CArray<CStringArray, CStringArray>List1array;
  213. DataToArray(&List1array, &g_List1array);
  214. if(List1array.GetSize ()==0)
  215. {
  216. AfxMessageBox("此客人记录已被删除!");
  217. CDialog::OnCancel();return 0;
  218. }
  219. checkmsg = atoi(List1array.ElementAt (0).ElementAt (0));
  220. name1 = List1array.ElementAt (0).ElementAt (1);
  221. name2 = List1array.ElementAt (0).ElementAt (2);
  222. food = List1array.ElementAt (0).ElementAt (3);
  223. sex = List1array.ElementAt (0).ElementAt (4);
  224. check1 = atoi(List1array.ElementAt (0).ElementAt (5));
  225. birthdaytype = atoi(List1array.ElementAt (0).ElementAt (6));
  226. birthday = List1array.ElementAt (0).ElementAt (7);
  227. pregnancydays = List1array.ElementAt (0).ElementAt (8);
  228. qq = List1array.ElementAt (0).ElementAt (9);
  229. date1 = GetTmFromStr(List1array.ElementAt (0).ElementAt (10));
  230. no = List1array.ElementAt (0).ElementAt (11);
  231. from = List1array.ElementAt (0).ElementAt (12);
  232. clerk = List1array.ElementAt (0).ElementAt (13);
  233. type = List1array.ElementAt (0).ElementAt (14);
  234. hospital = List1array.ElementAt (0).ElementAt (15);
  235. remark = List1array.ElementAt (0).ElementAt (16);
  236. phone1 = List1array.ElementAt (0).ElementAt (17);
  237. phone2 = List1array.ElementAt (0).ElementAt (18);
  238. phone3 = List1array.ElementAt (0).ElementAt (19);
  239. phone4 = List1array.ElementAt (0).ElementAt (20);
  240. phone5 = List1array.ElementAt (0).ElementAt (21);
  241. addr1 = List1array.ElementAt (0).ElementAt (22);
  242. addr2 = List1array.ElementAt (0).ElementAt (23);
  243. addr3 = List1array.ElementAt (0).ElementAt (24);
  244. post1 = List1array.ElementAt (0).ElementAt (25);
  245. post2 = List1array.ElementAt (0).ElementAt (26);
  246. post3 = List1array.ElementAt (0).ElementAt (27);
  247. if(foodCombo.FindString (0, food)==-1)
  248. foodCombo.AddString (food);
  249. foodCombo.SetCurSel (foodCombo.FindString (0, food));
  250. if(sexCombo.FindString (0, sex)==-1)
  251. sexCombo.AddString (sex);
  252. sexCombo.SetCurSel (sexCombo.FindString (0, sex));
  253. if(typeCombo.FindString (0, type)==-1)
  254. typeCombo.AddString (type);
  255. typeCombo.SetCurSel (typeCombo.FindString (0, type));
  256. if(hospitalCombo.FindString (0, hospital)==-1)
  257. hospitalCombo.AddString (hospital);
  258. hospitalCombo.SetCurSel (hospitalCombo.FindString (0, hospital));
  259. if(fromCombo.FindString (0, from)==-1)
  260. fromCombo.AddString (from);
  261. fromCombo.SetCurSel (fromCombo.FindString (0, from));
  262. if(clerkCombo.FindString (0, clerk)==-1)
  263. clerkCombo.AddString (clerk);
  264. clerkCombo.SetCurSel (clerkCombo.FindString (0, clerk));
  265. m_List1.DeleteAllItems2 ();
  266. int ii=0;
  267. m_List1.m_arLabels.SetSize( g_List1array.GetSize (), 1 );
  268. int count=0;
  269. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  270. {
  271. m_List1.m_arLabels.ElementAt (count++).Copy (g_List1array.ElementAt (ii));
  272. }
  273. m_List1.m_arLabels.SetSize(count, 1);
  274. ii=count;
  275. m_List1.m_LabelCount=ii;
  276. m_List1.SetItemCountEx (ii);
  277. UpdateData(0);
  278. }
  279. clerkCombo.RefDroppedWidth();
  280. return false; // return TRUE unless you set the focus to a control
  281. // EXCEPTION: OCX Property Pages should return FALSE
  282. }
  283. // 保存资料;
  284. void AddHospitalClient::OnOK()
  285. {
  286. if(bAdd)
  287. {
  288. if(NewID()==0)
  289. {
  290. return;
  291. }
  292. }
  293. // TODO: Add extra validation here
  294. UpdateData();
  295. name1.TrimLeft ();
  296. name1.TrimRight ();
  297. name2.TrimLeft ();
  298. name2.TrimRight ();
  299. if(name1.IsEmpty () && name2.IsEmpty ())
  300. {
  301. AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION);return;
  302. }
  303. if(!CheckDateOK(birthday))return;
  304. phone1.TrimLeft ();
  305. phone1.TrimRight ();
  306. if(!phone1.IsEmpty ())
  307. {
  308. #if 1 // 只判断手机长度;
  309. if (phone1.GetLength() != 11 || phone1.Left(1) != _T("1"))
  310. {
  311. if ( IDNO == MessageBox(_T("手机号码格式不正确,是否继续录入?"), _T("手机号码格式不正确"), MB_ICONWARNING|MB_YESNO) )
  312. {
  313. return;
  314. }
  315. }
  316. #else
  317. if(phone1.Left (1)=="1")
  318. {
  319. if(CheckPhoneType(phone1)==-1)
  320. {
  321. AfxMessageBox("手机号码:"+phone1+"错误!", MB_ICONINFORMATION);
  322. return;
  323. }
  324. }
  325. #endif
  326. }
  327. phone2.TrimLeft ();
  328. phone2.TrimRight ();
  329. if(!phone2.IsEmpty ())
  330. {
  331. #if 1 // 只判断手机长度;
  332. if (phone2.GetLength() != 11 || phone2.Left(1) != _T("1"))
  333. {
  334. if ( IDNO == MessageBox(_T("手机号码格式不正确,是否继续录入?"), _T("手机号码格式不正确"), MB_ICONWARNING|MB_YESNO) )
  335. {
  336. return;
  337. }
  338. }
  339. #else
  340. if(phone2.Left (1)=="1")
  341. {
  342. if(CheckPhoneType(phone2)==-1)
  343. {
  344. AfxMessageBox("手机号码:"+phone2+"错误!", MB_ICONINFORMATION);
  345. return;
  346. }
  347. }
  348. #endif
  349. }
  350. food=sex=type=hospital=from=clerk="";
  351. int pos=foodCombo.GetCurSel ();
  352. if(pos!=-1)
  353. {
  354. foodCombo.GetLBText (pos, food);
  355. }
  356. pos=sexCombo.GetCurSel ();
  357. if(pos!=-1)
  358. {
  359. sexCombo.GetLBText (pos, sex);
  360. }
  361. pos=typeCombo.GetCurSel ();
  362. if(pos!=-1)
  363. {
  364. typeCombo.GetLBText (pos, type);
  365. }
  366. pos=hospitalCombo.GetCurSel ();
  367. if(pos!=-1)
  368. {
  369. hospitalCombo.GetLBText (pos, hospital);
  370. }
  371. pos=fromCombo.GetCurSel ();
  372. if(pos!=-1)
  373. {
  374. fromCombo.GetLBText (pos, from);
  375. }
  376. pos=clerkCombo.GetCurSel ();
  377. if(pos!=-1)
  378. {
  379. clerkCombo.GetLBText (pos, clerk);
  380. }
  381. CString strRes1,strRes2;
  382. ChinesePinYin::GetFirstLetter(name1, strRes1);
  383. ChinesePinYin::GetFirstLetter(name2, strRes2);
  384. CString sql,sql2;
  385. if(bAdd)
  386. sql.Format ("insert into [hospitalclient] ([id],[checkmsg],[name1],[name2],[food],[sex],[check1],[birthdaytype],[birthday],[pregnancydays],[qq],[date1],[from],[clerk],[type],[hospital],[remark],[phone1],[phone2],[phone3],[phone4],[phone5],[addr1],[addr2],[addr3],[post1],[post2],[post3],[pinyin1],[pinyin2],[inputdate],[inputer])values('%s','%d','%s','%s','%s','%s','%d','%d','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",
  387. no,checkmsg,name1,name2,food,sex,check1,birthdaytype,birthday,pregnancydays,qq,date1.Format ("%Y-%m-%d"),from,clerk,type,hospital,remark,phone1,phone2,phone3,phone4,phone5,addr1,addr2,addr3,post1,post2,post3,strRes1,strRes2,g_date,g_user.name);
  388. else
  389. sql.Format ("update [hospitalclient] set [checkmsg]='%d',[name1]='%s',[name2]='%s',[food]='%s',[sex]='%s',[check1]='%d',[birthdaytype]='%d',[birthday]='%s',[pregnancydays]='%s',[qq]='%s',[date1]='%s',[from]='%s',[clerk]='%s',[type]='%s',[hospital]='%s',[remark]='%s',[phone1]='%s',[phone2]='%s',[phone3]='%s',[phone4]='%s',[phone5]='%s',[addr1]='%s',[addr2]='%s',[addr3]='%s',[post1]='%s',[post2]='%s',[post3]='%s',[pinyin1]='%s',[pinyin2]='%s' where [id]='%s'",
  390. checkmsg,name1,name2,food,sex,check1,birthdaytype,birthday,pregnancydays,qq,date1.Format ("%Y-%m-%d"),from,clerk,type,hospital,remark,phone1,phone2,phone3,phone4,phone5,addr1,addr2,addr3,post1,post2,post3,strRes1,strRes2,no);
  391. g_sendhead.bsql=1;
  392. g_pMainWnd->ProcessChatMessageRequest2(sql);
  393. if(g_bSendOK==0)
  394. return;
  395. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  396. bAdd=0;
  397. }
  398. BOOL AddHospitalClient::NewID()
  399. {
  400. g_bNoConnDlg=1;
  401. CString date=g_date;date.Replace("-", "");
  402. CString sql;
  403. sql="select max(id) as cot from [hospitalclient] where id like '"+date+"%' ";
  404. g_sendhead.bsql=1;
  405. g_pMainWnd->ProcessChatMessageRequest2(sql);
  406. g_bNoConnDlg=0;
  407. if(g_bSendOK==0)return 0;
  408. date.Replace ("-", "");
  409. no.Format ("%s-%03d", date, g_ncount+1);
  410. SetDlgItemText(IDC_EDITno, no);
  411. return 1;
  412. }
  413. void AddHospitalClient::GetContactReg()
  414. {
  415. CString filter="id='"+no+"'";
  416. g_sendhead.bsql=0;
  417. g_sendhead.code[0]=204;
  418. g_sendhead.tabcount=1;
  419. g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
  420. DataToArray(&g_List1array);
  421. m_List1.DeleteAllItems2 ();
  422. int ii=0;
  423. m_List1.m_arLabels.SetSize( g_List1array.GetSize (), 1 );
  424. int count=0;
  425. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  426. {
  427. m_List1.m_arLabels.ElementAt (count++).Copy (g_List1array.ElementAt (ii));
  428. }
  429. m_List1.m_arLabels.SetSize(count, 1);
  430. ii=count;
  431. m_List1.m_LabelCount=ii;
  432. m_List1.SetItemCountEx (ii);
  433. }
  434. void AddHospitalClient::OnButton2()
  435. {
  436. // TODO: Add your control notification handler code here
  437. POSITION pos;
  438. pos=m_List1.GetFirstSelectedItemPosition();
  439. if(pos==NULL)
  440. {
  441. AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);return;
  442. return;
  443. }
  444. if(AfxMessageBox("提醒:删除后无法恢复, 继续吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  445. int iItem=m_List1.GetNextSelectedItem(pos);
  446. CString autoid=m_List1.GetItemText (iItem, 0);
  447. CString sql;
  448. sql.Format ("delete from [hospitalclientcontactreg] where autoid=%d", atoi(autoid) );
  449. g_sendhead.bsql=1;
  450. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  451. GetContactReg();
  452. }
  453. void AddHospitalClient::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  454. {
  455. // TODO: Add your control notification handler code here
  456. POSITION pos;
  457. pos=m_List1.GetFirstSelectedItemPosition();
  458. if(pos==NULL)
  459. {
  460. businesstypeCombo.SetCurSel (-1);
  461. businessintentionCombo.SetCurSel (-1);
  462. desaddrCombo.SetCurSel (-1);
  463. bookingdate = GetTmFromStr(g_date);
  464. businessremark = _T("");
  465. alarmcheck = FALSE;
  466. alarmdate = GetTmFromStr(g_date);
  467. UpdateData(0);
  468. return;
  469. }
  470. int iItem=m_List1.GetNextSelectedItem(pos);
  471. CString autoid = m_List1.GetItemText (iItem, 0);
  472. businesstype = m_List1.GetItemText (iItem, 1);
  473. businessintention = m_List1.GetItemText (iItem, 2);
  474. bookingdate = GetTmFromStr(m_List1.GetItemText (iItem, 3));
  475. desaddr = m_List1.GetItemText (iItem, 4);
  476. businessremark = m_List1.GetItemText (iItem, 5);
  477. if(m_List1.GetItemText (iItem, 6)=="提醒")
  478. alarmcheck = 1;
  479. else
  480. alarmcheck = 0;
  481. alarmdate = GetTmFromStr(m_List1.GetItemText (iItem, 7));
  482. if(businesstypeCombo.FindString (0, businesstype)==-1)
  483. businesstypeCombo.AddString (businesstype);
  484. businesstypeCombo.SetCurSel (businesstypeCombo.FindString (0, businesstype));
  485. if(businessintentionCombo.FindString (0, businessintention)==-1)
  486. businessintentionCombo.AddString (businessintention);
  487. businessintentionCombo.SetCurSel (businessintentionCombo.FindString (0, businessintention));
  488. if(desaddrCombo.FindString (0, desaddr)==-1)
  489. desaddrCombo.AddString (desaddr);
  490. desaddrCombo.SetCurSel (desaddrCombo.FindString (0, desaddr));
  491. UpdateData(0);
  492. *pResult = 0;
  493. }
  494. void AddHospitalClient::OnButton1()
  495. {
  496. // TODO: Add your control notification handler code here
  497. UpdateData();
  498. if(bAdd)
  499. {
  500. AfxMessageBox("请先保存基本资料!", MB_ICONINFORMATION);return;
  501. return;
  502. }
  503. CString autoid;
  504. {
  505. POSITION pos;
  506. pos=m_List1.GetFirstSelectedItemPosition();
  507. if(pos!=NULL)
  508. {
  509. int iItem=m_List1.GetNextSelectedItem(pos);
  510. autoid = m_List1.GetItemText (iItem, 0);
  511. }
  512. }
  513. businesstype=businessintention=desaddr="";
  514. int pos=businesstypeCombo.GetCurSel ();
  515. if(pos!=-1)
  516. {
  517. businesstypeCombo.GetLBText (pos, businesstype);
  518. }
  519. else
  520. {
  521. AfxMessageBox("资料不全!", MB_ICONINFORMATION);return;
  522. return;
  523. }
  524. pos=businessintentionCombo.GetCurSel ();
  525. if(pos!=-1)
  526. {
  527. businessintentionCombo.GetLBText (pos, businessintention);
  528. }
  529. pos=desaddrCombo.GetCurSel ();
  530. if(pos!=-1)
  531. {
  532. desaddrCombo.GetLBText (pos, desaddr);
  533. }
  534. CString salarmcheck;
  535. if(alarmcheck)
  536. salarmcheck="提醒";
  537. else
  538. salarmcheck="不提醒";
  539. CString sql;
  540. if(autoid=="")
  541. sql.Format ("insert into [hospitalclientcontactreg]([id],[businesstype],[businessintention],[bookingdate],[desaddr],[businessremark],[alarmcheck],[alarmdate])values('%s','%s','%s','%s','%s','%s','%s','%s')",
  542. no,businesstype,businessintention,bookingdate.Format ("%Y-%m-%d"),desaddr,businessremark,salarmcheck,alarmdate.Format ("%Y-%m-%d"));
  543. else
  544. sql.Format ("update [hospitalclientcontactreg] set [businesstype]='%s',[businessintention]='%s',[bookingdate]='%s',[desaddr]='%s',[businessremark]='%s',[alarmcheck]='%s',[alarmdate]='%s' where [autoid]=%s",
  545. businesstype,businessintention,bookingdate.Format ("%Y-%m-%d"),desaddr,businessremark,salarmcheck,alarmdate.Format ("%Y-%m-%d"), autoid);
  546. g_sendhead.bsql=1;
  547. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  548. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  549. GetContactReg();
  550. }
  551. HBRUSH AddHospitalClient::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  552. {
  553. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  554. if ( nCtlColor == CTLCOLOR_DLG )
  555. return g_dlgBrush;
  556. else if ( nCtlColor == CTLCOLOR_STATIC )
  557. {
  558. //pDC->SetBkColor(g_bkcol);
  559. pDC->SetBkMode(TRANSPARENT);
  560. hbr=(HBRUSH)g_dlgBrush;
  561. }
  562. return hbr;
  563. }