123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- // ClientDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "AddMember.h"
- #include "GetClientInfo.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // AddMember dialog IDC_COMBO1
- AddMember::AddMember(CWnd* pParent /*=NULL*/)
- : CDialog(AddMember::IDD, pParent)
- {
- //{{AFX_DATA_INIT(AddMember)
- m_addr = _T("");
- m_name = _T("");
- m_occupation = _T("");
- m_phone = _T("");
- m_qq = _T("");
- m_birthday = _T("");
- m_memberno = _T("");
- m_jiage = _T("");
- m_check1 = FALSE;
- m_bAdd=1;
- m_mode=0;
- m_discount = _T("");
- //}}AFX_DATA_INIT
- }
- void AddMember::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(AddMember)
- DDX_Control(pDX, IDC_COMBOcardtype, m_combocardtype);
- DDX_Control(pDX, IDC_EDITjiage, m_editnum);
- DDX_Control(pDX, IDC_COMBO1, m_combosex);
- DDX_Control(pDX, IDC_EDITBirthday, m_datectrl1);
- DDX_Text(pDX, IDC_EDITaddr, m_addr);
- DDX_Text(pDX, IDC_EDITname, m_name);
- DDX_Text(pDX, IDC_EDITOccupation, m_occupation);
- DDX_Text(pDX, IDC_EDITphone, m_phone);
- DDX_Text(pDX, IDC_EDITqq, m_qq);
- DDX_Text(pDX, IDC_EDITBirthday, m_birthday);
- DDX_Text(pDX, IDC_EDITmemberno2, m_memberno);
- DDX_Text(pDX, IDC_EDITjiage, m_jiage);
- DDX_Check(pDX, IDC_CHECK1, m_check1);
- DDX_Text(pDX, IDC_EDITdiscount, m_discount);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(AddMember, CDialog)
- //{{AFX_MSG_MAP(AddMember)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_CBN_CLOSEUP(IDC_COMBOcardtype, OnCloseupCOMBOcardtype)
- ON_CBN_SELCHANGE(IDC_COMBOcardtype, OnSelchangeCOMBOcardtype)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // AddMember message handlers ]=59;
- BOOL AddMember::OnInitDialog()
- {
- CDialog::OnInitDialog();
- if(m_mode)
- {
- GetDlgItem(IDC_STATIC1)->ShowWindow(SW_SHOW);
- GetDlgItem(IDC_EDITjiage)->ShowWindow(SW_SHOW);
- m_combocardtype.ShowWindow(SW_HIDE);
- GetDlgItem(IDC_EDITdiscount)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_STATIC10)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_STATIC11)->ShowWindow(SW_HIDE);
- m_combocardtype.EnableWindow(0);
- GetDlgItem(IDC_EDITdiscount)->EnableWindow(0);
- }
- // TODO: Add extra initialization here
- m_combosex.AddString ("女");
- m_combosex.AddString ("男");
- m_combosex.SetCurSel (0);
- m_combocardtype.AddString ("普通卡");
- m_combocardtype.AddString ("活动卡");
- m_combocardtype.AddString ("打折卡");
- m_combocardtype.SetCurSel (0);
- if(m_bAdd==0)
- {
- CString filter="memberno='"+m_memberno+"'";
- if(m_mode)
- g_sendhead.code[0]=130;
- else
- g_sendhead.code[0]=68;
- g_sendhead.tabcount=1;
- g_sendhead.bsql=0;
- g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return 1;
- DataToArray(&g_List1array);
- if(g_List1array.GetSize ())
- {
- m_name = g_List1array.ElementAt (0).ElementAt (2);
- CString sex = g_List1array.ElementAt (0).ElementAt (3);
- m_phone = g_List1array.ElementAt (0).ElementAt (4);
- m_qq = g_List1array.ElementAt (0).ElementAt (5);
- m_addr = g_List1array.ElementAt (0).ElementAt (6);
- m_occupation = g_List1array.ElementAt (0).ElementAt (7);
- m_birthday = g_List1array.ElementAt (0).ElementAt (8);
- if(m_mode)
- m_jiage = g_List1array.ElementAt (0).ElementAt (9);
- else
- {
- m_cardtype = g_List1array.ElementAt (0).ElementAt (16);
- m_check1 = atoi(g_List1array.ElementAt (0).ElementAt (17));
- m_discount = g_List1array.ElementAt (0).ElementAt (18);
- }
- m_combocardtype.SetCurSel(m_combocardtype.FindString(0, m_cardtype));
- UpdateData(false);
- m_combosex.SetCurSel (m_combosex.FindString (0, sex));
- OnCloseupCOMBOcardtype();
- }
- GetDlgItem(IDC_EDITmemberno2)->EnableWindow(0);
- SetWindowText("修改会员资料");
- }
-
- this->CenterWindow (g_pMainWnd);
- return false; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void AddMember::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData();
- m_name.TrimLeft ();
- m_name.TrimRight ();
- if(m_name.IsEmpty () )
- {
- AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION);
- return;
- }
- if(m_name.Find("*")!=-1 )
- {
- AfxMessageBox("客人名字非法!", MB_ICONINFORMATION);
- return;
- }
- if(m_memberno.IsEmpty () )
- {
- AfxMessageBox("会员卡卡号不能为空!", MB_ICONINFORMATION);
- return;
- }
- m_phone.TrimLeft ();
- m_phone.TrimRight ();
- if(!m_phone.IsEmpty ())
- {
- if(m_phone.Left (1)=="1")
- {
- if(CheckPhoneType(m_phone)==-1)
- {
- AfxMessageBox("手机号码:"+m_phone+"错误!", MB_ICONINFORMATION);
- return;
- }
- }
- }
- if(m_mode)
- {
- if(atof(m_jiage)<1.0)
- {
- AfxMessageBox("请填写套系金额!", MB_ICONINFORMATION);
- return;
- }
- }
- if(atof(m_discount)<0.0 || atof(m_discount)>10.0)
- {
- AfxMessageBox("折扣错误,请填1-10", MB_ICONINFORMATION);
- return;
- }
- int pos=m_combosex.GetCurSel();
- CString sex;
- m_combosex.GetLBText (pos, sex);
-
- pos=m_combocardtype.GetCurSel();
- if(pos!=-1)
- m_combocardtype.GetLBText (pos, m_cardtype);
- else
- m_cardtype="普通卡";
- if(!CheckDateOK(m_birthday))return;
- CString strRes1;
- GetFirstLetter(m_name, strRes1);
- CString sql,sql2;
- if(m_mode)
- {
- if(m_bAdd)
- {
- g_sendhead.bsql=0;
- g_sendhead.code[0]=130;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(1);if(g_bSendOK==0)return;
- CArray<CStringArray, CStringArray>m_List1array;
- DataToArray(&m_List1array);
-
- for(int i=0; i<m_List1array.GetSize (); i++)
- {
- if(m_memberno==m_List1array.ElementAt (i).ElementAt (1))
- {
- AfxMessageBox("此会员卡卡号已存在,请重新输入!", MB_ICONINFORMATION);
- m_memberno="";
- UpdateData(false);
- GetDlgItem(IDC_EDITmemberno2)->SetFocus();
- return;
- }
- }
- 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);
- if(g_cominfoarray.ElementAt(0).ElementAt(54).IsEmpty ()==0 && atoi(g_cominfoarray.ElementAt(0).ElementAt(53)) )
- {
- CString m_content6 = g_cominfoarray.ElementAt(0).ElementAt(54);
- CString content,timestamp;
- CString name2=m_name;
- #ifndef CHILD_VERSION
- if(sex=="男")
- name2+="先生";
- else if(sex=="女")
- name2+="女士";
- #endif
- content.Format ("%s您好,%s", name2, m_content6);
- timestamp="msgtimestamp";
-
- if( CheckPhoneType(m_phone)!=-1 && CheckBadWords(content,0) && CheckBadWords2(content,0))
- {
- int count=GetLengthEx(content)/MSG_LENGTH;
- if(GetLengthEx(content)%MSG_LENGTH)
- count++;
- CString scount;
- scount.Format ("%d", count);
- CString sql2="***insert into [sendreg]([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('"+m_phone+"','"+content+"','"+timestamp+"','"+scount+"','0','0','0','系统自动发送')";
- sql+=sql2;
- }
- }
- }
- else
- 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);
- }
- else
- {
- if(m_bAdd)
- {
- g_sendhead.bsql=0;
- g_sendhead.code[0]=68;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(1);if(g_bSendOK==0)return;
- CArray<CStringArray, CStringArray>m_List1array;
- DataToArray(&m_List1array);
-
- for(int i=0; i<m_List1array.GetSize (); i++)
- {
- if(m_memberno==m_List1array.ElementAt (i).ElementAt (1))
- {
- AfxMessageBox("此会员卡卡号已存在,请重新输入!", MB_ICONINFORMATION);
- m_memberno="";
- UpdateData(false);
- GetDlgItem(IDC_EDITmemberno2)->SetFocus();
- return;
- }
- }
- 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);
- if(g_cominfoarray.ElementAt(0).ElementAt(54).IsEmpty ()==0 && atoi(g_cominfoarray.ElementAt(0).ElementAt(53)) )
- {
- CString m_content6 = g_cominfoarray.ElementAt(0).ElementAt(54);
- CString content,timestamp;
- CString name2=m_name;
- #ifndef CHILD_VERSION
- if(sex=="男")
- name2+="先生";
- else if(sex=="女")
- name2+="女士";
- #endif
- content.Format ("%s您好,%s", name2, m_content6);
- timestamp="msgtimestamp";
-
- if( CheckPhoneType(m_phone)!=-1 && CheckBadWords(content,0) && CheckBadWords2(content,0) )
- {
- int count=GetLengthEx(content)/MSG_LENGTH;
- if(GetLengthEx(content)%MSG_LENGTH)
- count++;
- CString scount;
- scount.Format ("%d", count);
- CString sql2="***insert into [sendreg]([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values('"+m_phone+"','"+content+"','"+timestamp+"','"+scount+"','0','0','0','系统自动发送')";
- sql+=sql2;
- }
- }
- }
- else
- 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);
- }
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
- AfxMessageBox("保存成功!", MB_ICONINFORMATION);
- CDialog::OnOK();
- }
- void AddMember::OnButton1()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- GetClientInfo dlg;
- if(dlg.DoModal ()==IDOK)
- {
- if(dlg.m_name2!="")
- m_name = dlg.m_name2 ;
- else
- m_name = dlg.m_name1 ;
- m_phone = dlg.m_phone ;
- m_qq = dlg.m_qq ;
- m_addr = dlg.m_addr ;
- m_birthday = dlg.m_birthday ;
-
-
- m_combosex.SetCurSel (m_combosex.FindString (0, dlg.m_sex));
- if(m_mode)
- m_jiage = dlg.m_jiage ;
- UpdateData(0);
- }
- }
- void AddMember::OnCloseupCOMBOcardtype()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- int pos=m_combocardtype.GetCurSel();
- if(pos!=2)
- {
- GetDlgItem(IDC_EDITdiscount)->EnableWindow(0);
- }
- else
- GetDlgItem(IDC_EDITdiscount)->EnableWindow(1);
- }
- void AddMember::OnSelchangeCOMBOcardtype()
- {
- // TODO: Add your control notification handler code here
- OnCloseupCOMBOcardtype();
- }
|