// MySalary.cpp : implementation file // #include "stdafx.h" #include "ylgl.h" #include "MySalary.h" #include "MyMdi.H" #include "SetSalary.h" #include "ShowHisSalary.h" #include "SalarySet4.h" #include "SelExpendType.h" #include "SelExportType.h" #include #include #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // MySalary IMPLEMENT_DYNCREATE(MySalary, MyFormView) MySalary::MySalary() : MyFormView(MySalary::IDD) { //{{AFX_DATA_INIT(MySalary) m_name = _T(""); m_rate1 = _T(""); m_rate2 = _T(""); m_bz = _T(""); m_base = _T(""); m_salary = _T(""); m_rate3 = _T(""); m_rate4 = _T(""); m_rate5 = _T(""); m_money1 = _T(""); m_money2 = _T(""); m_money3 = _T(""); m_money4 = _T(""); m_money5 = _T(""); m_money6 = _T(""); m_bInit=0; m_bAll=0; m_year = atoi(g_date.Mid (0,4)); m_month = atoi(g_date.Mid (5,2)); m_date2 = GetTmFromStr(g_date); m_date1 = m_date2-CTimeSpan(30, 0, 0, 0); //}}AFX_DATA_INIT } MySalary::~MySalary() { } void MySalary::DoDataExchange(CDataExchange* pDX) { MyFormView::DoDataExchange(pDX); //{{AFX_DATA_MAP(MySalary) DDX_Control(pDX, IDC_LIST11, m_ListTemp); DDX_Control(pDX, IDC_COMBO7, m_comboname); DDX_Control(pDX, IDC_COMBO6, m_combocaltype); DDX_Control(pDX, IDC_LIST8, m_Listdigital); DDX_Control(pDX, IDC_LIST7, m_Listtake); DDX_Control(pDX, IDC_LIST4, m_List4); DDX_Control(pDX, IDC_LIST3, m_List3); DDX_Control(pDX, IDC_LIST1, m_ListBox1); DDX_Control(pDX, IDC_SPIN2, m_spinmonth); DDX_Control(pDX, IDC_SPIN1, m_spinyear); DDX_Control(pDX, IDC_LIST2, m_List1); DDX_Control(pDX, IDC_STATIC1, m_static1); DDX_Text(pDX, IDC_EDITname, m_name); DDX_Text(pDX, IDC_EDITrate1, m_rate1); DDX_Text(pDX, IDC_EDITrate2, m_rate2); DDX_Text(pDX, IDC_EDITbz, m_bz); DDX_Text(pDX, IDC_EDITbase, m_base); DDX_Text(pDX, IDC_EDITmonth, m_month); DDV_MinMaxUInt(pDX, m_month, 1, 12); DDX_Text(pDX, IDC_EDITsalary, m_salary); DDX_Text(pDX, IDC_EDITyear, m_year); DDV_MinMaxUInt(pDX, m_year, 1900, 3000); DDX_Text(pDX, IDC_EDITrate3, m_rate3); DDX_Text(pDX, IDC_EDITrate4, m_rate4); DDX_Text(pDX, IDC_EDITrate6, m_rate5); DDX_Text(pDX, IDC_EDITmoney1, m_money1); DDX_Text(pDX, IDC_EDITmoney2, m_money2); DDX_Text(pDX, IDC_EDITmoney3, m_money3); DDX_Text(pDX, IDC_EDITmoney4, m_money4); DDX_Text(pDX, IDC_EDITmoney5, m_money5); DDX_Text(pDX, IDC_EDITmoney6, m_money6); DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER1, m_date1); DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER2, m_date2); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(MySalary, MyFormView) //{{AFX_MSG_MAP(MySalary) ON_BN_CLICKED(IDC_BUTclose, OnBUTclose) ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1) ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear) ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth) ON_BN_CLICKED(IDC_BUTshowall, OnBUTshowall) ON_BN_CLICKED(IDC_BUT1, OnBut1) ON_BN_CLICKED(IDC_BUT2, OnBut2) ON_BN_CLICKED(IDC_BUT3, OnBut3) ON_CBN_SELCHANGE(IDC_COMBO6, OnSelchangeCombo6) ON_BN_CLICKED(IDC_BUT4, OnBut4) ON_BN_CLICKED(IDC_BUTTON4, OnButton4) ON_BN_CLICKED(IDC_BUTTON5, OnButton5) ON_BN_CLICKED(IDC_BUTTON6, OnButton6) ON_CBN_CLOSEUP(IDC_COMBO7, OnCloseupCombo7) ON_BN_CLICKED(IDC_BUTTON14, OnButton14) ON_BN_CLICKED(IDC_BUTTON7, OnButton7) ON_BN_CLICKED(IDC_BUTTON8, OnButton8) ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETIMEPICKER1, OnDatetimechangeDatetimepicker1) ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETIMEPICKER2, OnDatetimechangeDatetimepicker2) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // MySalary diagnostics #ifdef _DEBUG void MySalary::AssertValid() const { MyFormView::AssertValid(); } void MySalary::Dump(CDumpContext& dc) const { MyFormView::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // MySalary message handlers void MySalary::OnInitialUpdate() { MyFormView::OnInitialUpdate(); if(IsHasRights2new(25)==0) { GetDlgItem(IDC_BUT1)->EnableWindow(0); } // TODO: Add your specialized code here and/or call the base class CMyMdi Mdi; Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this); m_combocaltype.AddString ("计算初修提成"); m_combocaltype.AddString ("计算精修提成"); m_combocaltype.AddString ("计算设计提成"); // Here we create the outbar control using the splitter as its parent // and setting its id to the first pane. CRect rc2; GetWindowRect(rc2); ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE); EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0); m_comboname.RefDroppedWidth(); m_combocaltype.GetWindowRect (rc2); ScreenToClient(rc2); rc2.bottom +=200; m_combocaltype.MoveWindow (rc2); m_static1.SetFont (&g_titlefont); #ifdef CHILD_VERSION m_List1.SetHeadings("金额,100;日期,100;款项类别,100;家长姓名,100;宝宝姓名,100;套系类别,100;付款方式,100" ); m_ListTemp.SetHeadings("金额,100;日期,100;款项类别,100;家长姓名,100;宝宝姓名,100;套系类别,100;付款方式,100" ); m_List1.LoadColumnInfo (23); m_List3.SetHeadings("姓名,100;总工资,100;基本工资,100;前期业绩,100;后期业绩,100;职务提成,100;部门,100;备注,100" ); m_List3.LoadColumnInfo (124); m_List4.SetHeadings("订单号,100;家长姓名,100;宝宝姓名,100;提成金额,100;部门,100;内容,100;数量,100;单价,100;提成方式,100;套系价格,100;日期,100" ); m_List4.LoadColumnInfo (139); m_Listtake.SetHeadings("订单号,100;家长姓名,100;宝宝姓名,100;套系,100;价格,100;景点,100;日期,100;摄影,100;助理,100;化妆师,100;助理,100;套系类别,100" ); #ifdef LKAY_VERSION m_Listdigital.SetHeadings("订单号,100;男宾姓名,100;女宾姓名,100;套系,100;价格,100;初修,100;日期1,100;精修,100;日期2,100;设计,100;日期3,100;初修,50;精修,50;设计,50;选片二销,50;套系类别,100;P数,50;张数,50" ); #else m_Listdigital.SetHeadings("订单号,100;男宾姓名,100;女宾姓名,100;套系,100;价格,100;初修,100;日期1,100;精修,100;日期2,100;设计,100;日期3,100;初修,50;精修,50;设计,50;选片二销,50;套系类别,100" ); #endif m_Listtake.LoadColumnInfo (210); m_Listdigital.LoadColumnInfo (211); #else m_List1.SetHeadings("金额,100;日期,100;款项类别,100;男宾姓名,100;女宾姓名,100;套系类别,100;付款方式,100" ); m_ListTemp.SetHeadings("金额,100;日期,100;款项类别,100;男宾姓名,100;女宾姓名,100;套系类别,100;付款方式,100" ); m_List1.LoadColumnInfo (23); m_List3.SetHeadings("姓名,100;总工资,100;基本工资,100;前期业绩,100;后期业绩,100;职务提成,100;部门,100;备注,100" ); m_List3.LoadColumnInfo (124); m_List4.SetHeadings("订单号,100;男宾姓名,100;女宾姓名,100;提成金额,100;部门,100;内容,100;数量,100;单价,100;提成方式,100;套系价格,100;日期,100" ); m_List4.LoadColumnInfo (139); m_Listtake.SetHeadings("订单号,100;男宾姓名,100;女宾姓名,100;套系,100;价格,100;景点,100;日期,100;摄影,100;助理,100;化妆师,100;助理,100;套系类别,100" ); m_Listdigital.SetHeadings("订单号,100;男宾姓名,100;女宾姓名,100;套系,100;价格,100;初修,100;日期1,100;精修,100;日期2,100;设计,100;日期3,100;初修,50;精修,50;设计,50;选片二销,50;套系类别,100" ); m_Listtake.LoadColumnInfo (210); m_Listdigital.LoadColumnInfo (211); #endif m_spinyear.SetRange (1900, 3000); m_spinmonth.SetRange (1, 12); BOOL bShowAll=0; if(g_ncount==100)bShowAll=1; g_ncount=0; GetData(); if(bShowAll==0) GetDlgItem(IDC_LIST3)->ShowWindow(0); if(IsHasRights2new(25)==0) { m_ListBox1.EnableWindow (0); m_comboname.EnableWindow (0); GetDlgItem(IDC_BUTshowall)->EnableWindow (0); } else if(bShowAll) { g_ncount=0; OnBUTshowall(); } } void MySalary::FillGrid(CArray*array) { m_List1.DeleteAllItems2 (); int ii=0; m_List1.m_arLabels.SetSize( array->GetSize (), 1 ); int count=0; for(ii=0; iiElementAt (ii)); } m_List1.m_arLabels.SetSize(count, 1); ii=count; m_List1.m_LabelCount=ii; m_List1.SetItemCountEx (ii); } void MySalary::FillGridTake(CArray*array) { m_Listtake.DeleteAllItems2 (); int ii=0; m_Listtake.m_arLabels.SetSize( array->GetSize (), 1 ); int count=0; for(ii=0; iiElementAt (ii)); } m_Listtake.m_arLabels.SetSize(count, 1); ii=count; m_Listtake.m_LabelCount=ii; m_Listtake.SetItemCountEx (ii); } void MySalary::FillGridDigital(CArray*array) { m_Listdigital.DeleteAllItems2 (); int ii=0; m_Listdigital.m_arLabels.SetSize( array->GetSize (), 1 ); int count=0; for(ii=0; iiElementAt (ii)); } m_Listdigital.m_arLabels.SetSize(count, 1); ii=count; m_Listdigital.m_LabelCount=ii; m_Listdigital.SetItemCountEx (ii); } void MySalary::OnBUTclose() { // TODO: Add your control notification handler code here GetParent()->SendMessage(WM_CLOSE); } void MySalary::GetData() { m_bInit=1; g_sendhead.bsql=0; g_sendhead.code[0]=34; g_sendhead.code[1]=146; g_sendhead.tabcount=2; CString filter="dimission='在职';"; g_pMainWnd->ProcessChatMessageRequest2(filter); if(g_bSendOK==0)return; DataToArray(&m_List1array, &m_Workratearray); m_ListBox1.ResetContent (); for(int i=0; iEnableWindow(0); GetDlgItem(IDC_DATETIMEPICKER2)->EnableWindow(0); if(m_bAll) { m_List3array.RemoveAll (); FillGrid2(); GetDlgItem(IDC_DATETIMEPICKER1)->EnableWindow(1); GetDlgItem(IDC_DATETIMEPICKER2)->EnableWindow(1); return; } CString name; /* int pos=m_ListBox1.GetCurSel (); if(pos==-1) { m_spinyear.EnableWindow(1); m_spinmonth.EnableWindow(1); return; } m_ListBox1.GetText (pos, name);*/ int pos=m_comboname.GetCurSel (); if(pos==-1) { GetDlgItem(IDC_DATETIMEPICKER1)->EnableWindow(1); GetDlgItem(IDC_DATETIMEPICKER2)->EnableWindow(1); return; } m_comboname.GetWindowText (name); CString date1,date2; date1=m_date1.Format("%Y-%m-%d"); date2=m_date2.Format("%Y-%m-%d"); m_year=m_date1.GetYear(); int i; int g_nYearposTemp=g_nYearpos; BOOL bLastYear=0; BOOL bThisYear=0; if(m_year==atoi(g_date.Left (4)) && g_hisyeararray.GetSize () ) bThisYear=1; else if(m_year<=atoi(g_date.Left (4))-1 && g_hisyeararray.GetSize ()) bLastYear=1; g_nYearpos=GetYearPos(m_year); /////////////// CString filter="name='"+name+"' and dimission='在职';date>='"+date1+"' and date<='"+date2+"';;date>='"+date1+"' and date<='"+date2+"' and renyuan3='"+name+"';time2>='"+date1+"' and time2<='"+date2+"' and status='OK'***date<'"+date1+"';datetime>='"+date1+"' and datetime<='"+date2+"' and name='"+name+"'"; CString temp; temp=";[date]>='"+date1+"' and [date]<='"+date2+"' and [status]='OK' and ([waiter1]='"+name+"' or [waiter12]='"+name+"' or [waiter2]='"+name+"' or [waiter22]='"+name+"')"; filter+=temp; temp=";([time8]>='"+date1+"' and [time8]<='"+date2+"' and [status4]='OK' and [waiter5]='"+name+"') or ([time9]>='"+date1+"' and [time9]<='"+date2+"' and [status6]='OK' and [waiter7]='"+name+"') or ([time10]>='"+date1+"' and [time10]<='"+date2+"' and [status5]='OK' and [waiter4]='"+name+"')"; filter+=temp; // printf("Jeff:filter=%s\n\n",filter); g_sendhead.code[0]=34; g_sendhead.code[1]=59; g_sendhead.code[2]=60; g_sendhead.code[3]=198; g_sendhead.code[4]=61; g_sendhead.code[5]=142; g_sendhead.code[6]=192; g_sendhead.code[7]=193; g_sendhead.tabcount=8; g_sendhead.bsql=0; g_pMainWnd->ProcessChatMessageRequest2(filter); if(g_bSendOK==0) { g_nYearpos=g_nYearposTemp; GetDlgItem(IDC_DATETIMEPICKER1)->EnableWindow(1); GetDlgItem(IDC_DATETIMEPICKER2)->EnableWindow(1); return; } CArrayuserarray; CArraybukuanarray; CArraywaiterarray; CArraysingleincomearray; CArraybukuanarray2; CArraytakearray; CArraydigitalarray; DataToArray(&userarray,&bukuanarray,&waiterarray,&singleincomearray,&bukuanarray2,&m_List4array,&takearray,&digitalarray); //AfxMessageBox("OK"); /////////////////// if(bLastYear)//如果是去年, 则加今年的补款 { g_nYearpos=-1;//今年 filter="name='"+name+"' and dimission='在职';date>='"+date1+"' and date<='"+date2+"';;date>='"+date1+"' and date<='"+date2+"' and renyuan3='"+name+"';time2>='"+date1+"' and time2<='"+date2+"' and status='OK'***date<'"+date1+"';datetime>='"+date1+"' and datetime<='"+date2+"' and name='"+name+"'"; CString temp; temp=";[date]>='"+date1+"' and [date]<='"+date2+"' and [status]='OK' and ([waiter1]='"+name+"' or [waiter12]='"+name+"' or [waiter2]='"+name+"' or [waiter22]='"+name+"')"; filter+=temp; temp=";([time8]>='"+date1+"' and [time8]<='"+date2+"' and [status4]='OK' and [waiter5]='"+name+"') or ([time9]>='"+date1+"' and [time9]<='"+date2+"' and [status6]='OK' and [waiter7]='"+name+"') or ([time10]>='"+date1+"' and [time10]<='"+date2+"' and [status5]='OK' and [waiter4]='"+name+"')"; filter+=temp; g_sendhead.code[0]=34; g_sendhead.code[1]=59; g_sendhead.code[2]=60; g_sendhead.code[3]=198; g_sendhead.code[4]=61; g_sendhead.code[5]=142; g_sendhead.code[6]=192; g_sendhead.code[7]=193; g_sendhead.tabcount=8; g_sendhead.bsql=0; g_pMainWnd->ProcessChatMessageRequest2(filter); if(g_bSendOK==0) { g_nYearpos=g_nYearposTemp; GetDlgItem(IDC_DATETIMEPICKER1)->EnableWindow(1); GetDlgItem(IDC_DATETIMEPICKER2)->EnableWindow(1); return; } CArrayThisYearbukuanarray; CArrayThisYearwaiterarray; CArrayThisYearsingleincomearray; CArrayThisYearbukuanarray2; CArrayThisYearm_List4array; CArrayThisYeartakearray; CArrayThisYeardigitalarray; DataToArray(&userarray,&ThisYearbukuanarray,&ThisYearwaiterarray,&ThisYearsingleincomearray,&ThisYearbukuanarray2,&ThisYearm_List4array,&ThisYeartakearray,&ThisYeardigitalarray); int oldsize=bukuanarray.GetSize (); bukuanarray.SetSize(oldsize+ThisYearbukuanarray.GetSize ()); for(i=oldsize; i='"+date1+"' and date<='"+date2+"' and renyuan3='"+name+"';time2>='"+date1+"' and time2<='"+date2+"' and status='OK'***date<'"+date1+"';datetime>='"+date1+"' and datetime<='"+date2+"' and name='"+name+"'"; CString temp; temp=";[date]>='"+date1+"' and [date]<='"+date2+"' and [status]='OK' and ([waiter1]='"+name+"' or [waiter12]='"+name+"' or [waiter2]='"+name+"' or [waiter22]='"+name+"')"; filter+=temp; temp=";([time8]>='"+date1+"' and [time8]<='"+date2+"' and [status4]='OK' and [waiter5]='"+name+"') or ([time9]>='"+date1+"' and [time9]<='"+date2+"' and [status6]='OK' and [waiter7]='"+name+"') or ([time10]>='"+date1+"' and [time10]<='"+date2+"' and [status5]='OK' and [waiter4]='"+name+"')"; filter+=temp; g_sendhead.code[0]=59; g_sendhead.code[1]=60; g_sendhead.code[2]=198; g_sendhead.code[3]=61; g_sendhead.code[4]=142; g_sendhead.code[5]=192; g_sendhead.code[6]=193; g_sendhead.tabcount=7; g_sendhead.bsql=0; g_pMainWnd->ProcessChatMessageRequest2(filter); if(g_bSendOK==0) { g_nYearpos=g_nYearposTemp; GetDlgItem(IDC_DATETIMEPICKER1)->EnableWindow(1); GetDlgItem(IDC_DATETIMEPICKER2)->EnableWindow(1); return; } CArrayThisYearbukuanarray; CArrayThisYearwaiterarray; CArrayThisYearsingleincomearray; CArrayThisYearbukuanarray2; CArrayThisYearm_List4array; CArrayThisYeartakearray; CArrayThisYeardigitalarray; DataToArray(&ThisYearbukuanarray,&ThisYearwaiterarray,&ThisYearsingleincomearray,&ThisYearbukuanarray2,&ThisYearm_List4array,&ThisYeartakearray,&ThisYeardigitalarray); int oldsize=bukuanarray.GetSize (); bukuanarray.SetSize(oldsize+ThisYearbukuanarray.GetSize ()); for(i=oldsize; iarray; array.SetSize(bukuanarray.GetSize ()*4+bukuanarray2.GetSize ()*4+singleincomearray.GetSize ()); float money1=0; float money2=0; float money3=0; float money4=0; float money5=0; CArraymoneyarray; CStringArray typearray; int typepos; int arraypos=0; for(int ii=0; iiEnableWindow(1); GetDlgItem(IDC_DATETIMEPICKER2)->EnableWindow(1); ////////////////////////////// CString totalstr,str,field1,field2,field3,field4,field5,field6,field7,field8,field9,field10,field11,field12; float sum=0; int waiter1count=0; int waiter12count=0; int waiter2count=0; int waiter22count=0; for(i=0; i=date1 && field5<=date2) { sum1+=atof(field3); sum12+=atof(field10); sum13+=atoi(field11); sum14+=atoi(field12); count1++; } if(m_Listdigital.GetItemText (i, 12)=="OK" && field6==name && field7>=date1 && field7<=date2) { sum2+=atof(field3); sum22+=atof(field10); sum23+=atoi(field11); sum24+=atoi(field12); count2++; } if(m_Listdigital.GetItemText (i, 13)=="OK" && field8==name && field9>=date1 && field9<=date2) { sum3+=atof(field3); sum32+=atof(field10); sum33+=atoi(field11); sum34+=atoi(field12); count3++; } } str="修片与精修与设计\r\n"; totalstr+=str; #ifdef LKAY_VERSION str.Format ("初修: %d单 \r\n订单金额:%0.2f \r\n选片二销:%0.2f\r\nP数:%d\r\n张数:%d\r\n\r\n", count1, sum1, sum12, sum13, sum14);totalstr+=str; str.Format ("精修: %d单 \r\n订单金额:%0.2f \r\n选片二销:%0.2f\r\nP数:%d\r\n张数:%d\r\n\r\n", count2, sum2, sum22, sum23, sum24);totalstr+=str; str.Format ("设计: %d单 \r\n订单金额:%0.2f \r\n选片二销:%0.2f\r\nP数:%d\r\n张数:%d\r\n\r\n", count3, sum3, sum32, sum33, sum34);totalstr+=str; #else str.Format ("初修: %d单 \r\n订单金额:%0.2f \r\n选片二销:%0.2f\r\n\r\n", count1, sum1, sum12);totalstr+=str; str.Format ("精修: %d单 \r\n订单金额:%0.2f \r\n选片二销:%0.2f\r\n\r\n", count2, sum2, sum22);totalstr+=str; str.Format ("设计: %d单 \r\n订单金额:%0.2f \r\n选片二销:%0.2f\r\n\r\n", count3, sum3, sum32);totalstr+=str; #endif GetDlgItem(IDC_EDITbz2)->SetWindowText(totalstr); } void MySalary::OnBUTshowall() //IDC_BUTshowall查看全部; { // TODO: Add your control notification handler code here m_bAll=!m_bAll; if(m_bAll) { GetDlgItem(IDC_BUTshowall)->SetWindowText("查看详情"); GetDlgItem(IDC_BUT3)->ShowWindow(SW_SHOW); } else { GetDlgItem(IDC_BUT3)->ShowWindow(SW_HIDE); GetDlgItem(IDC_BUTshowall)->SetWindowText("查看全部"); } GetDlgItem(IDC_BUTshowall)->Invalidate(); GetDlgItem(IDC_STATIC2)->ShowWindow(!m_bAll); GetDlgItem(IDC_STATIC3)->ShowWindow(!m_bAll); GetDlgItem(IDC_STATIC4)->ShowWindow(!m_bAll); GetDlgItem(IDC_STATIC5)->ShowWindow(!m_bAll); GetDlgItem(IDC_STATIC6)->ShowWindow(!m_bAll); GetDlgItem(IDC_STATIC7)->ShowWindow(!m_bAll); GetDlgItem(IDC_STATIC8)->ShowWindow(!m_bAll); GetDlgItem(IDC_STATIC26)->ShowWindow(!m_bAll); GetDlgItem(IDC_STATIC27)->ShowWindow(!m_bAll); // GetDlgItem(IDC_BUTTON5)->ShowWindow(!m_bAll); // GetDlgItem(IDC_BUTTON6)->ShowWindow(!m_bAll); GetDlgItem(IDC_BUTTON7)->ShowWindow(!m_bAll); GetDlgItem(IDC_BUTTON8)->ShowWindow(!m_bAll); GetDlgItem(IDC_BUTTON14)->ShowWindow(!m_bAll); GetDlgItem(IDC_STATIC9)->ShowWindow(!m_bAll); GetDlgItem(IDC_STATIC12)->ShowWindow(!m_bAll); GetDlgItem(IDC_STATIC16)->ShowWindow(!m_bAll); GetDlgItem(IDC_STATIC10)->ShowWindow(!m_bAll); // GetDlgItem(IDC_EDITname)->ShowWindow(!m_bAll); GetDlgItem(IDC_EDITbz)->ShowWindow(!m_bAll); GetDlgItem(IDC_EDITbz2)->ShowWindow(!m_bAll); GetDlgItem(IDC_EDITbase)->ShowWindow(!m_bAll); GetDlgItem(IDC_EDITmoney1)->ShowWindow(!m_bAll); GetDlgItem(IDC_EDITmoney2)->ShowWindow(!m_bAll); GetDlgItem(IDC_EDITsalary)->ShowWindow(!m_bAll); GetDlgItem(IDC_BUTTON4)->ShowWindow(!m_bAll); GetDlgItem(IDC_EDITmoney6)->ShowWindow(!m_bAll); GetDlgItem(IDC_STATIC15)->ShowWindow(!m_bAll); GetDlgItem(IDC_LIST4)->ShowWindow(!m_bAll); // GetDlgItem(IDC_LIST1)->ShowWindow(!m_bAll); GetDlgItem(IDC_LIST2)->ShowWindow(!m_bAll); GetDlgItem(IDC_LIST3)->ShowWindow(m_bAll); GetDlgItem(IDC_LIST7)->ShowWindow(!m_bAll); GetDlgItem(IDC_LIST8)->ShowWindow(!m_bAll); GetDlgItem(IDC_COMBO7)->ShowWindow(!m_bAll); if(m_bAll) FillGrid2(); else { POSITION pos; pos=m_List3.GetFirstSelectedItemPosition(); if(pos) { int iItem=m_List3.GetNextSelectedItem(pos); CString name=m_List3.GetItemText (iItem, 0); CString temp; for(int i=0; i='"+date1+"' and date<='"+date2+"';time2>='"+date1+"' and time2<='"+date2+"' and status='OK'***date<'"+date1+"';datetime>='"+date1+"' and datetime<='"+date2+"'"; g_sendhead.code[0]=59; g_sendhead.code[1]=60; g_sendhead.code[2]=198; g_sendhead.code[3]=61; g_sendhead.code[4]=142; g_sendhead.tabcount=5; g_sendhead.bsql=0; g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return; CArraybukuanarray; CArraywaiterarray; CArraysingleincomearray; CArraybukuanarray2; DataToArray(&bukuanarray,&waiterarray,&singleincomearray,&bukuanarray2,&m_List4array); /////////////////// if(bLastYear)//如果是去年, 则加今年的补款 { g_nYearpos=-1;//今年 filter="date>='"+date1+"' and date<='"+date2+"';;date>='"+date1+"' and date<='"+date2+"';time2>='"+date1+"' and time2<='"+date2+"' and status='OK'***date<'"+date1+"';datetime>='"+date1+"' and datetime<='"+date2+"'"; g_sendhead.code[0]=59; g_sendhead.code[1]=60; g_sendhead.code[2]=198; g_sendhead.code[3]=61; g_sendhead.code[4]=142; g_sendhead.tabcount=5; g_sendhead.bsql=0; g_pMainWnd->ProcessChatMessageRequest2(filter); if(g_bSendOK==0) { g_nYearpos=g_nYearposTemp; return; } CArrayLastYearbukuanarray; CArrayLastYearwaiterarray; CArrayLastYearsingleincomearray; CArrayLastYearbukuanarray2; CArrayLastYearm_List4array; DataToArray(&LastYearbukuanarray,&LastYearwaiterarray,&LastYearsingleincomearray,&LastYearbukuanarray2,&LastYearm_List4array); int oldsize=bukuanarray.GetSize (); bukuanarray.SetSize(oldsize+LastYearbukuanarray.GetSize ()); for(i=oldsize; i='"+date1+"' and date<='"+date2+"';time2>='"+date1+"' and time2<='"+date2+"' and status='OK'***date<'"+date1+"';datetime>='"+date1+"' and datetime<='"+date2+"'"; g_sendhead.code[0]=59; g_sendhead.code[1]=60; g_sendhead.code[2]=198; g_sendhead.code[3]=61; g_sendhead.code[4]=142; g_sendhead.tabcount=5; g_sendhead.bsql=0; g_pMainWnd->ProcessChatMessageRequest2(filter); if(g_bSendOK==0) { g_nYearpos=g_nYearposTemp; return; } CArrayLastYearbukuanarray; CArrayLastYearwaiterarray; CArrayLastYearsingleincomearray; CArrayLastYearbukuanarray2; CArrayLastYearm_List4array; DataToArray(&LastYearbukuanarray,&LastYearwaiterarray,&LastYearsingleincomearray,&LastYearbukuanarray2,&LastYearm_List4array); int oldsize=bukuanarray.GetSize (); bukuanarray.SetSize(oldsize+LastYearbukuanarray.GetSize ()); for(i=oldsize; imoneyarray; CStringArray typearray; int typepos; int arraypos=0; for( ii=0; ii100) m_List3array.ElementAt (n).SetAt (7, m_bz.Left (100)+".."); else m_List3array.ElementAt (n).SetAt (7, m_bz); } temp.Format ("%0.2f", sum1); ConvertToPrice(temp); m_List3array.ElementAt (n).Add ("统计:"); m_List3array.ElementAt (n).Add (temp); temp.Format ("%0.2f", sum2); ConvertToPrice(temp); m_List3array.ElementAt (n).Add (temp); temp.Format ("%0.2f", sum3); ConvertToPrice(temp); m_List3array.ElementAt (n).Add (temp); temp.Format ("%0.2f", sum4); ConvertToPrice(temp); m_List3array.ElementAt (n).Add (temp); m_List3array.ElementAt (n).Add (""); m_List3array.ElementAt (n).Add (""); m_List3array.ElementAt (n).Add (""); } void MySalary::FillGrid4(CString &sRet) { sRet="0"; if(m_Workratearray.GetSize ()==0) { /* #ifdef CHILD_VERSION AfxMessageBox("摄影师,引导师,数码师提成方案未设置,请在菜单-》初始设置-》工资设置中设置!"); #else AfxMessageBox("摄影师,化妆师,数码师提成方案未设置,请在菜单-》初始设置-》工资设置中设置!"); #endif*/ return; } float fsum=0; int m_data1sy=-1; CString m_data2sy; CString m_data3sy; CString m_data4sy; CString m_data5sy; int m_data1hz=-1; CString m_data2hz; CString m_data3hz; CString m_data4hz; CString m_data5hz; for(int i=0; iarray; while (pos) { iItem = m_List4.GetNextSelectedItem(pos); array.Add (iItem); } if(array.GetSize ()>1) { int n=array.GetSize (); int i,j,temp; bool change=true; for(i=0;iarray.ElementAt (j+1)) { temp=array.ElementAt (j); array.SetAt (j, array.ElementAt (j+1)); array.SetAt (j+1, temp); change=true; } } } for(int i=array.GetSize ()-1; i>=0; i--) m_List4.DeleteItem2 (array.ElementAt (i));*/ } void MySalary::OnSelchangeCombo6() { // TODO: Add your control notification handler code here /* int pos=m_ListBox1.GetCurSel (); if(pos==-1) { return; } CString name; m_ListBox1.GetText (pos, name); pos=m_combocaltype.GetCurSel (); if(pos==-1)return; FillGrid4(); for(int i=m_List4.GetItemCount ()-1; i>=0; i--) { if(pos==0 && m_List4.GetItemText (i,7)!=name) m_List4.DeleteItem2 (i); else if(pos==1 && m_List4.GetItemText (i,8)!=name) m_List4.DeleteItem2 (i); else if(pos==2 && m_List4.GetItemText (i,9)!=name) m_List4.DeleteItem2 (i); }*/ } void MySalary::OnBut4() { // TODO: Add your control notification handler code here // ShowHisSalary dlg; // dlg.DoModal(); } CString MySalary::GetPrice(CString name) { for(int i=0; iarray; CStringArray moneytypearray; CString str,field2,field3; float sum=0; for(int i=0; i=date1 && field5<=date2) { sum1+=atof(field3); sum12+=atof(field10); count1++; } if(m_Listdigital.GetItemText (i, 12)=="OK" && field6==name && field7>=date1 && field7<=date2) { sum2+=atof(field3); sum22+=atof(field10); count2++; } if(m_Listdigital.GetItemText (i, 13)=="OK" && field8==name && field9>=date1 && field9<=date2) { sum3+=atof(field3); sum32+=atof(field10); count3++; } FillLength(field1, leng1); FillLength(field2, leng2); FillLength(field3, leng3); FillLength(field4, leng4); FillLength(field5, leng5); FillLength(field6, leng6); FillLength(field7, leng7); FillLength(field8, leng8); FillLength(field9, leng9); FillLength(field10, leng10); str=field1+field2+field3+field4+field5+field6+field7+field8+field9+field10+"\n"; fp.WriteString (str); } fp.WriteString ("\n"); str="姓名: "+name; fp.WriteString (str);fp.WriteString ("\n"); str.Format ("初修: %d单 订单金额:%0.2f 选片二销:%0.2f\n", count1, sum1, sum12);fp.WriteString (str); str.Format ("精修: %d单 订单金额:%0.2f 选片二销:%0.2f\n", count2, sum2, sum22);fp.WriteString (str); str.Format ("设计: %d单 订单金额:%0.2f 选片二销:%0.2f\n", count3, sum3, sum32);fp.WriteString (str); } fp.Close (); MessageBox("资料已保存到c:\\"+name+"(数码).txt"); ShellExecute(NULL, _T("open"), _T("c:\\"+name+"(数码).txt"), NULL, NULL, SW_SHOWMAXIMIZED); } void MySalary::OnDatetimechangeDatetimepicker1(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here OnSelchangeList1(); *pResult = 0; } void MySalary::OnDatetimechangeDatetimepicker2(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here OnSelchangeList1(); *pResult = 0; } CString GetExcelDriver() { char szBuf[2001]; WORD cbBufMax = 2000; WORD cbBufOut; char *pszBuf = szBuf; CString sDriver; if (!SQLGetInstalledDrivers(szBuf, cbBufMax, &cbBufOut)) return ""; do { if (strstr(pszBuf, "Excel") != 0) { sDriver = CString(pszBuf); break; } pszBuf = strchr(pszBuf, '\0') + 1; } while (pszBuf[1] != '\0'); return sDriver; } BOOL MakeSurePathExists(CString &Path, bool FilenameIncluded) { int Pos=0; while((Pos=Path.Find('\\',Pos+1))!=-1) CreateDirectory(Path.Left(Pos),NULL); if(!FilenameIncluded) CreateDirectory(Path,NULL); // return ((!FilenameIncluded)?!_access(Path,0): // !_access(Path.Left(Path.ReverseFind('\\')),0)); return !_access(Path,0); } BOOL GetDefaultXlsFileName(CString &sExcelFile) { ///默认文件名:yyyymmddhhmmss.xls // prompt the user (with all document templates) CFileDialog dlgFile(FALSE,".xls",sExcelFile); CString title; CString strFilter; title = "导出"; strFilter = "Excel文件(*.xls)"; strFilter += (TCHAR)'\0'; // next string please strFilter += _T("*.xls"); strFilter += (TCHAR)'\0'; // last string dlgFile.m_ofn.nMaxCustFilter++; dlgFile.m_ofn.nFilterIndex = 1; // append the "*.*" all files filter CString allFilter; VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER)); strFilter += allFilter; strFilter += (TCHAR)'\0'; // next string please strFilter += _T("*.*"); strFilter += (TCHAR)'\0'; // last string dlgFile.m_ofn.nMaxCustFilter++; dlgFile.m_ofn.lpstrFilter = strFilter; dlgFile.m_ofn.lpstrTitle = title; if (dlgFile.DoModal()==IDCANCEL) return FALSE; // open cancelled sExcelFile=dlgFile.GetFileName (); if (MakeSurePathExists(sExcelFile,true)) { if(!DeleteFile(sExcelFile)) { // delete the file AfxMessageBox("覆盖文件时出错!"); return FALSE; } } return TRUE; } int FindArrayCount(CStringArray *pArray, CString Str) { int ret=0; for(int i=0; iGetSize (); i++) { if(pArray->ElementAt (i)==Str) ret++; } return ret; } void ListToXLS(CListCtrl *pList, CString savepath, int mode) { if(pList==NULL)return; CString strTitle="sheet1"; CString warningStr; CString str,temp; if (pList->GetItemCount ()>0) { CDatabase database; CString sDriver; CString sExcelFile; CString sSql; CString tableName = strTitle; CStringArray colarray; // 检索是否安装有Excel驱动 "Microsoft Excel Driver (*.xls)" sDriver = GetExcelDriver(); if (sDriver.IsEmpty()) { // 没有发现Excel驱动 AfxMessageBox("没有安装Excel!\n请先安装Excel软件才能使用导出功能!"); return; } sExcelFile=""; sExcelFile=savepath; ///默认文件名 if (!GetDefaultXlsFileName(sExcelFile)) return; // 创建进行存取的字符串 sSql.Format("DRIVER={%s};DSN='';FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=\"%s\";DBQ=%s",sDriver, sExcelFile, sExcelFile); // 创建数据库 (既Excel表格文件) if( database.OpenEx(sSql,CDatabase::noOdbcDialog) ) { // 创建表结构 int i; LVCOLUMN columnData; CString columnName; int columnNum = 0; CString strH; CString strV; sSql = ""; strH = ""; columnData.mask = LVCF_TEXT; columnData.cchTextMax =100; columnData.pszText = columnName.GetBuffer (100); { for(i=mode;pList->GetColumn(i,&columnData);i++) { if (i!=mode) { sSql = sSql + ", " ; strH = strH + ", " ; } temp=columnData.pszText; temp.Replace("/", ""); temp.Replace("(", ""); temp.Replace(")", ""); int countexist=FindArrayCount(&colarray, temp); if(countexist) { CString ss; ss.Format("%d", countexist+1); sSql = sSql + " " + temp+ss +" TEXT"; strH = strH + " " + temp+ss +" "; str=temp; str+=ss; colarray.Add (str); } else { sSql = sSql + " " + temp +" TEXT"; strH = strH + " " + temp +" "; colarray.Add (temp); } } } columnName.ReleaseBuffer (); columnNum = i; sSql = "CREATE TABLE " + tableName + " ( " + sSql + " ) "; database.ExecuteSQL(sSql); // 插入数据项 int nItemIndex; { for (nItemIndex=0;nItemIndexGetItemCount ();nItemIndex++) { strV = ""; for(i=mode;iGetItemText(nItemIndex,i) +"' "; } sSql = "INSERT INTO "+ tableName +" ("+ strH + ")" +" VALUES("+ strV + ")"; database.ExecuteSQL(sSql); } } } // 关闭数据库 database.Close(); ShellExecute(NULL, _T("open"), sExcelFile, NULL,NULL, SW_SHOW); } else AfxMessageBox("表中没有数据!"); } //%0.2f void MySalary::OnBut3() // 导出按钮; { // TODO: Add your control notification handler code here ListToXLS(&m_List3, "c:\\工资表.xls", 0); }