HospitalClientMsg.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. // HospitalClientMsg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "HospitalClientMsg.h"
  6. #include "MyMdi.H"
  7. #include "ModifyDinDan.h"
  8. #include "NeroDlg.h"
  9. #include "ClientRequirement.h"
  10. #include "./helper/ffsco.h"
  11. #include "SendMsgDlg.h"
  12. #include "HospitalMsgSet.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. #pragma comment(lib, "Shlwapi.lib")
  19. extern BOOL CovertDate(CString &date, CString &date2);
  20. /////////////////////////////////////////////////////////////////////////////
  21. // HospitalClientMsg
  22. IMPLEMENT_DYNCREATE(HospitalClientMsg, MyFormView)
  23. HospitalClientMsg::HospitalClientMsg()
  24. : MyFormView(HospitalClientMsg::IDD)
  25. {
  26. //{{AFX_DATA_INIT(HospitalClientMsg)
  27. m_age1 = 1;
  28. m_age2 = 100;
  29. m_radio1 = 0;
  30. m_bSearchAll=0;
  31. //}}AFX_DATA_INIT
  32. }
  33. HospitalClientMsg::~HospitalClientMsg()
  34. {
  35. }
  36. void HospitalClientMsg::DoDataExchange(CDataExchange* pDX)
  37. {
  38. MyFormView::DoDataExchange(pDX);
  39. //{{AFX_DATA_MAP(HospitalClientMsg)
  40. DDX_Control(pDX, IDC_SPIN2, m_spin2);
  41. DDX_Control(pDX, IDC_SPIN1, m_spin1);
  42. DDX_Control(pDX, IDC_LIST2, m_List1);
  43. DDX_Control(pDX, IDC_STATIC1, m_static1);
  44. DDX_Text(pDX, IDC_EDIT1, m_age1);
  45. DDX_Text(pDX, IDC_EDIT2, m_age2);
  46. DDX_Radio(pDX, IDC_RADIO1, m_radio1);
  47. //}}AFX_DATA_MAP
  48. }
  49. BEGIN_MESSAGE_MAP(HospitalClientMsg, MyFormView)
  50. //{{AFX_MSG_MAP(HospitalClientMsg)
  51. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  52. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  53. ON_BN_CLICKED(IDC_BUTshowphoto, OnBUTshowphoto)
  54. ON_BN_CLICKED(IDC_BUTexportphoto, OnBUTexportphoto)
  55. ON_BN_CLICKED(IDC_BUTimportphoto, OnBUTimportphoto)
  56. ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST2, OnItemchangedList2)
  57. ON_BN_CLICKED(IDC_BUTburncd, OnBUTHospitalClientMsg)
  58. ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
  59. ON_BN_CLICKED(IDC_BUTburncd2, OnBUTburncd2)
  60. ON_BN_CLICKED(IDC_BUTsendmsg, OnBUTsendmsg)
  61. ON_BN_CLICKED(IDC_BUTprint3, OnBUTprint3)
  62. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  63. //}}AFX_MSG_MAP
  64. END_MESSAGE_MAP()
  65. /////////////////////////////////////////////////////////////////////////////
  66. // HospitalClientMsg diagnostics
  67. #ifdef _DEBUG
  68. void HospitalClientMsg::AssertValid() const
  69. {
  70. MyFormView::AssertValid();
  71. }
  72. void HospitalClientMsg::Dump(CDumpContext& dc) const
  73. {
  74. MyFormView::Dump(dc);
  75. }
  76. #endif //_DEBUG
  77. /////////////////////////////////////////////////////////////////////////////
  78. // HospitalClientMsg message handlers
  79. void HospitalClientMsg::OnInitialUpdate()
  80. {
  81. MyFormView::OnInitialUpdate();
  82. GetDlgItem(IDC_BUTprint3)->EnableWindow(IsHasRights2new(49));
  83. // TODO: Add your specialized code here and/or call the base class
  84. CMyMdi Mdi;
  85. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  86. // Here we create the outbar control using the splitter as its parent
  87. // and setting its id to the first pane.
  88. CRect rc2;
  89. GetWindowRect(rc2);
  90. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  91. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  92. m_spin1.SetRange (1, 500);
  93. m_spin2.SetRange (1, 500);
  94. int idarray[]={IDC_BUTsendmsg,IDC_BUTprint3,IDC_BUTclose};
  95. int idcount=3;
  96. int btnwid;
  97. CRect prerc;
  98. for(int a=idcount-2; a>=0; a--)
  99. {
  100. GetDlgItem(idarray[a+1])->GetWindowRect (prerc);
  101. ScreenToClient(prerc);
  102. GetDlgItem(idarray[a])->GetWindowRect (rc2);
  103. ScreenToClient(rc2);
  104. btnwid=rc2.Width ();
  105. rc2.right =prerc.left ;
  106. rc2.left =rc2.right -btnwid;
  107. GetDlgItem(idarray[a])->MoveWindow (rc2);
  108. }
  109. m_static1.SetFont (&g_titlefont);
  110. m_List1.SetHeadings("来单批号,100;客户姓名,100;宝宝姓名,100;宝宝性别,100;是否农历,100;日期类型,100;日期,100;怀孕周期,100;宝宝年龄,100;宝宝天数,100;怀孕天数,100;QQ,100;来单日期,100;区域,100;门市,100;客户类型,100;医院,100;电话1,100;电话2,100;电话3,100;电话4,100;电话5,100" );
  111. // m_List1.LoadColumnInfo (144);
  112. m_List1.m_bSortSupport=0;
  113. GetData();
  114. }
  115. void HospitalClientMsg::OnBUTclose()
  116. {
  117. // TODO: Add your control notification handler code here
  118. GetParent()->SendMessage(WM_CLOSE);
  119. }
  120. void HospitalClientMsg::OnSelchangeCombo1()
  121. {
  122. // TODO: Add your control notification handler code here
  123. }
  124. BOOL HospitalClientMsg::PreTranslateMessage(MSG* pMsg)
  125. {
  126. // TODO: Add your specialized code here and/or call the base class
  127. try
  128. {
  129. if(pMsg->message==WM_KEYDOWN)
  130. {
  131. switch (pMsg->wParam)
  132. {
  133. case VK_RETURN:
  134. OnButton2();
  135. return 1;
  136. case 0x43: // copy
  137. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  138. {
  139. GetFocus()->SendMessage(WM_COPY);
  140. return TRUE;
  141. }
  142. break;
  143. case 0x56: //Ctrl + V:
  144. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  145. {
  146. GetFocus()->SendMessage(WM_PASTE);
  147. return TRUE;
  148. }
  149. break;
  150. case 0x58: // cut
  151. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  152. {
  153. GetFocus()->SendMessage(WM_CUT);
  154. return TRUE;
  155. }
  156. break;
  157. case 0x5A: //undo
  158. case 0x59: //redo
  159. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  160. {
  161. GetFocus()->SendMessage(WM_UNDO);
  162. return TRUE;
  163. }
  164. break;
  165. }
  166. }
  167. return MyFormView::PreTranslateMessage(pMsg);
  168. }
  169. catch(...)
  170. {
  171. }
  172. return true;
  173. }
  174. void HospitalClientMsg::GetSavePath(CString &path)
  175. {
  176. }
  177. int HospitalClientMsg::FindArray(CStringArray *pArray, CString Str)
  178. {
  179. return 0;
  180. }
  181. void HospitalClientMsg::GetNo(CString str, CStringArray &array)
  182. {
  183. }
  184. CString HospitalClientMsg::GetSelName(CString name, CArray<CStringArray, CStringArray>&spnamearray)
  185. {
  186. return "";
  187. }
  188. void HospitalClientMsg::OnBUTexportphoto()
  189. {
  190. }
  191. void HospitalClientMsg::OnBUTimportphoto()
  192. {
  193. }
  194. void HospitalClientMsg::OnBUTshowphoto()
  195. {
  196. // TODO: Add your control notification handler code here
  197. }
  198. void HospitalClientMsg::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult)
  199. {
  200. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  201. // TODO: Add your control notification handler code here
  202. *pResult = 0;
  203. }
  204. void HospitalClientMsg::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
  205. {
  206. // TODO: Add your control notification handler code here
  207. *pResult = 0;
  208. }
  209. void HospitalClientMsg::OnBUTsendmsg()
  210. {
  211. // TODO: Add your control notification handler code here
  212. POSITION pos;
  213. pos=m_List1.GetFirstSelectedItemPosition();
  214. if(pos==NULL)
  215. {
  216. AfxMessageBox("请先选中您要发送短信的客人!", MB_ICONINFORMATION);
  217. return;
  218. }
  219. int iItem;
  220. CStringArray array;
  221. while (pos)
  222. {
  223. iItem = m_List1.GetNextSelectedItem(pos);
  224. if(!m_List1.GetItemText (iItem, 17).IsEmpty ())
  225. array.Add (m_List1.GetItemText (iItem, 17));
  226. if(!m_List1.GetItemText (iItem, 18).IsEmpty ())
  227. array.Add (m_List1.GetItemText (iItem, 18));
  228. if(!m_List1.GetItemText (iItem, 19).IsEmpty ())
  229. array.Add (m_List1.GetItemText (iItem, 19));
  230. if(!m_List1.GetItemText (iItem, 20).IsEmpty ())
  231. array.Add (m_List1.GetItemText (iItem, 20));
  232. if(!m_List1.GetItemText (iItem, 21).IsEmpty ())
  233. array.Add (m_List1.GetItemText (iItem, 21));
  234. }
  235. SendMsgDlg dlg;
  236. dlg.m_mode=2;
  237. dlg.m_pArray=&array;
  238. dlg.DoModal ();
  239. }
  240. void HospitalClientMsg::OnBUTprint3()
  241. {
  242. ListToXLS(&m_List1, "c:\\短信列表.xls", 0);
  243. }
  244. void HospitalClientMsg::GetData()
  245. {
  246. g_sendhead.bsql=0;
  247. g_sendhead.code[0]=208;
  248. g_sendhead.tabcount=1;
  249. g_pMainWnd->ProcessChatMessageRequest2(1);if(g_bSendOK==0)return;
  250. DataToArray(&m_List1array);
  251. CString date1,date2,str,sdays,syears,pregnancydays;
  252. CTime tm=GetTmFromStr(g_date);
  253. int days;
  254. for(int i=0; i<m_List1array.GetSize (); i++)
  255. {
  256. sdays=syears=pregnancydays="";
  257. date1=m_List1array.ElementAt (i).ElementAt (6);
  258. if(m_List1array.ElementAt (i).ElementAt (4)=="1")
  259. {
  260. date2.Empty ();
  261. CovertDate(date1,date2);
  262. if(date2!="")date1=date2;
  263. }
  264. if(date1.GetLength ()==10)
  265. {
  266. if(m_List1array.ElementAt (i).ElementAt (5)=="0")
  267. {
  268. CTime tm2( atoi(date1.Mid (0,4)), atoi(date1.Mid (5,2)), atoi(date1.Mid (8,2)), 0,0,0);
  269. CTimeSpan dt=tm-tm2;
  270. days=dt.GetDays ()+1;
  271. sdays.Format ("%d", days);
  272. if(days%365==0)
  273. days/=365;
  274. else
  275. {
  276. days/=365;
  277. days++;
  278. }
  279. syears.Format ("%d", days);
  280. if(tm<tm2)sdays=syears="";
  281. }
  282. }
  283. if(atoi(m_List1array.ElementAt (i).ElementAt (7))>0)
  284. {
  285. date1=m_List1array.ElementAt (i).ElementAt (9);
  286. CTime tm2( atoi(date1.Mid (0,4)), atoi(date1.Mid (5,2)), atoi(date1.Mid (8,2)), 0,0,0);
  287. CTimeSpan dt=tm-tm2;
  288. pregnancydays.Format ("%d", atoi(m_List1array.ElementAt (i).ElementAt (7))+dt.GetDays ());
  289. if(atoi(pregnancydays)>288)
  290. pregnancydays="已生";
  291. }
  292. if(sdays=="")sdays="未知";
  293. if(syears=="")syears="未知";
  294. if(pregnancydays=="")pregnancydays="未知";
  295. m_List1array.ElementAt (i).InsertAt (8, pregnancydays);
  296. m_List1array.ElementAt (i).InsertAt (8, sdays);
  297. m_List1array.ElementAt (i).InsertAt (8, syears);
  298. if(m_List1array.ElementAt (i).ElementAt (4)=="1")
  299. m_List1array.ElementAt (i).SetAt (4, "农历");
  300. else
  301. m_List1array.ElementAt (i).SetAt (4, "公历");
  302. if(m_List1array.ElementAt (i).ElementAt (5)=="0")
  303. m_List1array.ElementAt (i).SetAt (5, "生日");
  304. else
  305. m_List1array.ElementAt (i).SetAt (5, "预产期");
  306. }
  307. FillGrid();
  308. }
  309. void HospitalClientMsg::FillGrid()
  310. {
  311. m_List1.DeleteAllItems2 ();
  312. int ii=0;
  313. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  314. int count=0;
  315. UpdateData();
  316. if(m_bSearchAll)
  317. {
  318. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  319. {
  320. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  321. }
  322. }
  323. else if(m_radio1==0)
  324. {
  325. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  326. {
  327. if(atoi(m_List1array.ElementAt (ii).ElementAt (9))<m_age1 || atoi(m_List1array.ElementAt (ii).ElementAt (9))>m_age2)
  328. continue;
  329. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  330. }
  331. }
  332. else if(m_radio1==1)
  333. {
  334. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  335. {
  336. if(atoi(m_List1array.ElementAt (ii).ElementAt (8))<m_age1 || atoi(m_List1array.ElementAt (ii).ElementAt (8))>m_age2)
  337. continue;
  338. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  339. }
  340. }
  341. else if(m_radio1==2)
  342. {
  343. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  344. {
  345. if(atoi(m_List1array.ElementAt (ii).ElementAt (10))<m_age1 || atoi(m_List1array.ElementAt (ii).ElementAt (10))>m_age2)
  346. continue;
  347. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  348. }
  349. }
  350. m_List1.m_arLabels.SetSize(count, 1);
  351. ii=count;
  352. m_List1.m_LabelCount=ii;
  353. m_List1.SetItemCountEx (ii);
  354. CString str;
  355. str.Format ("客人:%d", ii);
  356. SetDlgItemText(IDC_STATIC2, str);
  357. }
  358. void HospitalClientMsg::OnButton2()
  359. {
  360. // TODO: Add your control notification handler code here
  361. m_bSearchAll=0;
  362. FillGrid();
  363. }
  364. void HospitalClientMsg::OnBUTburncd2()
  365. {
  366. // TODO: Add your control notification handler code here
  367. m_bSearchAll=1;
  368. FillGrid();
  369. }
  370. void HospitalClientMsg::OnBUTHospitalClientMsg()
  371. {
  372. // TODO: Add your control notification handler code here
  373. HospitalMsgSet dlg;
  374. dlg.DoModal ();
  375. }