AddMember.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. // ClientDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "AddMember.h"
  6. #include "GetClientInfo.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // AddMember dialog IDC_COMBO1
  14. AddMember::AddMember(CWnd* pParent /*=NULL*/)
  15. : CDialog(AddMember::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(AddMember)
  18. m_addr = _T("");
  19. m_name = _T("");
  20. m_occupation = _T("");
  21. m_phone = _T("");
  22. m_qq = _T("");
  23. m_birthday = _T("");
  24. m_memberno = _T("");
  25. m_jiage = _T("");
  26. m_check1 = FALSE;
  27. m_bAdd=1;
  28. m_mode=0;
  29. m_discount = _T("");
  30. //}}AFX_DATA_INIT
  31. }
  32. void AddMember::DoDataExchange(CDataExchange* pDX)
  33. {
  34. CDialog::DoDataExchange(pDX);
  35. //{{AFX_DATA_MAP(AddMember)
  36. DDX_Control(pDX, IDC_COMBOcardtype, m_combocardtype);
  37. DDX_Control(pDX, IDC_EDITjiage, m_editnum);
  38. DDX_Control(pDX, IDC_COMBO1, m_combosex);
  39. DDX_Control(pDX, IDC_EDITBirthday, m_datectrl1);
  40. DDX_Text(pDX, IDC_EDITaddr, m_addr);
  41. DDX_Text(pDX, IDC_EDITname, m_name);
  42. DDX_Text(pDX, IDC_EDITOccupation, m_occupation);
  43. DDX_Text(pDX, IDC_EDITphone, m_phone);
  44. DDX_Text(pDX, IDC_EDITqq, m_qq);
  45. DDX_Text(pDX, IDC_EDITBirthday, m_birthday);
  46. DDX_Text(pDX, IDC_EDITmemberno2, m_memberno);
  47. DDX_Text(pDX, IDC_EDITjiage, m_jiage);
  48. DDX_Check(pDX, IDC_CHECK1, m_check1);
  49. DDX_Text(pDX, IDC_EDITdiscount, m_discount);
  50. //}}AFX_DATA_MAP
  51. }
  52. BEGIN_MESSAGE_MAP(AddMember, CDialog)
  53. //{{AFX_MSG_MAP(AddMember)
  54. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  55. ON_CBN_CLOSEUP(IDC_COMBOcardtype, OnCloseupCOMBOcardtype)
  56. ON_CBN_SELCHANGE(IDC_COMBOcardtype, OnSelchangeCOMBOcardtype)
  57. //}}AFX_MSG_MAP
  58. END_MESSAGE_MAP()
  59. /////////////////////////////////////////////////////////////////////////////
  60. // AddMember message handlers ]=59;
  61. BOOL AddMember::OnInitDialog()
  62. {
  63. CDialog::OnInitDialog();
  64. if(m_mode)
  65. {
  66. GetDlgItem(IDC_STATIC1)->ShowWindow(SW_SHOW);
  67. GetDlgItem(IDC_EDITjiage)->ShowWindow(SW_SHOW);
  68. m_combocardtype.ShowWindow(SW_HIDE);
  69. GetDlgItem(IDC_EDITdiscount)->ShowWindow(SW_HIDE);
  70. GetDlgItem(IDC_STATIC10)->ShowWindow(SW_HIDE);
  71. GetDlgItem(IDC_STATIC11)->ShowWindow(SW_HIDE);
  72. m_combocardtype.EnableWindow(0);
  73. GetDlgItem(IDC_EDITdiscount)->EnableWindow(0);
  74. }
  75. // TODO: Add extra initialization here
  76. m_combosex.AddString ("女");
  77. m_combosex.AddString ("男");
  78. m_combosex.SetCurSel (0);
  79. m_combocardtype.AddString ("普通卡");
  80. m_combocardtype.AddString ("活动卡");
  81. m_combocardtype.AddString ("打折卡");
  82. m_combocardtype.SetCurSel (0);
  83. if(m_bAdd==0)
  84. {
  85. CString filter="memberno='"+m_memberno+"'";
  86. if(m_mode)
  87. g_sendhead.code[0]=130;
  88. else
  89. g_sendhead.code[0]=68;
  90. g_sendhead.tabcount=1;
  91. g_sendhead.bsql=0;
  92. g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return 1;
  93. DataToArray(&g_List1array);
  94. if(g_List1array.GetSize ())
  95. {
  96. m_name = g_List1array.ElementAt (0).ElementAt (2);
  97. CString sex = g_List1array.ElementAt (0).ElementAt (3);
  98. m_phone = g_List1array.ElementAt (0).ElementAt (4);
  99. m_qq = g_List1array.ElementAt (0).ElementAt (5);
  100. m_addr = g_List1array.ElementAt (0).ElementAt (6);
  101. m_occupation = g_List1array.ElementAt (0).ElementAt (7);
  102. m_birthday = g_List1array.ElementAt (0).ElementAt (8);
  103. if(m_mode)
  104. m_jiage = g_List1array.ElementAt (0).ElementAt (9);
  105. else
  106. {
  107. m_cardtype = g_List1array.ElementAt (0).ElementAt (16);
  108. m_check1 = atoi(g_List1array.ElementAt (0).ElementAt (17));
  109. m_discount = g_List1array.ElementAt (0).ElementAt (18);
  110. }
  111. m_combocardtype.SetCurSel(m_combocardtype.FindString(0, m_cardtype));
  112. UpdateData(false);
  113. m_combosex.SetCurSel (m_combosex.FindString (0, sex));
  114. OnCloseupCOMBOcardtype();
  115. }
  116. GetDlgItem(IDC_EDITmemberno2)->EnableWindow(0);
  117. SetWindowText("修改会员资料");
  118. }
  119. this->CenterWindow (g_pMainWnd);
  120. return false; // return TRUE unless you set the focus to a control
  121. // EXCEPTION: OCX Property Pages should return FALSE
  122. }
  123. void AddMember::OnOK()
  124. {
  125. // TODO: Add extra validation here
  126. UpdateData();
  127. m_name.TrimLeft ();
  128. m_name.TrimRight ();
  129. if(m_name.IsEmpty () )
  130. {
  131. AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION);
  132. return;
  133. }
  134. if(m_name.Find("*")!=-1 )
  135. {
  136. AfxMessageBox("客人名字非法!", MB_ICONINFORMATION);
  137. return;
  138. }
  139. if(m_memberno.IsEmpty () )
  140. {
  141. AfxMessageBox("会员卡卡号不能为空!", MB_ICONINFORMATION);
  142. return;
  143. }
  144. m_phone.TrimLeft ();
  145. m_phone.TrimRight ();
  146. if(!m_phone.IsEmpty ())
  147. {
  148. if(m_phone.Left (1)=="1")
  149. {
  150. if(CheckPhoneType(m_phone)==-1)
  151. {
  152. AfxMessageBox("手机号码:"+m_phone+"错误!", MB_ICONINFORMATION);
  153. return;
  154. }
  155. }
  156. }
  157. if(m_mode)
  158. {
  159. if(atof(m_jiage)<1.0)
  160. {
  161. AfxMessageBox("请填写套系金额!", MB_ICONINFORMATION);
  162. return;
  163. }
  164. }
  165. if(atof(m_discount)<0.0 || atof(m_discount)>10.0)
  166. {
  167. AfxMessageBox("折扣错误,请填1-10", MB_ICONINFORMATION);
  168. return;
  169. }
  170. int pos=m_combosex.GetCurSel();
  171. CString sex;
  172. m_combosex.GetLBText (pos, sex);
  173. pos=m_combocardtype.GetCurSel();
  174. if(pos!=-1)
  175. m_combocardtype.GetLBText (pos, m_cardtype);
  176. else
  177. m_cardtype="普通卡";
  178. if(!CheckDateOK(m_birthday))return;
  179. CString strRes1;
  180. GetFirstLetter(m_name, strRes1);
  181. CString sql,sql2;
  182. if(m_mode)
  183. {
  184. if(m_bAdd)
  185. {
  186. g_sendhead.bsql=0;
  187. g_sendhead.code[0]=130;
  188. g_sendhead.tabcount=1;
  189. g_pMainWnd->ProcessChatMessageRequest2(1);if(g_bSendOK==0)return;
  190. CArray<CStringArray, CStringArray>m_List1array;
  191. DataToArray(&m_List1array);
  192. for(int i=0; i<m_List1array.GetSize (); i++)
  193. {
  194. if(m_memberno==m_List1array.ElementAt (i).ElementAt (1))
  195. {
  196. AfxMessageBox("此会员卡卡号已存在,请重新输入!", MB_ICONINFORMATION);
  197. m_memberno="";
  198. UpdateData(false);
  199. GetDlgItem(IDC_EDITmemberno2)->SetFocus();
  200. return;
  201. }
  202. }
  203. sql.Format ("insert into [membermanageblue]([memberno],[name],[sex],[phone],[qq],[addr],[occupation],[birthday],[date],[pinyin],[jiage])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",m_memberno,m_name,sex,m_phone,m_qq,m_addr,m_occupation,m_birthday,g_date,strRes1,m_jiage);
  204. if(g_cominfoarray.ElementAt(0).ElementAt(54).IsEmpty ()==0 && atoi(g_cominfoarray.ElementAt(0).ElementAt(53)) )
  205. {
  206. CString m_content6 = g_cominfoarray.ElementAt(0).ElementAt(54);
  207. CString content,timestamp;
  208. CString name2=m_name;
  209. #ifndef CHILD_VERSION
  210. if(sex=="男")
  211. name2+="先生";
  212. else if(sex=="女")
  213. name2+="女士";
  214. #endif
  215. content.Format ("%s您好,%s", name2, m_content6);
  216. timestamp="msgtimestamp";
  217. if( CheckPhoneType(m_phone)!=-1 && CheckBadWords(content,0) && CheckBadWords2(content,0))
  218. {
  219. int count=GetLengthEx(content)/MSG_LENGTH;
  220. if(GetLengthEx(content)%MSG_LENGTH)
  221. count++;
  222. CString scount;
  223. scount.Format ("%d", count);
  224. CString sql2="***insert into [sendreg]([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('"+m_phone+"','"+content+"','"+timestamp+"','"+scount+"','0','0','0','系统自动发送')";
  225. sql+=sql2;
  226. }
  227. }
  228. }
  229. else
  230. sql.Format ("update [membermanageblue] set [name]='%s',[sex]='%s',[phone]='%s',[qq]='%s',[addr]='%s',[occupation]='%s',[birthday]='%s',[pinyin]='%s',[jiage]='%s' where [memberno]='%s' ", m_name,sex,m_phone,m_qq,m_addr,m_occupation,m_birthday,strRes1,m_jiage,m_memberno);
  231. }
  232. else
  233. {
  234. if(m_bAdd)
  235. {
  236. g_sendhead.bsql=0;
  237. g_sendhead.code[0]=68;
  238. g_sendhead.tabcount=1;
  239. g_pMainWnd->ProcessChatMessageRequest2(1);if(g_bSendOK==0)return;
  240. CArray<CStringArray, CStringArray>m_List1array;
  241. DataToArray(&m_List1array);
  242. for(int i=0; i<m_List1array.GetSize (); i++)
  243. {
  244. if(m_memberno==m_List1array.ElementAt (i).ElementAt (1))
  245. {
  246. AfxMessageBox("此会员卡卡号已存在,请重新输入!", MB_ICONINFORMATION);
  247. m_memberno="";
  248. UpdateData(false);
  249. GetDlgItem(IDC_EDITmemberno2)->SetFocus();
  250. return;
  251. }
  252. }
  253. sql.Format ("insert into [membermanage]([memberno],[name],[sex],[phone],[qq],[addr],[occupation],[birthday],[date],[pinyin],[cardtype],[check1],[discount])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%s')",m_memberno,m_name,sex,m_phone,m_qq,m_addr,m_occupation,m_birthday,g_date,strRes1,m_cardtype,m_check1,m_discount);
  254. if(g_cominfoarray.ElementAt(0).ElementAt(54).IsEmpty ()==0 && atoi(g_cominfoarray.ElementAt(0).ElementAt(53)) )
  255. {
  256. CString m_content6 = g_cominfoarray.ElementAt(0).ElementAt(54);
  257. CString content,timestamp;
  258. CString name2=m_name;
  259. #ifndef CHILD_VERSION
  260. if(sex=="男")
  261. name2+="先生";
  262. else if(sex=="女")
  263. name2+="女士";
  264. #endif
  265. content.Format ("%s您好,%s", name2, m_content6);
  266. timestamp="msgtimestamp";
  267. if( CheckPhoneType(m_phone)!=-1 && CheckBadWords(content,0) && CheckBadWords2(content,0) )
  268. {
  269. int count=GetLengthEx(content)/MSG_LENGTH;
  270. if(GetLengthEx(content)%MSG_LENGTH)
  271. count++;
  272. CString scount;
  273. scount.Format ("%d", count);
  274. CString sql2="***insert into [sendreg]([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('"+m_phone+"','"+content+"','"+timestamp+"','"+scount+"','0','0','0','系统自动发送')";
  275. sql+=sql2;
  276. }
  277. }
  278. }
  279. else
  280. sql.Format ("update [membermanage] set [name]='%s',[sex]='%s',[phone]='%s',[qq]='%s',[addr]='%s',[occupation]='%s',[birthday]='%s',[pinyin]='%s',[cardtype]='%s',[check1]='%d',[discount]='%s' where [memberno]='%s' ", m_name,sex,m_phone,m_qq,m_addr,m_occupation,m_birthday,strRes1,m_cardtype,m_check1,m_discount,m_memberno);
  281. }
  282. g_sendhead.bsql=1;
  283. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  284. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  285. CDialog::OnOK();
  286. }
  287. void AddMember::OnButton1()
  288. {
  289. // TODO: Add your control notification handler code here
  290. UpdateData();
  291. GetClientInfo dlg;
  292. if(dlg.DoModal ()==IDOK)
  293. {
  294. if(dlg.m_name2!="")
  295. m_name = dlg.m_name2 ;
  296. else
  297. m_name = dlg.m_name1 ;
  298. m_phone = dlg.m_phone ;
  299. m_qq = dlg.m_qq ;
  300. m_addr = dlg.m_addr ;
  301. m_birthday = dlg.m_birthday ;
  302. m_combosex.SetCurSel (m_combosex.FindString (0, dlg.m_sex));
  303. if(m_mode)
  304. m_jiage = dlg.m_jiage ;
  305. UpdateData(0);
  306. }
  307. }
  308. void AddMember::OnCloseupCOMBOcardtype()
  309. {
  310. // TODO: Add your control notification handler code here
  311. UpdateData();
  312. int pos=m_combocardtype.GetCurSel();
  313. if(pos!=2)
  314. {
  315. GetDlgItem(IDC_EDITdiscount)->EnableWindow(0);
  316. }
  317. else
  318. GetDlgItem(IDC_EDITdiscount)->EnableWindow(1);
  319. }
  320. void AddMember::OnSelchangeCOMBOcardtype()
  321. {
  322. // TODO: Add your control notification handler code here
  323. OnCloseupCOMBOcardtype();
  324. }