1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.InitialSet
- {
- public partial class FrmRatingsProportion : LYFZ.Software.UI.InitialSet.FrmRatingsProportion
- {
- LYFZ.BLL.BLL_ErpCommissionPercentage cpbll = new BLL.BLL_ErpCommissionPercentage();
- LYFZ.BLL.BLL_ErpSystemCategory scbll = new BLL.BLL_ErpSystemCategory();
- public FrmRatingsProportion()
- {
- this.Load+=FrmRatingsProportion_Load;
- this.Shown += FrmRatingsProportion_Shown;
- this.btnClose.Click+=btnClose_Click;
- this.btnSave.Click+=btnSave_Click;
- this.txtCp_DeputyStoreProportion.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
- this.txtCp_MainStoreProportion.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
- this.txtThreeLevel.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
- this.txtTwoLevel.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
- this.txtOneLevel.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
- this.txtDeputyMake.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
- this.txtMainMake.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
- this.txtDeputyPhotography.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
- this.txtMainPhotography.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
- this.txtMainBootDivision.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
- this.txtDeputyBootDivision.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
- this.tabControlEx1.SelectedIndexChanged += tabControlEx1_SelectedIndexChanged;
- this.cmbtreevSc_ClassName.ComboBoxTree_NodeMouseClick += cmbtreevSc_ClassName_ComboBoxTree_NodeMouseClick;
- this.btnSet.Click += btnSet_Click;
- this.btnOk.Click += btnOk_Click;
- this.buttonExit.Click += buttonExit_Click;
- this.dgvPiecewiseList.CellClick += dgvPiecewiseList_CellClick;
- this.txtWcs_Percentage.KeyPress+=txtWcs_Percentage_KeyPress;
- this.txtWcs_PerformanceBeginValue.KeyPress += txtWcs_Percentage_KeyPress;
- this.txtWcs_PerformanceEndValue.KeyPress += txtWcs_Percentage_KeyPress;
- this.txtCommissionPoint.KeyPress += txtWcs_Percentage_KeyPress;
- this.txtValue.KeyPress += txtWcs_Percentage_KeyPress;
- this.txtWcs_PerformanceBeginValue.TextChanged += txtCommissionPoint_TextChanged;
- this.txtWcs_PerformanceEndValue.TextChanged += txtCommissionPoint_TextChanged;
- //this.txtCommissionPoint.TextChanged += txtCommissionPoint_TextChanged;
- this.txtValue.TextChanged += txtCommissionPoint_TextChanged;
- this.cmbSc_ClassName.ComboBoxTree_NodeMouseClick += cmbSc_ClassName_ComboBoxTree_NodeMouseClick;
- this.bntfSet.Click += bntfSet_Click;
- this.btnAdd.Click += btnAdd_Click;
- this.btnDeltee.Click += btnDeltee_Click;
- this.dgvCommissionRule.CellDoubleClick += dgvCommissionRule_CellDoubleClick;
- this.cbxType.SelectedIndexChanged += cbxType_SelectedIndexChanged;
- this.btnResults.Click += btnResults_Click;
- this.dgvCommissionRule.CellContentClick += dgvCommissionRule_CellContentClick;
- this.dgvPiecewiseList.CellContentClick += dgvPiecewiseList_CellContentClick;
- }
- void FrmRatingsProportion_Shown(object sender, EventArgs e)
- {
- this.bindCommissionPercentage();
- }
- /// <summary>
- /// 删除计件提成
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvPiecewiseList_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.ColumnIndex == 2 && e.RowIndex >= 0)
- {
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RatingsProportionCompetence, CustomAttributes.OperatingAuthority.Delete))
- {
- DataGridViewRow dgRow = this.dgvPiecewiseList.Rows[e.RowIndex];
- if (dgRow.Tag != null)
- {
- if (MessageBoxCustom.Show("正在准备删除“" + dgRow.Cells[0].Value.ToString() + "”的提成金额设置\r\n您确定要删除码?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
- {
- LYFZ.Model.Model_ErpWageCommissionSet model = (LYFZ.Model.Model_ErpWageCommissionSet)dgRow.Tag;
- if (wcsetbll.Delete(model.ID))
- {
- model = null;
- this.dgvPiecewiseList.Rows.Remove(dgRow);
- }
- else
- {
- MessageBoxCustom.Show("删除失败,请重试");
- }
- }
- else {
- return;
- }
- }
- else {
- MessageBoxCustom.Show("删除失败,数据对象获取失败");
- }
- }
- else
- {
- MessageBoxCustom.Show("对不起,你没有权限计件提成设置。");
- }
- }
- }
- /// <summary>
- /// 删除方案规则
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvCommissionRule_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.ColumnIndex == 5 && e.RowIndex >= 0)
- {
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RatingsProportionCompetence, CustomAttributes.OperatingAuthority.Delete))
- {
- btnDeltee_Click(null, null);
- }
- else
- {
- MessageBoxCustom.Show("对不起,你没有权限删除方案规则。");
- }
- }
- }
- /// <summary>
- /// 测试计算
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnResults_Click(object sender, EventArgs e)
- {
- this.txtResults.Text = "0";
- if (this.cmbSc_ClassName.TreeView.SelectedNode != null && this.cmbSc_ClassName.TreeView.SelectedNode.Tag != null && this.cmbSc_ClassName.TreeView.SelectedNode.Tag.ToString().Length>0)
- {
- string typeCode = this.cmbSc_ClassName.TreeView.SelectedNode.Tag.ToString().Trim();
- int resultValue = Convert.ToInt32(this.txtValue.Text.Trim());
- decimal sumResultValue = 0;
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- LYFZ.BLL.BLL_ErpWageCommissionSet.UpdateCommissionSet();
- sumResultValue = LYFZ.BLL.BLL_ErpWageCommissionSet.SumComputeResults(typeCode, resultValue);
- });
- this.txtResults.Text = sumResultValue.ToString("n2");
- }
- else
- {
- MessageBoxCustom.Show("请选择要测试计算的方案");
- }
- }
- void cbxType_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (this.cbxType.SelectedIndex == 1)
- {
- this.txtWcs_PerformanceBeginValue.Text = "0";
- this.txtWcs_PerformanceEndValue.Text = "0";
- this.txtWcs_PerformanceBeginValue.ReadOnly = true;
- this.txtWcs_PerformanceEndValue.ReadOnly = true;
- }
- else {
- this.txtWcs_PerformanceBeginValue.ReadOnly = false;
- this.txtWcs_PerformanceEndValue.ReadOnly = false;
- if (this.dgvCommissionRule.Rows.Count <= 0)
- {
- this.txtWcs_PerformanceBeginValue.Text = "0";
- }
- }
- }
- /// <summary>
- /// 更新“业绩超出部分”的提成方式
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvCommissionRule_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.RowIndex >= 0 && e.ColumnIndex == 2)
- {
- DataGridViewRow Row = this.dgvCommissionRule.Rows[e.RowIndex];
- if (Row == null || Row.Cells[e.ColumnIndex].Value ==null|| Row.Cells[e.ColumnIndex].Value.ToString().Trim() == "--")
- {
- return;
- }
- if (Row.Tag != null && Row.Tag.GetType() == typeof(ItemValue))
- {
- ItemValue item = (ItemValue)Row.Tag;
- int Wcs_PerformanceHight = 0;
- if (Row.Cells[e.ColumnIndex].Value.ToString() == "是")
- {
- Wcs_PerformanceHight = 0;
- }
- else
- {
- Wcs_PerformanceHight = 1;
- }
- bool updateOk = false;
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- if (wcsetbll.UpdateWageCommissionSet(Wcs_PerformanceHight, "Wcs_TypeCode='" + item.Value.ToString().Trim() + "'") > 0)
- {
- updateOk = true;
- }
- });
- if (updateOk)
- {
- if (Wcs_PerformanceHight == 1)
- {
- Row.Cells[e.ColumnIndex].Value = "是";
- }
- else
- {
- Row.Cells[e.ColumnIndex].Value = "否";
- }
- }
- }
- }
- }
- /// <summary>
- /// 删除提成点规则
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnDeltee_Click(object sender, EventArgs e)
- {
- //DataGridViewRow Row
- if (this.dgvCommissionRule.SelectedRows != null && this.dgvCommissionRule.SelectedRows.Count > 0)
- {
- try
- {
- DataGridViewRow Row = this.dgvCommissionRule.SelectedRows[0];
- bool deleteOk = false;
- if (Row.Tag != null && Row.Tag.GetType() == typeof(ItemValue))
- {
- if (MessageBoxCustom.Show("正在准备删除“" + Row.Cells[0].Value.ToString() + "”方案的所有规则\r\n您确定要删除码?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
- {
- ItemValue item = (ItemValue)Row.Tag;
- string classCode = item.Value.ToString();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- if (wcsetbll.Delete(" Wcs_TypeCode='" + classCode.Trim() + "'"))
- {
- deleteOk = true;
- }
- });
- }
- else {
- return;
- }
- }
- else if (Row.Tag != null && Row.Tag.GetType() == typeof(LYFZ.Model.Model_ErpWageCommissionSet))
- {
- int tempDelRowIndex = Row.Index;
- LYFZ.Model.Model_ErpWageCommissionSet cDelModel = (LYFZ.Model.Model_ErpWageCommissionSet)Row.Tag;
- StringBuilder tempDelIDList = new StringBuilder();
- tempDelIDList.Append(cDelModel.ID.ToString() + ",");
- LYFZ.Model.Model_ErpWageCommissionSet tempDelModel = null;
- foreach (DataGridViewRow tRow in this.dgvCommissionRule.Rows)
- {
- if (tRow.Tag != null && tRow.Tag.GetType() == typeof(LYFZ.Model.Model_ErpWageCommissionSet))
- {
- tempDelModel = (LYFZ.Model.Model_ErpWageCommissionSet)tRow.Tag;
- if (tRow.Index > tempDelRowIndex && tempDelModel.Wcs_TypeCode.Trim().ToLower() == cDelModel.Wcs_TypeCode.Trim().ToLower())
- {
- tempDelIDList.Append(tempDelModel.ID.ToString() + ",");
- }
- tempDelModel = null;
- }
- }
- if (tempDelIDList.ToString().Trim(',').Split(',').Length > 1)
- {
- if (MessageBoxCustom.Show("正在准备删除“" + GetWageCommissionText(cDelModel.Wcs_TypeCode, cDelModel.ID) + "”方案的“" + Row.Cells[3].Value.ToString() + "”规则,和其后价梯所有规则。\r\n您确定要删除码?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- deleteOk = wcsetbll.DeleteList(tempDelIDList.ToString().Trim(','));
- });
- }
- else {
- return;
- }
- }
- else
- {
- if (MessageBoxCustom.Show("正在准备删除“" + GetWageCommissionText(cDelModel.Wcs_TypeCode, cDelModel.ID) + "”方案的“" + Row.Cells[3].Value.ToString() + "”规则。\r\n您确定要删除码?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
- {
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- deleteOk = wcsetbll.Delete(cDelModel.ID);
- });
- }
- else {
- return;
- }
- }
- }
- if (deleteOk)
- {
- if (this.cmbSc_ClassName.TreeView.SelectedNode != null && this.cmbSc_ClassName.TreeView.SelectedNode.Tag != null)
- {
- BindCommissionRuleList(this.cmbSc_ClassName.TreeView.SelectedNode.Tag.ToString());
- }
- else {
- BindCommissionRuleList("");
- }
-
- if (this.dgvCommissionRule.Rows.Count <= 0)
- {
- this.cbxType.Enabled = this.flowLayoutPanel1.Enabled;
- }
- }
- else
- {
- MessageBoxCustom.Show("删除方案规则失败,请重试!");
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show("删除方案规则时出错:" + ex.Message);
- }
- }
- else
- {
- MessageBoxCustom.Show("请选择你要删除的方案规则");
- }
- }
- /// <summary>
- /// 添加提成点规则
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnAdd_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.cmbSc_ClassName.TreeView.SelectedNode == null)
- {
- MessageBoxCustom.Show("请选择方案");
- return;
- }
- if (this.cmbSc_ClassName.TreeView.SelectedNode.Tag == null || this.cmbSc_ClassName.TreeView.SelectedNode.Tag.ToString().Length <= 0)
- {
- MessageBoxCustom.Show("选择方案不正确,请重新选择");
- return;
- }
- if (this.txtWcs_PerformanceBeginValue.Text.Trim().Length <= 0)
- {
- MessageBoxCustom.Show("请输入阶梯业绩的 开始值");
- return;
- }
- if (this.txtWcs_PerformanceEndValue.Text.Trim().Length <= 0)
- {
- MessageBoxCustom.Show("请输入阶梯业绩的 终止值");
- return;
- }
- if (this.txtCommissionPoint.Text.Trim().Length <= 0)
- {
- MessageBoxCustom.Show("请输入阶梯业绩的 提成点数");
- return;
- }
- LYFZ.Model.Model_ErpWageCommissionSet addModel = new Model.Model_ErpWageCommissionSet();
- addModel.Wcs_Type = "提成点";
- addModel.Wcs_DividedShop = LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID;
- addModel.Wcs_PerformanceBeginValue = Convert.ToInt32(this.txtWcs_PerformanceBeginValue.Text.Trim());
- addModel.Wcs_Percentage = Convert.ToDecimal(this.txtCommissionPoint.Text.Trim());
- addModel.Wcs_CreateTime = SDateTime.Now;
- addModel.Wcs_TypeCode = this.cmbSc_ClassName.TreeView.SelectedNode.Tag.ToString();
- if (this.cbxType.SelectedIndex == 1)
- {
- addModel.Wcs_PerformanceEndValue = 2099999999;
- }
- else
- {
- addModel.Wcs_PerformanceEndValue = Convert.ToInt32(this.txtWcs_PerformanceEndValue.Text.Trim());
- }
- if (addModel.Wcs_Percentage < 0)
- {
- MessageBoxCustom.Show("业绩的提成点数不能小于零 “0”");
- return;
- }
- if (addModel.Wcs_PerformanceEndValue <= addModel.Wcs_PerformanceBeginValue)
- {
- MessageBoxCustom.Show("阶梯业绩的 开始值 必须大于 终止值");
- return;
- }
- if (this.cbxType.SelectedIndex != 1 && addModel.Wcs_PerformanceEndValue >= 2099999999)
- {
- MessageBoxCustom.Show("阶梯业绩的 终止值 不能大于等于 “2099999999”");
- return;
- }
- if (!CheckResults(addModel.Wcs_TypeCode, addModel.Wcs_PerformanceBeginValue))
- {
- if (this.cbxType.SelectedIndex == 1)
- {
- MessageBoxCustom.Show("要添加的提成规则已经存在,不能添加。");
- }
- else
- {
- MessageBoxCustom.Show("阶梯业绩的 开始值 已经在现有规则范围内,不能添加。");
- }
- return;
- }
- if (!CheckResults(addModel.Wcs_TypeCode, addModel.Wcs_PerformanceEndValue))
- {
- if (this.cbxType.SelectedIndex == 1)
- {
- MessageBoxCustom.Show("要添加的提成规则已经存在,不能添加。");
- }
- else
- {
- MessageBoxCustom.Show("阶梯业绩的 终止值 已经在现有规则范围内,不能添加。");
- }
- return;
- }
- if (this.dgvCommissionRule.Rows.Count <= 0 && addModel.Wcs_PerformanceBeginValue > 0)
- {
- MessageBoxCustom.Show("第一阶梯业绩的 开始值 必须为零 “0”");
- return;
- }
- addModel.Wcs_PerformanceHight = false;
- if (this.cbxType.SelectedIndex == 2)
- {
- addModel.Wcs_PerformanceHight = Convert.ToBoolean(selectItemValue.Value);
- }
- bool addOk = false;
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- addOk = wcsetbll.Add(addModel);
- });
- if (addOk)
- {
- BindCommissionRuleList(addModel.Wcs_TypeCode);
- this.cbxType.Enabled = false;
- }
- else
- {
- MessageBoxCustom.Show("添加方案规则失败,请重试!");
- }
- }
- catch (Exception ex){
- MessageBoxCustom.Show("添加方案规则时出错:"+ex.Message);
- }
- }
- /// <summary>
- /// 检查指定业绩值在指定方案中是否有效
- /// </summary>
- /// <param name="classCode">方案代码</param>
- /// <param name="resultsValue">指定业绩值</param>
- /// <param name="isEnd">是否为终止值</param>
- /// <returns></returns>
- bool CheckResults(string classCode, int resultsValue)
- {
- bool bl = true;
- LYFZ.Model.Model_ErpWageCommissionSet cModel = null;
- foreach (DataGridViewRow tRow in this.dgvCommissionRule.Rows)
- {
- if (tRow.Tag != null && tRow.Tag.GetType() == typeof(LYFZ.Model.Model_ErpWageCommissionSet))
- {
- cModel = (LYFZ.Model.Model_ErpWageCommissionSet)tRow.Tag;
- if (cModel.Wcs_TypeCode.Trim().ToLower() == classCode.Trim().ToLower())
- {
- if (resultsValue <= cModel.Wcs_PerformanceEndValue)
- {
- bl = false;
- break;
- }
- }
- }
- cModel = null;
- }
-
- return bl;
- }
- void txtCommissionPoint_TextChanged(object sender, EventArgs e)
- {
-
- ComponentLibrary.TextBoxBasicEx txtBox = (ComponentLibrary.TextBoxBasicEx)sender;
- if (txtBox.Text.Trim().Trim('-').Length > 0)
- {
- int tempInt = 0;
- if (!int.TryParse(txtBox.Text.Trim().Trim('.'), out tempInt))
- {
- txtBox.Text = "0";
- }
- }
- }
-
- ItemValue selectItemValue = null;
- /// <summary>
- /// 提成方案选择项事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void cmbSc_ClassName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- if (e.Node.Tag != null)
- {
- BindCommissionRuleList(e.Node.Tag.ToString().Trim());
- selectItemValue = GetCbxTypeIndex(e.Node.Tag.ToString().Trim());
- this.cbxType.SelectedIndex = Convert.ToInt32(selectItemValue.Text);
- if (this.cbxType.SelectedIndex > 0)
- {
- this.cbxType.Enabled = false;
- }
- else {
- this.cbxType.Enabled = this.flowLayoutPanel1.Enabled;
- }
- }
- }
- ItemValue GetCbxTypeIndex(string classCode)
- {
- int cbxTypeIndex = 0;
- bool PerformanceHight = true;
- foreach (DataGridViewRow Row in this.dgvCommissionRule.Rows)
- {
- if (Row.Tag != null && Row.Tag.GetType() == typeof(ItemValue))
- {
- ItemValue item=(ItemValue)Row.Tag;
- if (item.Value.ToString().ToLower().Trim() == classCode.Trim().ToLower())
- {
- if (Row.Cells[2].Value.ToString() == "是")
- {
- PerformanceHight = true;
- }
- else {
- PerformanceHight = false;
- }
- if (Row.Cells[1].Value.ToString() == this.cbxType.Items[1].ToString())
- {
- cbxTypeIndex = 1;
- }
- else if (Row.Cells[1].Value.ToString() == this.cbxType.Items[2].ToString())
- {
- cbxTypeIndex = 2;
- }
- break;
- }
- }
- }
- return new ItemValue(PerformanceHight, cbxTypeIndex.ToString());
- }
- void BindCommissionRuleList(string classCode)
- {
- string whereStr = "wcs_type='提成点'";
- if (!string.IsNullOrEmpty(classCode.Trim()))
- {
- whereStr = whereStr + " and Wcs_TypeCode='" + classCode.Trim() + "'";
- DisabledCommissionSet(true);
- }
- else {
- DisabledCommissionSet(false);
- }
- List<LYFZ.Model.Model_ErpWageCommissionSet> wcsetModelList = new List<Model.Model_ErpWageCommissionSet>();
- DataRow[] groupRows = null;
- DataTable dt = null;
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- dt = wcsetbll.GetList(whereStr, " Wcs_TypeCode,Wcs_PerformanceBeginValue asc").Tables[0];
- groupRows = dt.Select("Wcs_PerformanceBeginValue=0", "Wcs_TypeCode asc");
- wcsetModelList = wcsetbll.DataTableToList(dt);
-
- if (SystemCategoryTb == null)
- {
- BindSystemCategoryTb();
- }
- });
- this.dgvCommissionRule.Rows.Clear();
- if (groupRows != null)
- {
- foreach (DataRow row in groupRows)
- {
- System.Drawing.Color bgcolor = System.Drawing.Color.White;
- AddWageCommissionSet(row["Wcs_TypeCode"].ToString(), wcsetModelList, bgcolor);
- }
- }
- this.dgvCommissionRule.ClearSelection();
- groupRows = null;
- dt.Rows.Clear();
- dt.Dispose();
- dt = null;
- }
- void AddWageCommissionSet(string typeCode, List<LYFZ.Model.Model_ErpWageCommissionSet> wcsetModelList, System.Drawing.Color bgcolor)
- {
-
- //System.Drawing.SystemColors.GradientInactiveCaption
- System.Drawing.Color titleColor = System.Drawing.SystemColors.GradientInactiveCaption;
- DataGridViewRow dgRow0 = new DataGridViewRow();
- dgRow0.Tag =new ItemValue(typeCode,"0");
- dgRow0.CreateCells(this.dgvCommissionRule);
- dgRow0.Cells[0].Style = GetDataGridViewCellStyle(titleColor, DataGridViewContentAlignment.MiddleLeft);
- dgRow0.Cells[1].Style = GetDataGridViewCellStyle(titleColor, DataGridViewContentAlignment.MiddleCenter);
- dgRow0.Cells[2].Style = dgRow0.Cells[1].Style;
- dgRow0.Cells[3].Style = dgRow0.Cells[0].Style;
- dgRow0.Cells[4].Style = GetDataGridViewCellStyle(titleColor);
- dgRow0.Cells[5].Style = dgRow0.Cells[1].Style;
- dgRow0.Cells[5].Value = "删除";
- this.dgvCommissionRule.EraseCell = true;
- int i = 0;
- DataGridViewRow dgRow = null;
- foreach (LYFZ.Model.Model_ErpWageCommissionSet model in wcsetModelList)
- {
- if (model.Wcs_TypeCode.Trim().ToLower() == typeCode.Trim().ToLower())
- {
- dgRow = new DataGridViewRow();
- dgRow.CreateCells(this.dgvCommissionRule);
- dgRow.Tag = model;
- if (i == 0)
- {
- dgRow0.Cells[0].Value = GetWageCommissionText(model.Wcs_TypeCode, model.ID);
- if (model.Wcs_PerformanceEndValue == 2099999999)
- {
- dgRow0.Cells[1].Value = this.cbxType.Items[1].ToString();
- }
- else
- {
- dgRow0.Cells[1].Value = this.cbxType.Items[2].ToString();
- }
- if (model.Wcs_PerformanceHight)
- {
- dgRow0.Cells[2].Value = "是";
- }
- else if (model.Wcs_PerformanceEndValue != 2099999999)
- {
- dgRow0.Cells[2].Value = "否";
- }
- else {
- dgRow0.Cells[2].Value = "--";
- }
- this.dgvCommissionRule.Rows.Add(dgRow0);
- }
- dgRow.Cells[0].Tag = this.dgvCommissionRule.EraseCellDrawLine;
- dgRow.Cells[1].Tag = dgRow.Cells[0].Tag;
- dgRow.Cells[2].Tag = this.dgvCommissionRule.EraseCellDrawLineVEnd;
- if (model.Wcs_PerformanceEndValue == 2099999999)
- {
-
- dgRow.Cells[3].Value = "按总业绩提成";
-
- }
- else
- {
- dgRow.Cells[3].Value = model.Wcs_PerformanceBeginValue.ToString() + " 至 " + model.Wcs_PerformanceEndValue.ToString();
- }
- dgRow.Cells[4].Value = model.Wcs_Percentage.ToString("n2").TrimEnd('0').Trim('.') + "%";
- dgRow.Cells[5].Value = "删除";
- dgRow.Cells[0].Style = GetDataGridViewCellStyle(bgcolor, DataGridViewContentAlignment.MiddleLeft);
- dgRow.Cells[1].Style = GetDataGridViewCellStyle(bgcolor, DataGridViewContentAlignment.MiddleCenter);
- dgRow.Cells[2].Style = dgRow.Cells[1].Style;
- dgRow.Cells[3].Style = dgRow.Cells[0].Style;
- dgRow.Cells[4].Style = GetDataGridViewCellStyle(bgcolor);
- dgRow.Cells[5].Style = dgRow.Cells[1].Style;
- this.dgvCommissionRule.Rows.Add(dgRow);
- i++;
- }
- }
- if (dgRow != null)
- {
- dgRow.Cells[0].Tag = this.dgvCommissionRule.EraseCellDrawLineHEnd;
- dgRow.Cells[1].Tag = dgRow.Cells[0].Tag;
- dgRow.Cells[2].Tag = this.dgvCommissionRule.EraseCellDrawLineVHEnd;
- }
- }
- System.Windows.Forms.DataGridViewCellStyle GetDataGridViewCellStyle(System.Drawing.Color bgcolor,System.Windows.Forms.DataGridViewContentAlignment alignment= DataGridViewContentAlignment.MiddleCenter)
- {
-
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
- dataGridViewCellStyle2.Alignment = alignment;
- dataGridViewCellStyle2.BackColor = bgcolor;//System.Drawing.Color.FromArgb(((int)(((byte)(43)))), ((int)(((byte)(108)))), ((int)(((byte)(150)))));
- dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 10.5f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- dataGridViewCellStyle2.ForeColor = System.Drawing.Color.Black;
- dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- return dataGridViewCellStyle2;
- }
- void bntfSet_Click(object sender, EventArgs e)
- {
- try
- {
- LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet set = new InitialSet.FrmSystemSet();
- LYFZ.BLL.BLL_ErpSystemCategory bll = new BLL.BLL_ErpSystemCategory();
- DataTable dt = bll.GetList("Sc_ClassCode='" + BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.提成点方案).ToUpper() + "'").Tables[0];
- if (dt.Rows.Count > 0)
- {
- set.TypeName = dt.Rows[0]["Sc_ClassCode"].ToString();
- }
- set.IsLoadAllCategory = false;
- if (set.ShowDialog() == DialogResult.OK)
- {
- bindCommissionPoint();
- BindSystemCategoryTb();
- BindCommissionRuleList("");
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
-
- void dgvPiecewiseList_CellClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
- {
- LYFZ.Model.Model_ErpWageCommissionSet model = (LYFZ.Model.Model_ErpWageCommissionSet)this.dgvPiecewiseList.Rows[e.RowIndex].Tag;
- this.cmbtreevSc_ClassName.TextFindTag(this.dgvPiecewiseList.Rows[e.RowIndex].Cells[0].Value.ToString());
- cmbtreevSc_ClassName_ComboBoxTree_NodeMouseClick(null,null);
- }
- }
- void buttonExit_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- void btnOk_Click(object sender, EventArgs e)
- {
- try
- {
- LYFZ.BLL.BLL_ErpWageCommissionSet bll = new BLL.BLL_ErpWageCommissionSet();
- LYFZ.Model.Model_ErpWageCommissionSet model = new Model.Model_ErpWageCommissionSet();
- if (string.IsNullOrEmpty(this.cmbtreevSc_ClassName.Text.Trim()))
- { MessageBoxCustom.Show("请选择工作内容!"); return; }
- if (string.IsNullOrEmpty(txtWcs_Percentage.Text))
- { MessageBoxCustom.Show("请输入数字!"); return; }
- DataTable dt = bll.GetList("Wcs_TypeCode='" + this.cmbtreevSc_ClassName.Tag.ToString().Trim() + "'").Tables[0];
- bool IsSaveed = false;
- if (dt.Rows.Count == 0)
- {
- // 增加
- model.Wcs_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
- model.Wcs_Type = "计件式提成";
- model.Wcs_TypeCode = this.cmbtreevSc_ClassName.Tag.ToString().Trim();
- model.Wcs_Percentage = Convert.ToDecimal(txtWcs_Percentage.Text);
- model.Wcs_PerformanceHight = true;
- model.Wcs_CreateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
- IsSaveed = bll.Add(model);
- }
- else
- {
- // 修改
- if (bll.UpdateWcs_Percentage(txtWcs_Percentage.Text, "Wcs_TypeCode='" + this.cmbtreevSc_ClassName.Tag.ToString().Trim() + "'") > 0)
- { IsSaveed = true; }
- }
- if (IsSaveed)
- {
- MessageBoxCustom.Show("保存成功!");
-
- BindWageCommissionSet();
-
- //txtWcs_Percentage.Text = "";
- //this.cmbtreevSc_ClassName.TagFindText("");
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 文本框设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- protected void txtWcs_Percentage_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- else if (Char.IsPunctuation(e.KeyChar))
- {
- if (e.KeyChar == '.')
- {
- if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
- { e.Handled = true; }
- }
- else if (e.KeyChar == '-') {
- if (((System.Windows.Forms.TextBox)sender).Text.Length!= 0)
- { e.Handled = true; }
- }
- else
- { e.Handled = true; }
- }
- }
- void btnSet_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet set = new InitialSet.FrmSystemSet();
- set.IsLoadAllCategory = false;
- set.TypeName = BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.计件提成工作内容).ToUpper();
- if (set.ShowDialog() == DialogResult.OK)
- {
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.计件提成工作内容).ToUpper(), this.cmbtreevSc_ClassName, IsFirstNodeNull: true);
- BindSystemCategoryTb();
- BindWageCommissionSet();
- this.cmbtreevSc_ClassName.TagFindText("");
- txtWcs_Percentage.Text = "";
- }
- }
- void cmbtreevSc_ClassName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- try
- {
- txtWcs_Percentage.Text = "";
- if (sender == null)
- {
- if (this.dgvPiecewiseList.SelectedRows != null && this.dgvPiecewiseList.SelectedRows.Count > 0)
- {
- DataGridViewRow row = this.dgvPiecewiseList.SelectedRows[0];
- txtWcs_Percentage.Text = row.Cells[1].Value.ToString();
- }
-
- }
- else {
- if (this.dgvPiecewiseList.Rows != null && this.dgvPiecewiseList.Rows.Count > 0 && e.Node.Tag != null && e.Node.Tag.ToString().Trim().Length>0)
- {
- this.dgvPiecewiseList.ClearSelection();
- foreach (DataGridViewRow row in this.dgvPiecewiseList.Rows)
- {
- if (row.Tag != null)
- {
- LYFZ.Model.Model_ErpWageCommissionSet model = (LYFZ.Model.Model_ErpWageCommissionSet)row.Tag;
- if (model.Wcs_TypeCode.Trim().ToLower() == e.Node.Tag.ToString().Trim().ToLower())
- {
- txtWcs_Percentage.Text = row.Cells[1].Value.ToString();
- row.Selected = true;
- break;
- }
- }
- }
- }
-
- }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- bool isShowFrmEarlySecondPin = false;
- bool isLoadPiecewise = false;
- void tabControlEx1_SelectedIndexChanged(object sender, EventArgs e)
- {
- switch (this.tabControlEx1.SelectedTab.Name.ToLower()) {
- case "tabpage4"://前期/二销设置
- if (!isShowFrmEarlySecondPin)
- {
- LYFZ.Software.MainBusiness.InitialSet.WageSet.FrmEarlySecondPin frmspin = new WageSet.FrmEarlySecondPin();
- frmspin.TopLevel = false;
- frmspin.IsShadow = false;
- frmspin.MaximizeBox = false;
- frmspin.MinimizeBox = false;
- frmspin.IsShowCloseBox = false;
- frmspin.TitleBgImageHeight = 0;
- frmspin.BottomBgImageHeight = 0;
- frmspin.IsMaximized = false;
- frmspin.FormMobile = false;
- frmspin.IsUserControlsSize = false;
- frmspin.IsLoginValidation = true;
- frmspin.Dock = System.Windows.Forms.DockStyle.Fill;
- frmspin.IsCustomScrollBar = false;
- this.tabPage4.Controls.Add(frmspin);
- frmspin.Show();
- isShowFrmEarlySecondPin = true;
- }
- break;
- case "tabpage3"://计件式提成设置
- if (!isLoadPiecewise)
- {
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.计件提成工作内容).ToUpper(), this.cmbtreevSc_ClassName, IsFirstNodeNull: true);
- BindWageCommissionSet();
- isLoadPiecewise = true;
- }
- break;
- case "tabpage2"://按点提成方式设置
- if (!isbindCommissionPoint)
- {
- bindCommissionPoint();
- BindCommissionRuleList("");
- isbindCommissionPoint = true;
- }
- break;
- }
- }
- /// <summary>
- /// 禁用启用方案提成规则设置
- /// </summary>
- /// <param name="isDisabled">为 true 启用 为 false 禁用</param>
- void DisabledCommissionSet(bool isDisabled)
- {
- if (isDisabled)
- {
- isDisabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RatingsProportionCompetence, CustomAttributes.OperatingAuthority.Add);
- }
- else {
- this.cbxType.SelectedIndex = 0;
- this.txtWcs_PerformanceBeginValue.Text = "0";
- this.txtWcs_PerformanceEndValue.Text = "0";
- this.txtCommissionPoint.Text = "0.00";
- }
- this.flowLayoutPanel1.Enabled = isDisabled;
- this.cbxType.Enabled = isDisabled;
-
- }
- bool isbindCommissionPoint = false;
- /// <summary>
- /// 绑定提成点
- /// </summary>
- public void bindCommissionPoint()
- {
- DataTable dt = new DataTable();
- this.cmbSc_ClassName.ReadOnly = true;
- #region 绑定提成点
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.提成点方案).ToUpper(), this.cmbSc_ClassName, IsFirstNodeNull: true);
- DisabledCommissionSet(false);
- #endregion
- }
- LYFZ.BLL.BLL_ErpWageCommissionSet wcsetbll = new BLL.BLL_ErpWageCommissionSet();
- LYFZ.BLL.BLL_ErpSystemCategory sysCategoryBll = new BLL.BLL_ErpSystemCategory();
- DataTable SystemCategoryTb = null;
- void BindSystemCategoryTb()
- {
- if (SystemCategoryTb != null)
- {
- SystemCategoryTb.Rows.Clear();
- SystemCategoryTb = null;
- }
- LYFZ.Software.MainBusiness.FinancialManagement.frmEditStatisticsProgram.LoadAllSystemCategory();
- SystemCategoryTb = LYFZ.Software.MainBusiness.FinancialManagement.frmEditStatisticsProgram.AllSystemCategory;//sysCategoryBll.GetCategory("ID,Sc_ClassCode,Sc_ClassName,Sc_ClassParentID", "sc_classparentid>=0").Tables[0];
- }
- /// <summary>
- /// 绑定计件提成方案
- /// </summary>
- void BindWageCommissionSet()
- {
- List<LYFZ.Model.Model_ErpWageCommissionSet> wcsetModelList = new List<Model.Model_ErpWageCommissionSet>();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- wcsetModelList= wcsetbll.GetModelList("Wcs_Type='计件式提成'");
- if (SystemCategoryTb == null)
- {
- BindSystemCategoryTb();
- }
- });
- this.dgvPiecewiseList.Rows.Clear();
- foreach (LYFZ.Model.Model_ErpWageCommissionSet model in wcsetModelList)
- {
- DataGridViewRow dgRow = new DataGridViewRow();
- dgRow.CreateCells(this.dgvPiecewiseList);
- dgRow.Tag = model;
- dgRow.Cells[0].Value = GetWageCommissionText(model.Wcs_TypeCode,model.ID);
- dgRow.Cells[1].Value = model.Wcs_Percentage.ToString("n2");
- dgRow.Cells[2].Value = "删除";
- dgRow.Cells[3].Value = "";
- this.dgvPiecewiseList.Rows.Add(dgRow);
- }
- this.dgvPiecewiseList.ClearSelection();
- }
- string GetWageCommissionText(string classCode,int id)
- {
-
- string ret = "";
- if (SystemCategoryTb != null)
- {
- foreach (DataRow row in SystemCategoryTb.Rows)
- {
- if (row["Sc_ClassCode"].ToString().ToLower() == classCode.ToLower())
- {
- ret = row["Sc_ClassName"].ToString().Trim();
- break;
- }
- }
- }
- if (ret.Trim().Length <= 0)
- {
- ret = "--未知--";
- try
- {
- wcsetbll.Delete(id);
- }
- catch { }
- }
- return ret;
- }
-
- /// <summary>
- /// 按权限设置
- /// </summary>
- void RatingsProportionCompetence()
- {
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RatingsProportionCompetence, CustomAttributes.OperatingAuthority.Add))
- {
- this.btnSave.Enabled = true;
- this.btnOk.Enabled = true;
-
- this.btnAdd.Enabled = true;
- this.btnDeltee.Enabled = true;
- this.cbxType.Enabled = true;
-
- this.flowLayoutPanel1.Enabled = true;
- this.cbxType.Enabled = true;
- }
- else
- {
- this.btnSave.Enabled = false;
- this.btnOk.Enabled = false;
-
- this.btnAdd.Enabled = false;
- this.btnDeltee.Enabled = false;
- this.cbxType.Enabled = false;
-
- this.flowLayoutPanel1.Enabled = false;
- this.cbxType.Enabled = false;
- }
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RatingsProportionCompetence, CustomAttributes.OperatingAuthority.Setting))
- {
- this.btnSet.Enabled = true;
- this.bntfSet.Enabled = true;
- }
- else {
- this.btnSet.Enabled = false;
- this.bntfSet.Enabled = false;
- }
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void FrmRatingsProportion_Load(object sender, EventArgs e)
- {
- // this.tabControlEx1.TabPages.Remove(this.tabPage4);
- RatingsProportionCompetence();
-
-
- // this.btnSave.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RatingsProportionCompetence, CustomAttributes.OperatingAuthority.Add);
-
- }
- string StrLevelText1 = "";
- string StrLevelText2 = "";
- string StrLevelText3 = "";
- static DataTable _AttractionsRating = null;
- /// <summary>
- /// 景点等级
- /// </summary>
- static DataTable AttractionsRating
- {
- get
- {
- if (_AttractionsRating == null)
- {
- _AttractionsRating = new BLL.BLL_ErpSystemCategory().GetList("sc_classcode in('" + BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.一级景点).ToUpper() + "','" + BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.二级景点).ToUpper() + "','" + BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.三级景点).ToUpper() + "')").Tables[0];
- }
- return FrmRatingsProportion._AttractionsRating;
- }
- }
- LYFZ.Model.Model_ErpSystemCategory GetSystemCategory(string code)
- {
- foreach (DataRow row in AttractionsRating.Rows)
- {
- if (row["Sc_ClassCode"].ToString().Trim().ToLower() == code.ToLower().Trim())
- {
- return scbll.DataRowToModel(row);
- }
- }
- return null;
- }
-
- LYFZ.Model.Model_ErpSystemCategory aRLeve1 = null;
- LYFZ.Model.Model_ErpSystemCategory aRLeve2 = null;
- LYFZ.Model.Model_ErpSystemCategory aRLeve3 = null;
- List<LYFZ.Model.Model_ErpCommissionPercentage> CommissionPercentageList = null;
- LYFZ.Model.Model_ErpCommissionPercentage GetCommissionPercentage(string code)
- {
- foreach (LYFZ.Model.Model_ErpCommissionPercentage model in CommissionPercentageList)
- {
- if (model.Cp_ProportionCode.Trim().ToLower() == code.ToLower().Trim())
- {
- return model;
- }
- }
- LYFZ.Model.Model_ErpCommissionPercentage retModel = new Model.Model_ErpCommissionPercentage();
- retModel.Cp_ProportionCode = code;
- retModel.Cp_Proportion = 0;
- retModel.Cp_Enabled = 1;
- return retModel;
- }
- void SetCommissionPercentage(string code, ComponentLibrary.TextBoxBasicEx tBox, string proportionName, ComponentLibrary.CheckBoxEx chkBox)
- {
-
- foreach (LYFZ.Model.Model_ErpCommissionPercentage model in CommissionPercentageList)
- {
- if (model.Cp_ProportionCode.Trim().ToLower() == code.ToLower().Trim())
- {
- tBox.Text = model.Cp_Proportion.ToString();
- tBox.Tag = model;
- model.Cp_ProportionName = proportionName;
- chkBox.Checked = model.Cp_Enabled == 1 ? true : false;
- break;
- }
- }
- if (tBox.Tag == null)
- {
- tBox.Text = "50";
- LYFZ.Model.Model_ErpCommissionPercentage retModel = new Model.Model_ErpCommissionPercentage();
- retModel.Cp_ProportionCode = code;
- retModel.Cp_Proportion = 0;
- retModel.Cp_ProportionName = proportionName;
- tBox.Tag = retModel;
- }
- }
- /// <summary>
- /// 分业绩比例设置
- /// </summary>
- public void bindCommissionPercentage()
- {
- string StrSuffix = "比重(%):";
-
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- if (AttractionsRating.Rows.Count > 0)
- {
- if (aRLeve1 == null)
- aRLeve1 = GetSystemCategory(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.一级景点).ToUpper());
- if (aRLeve2 == null)
- aRLeve2 = GetSystemCategory(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.二级景点).ToUpper());
- if (aRLeve3 == null)
- aRLeve3 = GetSystemCategory(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.三级景点).ToUpper());
- }
- if (CommissionPercentageList == null)
- {
- CommissionPercentageList = cpbll.GetModelList("1=1");
- }
- });
-
- this.StrLevelText1 = aRLeve1.Sc_ClassName;
- this.StrLevelText2 = aRLeve2.Sc_ClassName;
- this.StrLevelText3 = aRLeve3.Sc_ClassName;
- this.lblOneLevel.Text = "* " + this.StrLevelText1 + StrSuffix;
- this.lblTwoLevel.Text = "* " + this.StrLevelText2 + StrSuffix;
- this.lblThreeLevel.Text = "* " + this.StrLevelText3 + StrSuffix;
- SetCommissionPercentage(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.一级景点).ToUpper(), this.txtOneLevel, "一级", this.chkLevel);
- SetCommissionPercentage(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.二级景点).ToUpper(), this.txtTwoLevel, "二级", this.chkLevel);
- SetCommissionPercentage(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.三级景点).ToUpper(), this.txtThreeLevel, "三级", this.chkLevel);
- //门市
- SetCommissionPercentage("MainStoreProportion", this.txtCp_MainStoreProportion, "主门市", this.chk_StoreProportion);
- SetCommissionPercentage("DeputyStoreProportion", this.txtCp_DeputyStoreProportion, "副门市", this.chk_StoreProportion);
- //摄影
- SetCommissionPercentage("MainPhotography", this.txtMainPhotography, "主摄影师", this.chk_Photography);
- SetCommissionPercentage("DeputyPhotography", this.txtDeputyPhotography, "摄影助理", this.chk_Photography);
- //化妆
- SetCommissionPercentage("MainMake", this.txtMainMake, "主化妆师", this.chk_Make);
- SetCommissionPercentage("DeputyMake", this.txtDeputyMake, "化妆助理", this.chk_Make);
- //引导
- SetCommissionPercentage("MainBootDivision", this.txtMainBootDivision, "主引导师", this.chk_BootDivision);
- SetCommissionPercentage("DeputyBootDivision", this.txtDeputyBootDivision, "导引助理", this.chk_BootDivision);
- //LaterOtherTwoSales 后期其它二销
- SetCommissionPercentage("MainLaterOtherTwoSales", this.txtQiTaierxiaoMain, "主接单人", this.chk_Taierxiao);
- SetCommissionPercentage("DeputyLaterOtherTwoSales", this.txtQiTaierxiaoSub, "副接单人", this.chk_Taierxiao);
- //会员充值主副接单人业绩分配
- SetCommissionPercentage("MainMemberToSingle", this.txtMainMemberToSingle, "主接单人", this.chk_MemberToSingle);
- SetCommissionPercentage("SubMemberToSingle", this.txtSubMemberToSingle, "副接单人", this.chk_MemberToSingle);
- DeleteInvalidData("MainLaterOtherTwoSales");
- DeleteInvalidData("DeputyLaterOtherTwoSales");
- DeleteInvalidData("MainBootDivision");
- DeleteInvalidData("DeputyBootDivision");
- DeleteInvalidData("MainMake");
- DeleteInvalidData("DeputyMake");
- DeleteInvalidData("MainPhotography");
- DeleteInvalidData("DeputyPhotography");
- DeleteInvalidData("MainStoreProportion");
- DeleteInvalidData("DeputyStoreProportion");
- DeleteInvalidData("MainMemberToSingle");
- DeleteInvalidData("SubMemberToSingle");
- }
- void DeleteInvalidData(string pcode)
- {
- if (cpbll.GetRecordCount("Cp_ProportionCode='" + pcode + "'") > 1)
- {
- cpbll.Delete("Cp_ProportionCode='" + pcode + "'");
- }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click(object sender, EventArgs e)
- { this.Close(); }
- /// <summary>
- /// 更新比例设置
- /// </summary>
- /// <param name="type"></param>
- /// <param name="tBox"></param>
- /// <returns></returns>
- bool UpdatetCommissionPercentage(int type, ComponentLibrary.TextBoxBasicEx tBox, ComponentLibrary.CheckBoxEx chkBox)
- {
- bool ret = false;
- if (tBox.Tag != null)
- {
- LYFZ.Model.Model_ErpCommissionPercentage cModel = (LYFZ.Model.Model_ErpCommissionPercentage)tBox.Tag;
- cModel.Cp_ProportionType = type;
- if (string.IsNullOrEmpty(tBox.Text.Trim()))
- {
- MessageBoxCustom.Show(cModel.Cp_ProportionName.Trim()+"比重不能为空!");
- return false;
- }
- try
- {
- cModel.Cp_Proportion = Convert.ToInt32(tBox.Text.Trim());
- cModel.Cp_Enabled = chkBox.Checked ? 1 : 0;
- }
- catch (Exception ex){
- MessageBoxCustom.Show(cModel.Cp_ProportionName.Trim() + "比重的值只能输入0-100的整数:"+ex.Message);
- return false;
- }
- if (cModel.Cp_Proportion < 0 || cModel.Cp_Proportion > 100)
- {
- MessageBoxCustom.Show(cModel.Cp_ProportionName.Trim() + "比重的值只能填在0到100之间");
- return false;
- }
- cModel.Cp_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID();
- cModel.Cp_UpdateTime = SDateTime.Now;
- if (cModel.ID > 0 && cpbll.Exists("Cp_ProportionCode", cModel.Cp_ProportionCode))
- {
- ret= cpbll.Update(cModel);
- }
- else {
- cModel.Cp_CreateTime = SDateTime.Now;
- if (!cpbll.Exists("Cp_ProportionCode", cModel.Cp_ProportionCode))
- {
- ret = cpbll.Add(cModel);
- }
- else {
- ret = true;
- }
- }
-
- }
- return ret;
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- // UpdatetCommissionPercentage(int type, ComponentLibrary.TextBoxBasicEx tBox);
- if (!UpdatetCommissionPercentage(0, this.txtOneLevel, this.chkLevel)) return;
- if (!UpdatetCommissionPercentage(0, this.txtTwoLevel, this.chkLevel)) return;
- if (!UpdatetCommissionPercentage(0, this.txtThreeLevel, this.chkLevel)) return;
- //门市
- if (!UpdatetCommissionPercentage(1, this.txtCp_MainStoreProportion, this.chk_StoreProportion)) return;
- if (!UpdatetCommissionPercentage(1, this.txtCp_DeputyStoreProportion, this.chk_StoreProportion)) return;
- //摄影
- if (!UpdatetCommissionPercentage(2, this.txtMainPhotography, this.chk_Photography)) return;
- if (!UpdatetCommissionPercentage(2, this.txtDeputyPhotography, this.chk_Photography)) return;
- //化妆
- if (!UpdatetCommissionPercentage(3, this.txtMainMake, this.chk_Make)) return;
- if (!UpdatetCommissionPercentage(3, this.txtDeputyMake, this.chk_Make)) return;
- //引导
- if (!UpdatetCommissionPercentage(4, this.txtMainBootDivision, this.chk_BootDivision)) return;
- if (!UpdatetCommissionPercentage(4, this.txtDeputyBootDivision, this.chk_BootDivision)) return;
- //其它二销
- if (!UpdatetCommissionPercentage(5, this.txtQiTaierxiaoMain, this.chk_Taierxiao)) return;
- if (!UpdatetCommissionPercentage(5, this.txtQiTaierxiaoSub, this.chk_Taierxiao)) return;
- //会员充值主副接单人业绩分配
- if (!UpdatetCommissionPercentage(6, this.txtMainMemberToSingle, this.chk_MemberToSingle)) return;
- if (!UpdatetCommissionPercentage(6, this.txtSubMemberToSingle, this.chk_MemberToSingle)) return;
- bindCommissionPercentage();
- MessageBoxCustom.Show("保存成功");
- }
- catch (Exception ex)
- { MessageBoxCustom.Show("保存比重设置失败:"+ex.Message); }
- }
- /// <summary>
- /// 文本框设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtCp_DeputyStoreProportion_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
- { e.Handled = true; }
- }
- }
- }
|