123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- // Booking.cpp : implementa tion file
- //
- #include "stdafx.h"
- #include "Booking.h"
- #include "UPhoneBox.h"
- #include "UPhoneBoxDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- extern BOOL g_bNewBooking;
- /////////////////////////////////////////////////////////////////////////////
- // Booking dialog
- Booking::Booking(CWnd* pParent /*=NULL*/)
- : CDialog(Booking::IDD, pParent)
- {
- //{{AFX_DATA_INIT(Booking)
- m_name1 = _T("");
- m_name2 = _T("");
- m_date = _T("");
- m_taketime = _T("");
- m_pos = -1;
- //}}AFX_DATA_INIT
- }
- void Booking::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(Booking)
- DDX_Control(pDX, IDC_EDITdate, m_dateedit);
- DDX_Control(pDX, IDC_COMBO2, m_combodatetime);
- DDX_Control(pDX, IDC_COMBO1, m_combotype);
- DDX_Text(pDX, IDC_EDITname1, m_name1);
- DDX_Text(pDX, IDC_EDITname2, m_name2);
- DDX_Text(pDX, IDC_EDITdate, m_date);
- DDX_CBString(pDX, IDC_COMBO2, m_taketime);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(Booking, CDialog)
- //{{AFX_MSG_MAP(Booking)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
- ON_WM_CLOSE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // Booking message handlers
- extern int g_nYearpos;
- extern BOOL g_bReturned2;
- extern CUPhoneBoxDlg *g_pMainWnd;
- extern void DataToArray(CArray<CStringArray, CStringArray>*List1array);
- BOOL Booking::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- m_combotype.AddString("预约拍照");
- m_combotype.AddString("预约选片");
- m_combotype.AddString("预约看设计");
- m_combotype.AddString("预约取件");
- m_combodatetime.AddString("上午9点");
- m_combodatetime.AddString("上午10点");
- m_combodatetime.AddString("上午11点");
- m_combodatetime.AddString("上午12点");
- m_combodatetime.AddString("下午1点");
- m_combodatetime.AddString("下午2点");
- m_combodatetime.AddString("下午3点");
- m_combodatetime.AddString("下午4点");
- m_combodatetime.AddString("下午5点");
- m_combodatetime.AddString("下午6点");
- m_combodatetime.AddString("晚上7点");
- m_combodatetime.AddString("晚上8点");
- m_combodatetime.AddString("晚上9点");
- m_combodatetime.AddString("晚上10点");
- g_nYearpos = -1;
- if (g_bNewBooking)
- {
- /* g_sendhead.code[0]=179;
- g_sendhead.tabcount=1;
- g_sendhead.bsql=0;
- g_pMainWnd->ProcessChatMessageRequest2(1);
- for(int i=0; i<20; i++)
- {
- if(g_bReturned2)break;
- ::Sleep (500);
- }
- if(i>=20)
- {
- nNeedConn2=1;
- CDialog::OnCancel ();
- return 0;
- }
- DataToArray(&m_Clientarray);*/
- GetListData(179, &m_Clientarray, "", 0, 0);
- m_pos = -1;
- for (int i = 0; i < m_Clientarray.GetSize(); i++)
- {
- if (m_id == m_Clientarray.ElementAt(i).ElementAt(0))
- {
- m_pos = i;
- break;
- }
- }
- m_array.Add("");
- m_array.Add("");
- m_array.Add("");
- m_array.Add("");
- m_array.Add("");
- m_array.Add("");
- m_array.Add("");
- m_array.Add("");
- }
- else
- {
- CArray<CStringArray, CStringArray>List1array;
- /* CString filter="id='"+m_id+"'";
- g_sendhead.code[0]=53;
- g_sendhead.tabcount=1;
- g_sendhead.bsql=0;
- g_pMainWnd->ProcessChatMessageRequest2(filter);
- for(int i=0; i<20; i++)
- {
- if(g_bReturned2)break;
- ::Sleep (500);
- }
- if(i>=20)
- {
- nNeedConn2=1;
- CDialog::OnCancel ();
- return 0;
- }
- DataToArray(&List1array);*/
- GetListData(53, &List1array, m_id, 0, 0);
- if (List1array.GetSize())
- {
- m_array.Add(List1array.ElementAt(0).ElementAt(0)); // 拍照日期;
- m_array.Add(List1array.ElementAt(0).ElementAt(1)); // 拍照时间;
- m_array.Add(List1array.ElementAt(0).ElementAt(13)); // 选片日期;
- m_array.Add(List1array.ElementAt(0).ElementAt(18)); // 选片时间;
- m_array.Add(List1array.ElementAt(0).ElementAt(15)); // 取件日期;
- m_array.Add(List1array.ElementAt(0).ElementAt(20)); // 取件时间;
- m_array.Add(List1array.ElementAt(0).ElementAt(14)); // 看样日期;
- m_array.Add(List1array.ElementAt(0).ElementAt(19)); // 看样时间;
- }
- }
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- BOOL CheckDateOK(CString str)
- {
- if (str.IsEmpty())return 1;
- CString tip;
- int i;
- CString demo = CTime::GetCurrentTime().Format("%Y-%m-%d");
- if (str.GetLength() != demo.GetLength())
- goto ll;
- //2009-01-01
- if (str.GetAt(4) != '-')
- goto ll;
- if (str.GetAt(7) != '-')
- goto ll;
- for (i = 0; i < str.GetLength(); i++)
- {
- if (i == 4 || i == 7)continue;
- if (str.GetAt(i) < '0' || str.GetAt(i) > '9')
- goto ll;
- }
- return 1;
- ll:
- tip.Format("日期:%s格式错误!\r\n样板:%s", str, demo);
- AfxMessageBox(tip, MB_ICONINFORMATION);
- return 0;
- }
- void Booking::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData();
- if (!CheckDateOK(m_date))return;
- int pos = m_combotype.GetCurSel();
- if (pos == -1)
- {
- AfxMessageBox("请选择预约内容!");
- return;
- }
- m_array.SetAt(pos * 2, m_date);
- m_array.SetAt(pos * 2 + 1, m_taketime);
- CString sql;
- if (g_bNewBooking && m_pos != -1)
- {
- CString timestamp;
- CTime tm = CTime::GetCurrentTime();
- timestamp = tm.Format("%Y%m%d%H%M%S");
- int pos2 = m_pos;
- CArray<CStringArray, CStringArray>*m_pClientArray = &m_Clientarray;
- CString name, phone;
- name = m_pClientArray->ElementAt(pos2).ElementAt(1) + " " + m_pClientArray->ElementAt(pos2).ElementAt(2);
- if (!m_pClientArray->ElementAt(pos2).ElementAt(3).IsEmpty())
- phone = m_pClientArray->ElementAt(pos2).ElementAt(3) + " " + m_pClientArray->ElementAt(pos2).ElementAt(4);
- else
- phone = m_pClientArray->ElementAt(pos2).ElementAt(4);
- CString taoxiname = m_pClientArray->ElementAt(pos2).ElementAt(5);
- CString m_taoxijiage = m_pClientArray->ElementAt(pos2).ElementAt(6);
- CString m_waiter1 = m_pClientArray->ElementAt(pos2).ElementAt(7);
- CString m_waiter2 = m_pClientArray->ElementAt(pos2).ElementAt(8);
- CString ren = m_pClientArray->ElementAt(pos2).ElementAt(9);
- CString money3 = m_pClientArray->ElementAt(pos2).ElementAt(10);
- CString m_id = m_pClientArray->ElementAt(pos2).ElementAt(0);
- CString clothescount;
- if (!m_pClientArray->ElementAt(pos2).ElementAt(11).IsEmpty())
- clothescount = "服装:" + m_pClientArray->ElementAt(pos2).ElementAt(11);
- sql.Format("insert into [todaytake]([name],[phone],[time],[type],[price],[waiter1],[waiter2],[receptionist],\
- [arrearage],[remark],[clerk],[timestamp],[date],[mode],[arrive],[id])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%d','%s','%s')", \
- name, phone, m_taketime, taoxiname, m_taoxijiage, m_waiter1, m_waiter2, ren, money3, clothescount, "电话预约", timestamp, m_date, pos, "未到", m_id);
- }
- else
- {
- if (pos == 0)
- sql.Format("update dindan set [time2]='%s',[taketime]='%s' where id='%s' ", \
- m_date, m_taketime, m_id);
- else if (pos == 1)
- sql.Format("update dindan set [time4]='%s',[datetime4]='%s' where id='%s' ", \
- m_date, m_taketime, m_id);
- else if (pos == 2)
- sql.Format("update dindan set [time6]='%s',[datetime6]='%s' where id='%s' ", \
- m_date, m_taketime, m_id);
- else
- sql.Format("update dindan set [time5]='%s',[datetime5]='%s' where id='%s' ", \
- m_date, m_taketime, m_id);
- }
- g_sendhead.bsql = 1;
- g_nYearpos = -1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- int i ;
- for ( i = 0; i < 20; i++)
- {
- if (g_bReturned2)break;
- ::Sleep(500);
- }
- if (i >= 20)
- {
- nNeedConn2 = 1;
- AfxMessageBox("保存失败!");
- return;
- }
- AfxMessageBox("保存成功!");
- // CDialog::OnOK();
- }
- void Booking::OnSelchangeCombo1()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- int pos = m_combotype.GetCurSel();
- if (pos == -1)
- {
- return;
- }
- if (m_array.GetSize())
- {
- m_date = m_array.ElementAt(pos * 2);
- m_taketime = m_array.ElementAt(pos * 2 + 1);
- UpdateData(0);
- }
- }
- void Booking::OnClose()
- {
- // TODO: Add your message handler code here and/or call default
- DestroyWindow();
- // CDialog::OnClose();
- }
- void Booking::OnCancel()
- {
- // TODO: Add extra cleanup here
- DestroyWindow();
- // CDialog::OnCancel();
- }
|