F_PAM_0402.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PAM_0402.cs
  5. * 2.功能描述:新建/编辑产品品质、品质考核
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/08/18 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Windows.Forms;
  14. using Dongke.IBOSS.PRD.Basics.BaseControls;
  15. using Dongke.IBOSS.PRD.Basics.BaseResources;
  16. using Dongke.IBOSS.PRD.Basics.DockPanel;
  17. using Dongke.IBOSS.PRD.Client.CommonModule;
  18. using Dongke.IBOSS.PRD.Client.Controls;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.DataModels.PAMModule;
  21. using Dongke.IBOSS.PRD.WCF.Proxys;
  22. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  23. namespace Dongke.IBOSS.PRD.Client.PAMModule
  24. {
  25. public partial class F_PAM_0402 : FormBase
  26. {
  27. #region 成员变量
  28. // 窗体模式ID
  29. private Constant.FormMode _formType;
  30. // 操作实体ID(方案)
  31. private int? _entityId;
  32. // 工序
  33. private DataSet _dsProcedure = new DataSet();
  34. // 工种编码值
  35. //private string _GoodsCodeValue;
  36. //private bool _ShowFlag = true;
  37. // 数据源
  38. DataTable dt = null;
  39. // 当前工资方案ID
  40. //private int? _currentWagesTypeID = null;
  41. // 产品全部数据集
  42. //DataTable dtAllDataLeft = null;
  43. // 质量全部数据集
  44. DataTable dtAllDataRight = null;
  45. // 产品工价数据源
  46. DataTable _dtLeftDataSource = null;
  47. // 质量工价数据源
  48. DataTable _dtRightDataSource = null;
  49. // 当前行ID
  50. private int _selectedrow = -1;
  51. // 当前选定行
  52. private int _currentRowIndexFlag = 0;
  53. // 当前标准工价
  54. private int _currentStandardWages = 0;
  55. // 计件工资策略ID
  56. private int? _PieceTacticsID = null;
  57. #endregion
  58. #region 属性
  59. /// <summary>
  60. /// 产品工价数据源属性
  61. /// </summary>
  62. public DataTable DtLeftDataSource
  63. {
  64. set
  65. {
  66. this._dtLeftDataSource = value;
  67. }
  68. get
  69. {
  70. if (this._dtLeftDataSource == null)
  71. {
  72. this._dtLeftDataSource = new DataTable();
  73. this._dtLeftDataSource.Columns.Add("WagesTypeID", typeof(decimal)); //工价分类ID
  74. this._dtLeftDataSource.Columns.Add("RowIndexFlag"); //行标识
  75. return this._dtLeftDataSource;
  76. }
  77. else
  78. {
  79. return this._dtLeftDataSource;
  80. }
  81. }
  82. }
  83. /// <summary>
  84. /// 质量工价数据源属性
  85. /// </summary>
  86. public DataTable DtRightDataSource
  87. {
  88. set
  89. {
  90. this._dtRightDataSource = value;
  91. }
  92. get
  93. {
  94. if (this._dtRightDataSource == null)
  95. {
  96. this._dtRightDataSource = new DataTable();
  97. this._dtRightDataSource.Columns.Add("QualityRate", typeof(decimal)); //质量区间开始
  98. this._dtRightDataSource.Columns.Add("WagesTypeID", typeof(int)); //差额
  99. this._dtRightDataSource.Columns.Add("QualityReward"); //质量工价
  100. this._dtRightDataSource.Columns.Add("RowIndexFlag", typeof(int)); //行标识
  101. return this._dtRightDataSource;
  102. }
  103. else
  104. {
  105. return this._dtRightDataSource;
  106. }
  107. }
  108. }
  109. #endregion
  110. #region 构造函数
  111. /// <summary>
  112. /// 窗体构造
  113. /// </summary>
  114. /// <param name="formType">窗体打开模式</param>
  115. /// <param name="entityId">操作实体ID</param>
  116. public F_PAM_0402(Constant.FormMode formType, int entityId)
  117. {
  118. InitializeComponent();
  119. this._formType = formType;
  120. this._entityId = entityId;
  121. this._PieceTacticsID = entityId;
  122. // 窗体显示的Title
  123. if (this._formType == Constant.FormMode.Add)
  124. {
  125. this.Text = FormTitles.F_PAM_0402_ADD;
  126. }
  127. else if (this._formType == Constant.FormMode.Edit)
  128. {
  129. this.Text = FormTitles.F_PAM_0402_EDIT;
  130. }
  131. this.btnSave.Text = ButtonText.BTN_SAVE;
  132. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  133. }
  134. #endregion
  135. #region 事件处理
  136. /// <summary>
  137. /// 窗体加载
  138. /// </summary>
  139. /// <param name="sender"></param>
  140. /// <param name="e"></param>
  141. private void F_MST_0702_Load(object sender, EventArgs e)
  142. {
  143. try
  144. {
  145. this.dgvWages.AutoGenerateColumns = false;
  146. this.dgvQualityWages.AutoGenerateColumns = false;
  147. //BindPieceType();//绑定计件工序类型
  148. // 绑定工资方案数据源
  149. DataSet dsPayPlan = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  150. {
  151. return PAMModuleProxy.Service.GetPayPlan();
  152. }));
  153. if (dsPayPlan != null && dsPayPlan.Tables[0].Rows.Count > 0)
  154. {
  155. DataRow dr = dsPayPlan.Tables[0].NewRow();
  156. dr["PayPlanName"] = "";
  157. dr["PayPlanID"] = -1;
  158. dsPayPlan.Tables[0].Rows.InsertAt(dr, 0);
  159. cmbPayPlan.DataSource = dsPayPlan.Tables[0];
  160. cmbPayPlan.DisplayMember = "PayPlanName";
  161. cmbPayPlan.ValueMember = "PayPlanID";
  162. }
  163. // 绑定工价分类数据源
  164. DataSet dsWagesType = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  165. {
  166. return PAMModuleProxy.Service.GetAllWagesType();
  167. }));
  168. if (dsWagesType != null && dsWagesType.Tables[0].Rows.Count > 0)
  169. {
  170. //DataView dv = dsWagesType.Tables[0].DefaultView;
  171. //dv.RowFilter = "valueflag=1";
  172. //this.WagesTypeID.DataSource = dv.ToTable();
  173. //this.WagesTypeID.DisplayMember = "WagesTypeName";
  174. //this.WagesTypeID.ValueMember = "WagesTypeID";
  175. DataView dv = dsWagesType.Tables[0].DefaultView;
  176. dv.RowFilter = "valueflag=1";
  177. DataTable dtWagesType = dv.ToTable();
  178. this.WagesTypeID.DataSource = dtWagesType;
  179. this.WagesTypeID.DisplayMember = "WagesTypeName";
  180. this.WagesTypeID.ValueMember = "WagesTypeID";
  181. if (this._formType == Constant.FormMode.Add)
  182. {
  183. for (int i = 0; i < dtWagesType.Rows.Count; i++)
  184. {
  185. DataRow dr = DtLeftDataSource.NewRow();
  186. dr["WagesTypeID"] = dtWagesType.Rows[i]["WagesTypeID"].ToString();
  187. dr["RowIndexFlag"] = i;
  188. DtLeftDataSource.Rows.Add(dr);
  189. }
  190. }
  191. }
  192. // 加载缺陷扣罚管理数据
  193. this.GetAllDefectFine();
  194. //// 缺陷扣罚
  195. //DataSet dsDefectFine = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  196. //{
  197. // return SystemModuleProxy.Service.GetDictionaryData(0, "ASE002");
  198. //}));
  199. //this.cmbDefectFine.DisplayMember = "DictionaryValue";
  200. //this.cmbDefectFine.ValueMember = "DictionaryID";
  201. //this.cmbDefectFine.DataSource = dsDefectFine.Tables[0];
  202. //如果是修改,要绑定选中的信息
  203. if (this._formType == Constant.FormMode.Edit)
  204. {
  205. DataSet dsWagesType2 = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  206. {
  207. return PAMModuleProxy.Service.GetAllWagesType();
  208. }));
  209. if (dsWagesType2 != null && dsWagesType2.Tables[0].Rows.Count > 0)
  210. {
  211. DataView dv = dsWagesType2.Tables[0].DefaultView;
  212. dv.RowFilter = "valueflag=1";
  213. DataTable dtWagesType = dv.ToTable();
  214. this.WagesTypeID.DataSource = dtWagesType;
  215. this.WagesTypeID.DisplayMember = "WagesTypeName";
  216. this.WagesTypeID.ValueMember = "WagesTypeID";
  217. }
  218. //BindJobsData();//编辑工种数据源
  219. BindData();//绑定工资工种数据源
  220. }
  221. //如果是新建,选项默认值设定
  222. else if (this._formType == Constant.FormMode.Add)
  223. {
  224. this.dgvWages.DataSource = DtLeftDataSource;
  225. this.dgvQualityWages.DataSource = DtRightDataSource.Copy(); ;
  226. }
  227. }
  228. catch (Exception ex)
  229. {
  230. // 对异常进行共通处理
  231. ExceptionManager.HandleEventException(this.ToString(),
  232. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  233. }
  234. }
  235. /// <summary>
  236. /// 获取缺陷扣罚管理的全部数据
  237. /// </summary>
  238. /// <param name="sUserInfo">用户信息</param>
  239. /// <returns></returns>
  240. /// <remarks>
  241. /// 2016.1.5 王鑫 新建
  242. /// </remarks>
  243. private void GetAllDefectFine()
  244. {
  245. try
  246. {
  247. DataSet dsResultAccount = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  248. {
  249. return SystemModuleProxy.Service.GetAllDefectFine();
  250. }));
  251. if(dsResultAccount!=null && dsResultAccount.Tables[0].Rows.Count>0)
  252. {
  253. DataView dv = dsResultAccount.Tables[0].DefaultView;
  254. dv.RowFilter = "valueflag=1";
  255. this.cmbDefectFine.DisplayMember = "DefectFineCode";
  256. this.cmbDefectFine.ValueMember = "DefectFineID";
  257. this.cmbDefectFine.DataSource = dv.ToTable();
  258. }
  259. }
  260. catch (Exception ex)
  261. {
  262. throw ex;
  263. }
  264. }
  265. /// <summary>
  266. /// 单元格开始编辑事件
  267. /// </summary>
  268. /// <param name="sender"></param>
  269. /// <param name="e"></param>
  270. private void dgvGoods_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
  271. {
  272. }
  273. /// <summary>
  274. /// 选定项发生改变事件
  275. /// </summary>
  276. /// <param name="sender"></param>
  277. /// <param name="e"></param>
  278. private void dgvWagesType_SelectionChanged(object sender, EventArgs e)
  279. {
  280. try
  281. {
  282. if (this.dgvWages.CurrentCell != null)
  283. {
  284. if (this.dgvWages.Rows[this.dgvWages.CurrentCell.RowIndex].Cells["RowIndexFlag"].Value.ToString() != string.Empty)
  285. {
  286. this._currentRowIndexFlag = Convert.ToInt32(this.dgvWages.Rows[this.dgvWages.CurrentCell.RowIndex].Cells["RowIndexFlag"].Value);
  287. if (this.dgvWages.Rows[this.dgvWages.CurrentCell.RowIndex].Cells["RowIndexFlag"].Value.ToString() != "")
  288. {
  289. //if (this.dgvWages.Rows[this.dgvWages.CurrentCell.RowIndex].Cells["StandardWages"].Value.ToString() != "")
  290. //{
  291. // this._currentStandardWages = Convert.ToInt32(this.dgvWages.Rows[this.dgvWages.CurrentCell.RowIndex].Cells["StandardWages"].Value);
  292. //}
  293. }
  294. DataTable dtJobs = this.DtRightDataSource;
  295. DataTable dtHistory = this.dgvQualityWages.DataSource as DataTable;//
  296. if (dtHistory != null)
  297. {
  298. dtHistory = dtHistory.Copy();
  299. }
  300. if (dtHistory != null && dtHistory.Rows.Count > 0)
  301. {
  302. if (dtHistory.Rows[0]["RowIndexFlag"].ToString() != "")
  303. {
  304. //DataRow[] dr = this.DtRightDataSource.Select("RowIndexFlag=" + dtHistory.Rows[0]["RowIndexFlag"]);
  305. DataRow[] dr = this.DtRightDataSource.Select("RowIndexFlag=" + (dtHistory.Rows[0]["RowIndexFlag"].ToString() == "" ? this._currentRowIndexFlag : Convert.ToInt32(dtHistory.Rows[0]["RowIndexFlag"].ToString())));
  306. //先删除掉
  307. foreach (DataRow r in dr)
  308. {
  309. r.Delete();
  310. }
  311. //重新插入
  312. for (int i = 0; i < dtHistory.Rows.Count; i++)
  313. {
  314. if (dtHistory.Rows[i]["QualityRate"].ToString() != "" || dtHistory.Rows[i]["QualityReward"].ToString() != "")
  315. {
  316. DataRow drNew = DtRightDataSource.NewRow();
  317. drNew["QualityRate"] = dtHistory.Rows[i]["QualityRate"].ToString();
  318. drNew["QualityReward"] = dtHistory.Rows[i]["QualityReward"].ToString();
  319. drNew["RowIndexFlag"] = dtHistory.Rows[i]["RowIndexFlag"].ToString();
  320. DtRightDataSource.Rows.Add(drNew);
  321. }
  322. }
  323. }
  324. }
  325. if (dtJobs != null)
  326. {
  327. DataView dv = dtJobs.DefaultView;
  328. dv.RowFilter = "RowIndexFlag=" + this._currentRowIndexFlag;
  329. this.dgvQualityWages.DataSource = dv.ToTable();
  330. }
  331. }
  332. else
  333. {
  334. //this._selectedrow++;
  335. //int rowindex = this._selectedrow;
  336. //this.dgvWages.Rows[this.dgvWages.CurrentCell.RowIndex].Cells["RowIndexFlag"].Value = rowindex;
  337. //this._currentRowIndexFlag = rowindex;
  338. //this._currentStandardWages = 0;
  339. DataTable dtJobs = this.DtRightDataSource;
  340. DataTable dtHistory = this.dgvQualityWages.DataSource as DataTable;//
  341. if (dtHistory != null && dtHistory.Rows.Count > 0)
  342. {
  343. // DataRow[] dr = this.DtRightDataSource.Select("RowIndexFlag=" + (dtHistory.Rows[0]["RowIndexFlag"].ToString() == "" ? "0" : dtHistory.Rows[0]["RowIndexFlag"].ToString()));
  344. DataRow[] dr = this.DtRightDataSource.Select("RowIndexFlag=" + (dtHistory.Rows[0]["RowIndexFlag"].ToString() == "" ? this._currentRowIndexFlag : Convert.ToInt32(dtHistory.Rows[0]["RowIndexFlag"].ToString())));
  345. //先删除掉
  346. foreach (DataRow r in dr)
  347. {
  348. r.Delete();
  349. }
  350. //重新插入
  351. for (int i = 0; i < dtHistory.Rows.Count; i++)
  352. {
  353. if (dtHistory.Rows[i]["QualityRate"].ToString() != "" || dtHistory.Rows[i]["QualityReward"].ToString() != "")
  354. {
  355. DataRow drNew = DtRightDataSource.NewRow();
  356. drNew["QualityRate"] = dtHistory.Rows[i]["QualityRate"].ToString();
  357. drNew["QualityReward"] = dtHistory.Rows[i]["QualityReward"].ToString();
  358. drNew["RowIndexFlag"] = dtHistory.Rows[i]["RowIndexFlag"].ToString();
  359. DtRightDataSource.Rows.Add(drNew);
  360. }
  361. }
  362. if (dtJobs != null)
  363. {
  364. DataView dv = dtJobs.DefaultView;
  365. //dv.RowFilter = "RowIndexFlag=" + this._currentRowIndexFlag;
  366. dv.RowFilter = "RowIndexFlag=-1";
  367. this.dgvQualityWages.DataSource = dv.ToTable();
  368. }
  369. //}
  370. }
  371. else
  372. {
  373. if (dtJobs != null)
  374. {
  375. DataView dv = dtJobs.DefaultView;
  376. dv.RowFilter = "RowIndexFlag=-1";
  377. this.dgvQualityWages.DataSource = dv.ToTable();
  378. }
  379. else
  380. {
  381. this.dgvQualityWages.DataSource = null;
  382. }
  383. }
  384. }
  385. }
  386. this.dgvQualityWages.IsSetInputColumnsColor = true;
  387. }
  388. catch (Exception ex)
  389. {
  390. // 对异常进行共通处理
  391. ExceptionManager.HandleEventException(this.ToString(),
  392. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  393. }
  394. }
  395. /// <summary>
  396. /// 保存按钮事件
  397. /// </summary>
  398. /// <param name="sender"></param>
  399. /// <param name="e"></param>
  400. private void btnSave_Click_1(object sender, EventArgs e)
  401. {
  402. try
  403. {
  404. if (string.IsNullOrEmpty(this.txtPayPlanName.Text))
  405. {
  406. // 提示信息
  407. MessageBox.Show("策略名称不能为空",
  408. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  409. return;
  410. }
  411. DataTable dtLeft = this.dgvWages.DataSource as DataTable;
  412. DataView dv = dtLeft.DefaultView;
  413. dv.RowFilter = "WagesTypeID>0";
  414. dtLeft = dv.ToTable();
  415. dtLeft.AcceptChanges();
  416. if (dtLeft.Rows.Count == 0)
  417. {
  418. MessageBox.Show("请添写工价分类信息",
  419. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  420. return;
  421. }
  422. if (this.DtRightDataSource != null && this.DtRightDataSource.Rows.Count == 0)
  423. {
  424. MessageBox.Show("请添写工价分类明细信息",
  425. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  426. return;
  427. }
  428. QualityASS entity = new QualityASS();
  429. entity.QualityASSTacticsID = this._PieceTacticsID;
  430. if (cmbPayPlan.SelectedValue.ToString() != "-1")
  431. {
  432. entity.PayPlanID = Convert.ToInt32(cmbPayPlan.SelectedValue);
  433. }
  434. entity.DefectFine = Convert.ToInt32(this.cmbDefectFine.SelectedValue);
  435. //entity.QualityBaseProcedureIDS = this.dkQualityBaseProcedure.ProcedureIDS;//质量基数工序
  436. entity.QualityTacticsName = this.txtPayPlanName.Text;
  437. if (dtLeft != null && dtLeft.Rows.Count > 0)
  438. {
  439. List<WCF.DataModels.PAMModule.QualityGoods> qagesentitys = new List<WCF.DataModels.PAMModule.QualityGoods>();
  440. for (int i = 0; i < dtLeft.Rows.Count; i++)
  441. {
  442. WCF.DataModels.PAMModule.QualityGoods wageentity = new WCF.DataModels.PAMModule.QualityGoods();
  443. wageentity.WagesTypeID = Convert.ToInt32(dtLeft.Rows[i]["WagesTypeID"]);
  444. //质量工价
  445. if (this.DtRightDataSource != null && this.DtRightDataSource.Rows.Count > 0)
  446. {
  447. List<WCF.DataModels.PAMModule.QualityReward> qualityWagesEntitys = new List<WCF.DataModels.PAMModule.QualityReward>();
  448. //for (int j = 0; j < DtRightDataSource.Rows.Count; j++)
  449. //{
  450. // DataRow[] drWagesTypeID = dtLeft.Select("RowIndexFlag=" + DtRightDataSource.Rows[j]["RowIndexFlag".ToString()]);
  451. //if (drWagesTypeID.Length > 0)
  452. //{
  453. DataRow[] dr2 = DtRightDataSource.Select("RowIndexFlag=" + dtLeft.Rows[i]["RowIndexFlag".ToString()]);
  454. foreach (DataRow r in dr2)
  455. {
  456. WCF.DataModels.PAMModule.QualityReward qualityWagesEntity = new WCF.DataModels.PAMModule.QualityReward();
  457. qualityWagesEntity.WagesTypeID = Convert.ToInt32(dtLeft.Rows[i]["WagesTypeID"]);
  458. qualityWagesEntity.QualityRate = Convert.ToDecimal(r["QualityRate"].ToString() == "" ? 0 : r["QualityRate"]) / 100;
  459. qualityWagesEntity.QualityReward2 = Convert.ToDecimal(r["QualityReward"].ToString() == "" ? 0 : r["QualityReward"]);
  460. qualityWagesEntitys.Add(qualityWagesEntity);
  461. }
  462. // }
  463. // }
  464. wageentity.qualityReward = qualityWagesEntitys;
  465. }
  466. qagesentitys.Add(wageentity);
  467. }
  468. entity.qualityGoods = qagesentitys;
  469. }
  470. int returnValue = (int)DoAsync(new BaseAsyncMethod(() =>
  471. {
  472. return PAMModuleProxy.Service.SaveQualityASS(entity);
  473. }));
  474. if (returnValue >= 0) //等于O,表示未修改数据,影响行为0
  475. {
  476. // 提示信息
  477. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  478. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  479. this.DialogResult = DialogResult.OK;
  480. }
  481. else if (returnValue == -1)
  482. {
  483. // 提示信息
  484. MessageBox.Show("一个解决方案只能对应一个计件工资策略",
  485. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  486. }
  487. else if (returnValue == -2)
  488. {
  489. // 提示信息
  490. MessageBox.Show("工价分类不能重复在工资方案使用",
  491. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  492. }
  493. else if (returnValue == -3)
  494. {
  495. // 提示信息
  496. MessageBox.Show("质量区间不能重复",
  497. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  498. }
  499. }
  500. catch (Exception ex)
  501. {
  502. // 对异常进行共通处理
  503. ExceptionManager.HandleEventException(this.ToString(),
  504. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  505. }
  506. }
  507. #endregion
  508. #region 私有方法
  509. /// <summary>
  510. /// 绑定编辑数据
  511. /// </summary>
  512. private void BindData()
  513. {
  514. try
  515. {
  516. DataSet dsResultAccount = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  517. {
  518. return PAMModuleProxy.Service.GetQualityASSByID(Convert.ToInt32(this._PieceTacticsID));
  519. }));
  520. if (dsResultAccount != null && dsResultAccount.Tables[0].Rows.Count > 0)
  521. {
  522. //绑定主信息
  523. if (dsResultAccount.Tables[0].Rows[0]["PayPlanID"].ToString() != "")
  524. {
  525. this.cmbPayPlan.SelectedValue = dsResultAccount.Tables[0].Rows[0]["PayPlanID"].ToString();
  526. }
  527. this.cmbDefectFine.SelectedValue = dsResultAccount.Tables[0].Rows[0]["DefectFine"].ToString();
  528. //this.dkQualityBaseProcedure.ProcedureID = Convert.ToInt32(dsResultAccount.Tables[0].Rows[0]["QualityBaseProcedureID"]);
  529. //this.dkQualityBaseProcedure.Text = dsResultAccount.Tables[0].Rows[0]["QualityBaseProcedure"].ToString();
  530. this.txtPayPlanName.Text = dsResultAccount.Tables[0].Rows[0]["QualityTacticsName"].ToString();
  531. //if (dsResultAccount.Tables[3].Rows.Count > 0)
  532. //{
  533. // string IDS = "";
  534. // string TextS = "";
  535. // foreach (DataRow r1 in dsResultAccount.Tables[3].Rows)
  536. // {
  537. // TextS += r1["ProcedureName"].ToString() + ",";
  538. // IDS += r1["ProcedureID"].ToString() + ",";
  539. // }
  540. // IDS = IDS.Trim(',');
  541. // TextS = TextS.Trim(',');
  542. // if (IDS != "")
  543. // {
  544. // //this.dkQualityBaseProcedure.Text = TextS;
  545. // //this.dkQualityBaseProcedure.ProcedureIDS = IDS;
  546. // }
  547. //}
  548. if (dsResultAccount != null && dsResultAccount.Tables[1].Rows.Count > 0)
  549. {
  550. //产品工价
  551. this._selectedrow = dsResultAccount.Tables[1].Rows.Count;
  552. for (int i = 0; i < dsResultAccount.Tables[1].Rows.Count; i++)
  553. {
  554. DataRow dr = this.DtLeftDataSource.NewRow();
  555. dr["WagesTypeID"] = dsResultAccount.Tables[1].Rows[i]["WagesTypeID"];
  556. dr["RowIndexFlag"] = i;
  557. this.DtLeftDataSource.Rows.Add(dr);
  558. //this._selectedrow++;//用于过滤边条件
  559. if (dsResultAccount != null && dsResultAccount.Tables[2].Rows.Count > 0)
  560. {
  561. DataRow[] r = dsResultAccount.Tables[2].Select("WagesTypeID=" + dsResultAccount.Tables[1].Rows[i]["WagesTypeID"]);
  562. if (r.Length > 0)
  563. {
  564. foreach (DataRow rr in r)
  565. {
  566. DataRow dr2 = this.DtRightDataSource.NewRow();
  567. dr2["QualityRate"] = Convert.ToDecimal(rr["QualityRate"]) * 100;
  568. dr2["WagesTypeID"] = rr["WagesTypeID"];
  569. dr2["QualityReward"] = rr["QualityReward"];
  570. dr2["RowIndexFlag"] = i;
  571. this.DtRightDataSource.Rows.Add(dr2);
  572. }
  573. }
  574. }
  575. }
  576. }
  577. DataView dv = this.DtRightDataSource.DefaultView;
  578. dv.RowFilter = "RowIndexFlag=0";
  579. this.dgvQualityWages.DataSource = dv.ToTable();// DtRightDataSource;
  580. this.dgvWages.DataSource = DtLeftDataSource;
  581. }
  582. }
  583. catch (Exception ex)
  584. {
  585. throw ex;
  586. }
  587. }
  588. #endregion
  589. /// <summary>
  590. /// 删除行时
  591. /// </summary>
  592. /// <param name="sender"></param>
  593. /// <param name="e"></param>
  594. private void dgvGoods_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  595. {
  596. }
  597. /// <summary>
  598. /// 产品工价添加行事件
  599. /// </summary>
  600. /// <param name="sender"></param>
  601. /// <param name="e"></param>
  602. private void dgvWages_UserAddedRow(object sender, DataGridViewRowEventArgs e)
  603. {
  604. try
  605. {
  606. if (e.Row.Index != -1)
  607. {
  608. if (this.dgvWages.CurrentCell != null)
  609. {
  610. this._selectedrow++;//用于过滤边条件
  611. this._currentRowIndexFlag = this._selectedrow;
  612. this.dgvWages.Rows[this.dgvWages.CurrentCell.RowIndex].Cells["RowIndexFlag"].Value = this._selectedrow;
  613. }
  614. }
  615. }
  616. catch (Exception ex)
  617. {
  618. throw ex;
  619. }
  620. }
  621. private void dgvQualityWages_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
  622. {
  623. }
  624. private void F_PAM_0402_Shown(object sender, EventArgs e)
  625. {
  626. this.dgvQualityWages.IsSetInputColumnsColor = true;
  627. }
  628. private void dgvQualityWages_CellValidated(object sender, DataGridViewCellEventArgs e)
  629. {
  630. if ((e.ColumnIndex == 0 || e.ColumnIndex == 1) && e.RowIndex != -Constant.INT_IS_ONE)
  631. {
  632. this.dgvQualityWages.Rows[this.dgvQualityWages.CurrentCell.RowIndex].Cells["RowIndexFlag1"].Value = this._currentRowIndexFlag;
  633. }
  634. }
  635. }
  636. }