frmPopCheckRec.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. using CoreFS.CA06;using Pur.Entity;
  10. using System.Collections;
  11. using Core.Mes.Client.Comm.Tool;
  12. using Pur.Entity.configureEntity;
  13. using Core.Mes.Client.Comm.Control;
  14. using com.hnshituo.pur.vo;
  15. using Infragistics.Win;
  16. using Pur.Entity;
  17. namespace Pur.ck
  18. {
  19. public partial class frmPopCheckRec : FrmPmsBase
  20. {
  21. object Qb_newcellvalue = null;
  22. public frmPopCheckRec(OpeBase ob, DataTable dt)
  23. {
  24. InitializeComponent();
  25. this.ob = ob;
  26. GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);//绑定物料分类表frmCheckItem
  27. GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], "RECNOTPASSQTY", "RECPASSQTY");
  28. initRec();
  29. }
  30. /// <summary>
  31. /// 初始化合格量为收货量
  32. /// </summary>
  33. private void initRec()
  34. {
  35. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  36. {
  37. ultraGrid1.Rows[i].Cells["RecNotPassQty"].Value = 0; ;//不合格量
  38. ultraGrid1.Rows[i].Cells["RecPassQty"].Value = ultraGrid1.Rows[i].Cells["RECQTY"].Value; ;//不合格量
  39. }
  40. }
  41. /// <summary>
  42. /// 值改变同时计算出相应的单元格值
  43. /// </summary>
  44. /// <param name="sender"></param>
  45. /// <param name="e"></param>
  46. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  47. {
  48. Qb_newcellvalue = e.Cell.Value;
  49. ultraGrid1.UpdateData();
  50. if (e.Cell.Value != null)
  51. {
  52. double b_newcellvalue = double.Parse(e.Cell.Value.ToString());
  53. if (e.Cell.Column.Key == "RECPASSQTY")//合格量
  54. {
  55. double bRECQTY = double.Parse(e.Cell.Row.Cells["RECQTY"].Value.ToString());//收货量
  56. double bRECNOTPASSQTY =0;
  57. double.TryParse(e.Cell.Row.Cells["RECNOTPASSQTY"].Value.ToString(),out bRECNOTPASSQTY);//不合格量
  58. if (bRECNOTPASSQTY != bRECQTY - b_newcellvalue)//若不相等则计算不合格量
  59. {
  60. bRECNOTPASSQTY = bRECQTY - b_newcellvalue;
  61. if (bRECNOTPASSQTY < 0)
  62. {
  63. e.Cell.Value = Qb_newcellvalue;//不允许大于收获量
  64. }
  65. else
  66. {
  67. e.Cell.Row.Cells["RECNOTPASSQTY"].Value = bRECQTY - b_newcellvalue;
  68. }
  69. }
  70. }
  71. else if (e.Cell.Column.Key == "RECNOTPASSQTY")//不合格量
  72. {
  73. double bRECQTY = double.Parse(e.Cell.Row.Cells["RECQTY"].Value.ToString());//收货量
  74. double bRECPASSQTY = 0;
  75. double.TryParse(e.Cell.Row.Cells["RECPASSQTY"].Value.ToString(), out bRECPASSQTY);//合格量
  76. if (bRECPASSQTY != bRECQTY - b_newcellvalue)//若不相等则计算合格量
  77. {
  78. bRECPASSQTY = bRECQTY - b_newcellvalue;
  79. if (bRECPASSQTY < 0)
  80. {
  81. e.Cell.Value = Qb_newcellvalue;//不允许大于收获量
  82. }
  83. else
  84. {
  85. e.Cell.Row.Cells["RECPASSQTY"].Value = bRECQTY - b_newcellvalue;
  86. }
  87. }
  88. }
  89. }
  90. }
  91. /// <summary>
  92. /// 开始初检
  93. /// </summary>
  94. private void checkRec()
  95. {
  96. ultraGrid1.UpdateData();
  97. ArrayList alCkRecBillEntity = new ArrayList();
  98. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  99. {
  100. PurCkRecBillEntity CkRecBillEntity = new PurCkRecBillEntity();
  101. CkRecBillEntity.RecId = ultraGrid1.Rows[i].Cells["RecId"].Value.ToString();
  102. CkRecBillEntity.RecPassQty = double.Parse(ultraGrid1.Rows[i].Cells["RecPassQty"].Value.ToString());//合格量
  103. CkRecBillEntity.Status = "2";
  104. alCkRecBillEntity.Add(CkRecBillEntity);
  105. }
  106. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.ck.service.CkRecBillService", "checkRec", new object[] { alCkRecBillEntity });
  107. if (crt.Resultcode != 0)
  108. {
  109. MessageUtil.ShowTips("初检失败 " + crt.Resultmsg);
  110. return;
  111. }
  112. MessageUtil.ShowTips("初检成功");
  113. this.Close();
  114. }
  115. /// <summary>
  116. /// 按钮控件
  117. /// </summary>
  118. /// <param name="sender"></param>
  119. /// <param name="e"></param>
  120. private void barsManagerButon_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  121. {
  122. switch (e.Tool.Key.ToString())
  123. {
  124. case "Query":
  125. {
  126. }
  127. break;
  128. case "conFirmation":
  129. {
  130. checkRec();
  131. }
  132. break;
  133. case "ESC":
  134. {
  135. this.Close();
  136. }
  137. break;
  138. }
  139. }
  140. }
  141. }