123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622 |
- // HireDress.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "HireDress.h"
- #include "ShowPhoto.h"
- #include "ShowEarlyWarning.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // HireDress IDC_EDITtime3 12
- HireDress::HireDress(CWnd* pParent /*=NULL*/)
- : CDialog(HireDress::IDD, pParent)
- {
- //{{AFX_DATA_INIT(HireDress)
- m_addr2 = _T("");
- m_name2 = _T("");
- m_occupation2 = _T("");
- m_phone2 = _T("");
- m_qq2 = _T("");
- m_birthday2 = _T("");
- m_time3 = _T("");
- m_id = _T("");
- m_money = _T("");
- m_money2 = _T("");
- m_inputdate = g_date;
- m_clerk = g_user.name ;
- m_balance = _T("");
- m_count = _T("");
- m_no = _T("");
- m_remark = _T("");
- m_date1 = _T("");
- m_date2 = _T("");
- m_bAdd=1;
- m_pImg=NULL;
- m_bIsSale=0;
- m_radio1 = 0;
- //}}AFX_DATA_INIT
- }
- void HireDress::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(HireDress)
- DDX_Control(pDX, IDC_EDITdate2, m_datectrl5);
- DDX_Control(pDX, IDC_EDITdate1, m_datectrl4);
- DDX_Control(pDX, IDC_EDITcount, m_editctrl3);
- DDX_Control(pDX, IDC_EDITmoney2, m_editctrl2);
- DDX_Control(pDX, IDC_EDITmoney, m_editctrl);
- DDX_Control(pDX, IDC_LIST4, m_List1);
- DDX_Control(pDX, IDC_COMBOname, m_comboname);
- DDX_Control(pDX, IDC_EDITtime3, m_datectrl3);
- DDX_Control(pDX, IDC_EDITBirthday2, m_datectrl2);
- DDX_Text(pDX, IDC_EDITaddr2, m_addr2);
- DDX_Text(pDX, IDC_EDITname2, m_name2);
- DDX_Text(pDX, IDC_EDITOccupation2, m_occupation2);
- DDX_Text(pDX, IDC_EDITphone2, m_phone2);
- DDX_Text(pDX, IDC_EDITqq2, m_qq2);
- DDX_Text(pDX, IDC_EDITBirthday2, m_birthday2);
- DDX_Text(pDX, IDC_EDITtime3, m_time3);
- DDX_Text(pDX, IDC_EDITid, m_id);
- DDX_Text(pDX, IDC_EDITmoney, m_money);
- DDX_Text(pDX, IDC_EDITmoney2, m_money2);
- DDX_Text(pDX, IDC_EDITinputdate, m_inputdate);
- DDX_Text(pDX, IDC_EDITclerk, m_clerk);
- DDX_Text(pDX, IDC_EDITbalance, m_balance);
- DDX_Text(pDX, IDC_EDITcount, m_count);
- DDX_Text(pDX, IDC_EDITno, m_no);
- DDX_Text(pDX, IDC_EDITremark, m_remark);
- DDV_MaxChars(pDX, m_remark, 1000);
- DDX_Text(pDX, IDC_EDITdate1, m_date1);
- DDX_Text(pDX, IDC_EDITdate2, m_date2);
- DDX_Radio(pDX, IDC_RADIO1, m_radio1);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(HireDress, CDialog)
- //{{AFX_MSG_MAP(HireDress)
- ON_CBN_SELCHANGE(IDC_COMBOname, OnSelchangeCOMBOname)
- ON_WM_DESTROY()
- ON_WM_PAINT()
- ON_BN_CLICKED(IDC_BUTTON1, OnAddDress)
- ON_BN_CLICKED(IDC_BUTTON2, OnDelDress)
- ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
- ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
- ON_BN_CLICKED(IDC_STATIC4, OnStatic4)
- ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // HireDress message handlers
- BOOL HireDress::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
-
- if(m_bAdd)
- {
- if(m_bIsSale)
- {
- SetWindowText("礼服出售单");
- GetDlgItem(IDC_STATIC10)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_EDITdate2)->ShowWindow(SW_HIDE);
- }
-
-
- CString sql="select max(id) as cot from dresshire where [date]='"+g_date+"'";
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- if(g_bSendOK==0)
- {
- CDialog::OnCancel ();
- return false;
- }
- CString date=g_date;
- date.Replace ("-", "");
- m_id.Format ("%s-(lf)%03d", date, g_ncount+1);
- g_sendhead.bsql=0;
- g_sendhead.code[0]=72;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(0);
- if(g_bSendOK==0)
- {
- CDialog::OnCancel ();
- return false;
- }
- DataToArray(&m_List1array);
-
- TypeChange();
- }
- else
- {
-
-
- if(m_bIsSale)
- {
- SetWindowText("礼服出售单修改");
- GetDlgItem(IDC_STATIC10)->ShowWindow(SW_HIDE);
- GetDlgItem(IDC_EDITdate2)->ShowWindow(SW_HIDE);
- }
- else
- SetWindowText("礼服出租单修改");
-
-
- CString filter=";id='"+m_id+"';id='"+m_id+"';id='"+m_id+"'";
- g_sendhead.bsql=0;
- g_sendhead.code[0]=72;
- g_sendhead.code[1]=73;
- g_sendhead.code[2]=74;
- g_sendhead.code[3]=52;
- g_sendhead.tabcount=4;
- g_pMainWnd->ProcessChatMessageRequest2(filter);
- if(g_bSendOK==0)
- {
- CDialog::OnCancel ();
- return false;
- }
- CArray<CStringArray, CStringArray>dresshirearray;
- CArray<CStringArray, CStringArray>dresshiredataarray;
- CArray<CStringArray, CStringArray>clientarray;
- DataToArray(&m_List1array, &dresshirearray, &dresshiredataarray, &clientarray);
- if(dresshirearray.GetSize ())
- {
- m_money = dresshirearray.ElementAt (0).ElementAt (1);
- m_money2 = dresshirearray.ElementAt (0).ElementAt (2);
- m_remark = dresshirearray.ElementAt (0).ElementAt (10);
- m_inputdate = dresshirearray.ElementAt (0).ElementAt (6);
- m_date1 = dresshirearray.ElementAt (0).ElementAt (7);
- m_date2 = dresshirearray.ElementAt (0).ElementAt (8);
- m_clerk = g_user.name ;
- }
- if(clientarray.GetSize ())
- {
- m_name2=clientarray.ElementAt (0).ElementAt (2);
- m_phone2=clientarray.ElementAt (0).ElementAt (4);
- m_qq2=clientarray.ElementAt (0).ElementAt (6);
- m_addr2=clientarray.ElementAt (0).ElementAt (8);
- m_occupation2=clientarray.ElementAt (0).ElementAt (10);
- m_birthday2=clientarray.ElementAt (0).ElementAt (12);
- m_time3=clientarray.ElementAt (0).ElementAt (20);
- }
- for(int i=0; i<dresshiredataarray.GetSize (); i++)
- {
- m_needgetbalancearray.Add (dresshiredataarray.ElementAt (i).ElementAt (1));
- m_seldressarray.Add (dresshiredataarray.ElementAt (i).ElementAt (1));
- m_seldressarray.Add (dresshiredataarray.ElementAt (i).ElementAt (2));
- m_seldressarray.Add (dresshiredataarray.ElementAt (i).ElementAt (3));
- m_seldressarray.Add (m_id);
- m_seldressarray.Add (dresshiredataarray.ElementAt (i).ElementAt (4));
- m_seldressarray.Add (dresshiredataarray.ElementAt (i).ElementAt (7));
-
- CString str;
- str=dresshiredataarray.ElementAt (i).ElementAt (2);
- str+="\r\n数量:";
- str+=dresshiredataarray.ElementAt (i).ElementAt (3);
- if(m_List1.GetCount()%2)
- m_List1.AddEntry( str , g_gridcol1, m_List1.GetCount());
- else
- m_List1.AddEntry( str , g_gridcol2, m_List1.GetCount());
- }
-
-
-
- TypeChange();
- }
-
- if(m_bIsSale)
- GetDlgItem(IDC_STATIC1)->SetWindowText("出售资料");
- CenterWindow();
- UpdateData(false);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void HireDress::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData();
- m_money.TrimLeft ();m_money.TrimRight ();
- m_money2.TrimLeft ();m_money2.TrimRight ();
- m_name2.TrimLeft ();m_name2.TrimRight ();
- m_phone2.TrimLeft ();m_phone2.TrimRight ();
-
- if(!CheckDateOK(m_birthday2))return;
- if(!CheckDateOK(m_time3))return;
- if(!CheckDateOK(m_date1))return;
-
- if(m_bIsSale)
- {
- m_date2="..";
- }
- else
- {
- if(!CheckDateOK(m_date2))return;
- }
-
-
- if(m_money.IsEmpty () || m_money2.IsEmpty () || m_name2.IsEmpty () || m_phone2.IsEmpty () || m_money.IsEmpty () )
- {
- AfxMessageBox("资料不全, 打*号的项目为必填项目!");
- return;
- }
-
- if(m_bIsSale==0)
- {
- if(m_date1.IsEmpty () || m_date2.IsEmpty ())
- {
- AfxMessageBox("资料不全, 打*号的项目为必填项目!");
- return;
- }
- }
-
- if( m_seldressarray.GetSize()==0 )
- {
- AfxMessageBox("礼服资料未添加!");
- return;
- }
- if(0)//m_bIsSale==0)//计算是否撞期
- {
- CString str,time1,time2,hireorsale,no,count;
- CTimeSpan dt(1, 0, 0, 0);
- for(int i=0; i<m_seldressarray.GetSize (); i+=6)
- {
- no=m_seldressarray.ElementAt (i);count=m_seldressarray.ElementAt (i+2);
- if(GetCountFromNo(no)>atoi(count))continue;
-
- CString filter="[no]='"+no+"'";
- g_sendhead.bsql=0;
- g_sendhead.code[0]=191;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
- CArray<CStringArray, CStringArray>m_List1array;
- DataToArray(&m_List1array);
- for(int j=0; j<m_List1array.GetSize (); j++)
- {
- hireorsale=m_List1array.ElementAt (j).ElementAt(4);
- if(hireorsale=="售")continue;
- time1=m_List1array.ElementAt (j).ElementAt(2);
- time2=m_List1array.ElementAt (j).ElementAt(3);
- if(CheckDateOK(time1) && CheckDateOK(time2))
- {
- CTime tm1(atoi(time1.Mid (0,4)),atoi(time1.Mid (5,2)),atoi(time1.Mid (8,2)),0,0,0);
- CTime tm2(atoi(time2.Mid (0,4)),atoi(time2.Mid (5,2)),atoi(time2.Mid (8,2)),0,0,0);
- CTime tm=tm2;
- tm+=dt;
- if(tm.Format ("%Y-%m-%d")==m_date1)
- {
- str.Format ("礼服:%s归还日与取件日只差一天! 是否继续?", no);
- if(AfxMessageBox(str, MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
- }
- }
- }
- }
- }
-
-
- CString sql,sql2;
- CString hireorsale="租";
- if(m_bIsSale)hireorsale="售";
- if(m_bAdd)
- {
- sql.Format ("insert into [dresshire]([id],[money],[money2],[date],[clerk],[hireorsale],[remark],[name],[phone],[date1],[date2])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",m_id,m_money,m_money2,m_inputdate,m_clerk,hireorsale,m_remark,m_name2,m_phone2,m_date1,m_date2);
- sql2.Format ("***insert into [client]([name2],[phone2],[qq2],[addr2],[occupation2],[birthday2],[time3],[id])values('%s','%s','%s','%s','%s','%s','%s','%s')",m_name2,m_phone2,m_qq2,m_addr2,m_occupation2,m_birthday2,m_time3,m_id);
- }
- else
- {
- sql="update [dresshire] set [money]='"+m_money+"',[money2]='"+m_money2+"',[clerk]='"+m_clerk+"',[remark]='"+m_remark+"',[name]='"+m_name2+"',[phone]='"+m_phone2+"',[date1]='"+m_date1+"',[date2]='"+m_date2+"' where [id]='"+m_id+"'";
-
- sql2.Format ("***update [client] set [name2]='%s',[phone2]='%s',[qq2]='%s',[addr2]='%s',[occupation2]='%s',[birthday2]='%s',[time3]='%s' where [id]='%s' ", m_name2,m_phone2,m_qq2,m_addr2,m_occupation2,m_birthday2,m_time3,m_id);
- }
- sql+=sql2;
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
-
- CStringArray m_seldressarraybak;
- m_seldressarraybak.Copy (m_seldressarray);
- int count=m_seldressarray.GetSize ();
- CString str;
- str.Format ("%d", count);
- for(int i=0; i<m_needgetbalancearray.GetSize (); i++)
- {
- m_seldressarray.Add (m_needgetbalancearray.ElementAt (i));
- }
- m_seldressarray.Add (str);
- m_seldressarray.Add (m_date1);
- m_seldressarray.Add (m_date2);
-
- CMemFile memfile;
- CArchive ar(&memfile, CArchive::store);
- m_seldressarray.Serialize (ar);
- ar.Close();
- int length=memfile.GetLength ();
- BYTE *pData = memfile.Detach();
- g_nSendCode=20;
- g_pMainWnd->ProcessChatMessageRequest2(pData, length);
- g_nSendCode=0;
- delete []pData;
-
- m_seldressarray.RemoveAll ();
- m_seldressarray.Copy (m_seldressarraybak);
-
- if(g_bSendOK==0)return;
-
- AfxMessageBox("保存成功!", MB_ICONINFORMATION);
- CDialog::OnOK();
- }
- void HireDress::OnSelchangeCOMBOname()
- {
- // TODO: Add your control notification handler code here
- int pos=m_comboname.GetCurSel ();
- if(pos==-1)return;
- UpdateData();
- CString name;
- m_comboname.GetLBText (pos, name);
- for(int i=0; i<m_List1array.GetSize (); i++)
- {
- if(name==m_List1array.ElementAt (i).ElementAt (2))
- {
- m_no=m_List1array.ElementAt (i).ElementAt (1);
- m_balance=m_List1array.ElementAt (i).ElementAt (4);
- m_sellcot=m_List1array.ElementAt (i).ElementAt (6);
-
-
- CString savepath=g_path5+"\\";
- if(m_pImg)delete m_pImg;m_pImg=NULL;
-
- if(PathFileExists( savepath+""+m_no+".jpg" ) )
- {
- ::LoadImageFromBuf (&m_pImg, savepath+""+m_no+".jpg");
- }
- CRect rc;
- GetDlgItem(IDC_STATIC4)->GetWindowRect(rc);
- ScreenToClient(rc);
- InvalidateRect(rc);
- UpdateData(false);
- }
- }
- }
- void HireDress::OnDestroy()
- {
-
-
- // TODO: Add your message handler code here
- if(m_pImg)delete m_pImg;m_pImg=NULL;
- CDialog::OnDestroy();
- }
- void HireDress::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
-
- // TODO: Add your message handler code here
- if(m_pImg)
- {
- CRect rc;
- GetDlgItem(IDC_STATIC4)->GetWindowRect(rc);
- ScreenToClient(rc);
- RectFitDes(m_pImg->GetWidth(), m_pImg->GetHeight(), rc);
- Graphics dcgraph(dc.GetSafeHdc());
- Rect destinationRect(rc.left , rc.top , rc.Width (), rc.Height ());
- dcgraph.DrawImage(m_pImg, destinationRect, 0,0,m_pImg->GetWidth(), m_pImg->GetHeight(),UnitPixel);
- }
- // Do not call CDialog::OnPaint() for painting messages
- }
- void HireDress::OnAddDress()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- int pos=m_comboname.GetCurSel ();
- if(pos==-1)return;
- CString name;
- m_comboname.GetLBText (pos, name);
- m_count.TrimLeft ();m_count.TrimRight ();
- if(atoi(m_count)<1)
- {
- AfxMessageBox("数量不能为空!");
- return;
- }
- if(atoi(m_count)>atoi(m_balance))
- {
- // AfxMessageBox("库存不足!");
- // return;
- }
- for(int i=0; i<m_seldressarray.GetSize (); i+=6)
- {
- if(name==m_seldressarray.ElementAt (i+1))
- {
- AfxMessageBox("已有此礼服的记录!");
- return;
- }
- }
-
- if(CheckEarlyWarning())
- {
- if(m_bIsSale)
- {
- if(AfxMessageBox("此日期礼服可能未回,是否继续开出售单?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
- }
- else
- return;
- }
-
- m_needgetbalancearray.Add (m_no);
- m_seldressarray.Add (m_no);
- m_seldressarray.Add (name);
- m_seldressarray.Add (m_count);
- m_seldressarray.Add (m_id);
- m_seldressarray.Add ("");
- if(m_bIsSale)
- m_seldressarray.Add ("售");
- else
- m_seldressarray.Add ("租");
- CString str;
- str=name;
- str+="\r\n数量:";
- str+=m_count;
- if(m_List1.GetCount()%2)
- m_List1.AddEntry( str , g_gridcol1, m_List1.GetCount());
- else
- m_List1.AddEntry( str , g_gridcol2, m_List1.GetCount());
-
- }
- void HireDress::OnDelDress()
- {
- // TODO: Add your control notification handler code here
- int pos=m_List1.GetCurSel ();
- if(pos==-1)
- {
- AfxMessageBox("请先选中您要删除的礼服!");
- return;
- }
- m_List1.DeleteString (pos);
- pos*=6;
-
- if(m_bAdd==0)
- m_needgetbalancearray.Add (m_seldressarray.ElementAt (pos));
-
- m_seldressarray.RemoveAt(pos+5);
- m_seldressarray.RemoveAt(pos+4);
- m_seldressarray.RemoveAt(pos+3);
- m_seldressarray.RemoveAt(pos+2);
- m_seldressarray.RemoveAt(pos+1);
- m_seldressarray.RemoveAt(pos);
- }
- int HireDress::GetCountFromNo(CString no)
- {
- /* for(int i=0; i<m_List1array.GetSize (); i++)
- {
- if(no==m_List1array.ElementAt (i).ElementAt (1))
- {
- return atoi(m_List1array.ElementAt (i).ElementAt (8));
- }
- }*/
- return 0;
- }
- void HireDress::OnRadio1()
- {
- // TODO: Add your control notification handler code here
- OnRadio2();
- }
- void HireDress::OnRadio2()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- TypeChange();
- }
- void HireDress::OnStatic4()
- {
- // TODO: Add your control notification handler code here
- if(m_pImg)
- {
- ShowPhoto dlg;
- dlg.m_pImg=m_pImg;
- dlg.DoModal();
- }
- }
- void HireDress::TypeChange()
- {
- m_comboname.ResetContent();
- for(int i=0; i<m_List1array.GetSize (); i++)
- {
- if(m_radio1!=atoi(m_List1array.ElementAt (i).ElementAt (12)))continue;
- m_comboname.AddString (m_List1array.ElementAt (i).ElementAt (2));
- }
- }
- void HireDress::OnButton3()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
-
- if(!CheckDateOK(m_date1))return;
- if(m_date1.IsEmpty () || m_no.IsEmpty () || m_count.IsEmpty ())
- {
- AfxMessageBox("取件日期和编号和数量为必填项目!");
- return;
- }
-
- if(m_bIsSale==0)
- {
- if(!CheckDateOK(m_date2))return;
- if(m_date2.IsEmpty ())
- {
- AfxMessageBox("取件日期和编号和数量为必填项目!");
- return;
- }
- }
-
- int pos=m_comboname.GetCurSel ();
- if(pos==-1)return;
- UpdateData();
- CString name;
- m_comboname.GetLBText (pos, name);
- ShowEarlyWarning dlg;
- dlg.m_no=m_no;
- dlg.m_name=name;
- dlg.m_cot1=m_balance;
- dlg.m_cot2=m_sellcot;
- dlg.m_cot3=m_count;
- dlg.m_date1=m_date1;
- if(m_bIsSale==0)dlg.m_date2=m_date2;
- dlg.DoModal();
- }
- BOOL HireDress::CheckEarlyWarning()
- {
- if(!CheckDateOK(m_date1))return 1;
-
- if(m_date1.IsEmpty () || m_no.IsEmpty () || m_count.IsEmpty ())
- {
- AfxMessageBox("取件日期和编号和数量为必填项目!");
- return 1;
- }
-
- if(m_bIsSale==0)
- {
- if(!CheckDateOK(m_date2))return 1;
- if(m_date2.IsEmpty ())
- {
- AfxMessageBox("取件日期和编号和数量为必填项目!");
- return 1;
- }
- }
-
-
- int pos=m_comboname.GetCurSel ();
- if(pos==-1)return 1;
-
- CString name;
- m_comboname.GetLBText (pos, name);
-
-
- ShowEarlyWarning dlg;
- dlg.m_mode=1;
- dlg.m_no=m_no;
- dlg.m_name=name;
- dlg.m_cot1=m_balance;
- dlg.m_cot2=m_sellcot;
- dlg.m_cot3=m_count;
- dlg.m_date1=m_date1;
- if(m_bIsSale==0)dlg.m_date2=m_date2;
- dlg.DoModal();
- return dlg.m_nRet;
- }
- //库存不足
|