123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- // AddClientLYFZ.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "AddClientLYFZ.h"
- #include "SPLBDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // AddClientLYFZ dialog
- AddClientLYFZ::AddClientLYFZ(CWnd* pParent /*=NULL*/)
- : CDialog(AddClientLYFZ::IDD, pParent)
- {
- //{{AFX_DATA_INIT(AddClientLYFZ)
- m_addr1 = _T("");
- m_name1 = _T("");
- m_phone1 = _T("");
- m_qq1 = _T("");
- m_from = _T("");
- m_bz = _T("");
- m_bAdd = 1;
- m_name2 = _T("");
- //}}AFX_DATA_INIT
- }
- void AddClientLYFZ::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(AddClientLYFZ)
- DDX_Control(pDX, IDC_COMBOarea, m_comboarea);
- DDX_Control(pDX, IDC_COMBOclerk, m_comboclerk);
- DDX_Control(pDX, IDC_COMBOstatus, m_combostatus);
- DDX_Control(pDX, IDC_COMBOfrom, m_combofrom);
- DDX_Text(pDX, IDC_EDITaddr, m_addr1);
- DDX_Text(pDX, IDC_EDITname, m_name1);
- DDX_Text(pDX, IDC_EDITphone, m_phone1);
- DDX_Text(pDX, IDC_EDITqq, m_qq1);
- DDX_CBString(pDX, IDC_COMBOfrom, m_from);
- DDX_Text(pDX, IDC_EDIT1, m_bz);
- DDX_Text(pDX, IDC_EDITname2, m_name2);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(AddClientLYFZ, CDialog)
- //{{AFX_MSG_MAP(AddClientLYFZ)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // AddClientLYFZ message handlers
- BOOL AddClientLYFZ::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- CString filter = "";
- g_sendhead.code[0] = 82;
- g_sendhead.code[1] = 186;
- g_sendhead.tabcount = 2;
- g_sendhead.bsql = 0;
- g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return 1;
- CArray<CStringArray, CStringArray>m_List1array;
- CArray<CStringArray, CStringArray>m_List2array;
- DataToArray(&m_List1array, &m_List2array);
- int i = 0;
- for ( i = 0; i < m_List1array.GetSize(); i++)
- {
- m_comboarea.AddString(m_List1array.ElementAt(i).ElementAt(0));
- }
- for (i = 0; i < m_List2array.GetSize(); i++)
- {
- m_combofrom.AddString(m_List2array.ElementAt(i).ElementAt(0));
- }
- m_combostatus.AddString("有意向");
- m_combostatus.AddString("很有意向");
- m_combostatus.AddString("意向一般");
- m_combostatus.AddString("无意向");
- m_combostatus.AddString("已购买");
- if (m_comboclerk.FindString(0, m_clerk) == -1)
- m_comboclerk.AddString(m_clerk);
- m_comboclerk.SetCurSel(m_comboclerk.FindString(0, m_clerk));
- m_combofrom.SetCurSel(m_combofrom.FindString(0, m_from));
- m_comboarea.SetCurSel(m_comboarea.FindString(0, m_area));
- m_combostatus.SetCurSel(m_combostatus.FindString(0, m_status));
- /* if(g_List1array.GetSize ())
- {
- m_bAdd=0;
- m_name1=g_List1array.ElementAt (0).ElementAt (1);
- m_name2=g_List1array.ElementAt (0).ElementAt (2);
- m_phone1=g_List1array.ElementAt (0).ElementAt (3);
- m_phone2=g_List1array.ElementAt (0).ElementAt (4);
- m_qq1=g_List1array.ElementAt (0).ElementAt (5);
- m_qq2=g_List1array.ElementAt (0).ElementAt (6);
- m_addr1=g_List1array.ElementAt (0).ElementAt (7);
- m_addr2=g_List1array.ElementAt (0).ElementAt (8);
- m_occupation1=g_List1array.ElementAt (0).ElementAt (9);
- m_occupation2=g_List1array.ElementAt (0).ElementAt (10);
- m_birthday1=g_List1array.ElementAt (0).ElementAt (11);
- m_birthday2=g_List1array.ElementAt (0).ElementAt (12);
- m_time3=m_List1array.ElementAt (0).ElementAt (12);
- m_area=g_List1array.ElementAt (0).ElementAt (13);
- m_area2=g_List1array.ElementAt (0).ElementAt (14);
- m_check1=atoi(g_List1array.ElementAt (0).ElementAt (15));
- m_check2=atoi(g_List1array.ElementAt (0).ElementAt (16));
- m_check3=atoi(g_List1array.ElementAt (0).ElementAt (17));
- UpdateData(false);
- m_comboarea.SetCurSel(m_comboarea.FindString(0,m_area));
- m_comboarea2.SetCurSel(m_comboarea2.FindString(0,m_area2));
- }*/
- this->CenterWindow(g_pMainWnd);
- return false; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void AddClientLYFZ::OnButton1()
- {
- // TODO: Add your control notification handler code here
- SPLBDlg dlg;
- dlg.m_mode = 8;
- dlg.DoModal();
- m_combofrom.ResetContent();
- if (m_combofrom.GetCount() < 2)
- {
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 186;
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(3); if (g_bSendOK == 0)return;
- DataToArray(&g_List1array);
- for (int ii = 0; ii < g_List1array.GetSize(); ii++)
- m_combofrom.AddString(g_List1array.ElementAt(ii).ElementAt(0));
- }
- }
- void AddClientLYFZ::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData();
- m_name1.TrimLeft();
- m_name1.TrimRight();
- m_name2.TrimLeft();
- m_name2.TrimRight();
- m_phone1.TrimLeft();
- m_phone1.TrimRight();
- if (m_name1.IsEmpty() || m_name2.IsEmpty() || m_phone1.IsEmpty())
- {
- AfxMessageBox("姓名不能为空!", MB_ICONINFORMATION); return;
- }
- if (m_name1.Find("*") != -1 || m_name2.Find("*") != -1)
- {
- AfxMessageBox("客人名字非法!", MB_ICONINFORMATION);
- return;
- }
- int pos = m_comboclerk.GetCurSel();
- if (pos != -1)
- {
- m_comboclerk.GetLBText(pos, m_clerk);
- }
- else
- m_clerk.Empty();
- if (m_clerk.IsEmpty())
- {
- AfxMessageBox("资料不全!", MB_ICONINFORMATION); return;
- }
- pos = m_comboarea.GetCurSel();
- if (pos != -1)
- {
- m_comboarea.GetLBText(pos, m_area);
- }
- else
- m_area.Empty();
- pos = m_combofrom.GetCurSel();
- if (pos != -1)
- {
- m_combofrom.GetLBText(pos, m_from);
- }
- else
- m_from.Empty();
- pos = m_combostatus.GetCurSel();
- if (pos != -1)
- {
- m_combostatus.GetLBText(pos, m_status);
- }
- else
- m_status.Empty();
- m_phone1.TrimLeft();
- m_phone1.TrimRight();
- if (!m_phone1.IsEmpty())
- {
- if (m_phone1.Left(1) == "1")
- {
- if (CheckPhoneType(m_phone1) == -1)
- {
- AfxMessageBox("手机号码:" + m_phone1 + "错误!", MB_ICONINFORMATION);
- return;
- }
- }
- }
- CString strRes1, strRes2;
- ChinesePinYin::GetFirstLetter(m_name1, strRes1);
- ChinesePinYin::GetFirstLetter(m_name2, strRes2);
- // dlg.m_pList2array=&m_List2array;
- for (int i = 0; i < m_pList2array->GetSize(); i++)
- {
- if (m_bAdd == 0)
- {
- if (m_pList2array->ElementAt(i).ElementAt(0) == id)continue;
- }
- if (m_pList2array->ElementAt(i).ElementAt(3) == m_name2)
- {
- AfxMessageBox("已有此客户的记录!", MB_ICONINFORMATION);
- return;
- }
- if (m_pList2array->ElementAt(i).ElementAt(5) == m_phone1)
- {
- AfxMessageBox("已有此电话的记录!", MB_ICONINFORMATION);
- return;
- }
- }
- CString sql, sql2;
- if (m_bAdd)
- sql.Format("insert into [client2]([name],[name2],[area],[phone],[ren],[qq],[addr],[from],[status],[bz],[pinyin],[pinyin2],[date])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", m_name1, m_name2, m_area, m_phone1, m_clerk, m_qq1, m_addr1, m_from, m_status, m_bz, strRes1, strRes2, g_date);
- else
- sql.Format("update [client2] set [name]='%s',[name2]='%s',[area]='%s',[phone]='%s',[ren]='%s',[qq]='%s',[addr]='%s',[from]='%s',[status]='%s',[bz]='%s',[pinyin]='%s',[pinyin2]='%s' where [id]=%d ", m_name1, m_name2, m_area, m_phone1, m_clerk, m_qq1, m_addr1, m_from, m_status, m_bz, strRes1, strRes2, atol(id));
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
- AfxMessageBox("保存成功!", MB_ICONINFORMATION);
- CDialog::OnOK();
- }
|