F_PAM_0302.cs 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PAM_0203.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_0302 : 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 decimal _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("StandardWages", typeof(decimal)); //标准工价
  75. this._dtLeftDataSource.Columns.Add("DamageSubsidyRate", typeof(decimal)); //损坯补贴系数
  76. this._dtLeftDataSource.Columns.Add("DamageSubsidy", typeof(decimal)); //损坯补贴
  77. this._dtLeftDataSource.Columns.Add("RSuperiorCoefficient", typeof(decimal)); //干补正品系数
  78. this._dtLeftDataSource.Columns.Add("RQualifiedCoefficient", typeof(decimal)); //干补副品系数
  79. this._dtLeftDataSource.Columns.Add("RepairSubsidyRate", typeof(decimal)); //干补补贴系数
  80. this._dtLeftDataSource.Columns.Add("RepairSubsidy", typeof(decimal)); //干补补贴
  81. this._dtLeftDataSource.Columns.Add("RowIndexFlag"); //行标识
  82. return this._dtLeftDataSource;
  83. }
  84. else
  85. {
  86. return this._dtLeftDataSource;
  87. }
  88. }
  89. }
  90. /// <summary>
  91. /// 质量工价数据源属性
  92. /// </summary>
  93. public DataTable DtRightDataSource
  94. {
  95. set
  96. {
  97. this._dtRightDataSource = value;
  98. }
  99. get
  100. {
  101. if (this._dtRightDataSource == null)
  102. {
  103. this._dtRightDataSource = new DataTable();
  104. this._dtRightDataSource.Columns.Add("QualityRate", typeof(decimal)); //质量区间开始
  105. this._dtRightDataSource.Columns.Add("Balance", typeof(decimal)); //差额
  106. this._dtRightDataSource.Columns.Add("QualityWages", typeof(decimal)); //质量工价
  107. this._dtRightDataSource.Columns.Add("RowIndexFlag",typeof(int)); //行标识
  108. return this._dtRightDataSource;
  109. }
  110. else
  111. {
  112. return this._dtRightDataSource;
  113. }
  114. }
  115. }
  116. #endregion
  117. #region 构造函数
  118. /// <summary>
  119. /// 窗体构造
  120. /// </summary>
  121. /// <param name="formType">窗体打开模式</param>
  122. /// <param name="entityId">操作实体ID</param>
  123. public F_PAM_0302(Constant.FormMode formType, int? entityId)
  124. {
  125. InitializeComponent();
  126. this._formType = formType;
  127. this._entityId = entityId;
  128. this._PieceTacticsID = entityId;
  129. // 窗体显示的Title
  130. if (this._formType == Constant.FormMode.Add)
  131. {
  132. this.Text = FormTitles.F_PAM_0302_ADD;
  133. }
  134. else if (this._formType == Constant.FormMode.Edit)
  135. {
  136. this.Text = FormTitles.F_PAM_0302_EDIT;
  137. }
  138. this.btnSave.Text = ButtonText.BTN_SAVE;
  139. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  140. }
  141. #endregion
  142. #region 事件处理
  143. /// <summary>
  144. /// 窗体加载
  145. /// </summary>
  146. /// <param name="sender"></param>
  147. /// <param name="e"></param>
  148. private void F_MST_0702_Load(object sender, EventArgs e)
  149. {
  150. try
  151. {
  152. this.dgvWages.AutoGenerateColumns = false;
  153. this.dgvQualityWages.AutoGenerateColumns = false;
  154. BindPieceType();//绑定计件工序类型
  155. // 绑定工资方案数据源
  156. DataSet dsPayPlan = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  157. {
  158. return PAMModuleProxy.Service.GetPayPlan();
  159. }));
  160. if (dsPayPlan != null && dsPayPlan.Tables[0].Rows.Count > 0)
  161. {
  162. DataRow dr = dsPayPlan.Tables[0].NewRow();
  163. dr["PayPlanName"] = "";
  164. dr["PayPlanID"] = -1;
  165. dsPayPlan.Tables[0].Rows.InsertAt(dr, 0);
  166. cmbPayPlan.DataSource = dsPayPlan.Tables[0];
  167. cmbPayPlan.DisplayMember = "PayPlanName";
  168. cmbPayPlan.ValueMember = "PayPlanID";
  169. }
  170. //// 绑定工价分类数据源
  171. //DataSet dsWagesType = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  172. //{
  173. // return PAMModuleProxy.Service.GetAllWagesType();
  174. //}));
  175. //if (dsWagesType != null && dsWagesType.Tables[0].Rows.Count > 0)
  176. //{
  177. // DataView dv = dsWagesType.Tables[0].DefaultView;
  178. // dv.RowFilter = "valueflag=1";
  179. // this.WagesTypeID.DataSource = dv.ToTable();
  180. // this.WagesTypeID.DisplayMember = "WagesTypeName";
  181. // this.WagesTypeID.ValueMember = "WagesTypeID";
  182. //}
  183. //如果是修改,要绑定选中的信息
  184. if (this._formType == Constant.FormMode.Edit)
  185. {
  186. //BindJobsData();//编辑工种数据源
  187. DataSet dsWagesType = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  188. {
  189. return PAMModuleProxy.Service.GetAllWagesType();
  190. }));
  191. if (dsWagesType != null && dsWagesType.Tables[0].Rows.Count > 0)
  192. {
  193. DataView dv = dsWagesType.Tables[0].DefaultView;
  194. dv.RowFilter = "valueflag=1";
  195. DataTable dtWagesType = dv.ToTable();
  196. this.WagesTypeID.DataSource = dtWagesType;
  197. this.WagesTypeID.DisplayMember = "WagesTypeName";
  198. this.WagesTypeID.ValueMember = "WagesTypeID";
  199. }
  200. BindData();//绑定工资工种数据源
  201. }
  202. //如果是新建,选项默认值设定
  203. else if (this._formType == Constant.FormMode.Add)
  204. {
  205. // 绑定工价分类数据源
  206. DataSet dsWagesType = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  207. {
  208. return PAMModuleProxy.Service.GetAllWagesType();
  209. }));
  210. if (dsWagesType != null && dsWagesType.Tables[0].Rows.Count > 0)
  211. {
  212. DataView dv = dsWagesType.Tables[0].DefaultView;
  213. dv.RowFilter = "valueflag=1";
  214. DataTable dtWagesType = dv.ToTable();
  215. this.WagesTypeID.DataSource = dtWagesType;
  216. this.WagesTypeID.DisplayMember = "WagesTypeName";
  217. this.WagesTypeID.ValueMember = "WagesTypeID";
  218. for (int i = 0; i < dtWagesType.Rows.Count; i++)
  219. {
  220. DataRow dr = DtLeftDataSource.NewRow();
  221. dr["WagesTypeID"] = dtWagesType.Rows[i]["WagesTypeID"].ToString();
  222. dr["StandardWages"] = 0;
  223. dr["DamageSubsidyRate"] = 1;
  224. dr["DamageSubsidy"] = 0;
  225. dr["RSuperiorCoefficient"] = 1;
  226. dr["RQualifiedCoefficient"] = 1;
  227. dr["RepairSubsidyRate"] = 1;
  228. dr["RepairSubsidy"] = 0;
  229. dr["RowIndexFlag"] = i;
  230. DtLeftDataSource.Rows.Add(dr);
  231. }
  232. }
  233. this.dgvWages.DataSource = DtLeftDataSource;
  234. this.dgvQualityWages.DataSource = DtRightDataSource;
  235. }
  236. }
  237. catch (Exception ex)
  238. {
  239. // 对异常进行共通处理
  240. ExceptionManager.HandleEventException(this.ToString(),
  241. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  242. }
  243. }
  244. /// <summary>
  245. /// 窗体关闭
  246. /// </summary>
  247. /// <param name="sender"></param>
  248. /// <param name="e"></param>
  249. private void btnCancel_Click(object sender, EventArgs e)
  250. {
  251. this.Close();
  252. }
  253. /// <summary>
  254. /// 窗体释放
  255. /// </summary>
  256. /// <param name="sender"></param>
  257. /// <param name="e"></param>
  258. private void F_MST_0702_FormClosed(object sender, FormClosedEventArgs e)
  259. {
  260. this.Dispose();
  261. }
  262. /// <summary>
  263. /// 数据统计工序变更
  264. /// </summary>
  265. /// <param name="sender"></param>
  266. /// <param name="e"></param>
  267. private void dgvGoods_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  268. {
  269. try
  270. {
  271. if (this.dgvQualityWages.Rows.Count <= 1)
  272. {
  273. return;
  274. }
  275. DataGridViewRow rowItem = this.dgvQualityWages.Rows[e.RowIndex];
  276. DataGridViewColumn columnItem = this.dgvQualityWages.Columns[e.ColumnIndex];
  277. // 用编号获取产品信息
  278. if ("GoodsCode".Equals(columnItem.Name))
  279. {
  280. string GoodsID = "";
  281. if (this.dgvQualityWages.Rows[e.RowIndex].Cells["GoodsID"].Value != null)
  282. {
  283. GoodsID = this.dgvQualityWages.Rows[e.RowIndex].Cells["GoodsID"].Value.ToString();
  284. }
  285. DataTable dtDataSource = FormUtility.BindGoodsRowDataSource(this.dgvQualityWages,
  286. e.RowIndex, columnItem.Name, _GoodsCodeValue);
  287. int row = e.RowIndex;
  288. // 返回多少行,进而给每个单元格传值,为的以后多个工资方案进行筛选
  289. if (dtDataSource != null && dtDataSource.Rows.Count > 0)
  290. {
  291. for (int i = 0; i < dtDataSource.Rows.Count; i++)
  292. {
  293. //this.dgvGoods.Rows[row].Cells["WagesTypeID1"].Value = this._currentWagesTypeID;
  294. //DataRow dr = this.dtAllData.NewRow();
  295. //dr["GoodsID"] = dtDataSource.Rows[i]["GoodsID"];
  296. //dr["GoodsCode"] = dtDataSource.Rows[i]["GoodsCode"];
  297. //dr["GoodsName"] = dtDataSource.Rows[i]["GoodsName"];
  298. //dr["WagesTypeID"] = this._currentWagesTypeID;
  299. //dtAllData.Rows.Add(dr);
  300. //row++;
  301. //如果存在数据集中,此列标记删除
  302. this.dgvQualityWages.Rows[row].Cells["WagesTypeID1"].Value = this._currentWagesTypeID;
  303. if (dtAllDataRight != null && GoodsID != "")
  304. {
  305. DataRow[] drSel = dtAllDataRight.Select(string.Format("WagesTypeID={0} and GoodsID={1}", this._currentWagesTypeID, GoodsID));
  306. if (drSel.Length > 0) //存在,需要更把此行删除
  307. {
  308. drSel[0].Delete();
  309. }
  310. }
  311. if (GoodsID == "") //新增的时候,是否存在相同的工种编码
  312. {
  313. //DataRow[] drSel = dtAllData.Select(string.Format("WagesTypeID={0} and GoodsID='{1}'", this._currentWagesTypeID, GoodsID));
  314. //if (drSel.Length == 0) //不存在,把此行添加进来
  315. //{
  316. DataRow dr = this.dtAllDataRight.NewRow();
  317. dr["GoodsID"] = dtDataSource.Rows[i]["GoodsID"];
  318. dr["GoodsCode"] = dtDataSource.Rows[i]["GoodsCode"];
  319. dr["GoodsName"] = dtDataSource.Rows[i]["GoodsName"];
  320. dr["WagesTypeID"] = this._currentWagesTypeID;
  321. dtAllDataRight.Rows.Add(dr);
  322. row++;
  323. // }
  324. }
  325. else
  326. {
  327. DataRow dr = this.dtAllDataRight.NewRow();
  328. dr["GoodsID"] = dtDataSource.Rows[i]["GoodsID"];
  329. dr["GoodsCode"] = dtDataSource.Rows[i]["GoodsCode"];
  330. dr["GoodsName"] = dtDataSource.Rows[i]["GoodsName"];
  331. dr["WagesTypeID"] = this._currentWagesTypeID;
  332. dtAllDataRight.Rows.Add(dr);
  333. row++;
  334. }
  335. }
  336. this.dgvQualityWages.Rows[e.RowIndex].Selected = true;
  337. }
  338. // 设置可输入单元格的颜色
  339. this.dgvQualityWages.IsSetInputColumnsColor = true;
  340. }
  341. }
  342. catch (Exception ex)
  343. {
  344. // 对异常进行共通处理
  345. ExceptionManager.HandleEventException(this.ToString(),
  346. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  347. }
  348. }
  349. /// <summary>
  350. /// 单元格开始编辑事件
  351. /// </summary>
  352. /// <param name="sender"></param>
  353. /// <param name="e"></param>
  354. private void dgvGoods_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
  355. {
  356. //try
  357. //{
  358. // if (this.dgvQualityWages.Rows.Count <= 1 || !_ShowFlag)
  359. // {
  360. // return;
  361. // }
  362. // DataGridViewColumn columnItem = this.dgvQualityWages.Columns[e.ColumnIndex];
  363. // //if ("GoodsCode".Equals(columnItem.Name))
  364. // //{
  365. // //_ShowFlag = false;
  366. // //_GoodsCodeValue = this.dgvQualityWages.Rows[e.RowIndex].Cells[columnItem.Name].Value + "";
  367. // this.dgvQualityWages.Rows[e.RowIndex].Cells["RowIndexFlag1"].Value = this._currentRowIndexFlag;
  368. // // }
  369. // _ShowFlag = true;
  370. //}
  371. //catch (Exception ex)
  372. //{
  373. // _ShowFlag = true;
  374. // // 对异常进行共通处理
  375. // ExceptionManager.HandleEventException(this.ToString(),
  376. // System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  377. //}
  378. }
  379. /// <summary>
  380. /// 选定项发生改变事件
  381. /// </summary>
  382. /// <param name="sender"></param>
  383. /// <param name="e"></param>
  384. private void dgvWagesType_SelectionChanged(object sender, EventArgs e)
  385. {
  386. try
  387. {
  388. if (this.dgvWages.CurrentCell != null)
  389. {
  390. if (this.dgvWages.Rows[this.dgvWages.CurrentCell.RowIndex].Cells["RowIndexFlag"].Value.ToString() != string.Empty)
  391. {
  392. this._currentRowIndexFlag = Convert.ToInt32(this.dgvWages.Rows[this.dgvWages.CurrentCell.RowIndex].Cells["RowIndexFlag"].Value);
  393. if (this.dgvWages.Rows[this.dgvWages.CurrentCell.RowIndex].Cells["RowIndexFlag"].Value.ToString() != "")
  394. {
  395. if (this.dgvWages.Rows[this.dgvWages.CurrentCell.RowIndex].Cells["StandardWages"].Value.ToString() != "")
  396. {
  397. this._currentStandardWages = Convert.ToDecimal(this.dgvWages.Rows[this.dgvWages.CurrentCell.RowIndex].Cells["StandardWages"].Value);
  398. }
  399. }
  400. DataTable dtJobs = this.DtRightDataSource;
  401. DataTable dtHistory = this.dgvQualityWages.DataSource as DataTable;//
  402. if (dtHistory != null && dtHistory.Rows.Count > 0)
  403. {
  404. DataRow[] dr = this.DtRightDataSource.Select("RowIndexFlag=" + (dtHistory.Rows[0]["RowIndexFlag"].ToString() == "" ? this._currentRowIndexFlag :Convert.ToInt32(dtHistory.Rows[0]["RowIndexFlag"].ToString())));
  405. //先删除掉
  406. foreach (DataRow r in dr)
  407. {
  408. r.Delete();
  409. }
  410. //重新插入
  411. for (int i = 0; i < dtHistory.Rows.Count; i++)
  412. {
  413. if (dtHistory.Rows[i]["QualityRate"].ToString() != "" || dtHistory.Rows[i]["Balance"].ToString() != "")
  414. {
  415. DataRow drNew = DtRightDataSource.NewRow();
  416. drNew["QualityRate"] = dtHistory.Rows[i]["QualityRate"].ToString();
  417. drNew["Balance"] = dtHistory.Rows[i]["Balance"].ToString();
  418. drNew["QualityWages"] = dtHistory.Rows[i]["QualityWages"].ToString();
  419. drNew["RowIndexFlag"] = dtHistory.Rows[i]["RowIndexFlag"].ToString() == "" ? Convert.ToInt32(dtHistory.Rows[0]["RowIndexFlag"]) : Convert.ToInt32(dtHistory.Rows[i]["RowIndexFlag"].ToString());
  420. DtRightDataSource.Rows.Add(drNew);
  421. }
  422. }
  423. //}
  424. }
  425. if (dtJobs != null)
  426. {
  427. DataView dv = dtJobs.DefaultView;
  428. dv.RowFilter = "RowIndexFlag=" + this._currentRowIndexFlag;
  429. this.dgvQualityWages.DataSource = dv.ToTable();
  430. }
  431. }
  432. else
  433. {
  434. //this._selectedrow++;
  435. //int rowindex = this._selectedrow;
  436. //this.dgvWages.Rows[this.dgvWages.CurrentCell.RowIndex].Cells["RowIndexFlag"].Value = rowindex;
  437. //this._currentRowIndexFlag = rowindex;
  438. //this._currentStandardWages = 0;
  439. DataTable dtJobs = this.DtRightDataSource;
  440. DataTable dtHistory = this.dgvQualityWages.DataSource as DataTable;//
  441. if (dtHistory != null && dtHistory.Rows.Count > 0)
  442. {
  443. DataRow[] dr = this.DtRightDataSource.Select("RowIndexFlag=" + (dtHistory.Rows[0]["RowIndexFlag"].ToString() == "" ? this._currentRowIndexFlag : Convert.ToInt32(dtHistory.Rows[0]["RowIndexFlag"].ToString())));
  444. //先删除掉
  445. foreach (DataRow r in dr)
  446. {
  447. r.Delete();
  448. }
  449. //重新插入
  450. for (int i = 0; i < dtHistory.Rows.Count; i++)
  451. {
  452. if (dtHistory.Rows[i]["QualityRate"].ToString() != "" || dtHistory.Rows[i]["Balance"].ToString() != "")
  453. {
  454. DataRow drNew = DtRightDataSource.NewRow();
  455. drNew["QualityRate"] = dtHistory.Rows[i]["QualityRate"].ToString();
  456. drNew["Balance"] = dtHistory.Rows[i]["Balance"].ToString();
  457. drNew["QualityWages"] = dtHistory.Rows[i]["QualityWages"].ToString();
  458. drNew["RowIndexFlag"] = dtHistory.Rows[i]["RowIndexFlag"].ToString() == "" ? Convert.ToInt32(dtHistory.Rows[0]["RowIndexFlag"]) : Convert.ToInt32(dtHistory.Rows[i]["RowIndexFlag"].ToString());
  459. DtRightDataSource.Rows.Add(drNew);
  460. }
  461. }
  462. if (dtJobs != null)
  463. {
  464. DataView dv = dtJobs.DefaultView;
  465. //dv.RowFilter = "RowIndexFlag=" + this._currentRowIndexFlag;
  466. dv.RowFilter = "RowIndexFlag=-1";
  467. this.dgvQualityWages.DataSource = dv.ToTable();
  468. }
  469. //}
  470. }
  471. else
  472. {
  473. if (dtJobs != null)
  474. {
  475. DataView dv = dtJobs.DefaultView;
  476. dv.RowFilter = "RowIndexFlag=-1";
  477. this.dgvQualityWages.DataSource = dv.ToTable();
  478. }
  479. else
  480. {
  481. this.dgvQualityWages.DataSource = null;
  482. }
  483. }
  484. }
  485. }
  486. this.dgvQualityWages.IsSetInputColumnsColor = true;
  487. }
  488. catch (Exception ex)
  489. {
  490. // 对异常进行共通处理
  491. ExceptionManager.HandleEventException(this.ToString(),
  492. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  493. }
  494. }
  495. /// <summary>
  496. /// 保存按钮事件
  497. /// </summary>
  498. /// <param name="sender"></param>
  499. /// <param name="e"></param>
  500. private void btnSave_Click_1(object sender, EventArgs e)
  501. {
  502. try
  503. {
  504. if (this.dkPieceProcedure.ProcedureIDS == null)
  505. {
  506. // 提示信息
  507. MessageBox.Show("计件工序不能为空",
  508. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  509. return;
  510. }
  511. if (this.txtPayPlanName.Text.Trim() == "")
  512. {
  513. // 提示信息
  514. MessageBox.Show("策略名称不能为空",
  515. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  516. return;
  517. }
  518. if (this.dkQualityBaseProcedure.ProcedureIDS == null)
  519. {
  520. // 提示信息
  521. MessageBox.Show("质量基数工序不能为空",
  522. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  523. return;
  524. }
  525. PieceworkEntity entity = new PieceworkEntity();
  526. entity.PieceTacticsID = this._PieceTacticsID;
  527. if (cmbPayPlan.SelectedValue.ToString() != "-1")
  528. {
  529. entity.PayPlanID = Convert.ToInt32(cmbPayPlan.SelectedValue);
  530. }
  531. entity.PieceType = Convert.ToInt32(cmbPieceType.SelectedValue);
  532. entity.PayPlanName = this.txtPayPlanName.Text.Trim();
  533. entity.QualityBaseProcedureIDS = this.dkQualityBaseProcedure.ProcedureIDS;//质量基数工序
  534. entity.DamageCoefficient = this.txtDamageCoefficient.Text.Trim() == "" ? 1 : Convert.ToDecimal(this.txtDamageCoefficient.Text.Trim());
  535. entity.UnqualifiedCoefficient = this.txtUnqualifiedCoefficient.Text.Trim() == "" ? 1 : Convert.ToDecimal(this.txtUnqualifiedCoefficient.Text.Trim());
  536. entity.QualifiedCoefficient = this.txtQualifiedCoefficient.Text.Trim() == "" ? 1 : Convert.ToDecimal(this.txtQualifiedCoefficient.Text.Trim());
  537. //损坯
  538. entity.DamageFlag = chkDamageFlag.Checked ? "1" : "0";
  539. entity.UnqualifiedFlag = chkUnqualifiedFlag.Checked ? "1" : "0";
  540. entity.QualifiedFlag = chkQualifiedFlag.Checked ? "1" : "0";
  541. entity.PieceProcedureIDS = this.dkPieceProcedure.ProcedureIDS;//计件工序
  542. entity.PieceCoefficient = this.txtPieceCoefficient.Text.Trim() == "" ? 1 : Convert.ToDecimal(this.txtPieceCoefficient.Text.Trim());
  543. DataTable dtLeft = this.dgvWages.DataSource as DataTable;
  544. //DataView dv = dtLeft.DefaultView;
  545. //dv.RowFilter = "WagesTypeID>0";
  546. //dtLeft = dv.ToTable();
  547. //dtLeft.AcceptChanges();
  548. DataTable dtHistory = this.dgvQualityWages.DataSource as DataTable;//
  549. if (dtHistory != null && dtHistory.Rows.Count > 0)
  550. {
  551. DataRow[] dr = this.DtRightDataSource.Select("RowIndexFlag=" + (dtHistory.Rows[0]["RowIndexFlag"].ToString() == "" ? this._currentRowIndexFlag : Convert.ToInt32(dtHistory.Rows[0]["RowIndexFlag"].ToString())));
  552. //先删除掉
  553. foreach (DataRow r in dr)
  554. {
  555. r.Delete();
  556. }
  557. //重新插入
  558. for (int i = 0; i < dtHistory.Rows.Count; i++)
  559. {
  560. if (dtHistory.Rows[i]["QualityRate"].ToString() != "" || dtHistory.Rows[i]["Balance"].ToString() != "")
  561. {
  562. DataRow drNew = DtRightDataSource.NewRow();
  563. drNew["QualityRate"] = dtHistory.Rows[i]["QualityRate"].ToString();
  564. drNew["Balance"] = dtHistory.Rows[i]["Balance"].ToString();
  565. drNew["QualityWages"] = dtHistory.Rows[i]["QualityWages"].ToString();
  566. drNew["RowIndexFlag"] = dtHistory.Rows[i]["RowIndexFlag"].ToString() == "" ? Convert.ToInt32(dtHistory.Rows[0]["RowIndexFlag"]) : Convert.ToInt32(dtHistory.Rows[i]["RowIndexFlag"].ToString());
  567. DtRightDataSource.Rows.Add(drNew);
  568. }
  569. }
  570. }
  571. if (dtLeft != null && dtLeft.Rows.Count > 0)
  572. {
  573. List<WCF.DataModels.PAMModule.WagesEntity> wagesentitys = new List<WCF.DataModels.PAMModule.WagesEntity>();
  574. for (int i = 0; i < dtLeft.Rows.Count; i++)
  575. {
  576. WCF.DataModels.PAMModule.WagesEntity wageentity = new WCF.DataModels.PAMModule.WagesEntity();
  577. wageentity.WagesTypeID = Convert.ToInt32(dtLeft.Rows[i]["WagesTypeID"]);
  578. wageentity.StandardWages = Convert.ToDecimal(dtLeft.Rows[i]["StandardWages"].ToString() == "" ? 0 : dtLeft.Rows[i]["StandardWages"]);
  579. wageentity.DamageSubsidyRate = Convert.ToDecimal(dtLeft.Rows[i]["DamageSubsidyRate"].ToString() == "" ? 1 : dtLeft.Rows[i]["DamageSubsidyRate"]);
  580. wageentity.DamageSubsidy = Convert.ToDecimal(dtLeft.Rows[i]["DamageSubsidy"].ToString() == "" ? 0 : dtLeft.Rows[i]["DamageSubsidy"]);
  581. wageentity.RSuperiorCoefficient = Convert.ToDecimal(dtLeft.Rows[i]["RSuperiorCoefficient"].ToString() == "" ? 1 : dtLeft.Rows[i]["RSuperiorCoefficient"]);
  582. wageentity.RQualifiedCoefficient = Convert.ToDecimal(dtLeft.Rows[i]["RQualifiedCoefficient"].ToString() == "" ? 1 : dtLeft.Rows[i]["RQualifiedCoefficient"]);
  583. wageentity.RepairSubsidyRate = Convert.ToDecimal(dtLeft.Rows[i]["RepairSubsidyRate"].ToString() == "" ? 1 : dtLeft.Rows[i]["RepairSubsidyRate"]);
  584. wageentity.RepairSubsidy = Convert.ToDecimal(dtLeft.Rows[i]["RepairSubsidy"].ToString() == "" ? 0 : dtLeft.Rows[i]["RepairSubsidy"]);
  585. //质量工价
  586. if (this.DtRightDataSource != null && this.DtRightDataSource.Rows.Count > 0)
  587. {
  588. List<WCF.DataModels.PAMModule.QualityWagesEntity> qualityWagesEntitys = new List<WCF.DataModels.PAMModule.QualityWagesEntity>();
  589. //for (int j = 0; j < DtRightDataSource.Rows.Count; j++)
  590. //{
  591. // DataRow[] drWagesTypeID = dtLeft.Select("RowIndexFlag=" + DtRightDataSource.Rows[j]["RowIndexFlag".ToString()]);
  592. //if (drWagesTypeID.Length > 0)
  593. //{
  594. DataRow[] dr2 = DtRightDataSource.Select("RowIndexFlag=" + dtLeft.Rows[i]["RowIndexFlag".ToString()]);
  595. foreach (DataRow r in dr2)
  596. {
  597. WCF.DataModels.PAMModule.QualityWagesEntity qualityWagesEntity = new WCF.DataModels.PAMModule.QualityWagesEntity();
  598. qualityWagesEntity.WagesTypeID = Convert.ToInt32(dtLeft.Rows[i]["WagesTypeID"]);
  599. qualityWagesEntity.QualityRate = Convert.ToDecimal(r["QualityRate"].ToString() == "" ? 0 : r["QualityRate"]) / 100;
  600. qualityWagesEntity.Balance = Convert.ToDecimal(r["Balance"].ToString() == "" ? 0 : r["Balance"]);
  601. qualityWagesEntity.QualityWages = Convert.ToDecimal(r["QualityWages"].ToString() == "" ? 0 : r["QualityWages"]);
  602. qualityWagesEntitys.Add(qualityWagesEntity);
  603. }
  604. // }
  605. // }
  606. wageentity.qualitywagesentity = qualityWagesEntitys;
  607. }
  608. wagesentitys.Add(wageentity);
  609. }
  610. entity.wagesentity = wagesentitys;
  611. }
  612. int returnValue = (int)DoAsync(new BaseAsyncMethod(() =>
  613. {
  614. return PAMModuleProxy.Service.SavePiecework(entity);
  615. }));
  616. if (returnValue >= 0) //等于O,表示未修改数据,影响行为0
  617. {
  618. // 提示信息
  619. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  620. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  621. this.DialogResult = DialogResult.OK;
  622. }
  623. else if (returnValue == -1)
  624. {
  625. PieceworkEntity pieceworkEndit = new PieceworkEntity();
  626. pieceworkEndit.PayPlanName = "";
  627. DataSet dsProductionData = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  628. {
  629. return PAMModuleProxy.Service.GetPieceworkData(pieceworkEndit);
  630. }));
  631. DataRow[] dr = dsProductionData.Tables[0].Select("PayPlanID=" + this.cmbPayPlan.SelectedValue.ToString());
  632. string errorMessage = string.Format("工资方案【{0}】已属于计件工资策略【{1}】,不能再被选择。", this.cmbPayPlan.Text, dr[0]["PieceTacticsName"].ToString());
  633. // 提示信息
  634. MessageBox.Show(errorMessage,
  635. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  636. }
  637. else if (returnValue == -2)
  638. {
  639. // 提示信息
  640. MessageBox.Show("工价分类不能重复在工资方案使用",
  641. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  642. }
  643. else if (returnValue == -3)
  644. {
  645. // 提示信息
  646. MessageBox.Show("质量区间不能重复",
  647. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  648. }
  649. }
  650. catch (Exception ex)
  651. {
  652. // 对异常进行共通处理
  653. ExceptionManager.HandleEventException(this.ToString(),
  654. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  655. }
  656. }
  657. #endregion
  658. #region 私有方法
  659. /// <summary>
  660. /// 绑定编辑数据
  661. /// </summary>
  662. private void BindData()
  663. {
  664. try
  665. {
  666. DataSet dsResultAccount = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  667. {
  668. return PAMModuleProxy.Service.GetPieceworkByID(Convert.ToInt32(this._PieceTacticsID));
  669. }));
  670. if (dsResultAccount != null && dsResultAccount.Tables[0].Rows.Count > 0)
  671. {
  672. //绑定主信息
  673. if (dsResultAccount.Tables[0].Rows[0]["PayPlanID"].ToString() != "")
  674. {
  675. this.cmbPayPlan.SelectedValue = dsResultAccount.Tables[0].Rows[0]["PayPlanID"].ToString();
  676. }
  677. this.txtPayPlanName.Text = dsResultAccount.Tables[0].Rows[0]["PieceTacticsName"].ToString();
  678. this.txtDamageCoefficient.Text = dsResultAccount.Tables[0].Rows[0]["DamageCoefficient"].ToString();
  679. this.chkDamageFlag.Checked = Convert.ToBoolean(Convert.ToInt32(dsResultAccount.Tables[0].Rows[0]["DamageFlag"]));
  680. //this.dkPieceProcedure.ProcedureID = Convert.ToInt32(dsResultAccount.Tables[0].Rows[0]["PieceProcedureID"]);
  681. //this.dkPieceProcedure.Text = dsResultAccount.Tables[0].Rows[0]["PieceProcedureName"].ToString();
  682. this.cmbPieceType.SelectedValue = Convert.ToInt32(dsResultAccount.Tables[0].Rows[0]["PieceType"]);
  683. this.txtUnqualifiedCoefficient.Text = dsResultAccount.Tables[0].Rows[0]["UnqualifiedCoefficient"].ToString();
  684. this.chkUnqualifiedFlag.Checked = Convert.ToBoolean(Convert.ToInt32(dsResultAccount.Tables[0].Rows[0]["UnqualifiedFlag"]));
  685. this.txtPieceCoefficient.Text = dsResultAccount.Tables[0].Rows[0]["PieceCoefficient"].ToString();
  686. this.chkQualifiedFlag.Checked = Convert.ToBoolean(Convert.ToInt32(dsResultAccount.Tables[0].Rows[0]["QualifiedFlag"]));
  687. //this.dkQualityBaseProcedure.ProcedureID = Convert.ToInt32(dsResultAccount.Tables[0].Rows[0]["QualityBaseProcedureID"]);
  688. //this.dkQualityBaseProcedure.Text = dsResultAccount.Tables[0].Rows[0]["QualityBaseProcedure"].ToString();
  689. this.txtQualifiedCoefficient.Text = dsResultAccount.Tables[0].Rows[0]["QualifiedCoefficient"].ToString();
  690. if (dsResultAccount.Tables[3].Rows.Count > 0)
  691. {
  692. DataRow[] dr1 = dsResultAccount.Tables[3].Select("ProcedureFlag=1");
  693. string IDS = "";
  694. string TextS = "";
  695. foreach (DataRow r1 in dr1)
  696. {
  697. TextS += r1["ProcedureName"].ToString() + ",";
  698. IDS += r1["ProcedureID"].ToString() + ",";
  699. }
  700. IDS = IDS.Trim(',');
  701. TextS = TextS.Trim(',');
  702. if (IDS != "")
  703. {
  704. this.dkPieceProcedure.Text = TextS;
  705. this.dkPieceProcedure.ProcedureIDS = IDS;
  706. }
  707. IDS = "";
  708. TextS = "";
  709. // 质量工序
  710. dr1 = dsResultAccount.Tables[3].Select("ProcedureFlag=2");
  711. foreach (DataRow r1 in dr1)
  712. {
  713. TextS += r1["ProcedureName"].ToString() + ",";
  714. IDS += r1["ProcedureID"].ToString() + ",";
  715. }
  716. IDS = IDS.Trim(',');
  717. TextS = TextS.Trim(',');
  718. if (IDS != "")
  719. {
  720. this.dkQualityBaseProcedure.Text = TextS;
  721. this.dkQualityBaseProcedure.ProcedureIDS = IDS;
  722. }
  723. }
  724. if (dsResultAccount != null && dsResultAccount.Tables[1].Rows.Count > 0)
  725. {
  726. //产品工价
  727. this._selectedrow = dsResultAccount.Tables[1].Rows.Count;
  728. for (int i = 0; i < dsResultAccount.Tables[1].Rows.Count; i++)
  729. {
  730. DataRow dr = this.DtLeftDataSource.NewRow();
  731. dr["WagesTypeID"] = dsResultAccount.Tables[1].Rows[i]["WagesTypeID"];
  732. dr["StandardWages"] = dsResultAccount.Tables[1].Rows[i]["StandardWages"];
  733. dr["DamageSubsidyRate"] = dsResultAccount.Tables[1].Rows[i]["DamageSubsidyRate"];
  734. dr["DamageSubsidy"] = dsResultAccount.Tables[1].Rows[i]["DamageSubsidy"];
  735. dr["RSuperiorCoefficient"] = dsResultAccount.Tables[1].Rows[i]["RSuperiorCoefficient"];
  736. dr["RQualifiedCoefficient"] = dsResultAccount.Tables[1].Rows[i]["RQualifiedCoefficient"];
  737. dr["RepairSubsidyRate"] = dsResultAccount.Tables[1].Rows[i]["RepairSubsidyRate"];
  738. dr["RepairSubsidy"] = dsResultAccount.Tables[1].Rows[i]["RepairSubsidy"];
  739. dr["RowIndexFlag"] = i;
  740. this.DtLeftDataSource.Rows.Add(dr);
  741. //this._selectedrow++;//用于过滤边条件
  742. if (dsResultAccount != null && dsResultAccount.Tables[2].Rows.Count > 0)
  743. {
  744. if (dsResultAccount.Tables[1].Rows[i]["WagesTypeID"].ToString() != "")
  745. {
  746. DataRow[] r = dsResultAccount.Tables[2].Select("WagesTypeID=" + dsResultAccount.Tables[1].Rows[i]["WagesTypeID"]);
  747. if (r.Length > 0)
  748. {
  749. foreach (DataRow rr in r)
  750. {
  751. DataRow dr2 = this.DtRightDataSource.NewRow();
  752. dr2["QualityRate"] = Convert.ToDecimal(rr["QualityRate"]) * 100;
  753. dr2["Balance"] = rr["Balance"];
  754. dr2["QualityWages"] = rr["QualityWages"];
  755. dr2["RowIndexFlag"] = i;
  756. this.DtRightDataSource.Rows.Add(dr2);
  757. }
  758. }
  759. }
  760. //else
  761. //{
  762. // DataRow dr2 = this.DtRightDataSource.NewRow();
  763. // dr2["QualityRate"] = "";
  764. // dr2["Balance"] = "";
  765. // dr2["QualityWages"] = "";
  766. // dr2["RowIndexFlag"] = i;
  767. // this.DtRightDataSource.Rows.Add(dr2);
  768. //}
  769. }
  770. }
  771. //this._currentRowIndexFlag = this._selectedrow;
  772. }
  773. DataView dv = this.DtRightDataSource.DefaultView;
  774. dv.RowFilter = "RowIndexFlag=0";
  775. this.dgvQualityWages.DataSource = dv.ToTable();// DtRightDataSource;
  776. this.dgvWages.DataSource = DtLeftDataSource;
  777. //this.dgvWages.DataSource = DtLeftDataSource;
  778. //this.dgvQualityWages.DataSource = DtRightDataSource.Copy();
  779. // this.dgvWages.Rows[DtLeftDataSource.Rows.Count - 1].Selected = true;
  780. }
  781. }
  782. catch (Exception ex)
  783. {
  784. throw ex;
  785. }
  786. }
  787. /// <summary>
  788. /// 绑定工种工资方案数据源
  789. /// </summary>
  790. private void BindJobsData()
  791. {
  792. try
  793. {
  794. DataSet dsResultAccount = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  795. {
  796. return PAMModuleProxy.Service.GetJobsPayPlanInfo(Convert.ToInt32(this._entityId));
  797. }));
  798. if (dsResultAccount != null && dsResultAccount.Tables[0].Rows.Count > 0)
  799. {
  800. this.dgvQualityWages.DataSource = dsResultAccount.Tables[0];
  801. }
  802. }
  803. catch (Exception ex)
  804. {
  805. throw ex;
  806. }
  807. }
  808. #endregion
  809. /// <summary>
  810. /// 删除行时
  811. /// </summary>
  812. /// <param name="sender"></param>
  813. /// <param name="e"></param>
  814. private void dgvGoods_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  815. {
  816. //try
  817. //{
  818. // if (e.Row.Index != -1)
  819. // {
  820. // if (this.dgvQualityWages.CurrentCell != null)
  821. // {
  822. // string JobsID = this.dgvQualityWages.Rows[e.Row.Index].Cells["GoodsID"].Value.ToString();
  823. // DataRow[] drSel = dtAllDataRight.Select(string.Format("WagesTypeID={0} and GoodsID={1}", this._currentWagesTypeID, JobsID));
  824. // if (drSel.Length > 0) //存在,需要更把此行删除
  825. // {
  826. // drSel[0].Delete();
  827. // }
  828. // }
  829. // }
  830. //}
  831. //catch (Exception ex)
  832. //{
  833. // throw ex;
  834. //}
  835. }
  836. /// <summary>
  837. /// 产品工价添加行事件
  838. /// </summary>
  839. /// <param name="sender"></param>
  840. /// <param name="e"></param>
  841. private void dgvWages_UserAddedRow(object sender, DataGridViewRowEventArgs e)
  842. {
  843. }
  844. /// <summary>
  845. /// 产品单元格验证事件
  846. /// </summary>
  847. /// <param name="sender"></param>
  848. /// <param name="e"></param>
  849. private void dgvWages_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
  850. {
  851. }
  852. private void dgvQualityWages_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
  853. {
  854. }
  855. /// <summary>
  856. /// 绑定计件工序类型
  857. /// </summary>
  858. private void BindPieceType()
  859. {
  860. DataTable dtPieceType = new DataTable();
  861. dtPieceType.Columns.Add("PieceTypeID");
  862. dtPieceType.Columns.Add("PieceType");
  863. DataRow dr = dtPieceType.NewRow();
  864. dr["PieceTypeID"] = 0;
  865. dr["PieceType"] = "工序计件";
  866. dtPieceType.Rows.Add(dr);
  867. dr = dtPieceType.NewRow();
  868. dr["PieceTypeID"] = 1;
  869. dr["PieceType"] = "经过工序计件";
  870. dtPieceType.Rows.Add(dr);
  871. this.cmbPieceType.DataSource = dtPieceType;
  872. this.cmbPieceType.DisplayMember = "PieceType";
  873. this.cmbPieceType.ValueMember = "PieceTypeID";
  874. }
  875. private void dgvQualityWages_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  876. {
  877. }
  878. private void F_PAM_0302_Shown(object sender, EventArgs e)
  879. {
  880. this.dgvQualityWages.IsSetInputColumnsColor = true;
  881. this.dgvWages.IsSetInputColumnsColor = true;
  882. }
  883. private void dgvWages_CellValidated(object sender, DataGridViewCellEventArgs e)
  884. {
  885. try
  886. {
  887. if (e.RowIndex < 0)
  888. {
  889. return;
  890. }
  891. DataGridViewRow rowItem = dgvWages.Rows[e.RowIndex];
  892. DataGridViewColumn columnItem = dgvWages.Columns[e.ColumnIndex];
  893. if ("StandardWages" == columnItem.Name)
  894. {
  895. object StandardWages = rowItem.Cells[e.ColumnIndex].FormattedValue;
  896. // 计算补贴
  897. if (StandardWages == null || StandardWages.ToString() == string.Empty)
  898. {
  899. StandardWages = 0;
  900. rowItem.Cells["StandardWages"].Value = 0;
  901. }
  902. // 2.损坯补贴系数
  903. object DamageSubsidyRate = rowItem.Cells["DamageSubsidyRate"].Value;
  904. if (DamageSubsidyRate == null || DamageSubsidyRate.ToString() == string.Empty)
  905. {
  906. DamageSubsidyRate = 1;
  907. rowItem.Cells["DamageSubsidyRate"].Value = 1;
  908. }
  909. rowItem.Cells["DamageSubsidy"].Value = Convert.ToDecimal(StandardWages.ToString()) * Convert.ToDecimal(DamageSubsidyRate.ToString());
  910. // 3.干补补贴系数
  911. object RepairSubsidyRate = rowItem.Cells["RepairSubsidyRate"].Value;
  912. if (RepairSubsidyRate == null || RepairSubsidyRate.ToString() == string.Empty)
  913. {
  914. RepairSubsidyRate = 1;
  915. rowItem.Cells["RepairSubsidyRate"].Value = 1;
  916. }
  917. rowItem.Cells["RepairSubsidy"].Value = Convert.ToDecimal(StandardWages.ToString()) * Convert.ToDecimal(RepairSubsidyRate.ToString());
  918. //this.dgvWages.Rows[this.dgvWages.CurrentCell.RowIndex].Cells["StandardWages"].Value = StandardWages;
  919. this._currentStandardWages = Convert.ToDecimal(StandardWages);
  920. // 计算补贴 end
  921. //更改标准价格的时候,遍历子表修改质量工价
  922. // 1.获取当前标识行信息
  923. object objRowIndexFlag = rowItem.Cells["RowIndexFlag"].Value;
  924. if (objRowIndexFlag != null || objRowIndexFlag.ToString() != "")
  925. {
  926. DataRow[] dr = this.DtRightDataSource.Select("RowIndexFlag=" + objRowIndexFlag);
  927. if (dr.Length > 0) //表示有质量工价
  928. {
  929. int rowIndex = 0;
  930. foreach (DataRow r in dr)
  931. {
  932. r["QualityWages"] = Convert.ToDecimal(StandardWages) + (r["Balance"].ToString() == "" ? 0 : Convert.ToDecimal(r["Balance"]));
  933. this.dgvQualityWages.Rows[rowIndex].Cells["QualityWages"].Value = r["QualityWages"];
  934. rowIndex++;
  935. }
  936. this.DtRightDataSource.AcceptChanges();
  937. }
  938. }
  939. }
  940. if ("DamageSubsidyRate" == columnItem.Name)
  941. {
  942. object DamageSubsidyRate = rowItem.Cells[e.ColumnIndex].FormattedValue;
  943. // 损坯补贴系数
  944. if (DamageSubsidyRate == null || DamageSubsidyRate.ToString() == string.Empty)
  945. {
  946. DamageSubsidyRate = 1;
  947. rowItem.Cells["DamageSubsidyRate"].Value = 1;
  948. }
  949. // 2.标准工价
  950. object StandardWages = rowItem.Cells["StandardWages"].Value;
  951. if (StandardWages == null || StandardWages.ToString() == string.Empty)
  952. {
  953. StandardWages = 0;
  954. rowItem.Cells["StandardWages"].Value = 0;
  955. }
  956. rowItem.Cells["DamageSubsidy"].Value = Convert.ToDecimal(StandardWages.ToString()) * Convert.ToDecimal(DamageSubsidyRate.ToString());
  957. // 计算补贴 end
  958. //rowItem.Cells["DamageSubsidyRate"].Value = DamageSubsidyRate;
  959. }
  960. if ("RepairSubsidyRate" == columnItem.Name)
  961. {
  962. object RepairSubsidyRate = rowItem.Cells[e.ColumnIndex].FormattedValue;
  963. // 计算补贴
  964. if (RepairSubsidyRate == null || RepairSubsidyRate.ToString() == string.Empty)
  965. {
  966. RepairSubsidyRate = 1;
  967. rowItem.Cells["RepairSubsidyRate"].Value = 1;
  968. }
  969. // 2.标准工价
  970. object StandardWages = rowItem.Cells["StandardWages"].Value;
  971. if (StandardWages == null || StandardWages.ToString() == string.Empty)
  972. {
  973. StandardWages = 0;
  974. rowItem.Cells["StandardWages"].Value = 0;
  975. }
  976. rowItem.Cells["RepairSubsidy"].Value = Convert.ToDecimal(StandardWages.ToString()) * Convert.ToDecimal(RepairSubsidyRate.ToString());
  977. // 计算补贴 end
  978. //rowItem.Cells["RepairSubsidyRate"].Value = RepairSubsidyRate;
  979. }
  980. }
  981. catch (Exception ex)
  982. {
  983. // 对异常进行共通处理
  984. ExceptionManager.HandleEventException(this.ToString(),
  985. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  986. }
  987. }
  988. private void dgvQualityWages_CellValidated(object sender, DataGridViewCellEventArgs e)
  989. {
  990. try
  991. {
  992. if (e.RowIndex < 0)
  993. {
  994. return;
  995. }
  996. DataGridViewRow rowItem = dgvQualityWages.Rows[e.RowIndex];
  997. DataGridViewColumn columnItem = dgvQualityWages.Columns[e.ColumnIndex];
  998. if ((e.ColumnIndex == 0 || e.ColumnIndex == 1) && e.RowIndex != -Constant.INT_IS_ONE)
  999. {
  1000. rowItem.Cells["RowIndexFlag1"].Value = this._currentRowIndexFlag;
  1001. }
  1002. if ("Balance" == columnItem.Name)
  1003. {
  1004. object Balance = rowItem.Cells[columnItem.Name].FormattedValue;
  1005. if (Balance == null || Balance.ToString() == string.Empty)
  1006. {
  1007. Balance = 0;
  1008. rowItem.Cells["Balance"].Value = 0;
  1009. }
  1010. rowItem.Cells["QualityWages"].Value = this._currentStandardWages + Convert.ToDecimal(Balance);
  1011. }
  1012. }
  1013. catch (Exception ex)
  1014. {
  1015. // 对异常进行共通处理
  1016. ExceptionManager.HandleEventException(this.ToString(),
  1017. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1018. }
  1019. }
  1020. }
  1021. }