FrmRatingsProportion.cs 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.Software.MainBusiness.InitialSet
  10. {
  11. public partial class FrmRatingsProportion : LYFZ.Software.UI.InitialSet.FrmRatingsProportion
  12. {
  13. LYFZ.BLL.BLL_ErpCommissionPercentage cpbll = new BLL.BLL_ErpCommissionPercentage();
  14. LYFZ.BLL.BLL_ErpSystemCategory scbll = new BLL.BLL_ErpSystemCategory();
  15. public FrmRatingsProportion()
  16. {
  17. this.Load+=FrmRatingsProportion_Load;
  18. this.Shown += FrmRatingsProportion_Shown;
  19. this.btnClose.Click+=btnClose_Click;
  20. this.btnSave.Click+=btnSave_Click;
  21. this.txtCp_DeputyStoreProportion.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
  22. this.txtCp_MainStoreProportion.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
  23. this.txtThreeLevel.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
  24. this.txtTwoLevel.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
  25. this.txtOneLevel.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
  26. this.txtDeputyMake.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
  27. this.txtMainMake.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
  28. this.txtDeputyPhotography.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
  29. this.txtMainPhotography.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
  30. this.txtMainBootDivision.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
  31. this.txtDeputyBootDivision.KeyPress += txtCp_DeputyStoreProportion_KeyPress;
  32. this.tabControlEx1.SelectedIndexChanged += tabControlEx1_SelectedIndexChanged;
  33. this.cmbtreevSc_ClassName.ComboBoxTree_NodeMouseClick += cmbtreevSc_ClassName_ComboBoxTree_NodeMouseClick;
  34. this.btnSet.Click += btnSet_Click;
  35. this.btnOk.Click += btnOk_Click;
  36. this.buttonExit.Click += buttonExit_Click;
  37. this.dgvPiecewiseList.CellClick += dgvPiecewiseList_CellClick;
  38. this.txtWcs_Percentage.KeyPress+=txtWcs_Percentage_KeyPress;
  39. this.txtWcs_PerformanceBeginValue.KeyPress += txtWcs_Percentage_KeyPress;
  40. this.txtWcs_PerformanceEndValue.KeyPress += txtWcs_Percentage_KeyPress;
  41. this.txtCommissionPoint.KeyPress += txtWcs_Percentage_KeyPress;
  42. this.txtValue.KeyPress += txtWcs_Percentage_KeyPress;
  43. this.txtWcs_PerformanceBeginValue.TextChanged += txtCommissionPoint_TextChanged;
  44. this.txtWcs_PerformanceEndValue.TextChanged += txtCommissionPoint_TextChanged;
  45. //this.txtCommissionPoint.TextChanged += txtCommissionPoint_TextChanged;
  46. this.txtValue.TextChanged += txtCommissionPoint_TextChanged;
  47. this.cmbSc_ClassName.ComboBoxTree_NodeMouseClick += cmbSc_ClassName_ComboBoxTree_NodeMouseClick;
  48. this.bntfSet.Click += bntfSet_Click;
  49. this.btnAdd.Click += btnAdd_Click;
  50. this.btnDeltee.Click += btnDeltee_Click;
  51. this.dgvCommissionRule.CellDoubleClick += dgvCommissionRule_CellDoubleClick;
  52. this.cbxType.SelectedIndexChanged += cbxType_SelectedIndexChanged;
  53. this.btnResults.Click += btnResults_Click;
  54. this.dgvCommissionRule.CellContentClick += dgvCommissionRule_CellContentClick;
  55. this.dgvPiecewiseList.CellContentClick += dgvPiecewiseList_CellContentClick;
  56. }
  57. void FrmRatingsProportion_Shown(object sender, EventArgs e)
  58. {
  59. this.bindCommissionPercentage();
  60. }
  61. /// <summary>
  62. /// 删除计件提成
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="e"></param>
  66. void dgvPiecewiseList_CellContentClick(object sender, DataGridViewCellEventArgs e)
  67. {
  68. if (e.ColumnIndex == 2 && e.RowIndex >= 0)
  69. {
  70. if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RatingsProportionCompetence, CustomAttributes.OperatingAuthority.Delete))
  71. {
  72. DataGridViewRow dgRow = this.dgvPiecewiseList.Rows[e.RowIndex];
  73. if (dgRow.Tag != null)
  74. {
  75. if (MessageBoxCustom.Show("正在准备删除“" + dgRow.Cells[0].Value.ToString() + "”的提成金额设置\r\n您确定要删除码?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
  76. {
  77. LYFZ.Model.Model_ErpWageCommissionSet model = (LYFZ.Model.Model_ErpWageCommissionSet)dgRow.Tag;
  78. if (wcsetbll.Delete(model.ID))
  79. {
  80. model = null;
  81. this.dgvPiecewiseList.Rows.Remove(dgRow);
  82. }
  83. else
  84. {
  85. MessageBoxCustom.Show("删除失败,请重试");
  86. }
  87. }
  88. else {
  89. return;
  90. }
  91. }
  92. else {
  93. MessageBoxCustom.Show("删除失败,数据对象获取失败");
  94. }
  95. }
  96. else
  97. {
  98. MessageBoxCustom.Show("对不起,你没有权限计件提成设置。");
  99. }
  100. }
  101. }
  102. /// <summary>
  103. /// 删除方案规则
  104. /// </summary>
  105. /// <param name="sender"></param>
  106. /// <param name="e"></param>
  107. void dgvCommissionRule_CellContentClick(object sender, DataGridViewCellEventArgs e)
  108. {
  109. if (e.ColumnIndex == 5 && e.RowIndex >= 0)
  110. {
  111. if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RatingsProportionCompetence, CustomAttributes.OperatingAuthority.Delete))
  112. {
  113. btnDeltee_Click(null, null);
  114. }
  115. else
  116. {
  117. MessageBoxCustom.Show("对不起,你没有权限删除方案规则。");
  118. }
  119. }
  120. }
  121. /// <summary>
  122. /// 测试计算
  123. /// </summary>
  124. /// <param name="sender"></param>
  125. /// <param name="e"></param>
  126. void btnResults_Click(object sender, EventArgs e)
  127. {
  128. this.txtResults.Text = "0";
  129. if (this.cmbSc_ClassName.TreeView.SelectedNode != null && this.cmbSc_ClassName.TreeView.SelectedNode.Tag != null && this.cmbSc_ClassName.TreeView.SelectedNode.Tag.ToString().Length>0)
  130. {
  131. string typeCode = this.cmbSc_ClassName.TreeView.SelectedNode.Tag.ToString().Trim();
  132. int resultValue = Convert.ToInt32(this.txtValue.Text.Trim());
  133. decimal sumResultValue = 0;
  134. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  135. {
  136. LYFZ.BLL.BLL_ErpWageCommissionSet.UpdateCommissionSet();
  137. sumResultValue = LYFZ.BLL.BLL_ErpWageCommissionSet.SumComputeResults(typeCode, resultValue);
  138. });
  139. this.txtResults.Text = sumResultValue.ToString("n2");
  140. }
  141. else
  142. {
  143. MessageBoxCustom.Show("请选择要测试计算的方案");
  144. }
  145. }
  146. void cbxType_SelectedIndexChanged(object sender, EventArgs e)
  147. {
  148. if (this.cbxType.SelectedIndex == 1)
  149. {
  150. this.txtWcs_PerformanceBeginValue.Text = "0";
  151. this.txtWcs_PerformanceEndValue.Text = "0";
  152. this.txtWcs_PerformanceBeginValue.ReadOnly = true;
  153. this.txtWcs_PerformanceEndValue.ReadOnly = true;
  154. }
  155. else {
  156. this.txtWcs_PerformanceBeginValue.ReadOnly = false;
  157. this.txtWcs_PerformanceEndValue.ReadOnly = false;
  158. if (this.dgvCommissionRule.Rows.Count <= 0)
  159. {
  160. this.txtWcs_PerformanceBeginValue.Text = "0";
  161. }
  162. }
  163. }
  164. /// <summary>
  165. /// 更新“业绩超出部分”的提成方式
  166. /// </summary>
  167. /// <param name="sender"></param>
  168. /// <param name="e"></param>
  169. void dgvCommissionRule_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  170. {
  171. if (e.RowIndex >= 0 && e.ColumnIndex == 2)
  172. {
  173. DataGridViewRow Row = this.dgvCommissionRule.Rows[e.RowIndex];
  174. if (Row == null || Row.Cells[e.ColumnIndex].Value ==null|| Row.Cells[e.ColumnIndex].Value.ToString().Trim() == "--")
  175. {
  176. return;
  177. }
  178. if (Row.Tag != null && Row.Tag.GetType() == typeof(ItemValue))
  179. {
  180. ItemValue item = (ItemValue)Row.Tag;
  181. int Wcs_PerformanceHight = 0;
  182. if (Row.Cells[e.ColumnIndex].Value.ToString() == "是")
  183. {
  184. Wcs_PerformanceHight = 0;
  185. }
  186. else
  187. {
  188. Wcs_PerformanceHight = 1;
  189. }
  190. bool updateOk = false;
  191. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  192. {
  193. if (wcsetbll.UpdateWageCommissionSet(Wcs_PerformanceHight, "Wcs_TypeCode='" + item.Value.ToString().Trim() + "'") > 0)
  194. {
  195. updateOk = true;
  196. }
  197. });
  198. if (updateOk)
  199. {
  200. if (Wcs_PerformanceHight == 1)
  201. {
  202. Row.Cells[e.ColumnIndex].Value = "是";
  203. }
  204. else
  205. {
  206. Row.Cells[e.ColumnIndex].Value = "否";
  207. }
  208. }
  209. }
  210. }
  211. }
  212. /// <summary>
  213. /// 删除提成点规则
  214. /// </summary>
  215. /// <param name="sender"></param>
  216. /// <param name="e"></param>
  217. void btnDeltee_Click(object sender, EventArgs e)
  218. {
  219. //DataGridViewRow Row
  220. if (this.dgvCommissionRule.SelectedRows != null && this.dgvCommissionRule.SelectedRows.Count > 0)
  221. {
  222. try
  223. {
  224. DataGridViewRow Row = this.dgvCommissionRule.SelectedRows[0];
  225. bool deleteOk = false;
  226. if (Row.Tag != null && Row.Tag.GetType() == typeof(ItemValue))
  227. {
  228. if (MessageBoxCustom.Show("正在准备删除“" + Row.Cells[0].Value.ToString() + "”方案的所有规则\r\n您确定要删除码?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
  229. {
  230. ItemValue item = (ItemValue)Row.Tag;
  231. string classCode = item.Value.ToString();
  232. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  233. {
  234. if (wcsetbll.Delete(" Wcs_TypeCode='" + classCode.Trim() + "'"))
  235. {
  236. deleteOk = true;
  237. }
  238. });
  239. }
  240. else {
  241. return;
  242. }
  243. }
  244. else if (Row.Tag != null && Row.Tag.GetType() == typeof(LYFZ.Model.Model_ErpWageCommissionSet))
  245. {
  246. int tempDelRowIndex = Row.Index;
  247. LYFZ.Model.Model_ErpWageCommissionSet cDelModel = (LYFZ.Model.Model_ErpWageCommissionSet)Row.Tag;
  248. StringBuilder tempDelIDList = new StringBuilder();
  249. tempDelIDList.Append(cDelModel.ID.ToString() + ",");
  250. LYFZ.Model.Model_ErpWageCommissionSet tempDelModel = null;
  251. foreach (DataGridViewRow tRow in this.dgvCommissionRule.Rows)
  252. {
  253. if (tRow.Tag != null && tRow.Tag.GetType() == typeof(LYFZ.Model.Model_ErpWageCommissionSet))
  254. {
  255. tempDelModel = (LYFZ.Model.Model_ErpWageCommissionSet)tRow.Tag;
  256. if (tRow.Index > tempDelRowIndex && tempDelModel.Wcs_TypeCode.Trim().ToLower() == cDelModel.Wcs_TypeCode.Trim().ToLower())
  257. {
  258. tempDelIDList.Append(tempDelModel.ID.ToString() + ",");
  259. }
  260. tempDelModel = null;
  261. }
  262. }
  263. if (tempDelIDList.ToString().Trim(',').Split(',').Length > 1)
  264. {
  265. if (MessageBoxCustom.Show("正在准备删除“" + GetWageCommissionText(cDelModel.Wcs_TypeCode, cDelModel.ID) + "”方案的“" + Row.Cells[3].Value.ToString() + "”规则,和其后价梯所有规则。\r\n您确定要删除码?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
  266. {
  267. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  268. {
  269. deleteOk = wcsetbll.DeleteList(tempDelIDList.ToString().Trim(','));
  270. });
  271. }
  272. else {
  273. return;
  274. }
  275. }
  276. else
  277. {
  278. if (MessageBoxCustom.Show("正在准备删除“" + GetWageCommissionText(cDelModel.Wcs_TypeCode, cDelModel.ID) + "”方案的“" + Row.Cells[3].Value.ToString() + "”规则。\r\n您确定要删除码?", msgBoxButton: MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
  279. {
  280. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  281. {
  282. deleteOk = wcsetbll.Delete(cDelModel.ID);
  283. });
  284. }
  285. else {
  286. return;
  287. }
  288. }
  289. }
  290. if (deleteOk)
  291. {
  292. if (this.cmbSc_ClassName.TreeView.SelectedNode != null && this.cmbSc_ClassName.TreeView.SelectedNode.Tag != null)
  293. {
  294. BindCommissionRuleList(this.cmbSc_ClassName.TreeView.SelectedNode.Tag.ToString());
  295. }
  296. else {
  297. BindCommissionRuleList("");
  298. }
  299. if (this.dgvCommissionRule.Rows.Count <= 0)
  300. {
  301. this.cbxType.Enabled = this.flowLayoutPanel1.Enabled;
  302. }
  303. }
  304. else
  305. {
  306. MessageBoxCustom.Show("删除方案规则失败,请重试!");
  307. }
  308. }
  309. catch (Exception ex)
  310. {
  311. MessageBoxCustom.Show("删除方案规则时出错:" + ex.Message);
  312. }
  313. }
  314. else
  315. {
  316. MessageBoxCustom.Show("请选择你要删除的方案规则");
  317. }
  318. }
  319. /// <summary>
  320. /// 添加提成点规则
  321. /// </summary>
  322. /// <param name="sender"></param>
  323. /// <param name="e"></param>
  324. void btnAdd_Click(object sender, EventArgs e)
  325. {
  326. try
  327. {
  328. if (this.cmbSc_ClassName.TreeView.SelectedNode == null)
  329. {
  330. MessageBoxCustom.Show("请选择方案");
  331. return;
  332. }
  333. if (this.cmbSc_ClassName.TreeView.SelectedNode.Tag == null || this.cmbSc_ClassName.TreeView.SelectedNode.Tag.ToString().Length <= 0)
  334. {
  335. MessageBoxCustom.Show("选择方案不正确,请重新选择");
  336. return;
  337. }
  338. if (this.txtWcs_PerformanceBeginValue.Text.Trim().Length <= 0)
  339. {
  340. MessageBoxCustom.Show("请输入阶梯业绩的 开始值");
  341. return;
  342. }
  343. if (this.txtWcs_PerformanceEndValue.Text.Trim().Length <= 0)
  344. {
  345. MessageBoxCustom.Show("请输入阶梯业绩的 终止值");
  346. return;
  347. }
  348. if (this.txtCommissionPoint.Text.Trim().Length <= 0)
  349. {
  350. MessageBoxCustom.Show("请输入阶梯业绩的 提成点数");
  351. return;
  352. }
  353. LYFZ.Model.Model_ErpWageCommissionSet addModel = new Model.Model_ErpWageCommissionSet();
  354. addModel.Wcs_Type = "提成点";
  355. addModel.Wcs_DividedShop = LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID;
  356. addModel.Wcs_PerformanceBeginValue = Convert.ToInt32(this.txtWcs_PerformanceBeginValue.Text.Trim());
  357. addModel.Wcs_Percentage = Convert.ToDecimal(this.txtCommissionPoint.Text.Trim());
  358. addModel.Wcs_CreateTime = SDateTime.Now;
  359. addModel.Wcs_TypeCode = this.cmbSc_ClassName.TreeView.SelectedNode.Tag.ToString();
  360. if (this.cbxType.SelectedIndex == 1)
  361. {
  362. addModel.Wcs_PerformanceEndValue = 2099999999;
  363. }
  364. else
  365. {
  366. addModel.Wcs_PerformanceEndValue = Convert.ToInt32(this.txtWcs_PerformanceEndValue.Text.Trim());
  367. }
  368. if (addModel.Wcs_Percentage < 0)
  369. {
  370. MessageBoxCustom.Show("业绩的提成点数不能小于零 “0”");
  371. return;
  372. }
  373. if (addModel.Wcs_PerformanceEndValue <= addModel.Wcs_PerformanceBeginValue)
  374. {
  375. MessageBoxCustom.Show("阶梯业绩的 开始值 必须大于 终止值");
  376. return;
  377. }
  378. if (this.cbxType.SelectedIndex != 1 && addModel.Wcs_PerformanceEndValue >= 2099999999)
  379. {
  380. MessageBoxCustom.Show("阶梯业绩的 终止值 不能大于等于 “2099999999”");
  381. return;
  382. }
  383. if (!CheckResults(addModel.Wcs_TypeCode, addModel.Wcs_PerformanceBeginValue))
  384. {
  385. if (this.cbxType.SelectedIndex == 1)
  386. {
  387. MessageBoxCustom.Show("要添加的提成规则已经存在,不能添加。");
  388. }
  389. else
  390. {
  391. MessageBoxCustom.Show("阶梯业绩的 开始值 已经在现有规则范围内,不能添加。");
  392. }
  393. return;
  394. }
  395. if (!CheckResults(addModel.Wcs_TypeCode, addModel.Wcs_PerformanceEndValue))
  396. {
  397. if (this.cbxType.SelectedIndex == 1)
  398. {
  399. MessageBoxCustom.Show("要添加的提成规则已经存在,不能添加。");
  400. }
  401. else
  402. {
  403. MessageBoxCustom.Show("阶梯业绩的 终止值 已经在现有规则范围内,不能添加。");
  404. }
  405. return;
  406. }
  407. if (this.dgvCommissionRule.Rows.Count <= 0 && addModel.Wcs_PerformanceBeginValue > 0)
  408. {
  409. MessageBoxCustom.Show("第一阶梯业绩的 开始值 必须为零 “0”");
  410. return;
  411. }
  412. addModel.Wcs_PerformanceHight = false;
  413. if (this.cbxType.SelectedIndex == 2)
  414. {
  415. addModel.Wcs_PerformanceHight = Convert.ToBoolean(selectItemValue.Value);
  416. }
  417. bool addOk = false;
  418. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  419. {
  420. addOk = wcsetbll.Add(addModel);
  421. });
  422. if (addOk)
  423. {
  424. BindCommissionRuleList(addModel.Wcs_TypeCode);
  425. this.cbxType.Enabled = false;
  426. }
  427. else
  428. {
  429. MessageBoxCustom.Show("添加方案规则失败,请重试!");
  430. }
  431. }
  432. catch (Exception ex){
  433. MessageBoxCustom.Show("添加方案规则时出错:"+ex.Message);
  434. }
  435. }
  436. /// <summary>
  437. /// 检查指定业绩值在指定方案中是否有效
  438. /// </summary>
  439. /// <param name="classCode">方案代码</param>
  440. /// <param name="resultsValue">指定业绩值</param>
  441. /// <param name="isEnd">是否为终止值</param>
  442. /// <returns></returns>
  443. bool CheckResults(string classCode, int resultsValue)
  444. {
  445. bool bl = true;
  446. LYFZ.Model.Model_ErpWageCommissionSet cModel = null;
  447. foreach (DataGridViewRow tRow in this.dgvCommissionRule.Rows)
  448. {
  449. if (tRow.Tag != null && tRow.Tag.GetType() == typeof(LYFZ.Model.Model_ErpWageCommissionSet))
  450. {
  451. cModel = (LYFZ.Model.Model_ErpWageCommissionSet)tRow.Tag;
  452. if (cModel.Wcs_TypeCode.Trim().ToLower() == classCode.Trim().ToLower())
  453. {
  454. if (resultsValue <= cModel.Wcs_PerformanceEndValue)
  455. {
  456. bl = false;
  457. break;
  458. }
  459. }
  460. }
  461. cModel = null;
  462. }
  463. return bl;
  464. }
  465. void txtCommissionPoint_TextChanged(object sender, EventArgs e)
  466. {
  467. ComponentLibrary.TextBoxBasicEx txtBox = (ComponentLibrary.TextBoxBasicEx)sender;
  468. if (txtBox.Text.Trim().Trim('-').Length > 0)
  469. {
  470. int tempInt = 0;
  471. if (!int.TryParse(txtBox.Text.Trim().Trim('.'), out tempInt))
  472. {
  473. txtBox.Text = "0";
  474. }
  475. }
  476. }
  477. ItemValue selectItemValue = null;
  478. /// <summary>
  479. /// 提成方案选择项事件
  480. /// </summary>
  481. /// <param name="sender"></param>
  482. /// <param name="e"></param>
  483. void cmbSc_ClassName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  484. {
  485. if (e.Node.Tag != null)
  486. {
  487. BindCommissionRuleList(e.Node.Tag.ToString().Trim());
  488. selectItemValue = GetCbxTypeIndex(e.Node.Tag.ToString().Trim());
  489. this.cbxType.SelectedIndex = Convert.ToInt32(selectItemValue.Text);
  490. if (this.cbxType.SelectedIndex > 0)
  491. {
  492. this.cbxType.Enabled = false;
  493. }
  494. else {
  495. this.cbxType.Enabled = this.flowLayoutPanel1.Enabled;
  496. }
  497. }
  498. }
  499. ItemValue GetCbxTypeIndex(string classCode)
  500. {
  501. int cbxTypeIndex = 0;
  502. bool PerformanceHight = true;
  503. foreach (DataGridViewRow Row in this.dgvCommissionRule.Rows)
  504. {
  505. if (Row.Tag != null && Row.Tag.GetType() == typeof(ItemValue))
  506. {
  507. ItemValue item=(ItemValue)Row.Tag;
  508. if (item.Value.ToString().ToLower().Trim() == classCode.Trim().ToLower())
  509. {
  510. if (Row.Cells[2].Value.ToString() == "是")
  511. {
  512. PerformanceHight = true;
  513. }
  514. else {
  515. PerformanceHight = false;
  516. }
  517. if (Row.Cells[1].Value.ToString() == this.cbxType.Items[1].ToString())
  518. {
  519. cbxTypeIndex = 1;
  520. }
  521. else if (Row.Cells[1].Value.ToString() == this.cbxType.Items[2].ToString())
  522. {
  523. cbxTypeIndex = 2;
  524. }
  525. break;
  526. }
  527. }
  528. }
  529. return new ItemValue(PerformanceHight, cbxTypeIndex.ToString());
  530. }
  531. void BindCommissionRuleList(string classCode)
  532. {
  533. string whereStr = "wcs_type='提成点'";
  534. if (!string.IsNullOrEmpty(classCode.Trim()))
  535. {
  536. whereStr = whereStr + " and Wcs_TypeCode='" + classCode.Trim() + "'";
  537. DisabledCommissionSet(true);
  538. }
  539. else {
  540. DisabledCommissionSet(false);
  541. }
  542. List<LYFZ.Model.Model_ErpWageCommissionSet> wcsetModelList = new List<Model.Model_ErpWageCommissionSet>();
  543. DataRow[] groupRows = null;
  544. DataTable dt = null;
  545. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  546. {
  547. dt = wcsetbll.GetList(whereStr, " Wcs_TypeCode,Wcs_PerformanceBeginValue asc").Tables[0];
  548. groupRows = dt.Select("Wcs_PerformanceBeginValue=0", "Wcs_TypeCode asc");
  549. wcsetModelList = wcsetbll.DataTableToList(dt);
  550. if (SystemCategoryTb == null)
  551. {
  552. BindSystemCategoryTb();
  553. }
  554. });
  555. this.dgvCommissionRule.Rows.Clear();
  556. if (groupRows != null)
  557. {
  558. foreach (DataRow row in groupRows)
  559. {
  560. System.Drawing.Color bgcolor = System.Drawing.Color.White;
  561. AddWageCommissionSet(row["Wcs_TypeCode"].ToString(), wcsetModelList, bgcolor);
  562. }
  563. }
  564. this.dgvCommissionRule.ClearSelection();
  565. groupRows = null;
  566. dt.Rows.Clear();
  567. dt.Dispose();
  568. dt = null;
  569. }
  570. void AddWageCommissionSet(string typeCode, List<LYFZ.Model.Model_ErpWageCommissionSet> wcsetModelList, System.Drawing.Color bgcolor)
  571. {
  572. //System.Drawing.SystemColors.GradientInactiveCaption
  573. System.Drawing.Color titleColor = System.Drawing.SystemColors.GradientInactiveCaption;
  574. DataGridViewRow dgRow0 = new DataGridViewRow();
  575. dgRow0.Tag =new ItemValue(typeCode,"0");
  576. dgRow0.CreateCells(this.dgvCommissionRule);
  577. dgRow0.Cells[0].Style = GetDataGridViewCellStyle(titleColor, DataGridViewContentAlignment.MiddleLeft);
  578. dgRow0.Cells[1].Style = GetDataGridViewCellStyle(titleColor, DataGridViewContentAlignment.MiddleCenter);
  579. dgRow0.Cells[2].Style = dgRow0.Cells[1].Style;
  580. dgRow0.Cells[3].Style = dgRow0.Cells[0].Style;
  581. dgRow0.Cells[4].Style = GetDataGridViewCellStyle(titleColor);
  582. dgRow0.Cells[5].Style = dgRow0.Cells[1].Style;
  583. dgRow0.Cells[5].Value = "删除";
  584. this.dgvCommissionRule.EraseCell = true;
  585. int i = 0;
  586. DataGridViewRow dgRow = null;
  587. foreach (LYFZ.Model.Model_ErpWageCommissionSet model in wcsetModelList)
  588. {
  589. if (model.Wcs_TypeCode.Trim().ToLower() == typeCode.Trim().ToLower())
  590. {
  591. dgRow = new DataGridViewRow();
  592. dgRow.CreateCells(this.dgvCommissionRule);
  593. dgRow.Tag = model;
  594. if (i == 0)
  595. {
  596. dgRow0.Cells[0].Value = GetWageCommissionText(model.Wcs_TypeCode, model.ID);
  597. if (model.Wcs_PerformanceEndValue == 2099999999)
  598. {
  599. dgRow0.Cells[1].Value = this.cbxType.Items[1].ToString();
  600. }
  601. else
  602. {
  603. dgRow0.Cells[1].Value = this.cbxType.Items[2].ToString();
  604. }
  605. if (model.Wcs_PerformanceHight)
  606. {
  607. dgRow0.Cells[2].Value = "是";
  608. }
  609. else if (model.Wcs_PerformanceEndValue != 2099999999)
  610. {
  611. dgRow0.Cells[2].Value = "否";
  612. }
  613. else {
  614. dgRow0.Cells[2].Value = "--";
  615. }
  616. this.dgvCommissionRule.Rows.Add(dgRow0);
  617. }
  618. dgRow.Cells[0].Tag = this.dgvCommissionRule.EraseCellDrawLine;
  619. dgRow.Cells[1].Tag = dgRow.Cells[0].Tag;
  620. dgRow.Cells[2].Tag = this.dgvCommissionRule.EraseCellDrawLineVEnd;
  621. if (model.Wcs_PerformanceEndValue == 2099999999)
  622. {
  623. dgRow.Cells[3].Value = "按总业绩提成";
  624. }
  625. else
  626. {
  627. dgRow.Cells[3].Value = model.Wcs_PerformanceBeginValue.ToString() + " 至 " + model.Wcs_PerformanceEndValue.ToString();
  628. }
  629. dgRow.Cells[4].Value = model.Wcs_Percentage.ToString("n2").TrimEnd('0').Trim('.') + "%";
  630. dgRow.Cells[5].Value = "删除";
  631. dgRow.Cells[0].Style = GetDataGridViewCellStyle(bgcolor, DataGridViewContentAlignment.MiddleLeft);
  632. dgRow.Cells[1].Style = GetDataGridViewCellStyle(bgcolor, DataGridViewContentAlignment.MiddleCenter);
  633. dgRow.Cells[2].Style = dgRow.Cells[1].Style;
  634. dgRow.Cells[3].Style = dgRow.Cells[0].Style;
  635. dgRow.Cells[4].Style = GetDataGridViewCellStyle(bgcolor);
  636. dgRow.Cells[5].Style = dgRow.Cells[1].Style;
  637. this.dgvCommissionRule.Rows.Add(dgRow);
  638. i++;
  639. }
  640. }
  641. if (dgRow != null)
  642. {
  643. dgRow.Cells[0].Tag = this.dgvCommissionRule.EraseCellDrawLineHEnd;
  644. dgRow.Cells[1].Tag = dgRow.Cells[0].Tag;
  645. dgRow.Cells[2].Tag = this.dgvCommissionRule.EraseCellDrawLineVHEnd;
  646. }
  647. }
  648. System.Windows.Forms.DataGridViewCellStyle GetDataGridViewCellStyle(System.Drawing.Color bgcolor,System.Windows.Forms.DataGridViewContentAlignment alignment= DataGridViewContentAlignment.MiddleCenter)
  649. {
  650. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
  651. dataGridViewCellStyle2.Alignment = alignment;
  652. dataGridViewCellStyle2.BackColor = bgcolor;//System.Drawing.Color.FromArgb(((int)(((byte)(43)))), ((int)(((byte)(108)))), ((int)(((byte)(150)))));
  653. dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 10.5f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  654. dataGridViewCellStyle2.ForeColor = System.Drawing.Color.Black;
  655. dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  656. dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  657. return dataGridViewCellStyle2;
  658. }
  659. void bntfSet_Click(object sender, EventArgs e)
  660. {
  661. try
  662. {
  663. LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet set = new InitialSet.FrmSystemSet();
  664. LYFZ.BLL.BLL_ErpSystemCategory bll = new BLL.BLL_ErpSystemCategory();
  665. DataTable dt = bll.GetList("Sc_ClassCode='" + BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.提成点方案).ToUpper() + "'").Tables[0];
  666. if (dt.Rows.Count > 0)
  667. {
  668. set.TypeName = dt.Rows[0]["Sc_ClassCode"].ToString();
  669. }
  670. set.IsLoadAllCategory = false;
  671. if (set.ShowDialog() == DialogResult.OK)
  672. {
  673. bindCommissionPoint();
  674. BindSystemCategoryTb();
  675. BindCommissionRuleList("");
  676. }
  677. }
  678. catch (Exception ex)
  679. {
  680. MessageBoxCustom.Show(ex.Message);
  681. }
  682. }
  683. void dgvPiecewiseList_CellClick(object sender, DataGridViewCellEventArgs e)
  684. {
  685. if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
  686. {
  687. LYFZ.Model.Model_ErpWageCommissionSet model = (LYFZ.Model.Model_ErpWageCommissionSet)this.dgvPiecewiseList.Rows[e.RowIndex].Tag;
  688. this.cmbtreevSc_ClassName.TextFindTag(this.dgvPiecewiseList.Rows[e.RowIndex].Cells[0].Value.ToString());
  689. cmbtreevSc_ClassName_ComboBoxTree_NodeMouseClick(null,null);
  690. }
  691. }
  692. void buttonExit_Click(object sender, EventArgs e)
  693. {
  694. this.Close();
  695. }
  696. void btnOk_Click(object sender, EventArgs e)
  697. {
  698. try
  699. {
  700. LYFZ.BLL.BLL_ErpWageCommissionSet bll = new BLL.BLL_ErpWageCommissionSet();
  701. LYFZ.Model.Model_ErpWageCommissionSet model = new Model.Model_ErpWageCommissionSet();
  702. if (string.IsNullOrEmpty(this.cmbtreevSc_ClassName.Text.Trim()))
  703. { MessageBoxCustom.Show("请选择工作内容!"); return; }
  704. if (string.IsNullOrEmpty(txtWcs_Percentage.Text))
  705. { MessageBoxCustom.Show("请输入数字!"); return; }
  706. DataTable dt = bll.GetList("Wcs_TypeCode='" + this.cmbtreevSc_ClassName.Tag.ToString().Trim() + "'").Tables[0];
  707. bool IsSaveed = false;
  708. if (dt.Rows.Count == 0)
  709. {
  710. // 增加
  711. model.Wcs_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  712. model.Wcs_Type = "计件式提成";
  713. model.Wcs_TypeCode = this.cmbtreevSc_ClassName.Tag.ToString().Trim();
  714. model.Wcs_Percentage = Convert.ToDecimal(txtWcs_Percentage.Text);
  715. model.Wcs_PerformanceHight = true;
  716. model.Wcs_CreateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  717. IsSaveed = bll.Add(model);
  718. }
  719. else
  720. {
  721. // 修改
  722. if (bll.UpdateWcs_Percentage(txtWcs_Percentage.Text, "Wcs_TypeCode='" + this.cmbtreevSc_ClassName.Tag.ToString().Trim() + "'") > 0)
  723. { IsSaveed = true; }
  724. }
  725. if (IsSaveed)
  726. {
  727. MessageBoxCustom.Show("保存成功!");
  728. BindWageCommissionSet();
  729. //txtWcs_Percentage.Text = "";
  730. //this.cmbtreevSc_ClassName.TagFindText("");
  731. }
  732. }
  733. catch (Exception ex)
  734. { MessageBoxCustom.Show(ex.Message); }
  735. }
  736. /// <summary>
  737. /// 文本框设置
  738. /// </summary>
  739. /// <param name="sender"></param>
  740. /// <param name="e"></param>
  741. protected void txtWcs_Percentage_KeyPress(object sender, KeyPressEventArgs e)
  742. {
  743. if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
  744. { e.Handled = true; }
  745. else if (Char.IsPunctuation(e.KeyChar))
  746. {
  747. if (e.KeyChar == '.')
  748. {
  749. if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
  750. { e.Handled = true; }
  751. }
  752. else if (e.KeyChar == '-') {
  753. if (((System.Windows.Forms.TextBox)sender).Text.Length!= 0)
  754. { e.Handled = true; }
  755. }
  756. else
  757. { e.Handled = true; }
  758. }
  759. }
  760. void btnSet_Click(object sender, EventArgs e)
  761. {
  762. LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet set = new InitialSet.FrmSystemSet();
  763. set.IsLoadAllCategory = false;
  764. set.TypeName = BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.计件提成工作内容).ToUpper();
  765. if (set.ShowDialog() == DialogResult.OK)
  766. {
  767. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.计件提成工作内容).ToUpper(), this.cmbtreevSc_ClassName, IsFirstNodeNull: true);
  768. BindSystemCategoryTb();
  769. BindWageCommissionSet();
  770. this.cmbtreevSc_ClassName.TagFindText("");
  771. txtWcs_Percentage.Text = "";
  772. }
  773. }
  774. void cmbtreevSc_ClassName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  775. {
  776. try
  777. {
  778. txtWcs_Percentage.Text = "";
  779. if (sender == null)
  780. {
  781. if (this.dgvPiecewiseList.SelectedRows != null && this.dgvPiecewiseList.SelectedRows.Count > 0)
  782. {
  783. DataGridViewRow row = this.dgvPiecewiseList.SelectedRows[0];
  784. txtWcs_Percentage.Text = row.Cells[1].Value.ToString();
  785. }
  786. }
  787. else {
  788. if (this.dgvPiecewiseList.Rows != null && this.dgvPiecewiseList.Rows.Count > 0 && e.Node.Tag != null && e.Node.Tag.ToString().Trim().Length>0)
  789. {
  790. this.dgvPiecewiseList.ClearSelection();
  791. foreach (DataGridViewRow row in this.dgvPiecewiseList.Rows)
  792. {
  793. if (row.Tag != null)
  794. {
  795. LYFZ.Model.Model_ErpWageCommissionSet model = (LYFZ.Model.Model_ErpWageCommissionSet)row.Tag;
  796. if (model.Wcs_TypeCode.Trim().ToLower() == e.Node.Tag.ToString().Trim().ToLower())
  797. {
  798. txtWcs_Percentage.Text = row.Cells[1].Value.ToString();
  799. row.Selected = true;
  800. break;
  801. }
  802. }
  803. }
  804. }
  805. }
  806. }
  807. catch (Exception ex)
  808. { MessageBoxCustom.Show(ex.Message); }
  809. }
  810. bool isShowFrmEarlySecondPin = false;
  811. bool isLoadPiecewise = false;
  812. void tabControlEx1_SelectedIndexChanged(object sender, EventArgs e)
  813. {
  814. switch (this.tabControlEx1.SelectedTab.Name.ToLower()) {
  815. case "tabpage4"://前期/二销设置
  816. if (!isShowFrmEarlySecondPin)
  817. {
  818. LYFZ.Software.MainBusiness.InitialSet.WageSet.FrmEarlySecondPin frmspin = new WageSet.FrmEarlySecondPin();
  819. frmspin.TopLevel = false;
  820. frmspin.IsShadow = false;
  821. frmspin.MaximizeBox = false;
  822. frmspin.MinimizeBox = false;
  823. frmspin.IsShowCloseBox = false;
  824. frmspin.TitleBgImageHeight = 0;
  825. frmspin.BottomBgImageHeight = 0;
  826. frmspin.IsMaximized = false;
  827. frmspin.FormMobile = false;
  828. frmspin.IsUserControlsSize = false;
  829. frmspin.IsLoginValidation = true;
  830. frmspin.Dock = System.Windows.Forms.DockStyle.Fill;
  831. frmspin.IsCustomScrollBar = false;
  832. this.tabPage4.Controls.Add(frmspin);
  833. frmspin.Show();
  834. isShowFrmEarlySecondPin = true;
  835. }
  836. break;
  837. case "tabpage3"://计件式提成设置
  838. if (!isLoadPiecewise)
  839. {
  840. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.计件提成工作内容).ToUpper(), this.cmbtreevSc_ClassName, IsFirstNodeNull: true);
  841. BindWageCommissionSet();
  842. isLoadPiecewise = true;
  843. }
  844. break;
  845. case "tabpage2"://按点提成方式设置
  846. if (!isbindCommissionPoint)
  847. {
  848. bindCommissionPoint();
  849. BindCommissionRuleList("");
  850. isbindCommissionPoint = true;
  851. }
  852. break;
  853. }
  854. }
  855. /// <summary>
  856. /// 禁用启用方案提成规则设置
  857. /// </summary>
  858. /// <param name="isDisabled">为 true 启用 为 false 禁用</param>
  859. void DisabledCommissionSet(bool isDisabled)
  860. {
  861. if (isDisabled)
  862. {
  863. isDisabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RatingsProportionCompetence, CustomAttributes.OperatingAuthority.Add);
  864. }
  865. else {
  866. this.cbxType.SelectedIndex = 0;
  867. this.txtWcs_PerformanceBeginValue.Text = "0";
  868. this.txtWcs_PerformanceEndValue.Text = "0";
  869. this.txtCommissionPoint.Text = "0.00";
  870. }
  871. this.flowLayoutPanel1.Enabled = isDisabled;
  872. this.cbxType.Enabled = isDisabled;
  873. }
  874. bool isbindCommissionPoint = false;
  875. /// <summary>
  876. /// 绑定提成点
  877. /// </summary>
  878. public void bindCommissionPoint()
  879. {
  880. DataTable dt = new DataTable();
  881. this.cmbSc_ClassName.ReadOnly = true;
  882. #region 绑定提成点
  883. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.提成点方案).ToUpper(), this.cmbSc_ClassName, IsFirstNodeNull: true);
  884. DisabledCommissionSet(false);
  885. #endregion
  886. }
  887. LYFZ.BLL.BLL_ErpWageCommissionSet wcsetbll = new BLL.BLL_ErpWageCommissionSet();
  888. LYFZ.BLL.BLL_ErpSystemCategory sysCategoryBll = new BLL.BLL_ErpSystemCategory();
  889. DataTable SystemCategoryTb = null;
  890. void BindSystemCategoryTb()
  891. {
  892. if (SystemCategoryTb != null)
  893. {
  894. SystemCategoryTb.Rows.Clear();
  895. SystemCategoryTb = null;
  896. }
  897. LYFZ.Software.MainBusiness.FinancialManagement.frmEditStatisticsProgram.LoadAllSystemCategory();
  898. SystemCategoryTb = LYFZ.Software.MainBusiness.FinancialManagement.frmEditStatisticsProgram.AllSystemCategory;//sysCategoryBll.GetCategory("ID,Sc_ClassCode,Sc_ClassName,Sc_ClassParentID", "sc_classparentid>=0").Tables[0];
  899. }
  900. /// <summary>
  901. /// 绑定计件提成方案
  902. /// </summary>
  903. void BindWageCommissionSet()
  904. {
  905. List<LYFZ.Model.Model_ErpWageCommissionSet> wcsetModelList = new List<Model.Model_ErpWageCommissionSet>();
  906. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  907. {
  908. wcsetModelList= wcsetbll.GetModelList("Wcs_Type='计件式提成'");
  909. if (SystemCategoryTb == null)
  910. {
  911. BindSystemCategoryTb();
  912. }
  913. });
  914. this.dgvPiecewiseList.Rows.Clear();
  915. foreach (LYFZ.Model.Model_ErpWageCommissionSet model in wcsetModelList)
  916. {
  917. DataGridViewRow dgRow = new DataGridViewRow();
  918. dgRow.CreateCells(this.dgvPiecewiseList);
  919. dgRow.Tag = model;
  920. dgRow.Cells[0].Value = GetWageCommissionText(model.Wcs_TypeCode,model.ID);
  921. dgRow.Cells[1].Value = model.Wcs_Percentage.ToString("n2");
  922. dgRow.Cells[2].Value = "删除";
  923. dgRow.Cells[3].Value = "";
  924. this.dgvPiecewiseList.Rows.Add(dgRow);
  925. }
  926. this.dgvPiecewiseList.ClearSelection();
  927. }
  928. string GetWageCommissionText(string classCode,int id)
  929. {
  930. string ret = "";
  931. if (SystemCategoryTb != null)
  932. {
  933. foreach (DataRow row in SystemCategoryTb.Rows)
  934. {
  935. if (row["Sc_ClassCode"].ToString().ToLower() == classCode.ToLower())
  936. {
  937. ret = row["Sc_ClassName"].ToString().Trim();
  938. break;
  939. }
  940. }
  941. }
  942. if (ret.Trim().Length <= 0)
  943. {
  944. ret = "--未知--";
  945. try
  946. {
  947. wcsetbll.Delete(id);
  948. }
  949. catch { }
  950. }
  951. return ret;
  952. }
  953. /// <summary>
  954. /// 按权限设置
  955. /// </summary>
  956. void RatingsProportionCompetence()
  957. {
  958. if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RatingsProportionCompetence, CustomAttributes.OperatingAuthority.Add))
  959. {
  960. this.btnSave.Enabled = true;
  961. this.btnOk.Enabled = true;
  962. this.btnAdd.Enabled = true;
  963. this.btnDeltee.Enabled = true;
  964. this.cbxType.Enabled = true;
  965. this.flowLayoutPanel1.Enabled = true;
  966. this.cbxType.Enabled = true;
  967. }
  968. else
  969. {
  970. this.btnSave.Enabled = false;
  971. this.btnOk.Enabled = false;
  972. this.btnAdd.Enabled = false;
  973. this.btnDeltee.Enabled = false;
  974. this.cbxType.Enabled = false;
  975. this.flowLayoutPanel1.Enabled = false;
  976. this.cbxType.Enabled = false;
  977. }
  978. if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RatingsProportionCompetence, CustomAttributes.OperatingAuthority.Setting))
  979. {
  980. this.btnSet.Enabled = true;
  981. this.bntfSet.Enabled = true;
  982. }
  983. else {
  984. this.btnSet.Enabled = false;
  985. this.bntfSet.Enabled = false;
  986. }
  987. }
  988. /// <summary>
  989. /// 窗体加载事件
  990. /// </summary>
  991. /// <param name="sender"></param>
  992. /// <param name="e"></param>
  993. void FrmRatingsProportion_Load(object sender, EventArgs e)
  994. {
  995. // this.tabControlEx1.TabPages.Remove(this.tabPage4);
  996. RatingsProportionCompetence();
  997. // this.btnSave.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RatingsProportionCompetence, CustomAttributes.OperatingAuthority.Add);
  998. }
  999. string StrLevelText1 = "";
  1000. string StrLevelText2 = "";
  1001. string StrLevelText3 = "";
  1002. static DataTable _AttractionsRating = null;
  1003. /// <summary>
  1004. /// 景点等级
  1005. /// </summary>
  1006. static DataTable AttractionsRating
  1007. {
  1008. get
  1009. {
  1010. if (_AttractionsRating == null)
  1011. {
  1012. _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];
  1013. }
  1014. return FrmRatingsProportion._AttractionsRating;
  1015. }
  1016. }
  1017. LYFZ.Model.Model_ErpSystemCategory GetSystemCategory(string code)
  1018. {
  1019. foreach (DataRow row in AttractionsRating.Rows)
  1020. {
  1021. if (row["Sc_ClassCode"].ToString().Trim().ToLower() == code.ToLower().Trim())
  1022. {
  1023. return scbll.DataRowToModel(row);
  1024. }
  1025. }
  1026. return null;
  1027. }
  1028. LYFZ.Model.Model_ErpSystemCategory aRLeve1 = null;
  1029. LYFZ.Model.Model_ErpSystemCategory aRLeve2 = null;
  1030. LYFZ.Model.Model_ErpSystemCategory aRLeve3 = null;
  1031. List<LYFZ.Model.Model_ErpCommissionPercentage> CommissionPercentageList = null;
  1032. LYFZ.Model.Model_ErpCommissionPercentage GetCommissionPercentage(string code)
  1033. {
  1034. foreach (LYFZ.Model.Model_ErpCommissionPercentage model in CommissionPercentageList)
  1035. {
  1036. if (model.Cp_ProportionCode.Trim().ToLower() == code.ToLower().Trim())
  1037. {
  1038. return model;
  1039. }
  1040. }
  1041. LYFZ.Model.Model_ErpCommissionPercentage retModel = new Model.Model_ErpCommissionPercentage();
  1042. retModel.Cp_ProportionCode = code;
  1043. retModel.Cp_Proportion = 0;
  1044. retModel.Cp_Enabled = 1;
  1045. return retModel;
  1046. }
  1047. void SetCommissionPercentage(string code, ComponentLibrary.TextBoxBasicEx tBox, string proportionName, ComponentLibrary.CheckBoxEx chkBox)
  1048. {
  1049. foreach (LYFZ.Model.Model_ErpCommissionPercentage model in CommissionPercentageList)
  1050. {
  1051. if (model.Cp_ProportionCode.Trim().ToLower() == code.ToLower().Trim())
  1052. {
  1053. tBox.Text = model.Cp_Proportion.ToString();
  1054. tBox.Tag = model;
  1055. model.Cp_ProportionName = proportionName;
  1056. chkBox.Checked = model.Cp_Enabled == 1 ? true : false;
  1057. break;
  1058. }
  1059. }
  1060. if (tBox.Tag == null)
  1061. {
  1062. tBox.Text = "50";
  1063. LYFZ.Model.Model_ErpCommissionPercentage retModel = new Model.Model_ErpCommissionPercentage();
  1064. retModel.Cp_ProportionCode = code;
  1065. retModel.Cp_Proportion = 0;
  1066. retModel.Cp_ProportionName = proportionName;
  1067. tBox.Tag = retModel;
  1068. }
  1069. }
  1070. /// <summary>
  1071. /// 分业绩比例设置
  1072. /// </summary>
  1073. public void bindCommissionPercentage()
  1074. {
  1075. string StrSuffix = "比重(%):";
  1076. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  1077. {
  1078. if (AttractionsRating.Rows.Count > 0)
  1079. {
  1080. if (aRLeve1 == null)
  1081. aRLeve1 = GetSystemCategory(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.一级景点).ToUpper());
  1082. if (aRLeve2 == null)
  1083. aRLeve2 = GetSystemCategory(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.二级景点).ToUpper());
  1084. if (aRLeve3 == null)
  1085. aRLeve3 = GetSystemCategory(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.三级景点).ToUpper());
  1086. }
  1087. if (CommissionPercentageList == null)
  1088. {
  1089. CommissionPercentageList = cpbll.GetModelList("1=1");
  1090. }
  1091. });
  1092. this.StrLevelText1 = aRLeve1.Sc_ClassName;
  1093. this.StrLevelText2 = aRLeve2.Sc_ClassName;
  1094. this.StrLevelText3 = aRLeve3.Sc_ClassName;
  1095. this.lblOneLevel.Text = "* " + this.StrLevelText1 + StrSuffix;
  1096. this.lblTwoLevel.Text = "* " + this.StrLevelText2 + StrSuffix;
  1097. this.lblThreeLevel.Text = "* " + this.StrLevelText3 + StrSuffix;
  1098. SetCommissionPercentage(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.一级景点).ToUpper(), this.txtOneLevel, "一级", this.chkLevel);
  1099. SetCommissionPercentage(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.二级景点).ToUpper(), this.txtTwoLevel, "二级", this.chkLevel);
  1100. SetCommissionPercentage(BLL.BLL_ErpSystemCategory.GetSysTemCategoryCode(BLL.SysTemCategoryCodeType.三级景点).ToUpper(), this.txtThreeLevel, "三级", this.chkLevel);
  1101. //门市
  1102. SetCommissionPercentage("MainStoreProportion", this.txtCp_MainStoreProportion, "主门市", this.chk_StoreProportion);
  1103. SetCommissionPercentage("DeputyStoreProportion", this.txtCp_DeputyStoreProportion, "副门市", this.chk_StoreProportion);
  1104. //摄影
  1105. SetCommissionPercentage("MainPhotography", this.txtMainPhotography, "主摄影师", this.chk_Photography);
  1106. SetCommissionPercentage("DeputyPhotography", this.txtDeputyPhotography, "摄影助理", this.chk_Photography);
  1107. //化妆
  1108. SetCommissionPercentage("MainMake", this.txtMainMake, "主化妆师", this.chk_Make);
  1109. SetCommissionPercentage("DeputyMake", this.txtDeputyMake, "化妆助理", this.chk_Make);
  1110. //引导
  1111. SetCommissionPercentage("MainBootDivision", this.txtMainBootDivision, "主引导师", this.chk_BootDivision);
  1112. SetCommissionPercentage("DeputyBootDivision", this.txtDeputyBootDivision, "导引助理", this.chk_BootDivision);
  1113. //LaterOtherTwoSales 后期其它二销
  1114. SetCommissionPercentage("MainLaterOtherTwoSales", this.txtQiTaierxiaoMain, "主接单人", this.chk_Taierxiao);
  1115. SetCommissionPercentage("DeputyLaterOtherTwoSales", this.txtQiTaierxiaoSub, "副接单人", this.chk_Taierxiao);
  1116. //会员充值主副接单人业绩分配
  1117. SetCommissionPercentage("MainMemberToSingle", this.txtMainMemberToSingle, "主接单人", this.chk_MemberToSingle);
  1118. SetCommissionPercentage("SubMemberToSingle", this.txtSubMemberToSingle, "副接单人", this.chk_MemberToSingle);
  1119. DeleteInvalidData("MainLaterOtherTwoSales");
  1120. DeleteInvalidData("DeputyLaterOtherTwoSales");
  1121. DeleteInvalidData("MainBootDivision");
  1122. DeleteInvalidData("DeputyBootDivision");
  1123. DeleteInvalidData("MainMake");
  1124. DeleteInvalidData("DeputyMake");
  1125. DeleteInvalidData("MainPhotography");
  1126. DeleteInvalidData("DeputyPhotography");
  1127. DeleteInvalidData("MainStoreProportion");
  1128. DeleteInvalidData("DeputyStoreProportion");
  1129. DeleteInvalidData("MainMemberToSingle");
  1130. DeleteInvalidData("SubMemberToSingle");
  1131. }
  1132. void DeleteInvalidData(string pcode)
  1133. {
  1134. if (cpbll.GetRecordCount("Cp_ProportionCode='" + pcode + "'") > 1)
  1135. {
  1136. cpbll.Delete("Cp_ProportionCode='" + pcode + "'");
  1137. }
  1138. }
  1139. /// <summary>
  1140. /// 关闭
  1141. /// </summary>
  1142. /// <param name="sender"></param>
  1143. /// <param name="e"></param>
  1144. void btnClose_Click(object sender, EventArgs e)
  1145. { this.Close(); }
  1146. /// <summary>
  1147. /// 更新比例设置
  1148. /// </summary>
  1149. /// <param name="type"></param>
  1150. /// <param name="tBox"></param>
  1151. /// <returns></returns>
  1152. bool UpdatetCommissionPercentage(int type, ComponentLibrary.TextBoxBasicEx tBox, ComponentLibrary.CheckBoxEx chkBox)
  1153. {
  1154. bool ret = false;
  1155. if (tBox.Tag != null)
  1156. {
  1157. LYFZ.Model.Model_ErpCommissionPercentage cModel = (LYFZ.Model.Model_ErpCommissionPercentage)tBox.Tag;
  1158. cModel.Cp_ProportionType = type;
  1159. if (string.IsNullOrEmpty(tBox.Text.Trim()))
  1160. {
  1161. MessageBoxCustom.Show(cModel.Cp_ProportionName.Trim()+"比重不能为空!");
  1162. return false;
  1163. }
  1164. try
  1165. {
  1166. cModel.Cp_Proportion = Convert.ToInt32(tBox.Text.Trim());
  1167. cModel.Cp_Enabled = chkBox.Checked ? 1 : 0;
  1168. }
  1169. catch (Exception ex){
  1170. MessageBoxCustom.Show(cModel.Cp_ProportionName.Trim() + "比重的值只能输入0-100的整数:"+ex.Message);
  1171. return false;
  1172. }
  1173. if (cModel.Cp_Proportion < 0 || cModel.Cp_Proportion > 100)
  1174. {
  1175. MessageBoxCustom.Show(cModel.Cp_ProportionName.Trim() + "比重的值只能填在0到100之间");
  1176. return false;
  1177. }
  1178. cModel.Cp_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID();
  1179. cModel.Cp_UpdateTime = SDateTime.Now;
  1180. if (cModel.ID > 0 && cpbll.Exists("Cp_ProportionCode", cModel.Cp_ProportionCode))
  1181. {
  1182. ret= cpbll.Update(cModel);
  1183. }
  1184. else {
  1185. cModel.Cp_CreateTime = SDateTime.Now;
  1186. if (!cpbll.Exists("Cp_ProportionCode", cModel.Cp_ProportionCode))
  1187. {
  1188. ret = cpbll.Add(cModel);
  1189. }
  1190. else {
  1191. ret = true;
  1192. }
  1193. }
  1194. }
  1195. return ret;
  1196. }
  1197. /// <summary>
  1198. /// 保存
  1199. /// </summary>
  1200. /// <param name="sender"></param>
  1201. /// <param name="e"></param>
  1202. void btnSave_Click(object sender, EventArgs e)
  1203. {
  1204. try
  1205. {
  1206. // UpdatetCommissionPercentage(int type, ComponentLibrary.TextBoxBasicEx tBox);
  1207. if (!UpdatetCommissionPercentage(0, this.txtOneLevel, this.chkLevel)) return;
  1208. if (!UpdatetCommissionPercentage(0, this.txtTwoLevel, this.chkLevel)) return;
  1209. if (!UpdatetCommissionPercentage(0, this.txtThreeLevel, this.chkLevel)) return;
  1210. //门市
  1211. if (!UpdatetCommissionPercentage(1, this.txtCp_MainStoreProportion, this.chk_StoreProportion)) return;
  1212. if (!UpdatetCommissionPercentage(1, this.txtCp_DeputyStoreProportion, this.chk_StoreProportion)) return;
  1213. //摄影
  1214. if (!UpdatetCommissionPercentage(2, this.txtMainPhotography, this.chk_Photography)) return;
  1215. if (!UpdatetCommissionPercentage(2, this.txtDeputyPhotography, this.chk_Photography)) return;
  1216. //化妆
  1217. if (!UpdatetCommissionPercentage(3, this.txtMainMake, this.chk_Make)) return;
  1218. if (!UpdatetCommissionPercentage(3, this.txtDeputyMake, this.chk_Make)) return;
  1219. //引导
  1220. if (!UpdatetCommissionPercentage(4, this.txtMainBootDivision, this.chk_BootDivision)) return;
  1221. if (!UpdatetCommissionPercentage(4, this.txtDeputyBootDivision, this.chk_BootDivision)) return;
  1222. //其它二销
  1223. if (!UpdatetCommissionPercentage(5, this.txtQiTaierxiaoMain, this.chk_Taierxiao)) return;
  1224. if (!UpdatetCommissionPercentage(5, this.txtQiTaierxiaoSub, this.chk_Taierxiao)) return;
  1225. //会员充值主副接单人业绩分配
  1226. if (!UpdatetCommissionPercentage(6, this.txtMainMemberToSingle, this.chk_MemberToSingle)) return;
  1227. if (!UpdatetCommissionPercentage(6, this.txtSubMemberToSingle, this.chk_MemberToSingle)) return;
  1228. bindCommissionPercentage();
  1229. MessageBoxCustom.Show("保存成功");
  1230. }
  1231. catch (Exception ex)
  1232. { MessageBoxCustom.Show("保存比重设置失败:"+ex.Message); }
  1233. }
  1234. /// <summary>
  1235. /// 文本框设置
  1236. /// </summary>
  1237. /// <param name="sender"></param>
  1238. /// <param name="e"></param>
  1239. void txtCp_DeputyStoreProportion_KeyPress(object sender, KeyPressEventArgs e)
  1240. {
  1241. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  1242. { e.Handled = true; }
  1243. }
  1244. }
  1245. }