HospitalClientMsg.cpp 11 KB

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