AddHospitalClient.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  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(phone1.Left (1)=="1")
  309. {
  310. if(CheckPhoneType(phone1)==-1)
  311. {
  312. AfxMessageBox("手机号码:"+phone1+"错误!", MB_ICONINFORMATION);
  313. return;
  314. }
  315. }
  316. }
  317. phone2.TrimLeft ();
  318. phone2.TrimRight ();
  319. if(!phone2.IsEmpty ())
  320. {
  321. if(phone2.Left (1)=="1")
  322. {
  323. if(CheckPhoneType(phone2)==-1)
  324. {
  325. AfxMessageBox("手机号码:"+phone2+"错误!", MB_ICONINFORMATION);
  326. return;
  327. }
  328. }
  329. }
  330. food=sex=type=hospital=from=clerk="";
  331. int pos=foodCombo.GetCurSel ();
  332. if(pos!=-1)
  333. {
  334. foodCombo.GetLBText (pos, food);
  335. }
  336. pos=sexCombo.GetCurSel ();
  337. if(pos!=-1)
  338. {
  339. sexCombo.GetLBText (pos, sex);
  340. }
  341. pos=typeCombo.GetCurSel ();
  342. if(pos!=-1)
  343. {
  344. typeCombo.GetLBText (pos, type);
  345. }
  346. pos=hospitalCombo.GetCurSel ();
  347. if(pos!=-1)
  348. {
  349. hospitalCombo.GetLBText (pos, hospital);
  350. }
  351. pos=fromCombo.GetCurSel ();
  352. if(pos!=-1)
  353. {
  354. fromCombo.GetLBText (pos, from);
  355. }
  356. pos=clerkCombo.GetCurSel ();
  357. if(pos!=-1)
  358. {
  359. clerkCombo.GetLBText (pos, clerk);
  360. }
  361. CString strRes1,strRes2;
  362. ChinesePinYin::GetFirstLetter(name1, strRes1);
  363. ChinesePinYin::GetFirstLetter(name2, strRes2);
  364. CString sql,sql2;
  365. if(bAdd)
  366. 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')",
  367. 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);
  368. else
  369. 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'",
  370. 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);
  371. g_sendhead.bsql=1;
  372. g_pMainWnd->ProcessChatMessageRequest2(sql);
  373. if(g_bSendOK==0)
  374. return;
  375. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  376. bAdd=0;
  377. }
  378. BOOL AddHospitalClient::NewID()
  379. {
  380. g_bNoConnDlg=1;
  381. CString date=g_date;date.Replace("-", "");
  382. CString sql;
  383. sql="select max(id) as cot from [hospitalclient] where id like '"+date+"%' ";
  384. g_sendhead.bsql=1;
  385. g_pMainWnd->ProcessChatMessageRequest2(sql);
  386. g_bNoConnDlg=0;
  387. if(g_bSendOK==0)return 0;
  388. date.Replace ("-", "");
  389. no.Format ("%s-%03d", date, g_ncount+1);
  390. SetDlgItemText(IDC_EDITno, no);
  391. return 1;
  392. }
  393. void AddHospitalClient::GetContactReg()
  394. {
  395. CString filter="id='"+no+"'";
  396. g_sendhead.bsql=0;
  397. g_sendhead.code[0]=204;
  398. g_sendhead.tabcount=1;
  399. g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
  400. DataToArray(&g_List1array);
  401. m_List1.DeleteAllItems2 ();
  402. int ii=0;
  403. m_List1.m_arLabels.SetSize( g_List1array.GetSize (), 1 );
  404. int count=0;
  405. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  406. {
  407. m_List1.m_arLabels.ElementAt (count++).Copy (g_List1array.ElementAt (ii));
  408. }
  409. m_List1.m_arLabels.SetSize(count, 1);
  410. ii=count;
  411. m_List1.m_LabelCount=ii;
  412. m_List1.SetItemCountEx (ii);
  413. }
  414. void AddHospitalClient::OnButton2()
  415. {
  416. // TODO: Add your control notification handler code here
  417. POSITION pos;
  418. pos=m_List1.GetFirstSelectedItemPosition();
  419. if(pos==NULL)
  420. {
  421. AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION);return;
  422. return;
  423. }
  424. if(AfxMessageBox("提醒:删除后无法恢复, 继续吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  425. int iItem=m_List1.GetNextSelectedItem(pos);
  426. CString autoid=m_List1.GetItemText (iItem, 0);
  427. CString sql;
  428. sql.Format ("delete from [hospitalclientcontactreg] where autoid=%d", atoi(autoid) );
  429. g_sendhead.bsql=1;
  430. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  431. GetContactReg();
  432. }
  433. void AddHospitalClient::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  434. {
  435. // TODO: Add your control notification handler code here
  436. POSITION pos;
  437. pos=m_List1.GetFirstSelectedItemPosition();
  438. if(pos==NULL)
  439. {
  440. businesstypeCombo.SetCurSel (-1);
  441. businessintentionCombo.SetCurSel (-1);
  442. desaddrCombo.SetCurSel (-1);
  443. bookingdate = GetTmFromStr(g_date);
  444. businessremark = _T("");
  445. alarmcheck = FALSE;
  446. alarmdate = GetTmFromStr(g_date);
  447. UpdateData(0);
  448. return;
  449. }
  450. int iItem=m_List1.GetNextSelectedItem(pos);
  451. CString autoid = m_List1.GetItemText (iItem, 0);
  452. businesstype = m_List1.GetItemText (iItem, 1);
  453. businessintention = m_List1.GetItemText (iItem, 2);
  454. bookingdate = GetTmFromStr(m_List1.GetItemText (iItem, 3));
  455. desaddr = m_List1.GetItemText (iItem, 4);
  456. businessremark = m_List1.GetItemText (iItem, 5);
  457. if(m_List1.GetItemText (iItem, 6)=="提醒")
  458. alarmcheck = 1;
  459. else
  460. alarmcheck = 0;
  461. alarmdate = GetTmFromStr(m_List1.GetItemText (iItem, 7));
  462. if(businesstypeCombo.FindString (0, businesstype)==-1)
  463. businesstypeCombo.AddString (businesstype);
  464. businesstypeCombo.SetCurSel (businesstypeCombo.FindString (0, businesstype));
  465. if(businessintentionCombo.FindString (0, businessintention)==-1)
  466. businessintentionCombo.AddString (businessintention);
  467. businessintentionCombo.SetCurSel (businessintentionCombo.FindString (0, businessintention));
  468. if(desaddrCombo.FindString (0, desaddr)==-1)
  469. desaddrCombo.AddString (desaddr);
  470. desaddrCombo.SetCurSel (desaddrCombo.FindString (0, desaddr));
  471. UpdateData(0);
  472. *pResult = 0;
  473. }
  474. void AddHospitalClient::OnButton1()
  475. {
  476. // TODO: Add your control notification handler code here
  477. UpdateData();
  478. if(bAdd)
  479. {
  480. AfxMessageBox("请先保存基本资料!", MB_ICONINFORMATION);return;
  481. return;
  482. }
  483. CString autoid;
  484. {
  485. POSITION pos;
  486. pos=m_List1.GetFirstSelectedItemPosition();
  487. if(pos!=NULL)
  488. {
  489. int iItem=m_List1.GetNextSelectedItem(pos);
  490. autoid = m_List1.GetItemText (iItem, 0);
  491. }
  492. }
  493. businesstype=businessintention=desaddr="";
  494. int pos=businesstypeCombo.GetCurSel ();
  495. if(pos!=-1)
  496. {
  497. businesstypeCombo.GetLBText (pos, businesstype);
  498. }
  499. else
  500. {
  501. AfxMessageBox("资料不全!", MB_ICONINFORMATION);return;
  502. return;
  503. }
  504. pos=businessintentionCombo.GetCurSel ();
  505. if(pos!=-1)
  506. {
  507. businessintentionCombo.GetLBText (pos, businessintention);
  508. }
  509. pos=desaddrCombo.GetCurSel ();
  510. if(pos!=-1)
  511. {
  512. desaddrCombo.GetLBText (pos, desaddr);
  513. }
  514. CString salarmcheck;
  515. if(alarmcheck)
  516. salarmcheck="提醒";
  517. else
  518. salarmcheck="不提醒";
  519. CString sql;
  520. if(autoid=="")
  521. sql.Format ("insert into [hospitalclientcontactreg]([id],[businesstype],[businessintention],[bookingdate],[desaddr],[businessremark],[alarmcheck],[alarmdate])values('%s','%s','%s','%s','%s','%s','%s','%s')",
  522. no,businesstype,businessintention,bookingdate.Format ("%Y-%m-%d"),desaddr,businessremark,salarmcheck,alarmdate.Format ("%Y-%m-%d"));
  523. else
  524. sql.Format ("update [hospitalclientcontactreg] set [businesstype]='%s',[businessintention]='%s',[bookingdate]='%s',[desaddr]='%s',[businessremark]='%s',[alarmcheck]='%s',[alarmdate]='%s' where [autoid]=%s",
  525. businesstype,businessintention,bookingdate.Format ("%Y-%m-%d"),desaddr,businessremark,salarmcheck,alarmdate.Format ("%Y-%m-%d"), autoid);
  526. g_sendhead.bsql=1;
  527. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  528. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  529. GetContactReg();
  530. }
  531. HBRUSH AddHospitalClient::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  532. {
  533. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  534. if ( nCtlColor == CTLCOLOR_DLG )
  535. return g_dlgBrush;
  536. else if ( nCtlColor == CTLCOLOR_STATIC )
  537. {
  538. //pDC->SetBkColor(g_bkcol);
  539. pDC->SetBkMode(TRANSPARENT);
  540. hbr=(HBRUSH)g_dlgBrush;
  541. }
  542. return hbr;
  543. }