123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557 |
- // SalarySet4.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "SalarySet4.h"
- #include "SelExpendType.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // SalarySet4 dialog
- SalarySet4::SalarySet4(CWnd* pParent /*=NULL*/)
- : CDialog(SalarySet4::IDD, pParent)
- {
- //{{AFX_DATA_INIT(SalarySet4)
- m_money1 = 0;
- m_money2 = 0;
- m_rate = 0.0f;
- m_check1 = FALSE;
- m_testmoney = 0.0f;
- //}}AFX_DATA_INIT
- }
- void SalarySet4::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(SalarySet4)
- DDX_Control(pDX, IDC_EDIT8, m_numctrl4);
- DDX_Control(pDX, IDC_LIST1, m_list1);
- DDX_Control(pDX, IDC_EDIT3, m_numctrl3);
- DDX_Control(pDX, IDC_EDIT2, m_numctrl2);
- DDX_Control(pDX, IDC_EDIT1, m_numctrl1);
- DDX_Text(pDX, IDC_EDIT1, m_money1);
- DDX_Text(pDX, IDC_EDIT2, m_money2);
- DDX_Text(pDX, IDC_EDIT3, m_rate);
- DDX_Check(pDX, IDC_CHECK1, m_check1);
- DDX_Text(pDX, IDC_EDIT8, m_testmoney);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(SalarySet4, CDialog)
- //{{AFX_MSG_MAP(SalarySet4)
- ON_BN_CLICKED(IDC_BUTTON1, OnAdd)
- ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
- ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
- ON_BN_CLICKED(IDC_BUTTON14, OnButton14)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // SalarySet4 message handlers
- BOOL SalarySet4::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- if (IsHasRights2new(25) == 0)
- {
- GetDlgItem(IDOK)->EnableWindow(0);
- }
- CString str = g_cominfoarray.ElementAt(0).ElementAt(77);
- int pos = str.Find(m_header);
- int headleng = m_header.GetLength();
- if (pos != -1)
- {
- str = str.Right(str.GetLength() - pos);
- str.Delete(0, headleng);
- pos = str.Find("$");
- if (pos != -1)
- str = str.Left(pos);
- InitRule(str);
- }
- str = m_header;
- str.TrimLeft("$");
- str.TrimRight(":");
- SetWindowText("阶梯提成方案-" + str);
- //////////////////////////////////////////////////////
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 160;
- g_sendhead.code[1] = 169;
- g_sendhead.tabcount = 2;
- g_pMainWnd->ProcessChatMessageRequest2(1);
- if (g_bSendOK == 0)
- {
- CDialog::OnCancel();
- return 0;
- }
- CArray<CStringArray, CStringArray>expendtypearray;
- CArray<CStringArray, CStringArray>baseexpendtypearray;
- DataToArray(&expendtypearray, &baseexpendtypearray);
- int i = 0;
- for ( i = 0; i < baseexpendtypearray.GetSize(); i++)
- {
- m_expendtypearray.Add(baseexpendtypearray.ElementAt(i).ElementAt(0));
- }
- for (i = 0; i < expendtypearray.GetSize(); i++)
- {
- m_expendtypearray.Add(expendtypearray.ElementAt(i).ElementAt(0));
- }
- m_expendtypearray.Add("摄影二销");
- #ifdef CHILD_VERSION
- m_expendtypearray.Add("引导二销");
- #else
- m_expendtypearray.Add("化妆二销");
- #endif // CHILD_VERSION
- m_expendtypearray.Add("选片二销");
- m_expendtypearray.Add("摄影选片二销");
- #ifdef CHILD_VERSION
- m_expendtypearray.Add("引导选片二销");
- #else
- m_expendtypearray.Add("化妆选片二销");
- #endif // CHILD_VERSION
- CenterWindow();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void SalarySet4::OnAdd()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- if (CheckRange() == 0)
- return;
- CString str, temp;
- if (m_money1 >= m_money2)
- {
- AfxMessageBox("业绩范围出错!", MB_ICONINFORMATION);
- return;
- }
- if (m_list1.GetCount() == 0 && m_money1 != 0)
- {
- AfxMessageBox("起始业绩应从0开始!", MB_ICONINFORMATION);
- return;
- }
- str.Format("%d-%d 提:%0.1f", m_money1, m_money2, m_rate); str += "%";
- for (int i = 0; i < m_list1.GetCount(); i++)
- {
- m_list1.GetText(i, temp);
- if (str == temp)
- {
- AfxMessageBox("已有此规则!", MB_ICONINFORMATION);
- return;
- }
- }
- m_list1.AddString(str);
- }
- BOOL SalarySet4::CheckRange()
- {
- CString str, temp;
- int money1, money2;
- for (int i = 0; i < m_list1.GetCount(); i++)
- {
- m_list1.GetText(i, temp);
- int pos = temp.Find(" ");
- temp = temp.Left(pos);
- pos = temp.Find("-");
- money1 = atoi(temp.Left(pos));
- money2 = atoi(temp.Right(temp.GetLength() - pos - 1));
- if (m_money1 >= money1 && m_money1 <= money2)
- {
- AfxMessageBox("起始业绩已包含在已有的规则中!", MB_ICONINFORMATION);
- return 0;
- }
- if (m_money2 >= money1 && m_money2 <= money2)
- {
- AfxMessageBox("终止业绩已包含在已有的规则中!", MB_ICONINFORMATION);
- return 0;
- }
- }
- if (m_list1.GetCount())
- {
- m_list1.GetText(m_list1.GetCount() - 1, temp);
- int pos = temp.Find(" ");
- temp = temp.Left(pos);
- pos = temp.Find("-");
- money2 = atoi(temp.Right(temp.GetLength() - pos - 1));
- if (m_money1 != money2 + 1)
- {
- AfxMessageBox("业绩段不连续,起始业绩应比上一规则段终止业绩大1", MB_ICONINFORMATION);
- return 0;
- }
- }
- return 1;
- }
- void SalarySet4::OnButton3()
- {
- // TODO: Add your control notification handler code here
- if (AfxMessageBox("确定要删除全部规则吗?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return;
- m_list1.ResetContent();
- }
- void SalarySet4::OnOK()
- {
- // TODO: Add extra validation here
- UpdateData();
- CString str, temp;
- str = m_header;
- for (int i = 0; i < m_list1.GetCount(); i++)
- {
- m_list1.GetText(i, temp);
- str += temp;
- str += ";";
- }
- temp.Format("%d", m_check1);
- str += temp;
- CString oldrule = g_cominfoarray.ElementAt(0).ElementAt(77);
- CString left, right;
- int pos = oldrule.Find(m_header);
- if (pos != -1)
- {
- left = oldrule.Left(pos);
- right = oldrule.Right(oldrule.GetLength() - pos - m_header.GetLength());
- pos = right.Find("$");
- if (pos != -1)
- right = right.Right(right.GetLength() - pos);
- else
- right.Empty();
- str = left + str + right;
- }
- else
- str += oldrule;
- CString name;
- temp.Empty();
- pos = str.Find("$");
- while (pos != -1)
- {
- int pos2 = str.Find(":");
- name = str.Mid(pos + 1, pos2 - pos - 1);
- BOOL bFind = 0;
- for (int i = 0; i < m_expendtypearray.GetSize(); i++)
- {
- if (name == m_expendtypearray.ElementAt(i))
- {
- bFind = 1;
- break;
- }
- }
- if (bFind)
- {
- temp += str.Left(pos2);
- str = str.Right(str.GetLength() - pos2);
- pos = str.Find("$");
- if (pos != -1)
- {
- temp += str.Left(pos);
- str = str.Right(str.GetLength() - pos);
- }
- else
- temp += str;
- pos = str.Find("$");
- }
- else
- {
- str = str.Right(str.GetLength() - pos2);
- pos = str.Find("$");
- if (pos != -1)
- {
- str = str.Right(str.GetLength() - pos);
- }
- pos = str.Find("$");
- }
- }
- str = temp;
- //$摄影师前期:0-1000 提:1.0%;0$门市前期:0-1000 提:1.0%;0$摄影二消:0$前期:0$化妆二消:0$选片二消:1
- // m_expendtypearray
- CString sql;
- sql.Format("update version set [salaryset]='%s'", str);
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
- AfxMessageBox("保存成功!", MB_ICONINFORMATION);
- g_cominfoarray.ElementAt(0).SetAt(77, str);
- CDialog::OnOK();
- }
- float GetSalaryFromRule(float fmoney, CString rule)
- {
- float fresult = 0;
- int pos = rule.Find(":");
- if (pos == -1)return 0;
- rule = rule.Right(rule.GetLength() - pos - 1);
- CStringArray rulearray;
- pos = rule.Find(";");
- while (pos != -1)
- {
- rulearray.Add(rule.Left(pos));
- rule = rule.Right(rule.GetLength() - pos - 1);
- pos = rule.Find(";");
- }
- BOOL check1 = atoi(rule);
- if (rulearray.GetSize() == 0)return 0;
- CString str, temp;
- int money1, money2;
- float frate;
- if (check1 == 0)
- {
- for (int i = 0; i < rulearray.GetSize(); i++)
- {
- temp = rulearray.ElementAt(i);
- int pos = temp.Find(" ");
- temp = temp.Left(pos);
- pos = temp.Find("-");
- money1 = atoi(temp.Left(pos));
- money2 = atoi(temp.Right(temp.GetLength() - pos - 1));
- if ((i == rulearray.GetSize() - 1) || (fmoney >= money1 && fmoney <= money2))
- {
- temp = rulearray.ElementAt(i);
- pos = temp.Find(":");
- temp = temp.Right(temp.GetLength() - pos - 1);
- temp.TrimRight("%");
- frate = atof(temp) / 100.0;
- fresult = frate*fmoney;
- return fresult;
- }
- }
- }
- else//////
- {
- for (int i = 0; i < rulearray.GetSize(); i++)
- {
- temp = rulearray.ElementAt(i);
- int pos = temp.Find(" ");
- temp = temp.Left(pos);
- pos = temp.Find("-");
- money1 = atoi(temp.Left(pos));
- money2 = atoi(temp.Right(temp.GetLength() - pos - 1));
- if ((i == rulearray.GetSize() - 1) || (fmoney >= money1 && fmoney <= money2))
- {
- temp = rulearray.ElementAt(i);
- pos = temp.Find(":");
- temp = temp.Right(temp.GetLength() - pos - 1);
- temp.TrimRight("%");
- frate = atof(temp) / 100.0;
- float dtmoney = fmoney - money1;
- fresult += frate*dtmoney;
- if (i == 0)//只有一条规则
- {
- fresult = frate*fmoney;
- return fresult;
- }
- while (i)
- {
- i--;
- temp = rulearray.ElementAt(i);
- pos = temp.Find(" ");
- temp = temp.Left(pos);
- pos = temp.Find("-");
- money1 = atoi(temp.Left(pos));
- money2 = atoi(temp.Right(temp.GetLength() - pos - 1));
- temp = rulearray.ElementAt(i);
- pos = temp.Find(":");
- temp = temp.Right(temp.GetLength() - pos - 1);
- temp.TrimRight("%");
- frate = atof(temp) / 100.0;
- dtmoney = money2 - money1;
- fresult += frate*dtmoney;
- }
- return fresult;
- }
- }
- }
- return fresult;
- }
- /*
- float GetSalaryFromRule(float fmoney, CString rule)
- {
- float fresult=0;
- int pos=rule.Find (":");
- if(pos==-1)return 0;
- rule=rule.Right (rule.GetLength ()-pos-1);
- CStringArray rulearray;
- pos=rule.Find (";");
- while(pos!=-1)
- {
- rulearray.Add (rule.Left (pos));
- rule=rule.Right (rule.GetLength ()-pos-1);
- pos=rule.Find (";");
- }
- BOOL check1=atoi(rule);
- if(rulearray.GetSize ()==0)return 0;
- CString str,temp;
- int money1,money2;
- float frate;
- for(int i=0; i<rulearray.GetSize (); i++)
- {
- temp=rulearray.ElementAt (i);
- int pos=temp.Find(" ");
- temp=temp.Left(pos);
- pos=temp.Find("-");
- money1=atoi(temp.Left(pos));
- money2=atoi(temp.Right(temp.GetLength()-pos-1));
- if( (i==rulearray.GetSize ()-1) || (fmoney>=money1 && fmoney<=money2) )
- {
- temp=rulearray.ElementAt (i);
- pos=temp.Find (":");
- temp=temp.Right (temp.GetLength ()-pos-1);
- temp.TrimRight ("%");
- frate=atof(temp)/100.0;
- if(check1 && i>0)
- {
- temp=rulearray.ElementAt (i-1);
- pos=temp.Find (":");
- temp=temp.Right (temp.GetLength ()-pos-1);
- temp.TrimRight ("%");
- float frate2=atof(temp)/100.0;
- fresult=(money1-1)*frate2+frate*(fmoney-money1+1);
- }
- else
- {
- fresult=frate*fmoney;
- }
- return fresult;
- }
- }
- return fresult;
- }
- */
- void SalarySet4::OnButton2()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- if (m_testmoney < 1)
- {
- m_testmoney = 100000;
- UpdateData(0);
- }
- CString rule = GetRule();
- float fresult = GetSalaryFromRule(m_testmoney, rule);
- CString temp;
- temp.Format("%0.2f", fresult);
- SetDlgItemText(IDC_EDIT4, temp);
- /* CString str,temp;
- int money1,money2;
- float frate;
- for(int i=0; i<m_list1.GetCount (); i++)
- {
- m_list1.GetText (i, temp);
- int pos=temp.Find(" ");
- temp=temp.Left(pos);
- pos=temp.Find("-");
- money1=atoi(temp.Left(pos));
- money2=atoi(temp.Right(temp.GetLength()-pos-1));
- if( (i==m_list1.GetCount ()-1) || (m_testmoney>=money1 && m_testmoney<=money2) )
- {
- m_list1.GetText (i, temp);
- pos=temp.Find (":");
- temp=temp.Right (temp.GetLength ()-pos-1);
- temp.TrimRight ("%");
- frate=atof(temp)/100.0;
- float fresult;
- if(m_check1 && i>0)
- {
- m_list1.GetText (i-1, temp);
- pos=temp.Find (":");
- temp=temp.Right (temp.GetLength ()-pos-1);
- temp.TrimRight ("%");
- float frate2=atof(temp)/100.0;
- fresult=(money1-1)*frate2+frate*(m_testmoney-money1+1);
- }
- else
- {
- fresult=frate*m_testmoney;
- }
- temp.Format ("%0.2f", fresult);
- SetDlgItemText(IDC_EDIT4, temp);
- return;
- }
- }
- AfxMessageBox("请先设规则!", MB_ICONINFORMATION);*/
- }
- CString SalarySet4::GetRule()
- {
- CString str, temp;
- str = m_header;//"$前期:";
- for (int i = 0; i < m_list1.GetCount(); i++)
- {
- m_list1.GetText(i, temp);
- str += temp;
- str += ";";
- }
- temp.Format("%d", m_check1);
- str += temp;
- return str;
- }
- void SalarySet4::OnButton14()
- {
- // TODO: Add your control notification handler code here
- SelExpendType seldlg;
- seldlg.m_mode = 1;
- seldlg.m_bSecond = 1;
- if (seldlg.DoModal() != IDOK)return;
- CString oldrule = g_cominfoarray.ElementAt(0).ElementAt(77);
- CString header = "$" + seldlg.m_sel + ":";
- CString left, right;
- int pos = oldrule.Find(header);
- if (pos != -1)
- {
- right = oldrule.Right(oldrule.GetLength() - pos - header.GetLength());
- pos = right.Find("$");
- if (pos != -1)
- right = right.Left(pos);
- InitRule(right);
- }
- else
- {
- AfxMessageBox(seldlg.m_sel + "未设置规则!", MB_ICONINFORMATION);
- }
- }
- void SalarySet4::InitRule(CString str)
- {
- m_list1.ResetContent();
- int pos = str.Find(";");
- while (pos != -1)
- {
- m_list1.AddString(str.Left(pos));
- str = str.Right(str.GetLength() - pos - 1);
- pos = str.Find(";");
- }
- m_check1 = atoi(str);
- UpdateData(false);
- }
|