ucResCcm.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. using System;
  2. using System.Collections;
  3. using System.Windows.Forms;
  4. using CoreFS.CA06;
  5. using Infragistics.Win;
  6. using Infragistics.Win.UltraWinGrid;
  7. using System.Drawing;
  8. namespace Core.StlMes.Client.LgCommon
  9. {
  10. public partial class ucResCcm : ucResBase
  11. {
  12. public bool allowSave = true; //是否允许修改实绩
  13. public bool allowSave1 = true; //是否允许修改实绩
  14. public bool allowSave2 = true; //是否允许修改实绩
  15. public bool allowSave3 = true; //是否允许修改实绩
  16. public ucResCcm()
  17. {
  18. InitializeComponent();
  19. }
  20. protected override void InitValuelist()
  21. {
  22. base.InitValuelist();
  23. try
  24. {
  25. ValueList vlist = ClsBusinessPack.GetValuelistLogic();
  26. ClsControlPack.SetGridValuelist(ref ultraGrid1, "BALEFLOWFLAG", ref vlist);
  27. ValueList vlist1 = ClsBusinessPack.GetValuelistDigital(5);
  28. ClsControlPack.SetGridValuelist(ref ultraGrid1, "BALEFLOWTIEMS", ref vlist1);
  29. }
  30. catch { }
  31. }
  32. public void GetValuelistProtectiveSlag(OpeBase ob)
  33. {
  34. try
  35. {
  36. ValueList vlist = ClsBusinessPack.GetValuelistProtectiveSlag(ob);
  37. ClsControlPack.SetGridValuelist(ref ultraGrid1, "PROTECTDTEG", ref vlist);
  38. }
  39. catch { }
  40. }
  41. public override void SetData(Hashtable ar)
  42. {
  43. base.SetData(ar);
  44. try
  45. {
  46. UltraGridRow row = ultraGrid1.Rows[0];
  47. ClsBusinessPack.GetNetWeightfromUI(row.Cells["PFBALEWGT"], row.Cells["BALELEAVEWGT"], row.Cells["MOULDWGT"]);
  48. }
  49. catch { }
  50. }
  51. private void ultraGrid1_KeyPress(object sender, KeyPressEventArgs e)
  52. {
  53. string strKey = this.ultraGrid1.ActiveCell.Column.ToString();
  54. if (strKey == "PFBALEWGT" || strKey == "BALELEAVEWGT" || strKey == "RSMOLSTLWGT" ||
  55. strKey == "BALEMOULDTIME" || strKey == "BALEFLOWTIEMS" || strKey == "BAKEO2TIEMS" ||
  56. strKey == "MWRAPTEMPT" || strKey == "MOULDWGT" || strKey == "MOULDWGT"||
  57. strKey == "PFBALETEMPT" || strKey == "MOULDBALEWGT" || strKey == "PROTECTDTEGDOSAGE" ||
  58. strKey == "RESIDUETHICKNESS" || strKey == "SWRAPREMAINWGT")
  59. {
  60. if (!(e.KeyChar == '\b') && ultraGrid1.ActiveRow.Cells[strKey].Value.ToString().Length >= 6)
  61. {
  62. e.Handled = true;
  63. }
  64. if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.'))
  65. {
  66. e.Handled = true;
  67. }
  68. if (e.KeyChar == '.')
  69. {
  70. char[] arrary = ultraGrid1.ActiveRow.Cells[strKey].Text.ToCharArray();
  71. if (arrary.Length == 0)
  72. {
  73. ultraGrid1.ActiveRow.Cells[strKey].Value = "0.";
  74. ultraGrid1.ActiveRow.Cells[strKey].SelStart = ultraGrid1.ActiveRow.Cells[strKey].Value.ToString().Length;
  75. e.Handled = true;
  76. }
  77. else
  78. {
  79. for (int i = 0; i < arrary.Length; i++)
  80. {
  81. if (arrary[i] == '.')
  82. e.Handled = true;
  83. }
  84. }
  85. }
  86. }
  87. if (strKey == "MEMO")
  88. {
  89. char[] arrary = ultraGrid1.ActiveRow.Cells[strKey].Text.ToCharArray();
  90. if (!(e.KeyChar == '\b') && arrary.Length >= 40)
  91. {
  92. // MessageBox.Show("生产记事不能超过40个字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  93. e.Handled = true;
  94. }
  95. }
  96. if (strKey == "PROTECTDTEG")
  97. {
  98. char[] arrary = ultraGrid1.ActiveRow.Cells[strKey].Text.ToCharArray();
  99. if (!(e.KeyChar == '\b') && arrary.Length >= 10)
  100. {
  101. // MessageBox.Show("保护渣名称不能超过10个字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  102. e.Handled = true;
  103. }
  104. }
  105. }
  106. protected override void ultraGrid1_AfterCellUpdate(object sender, CellEventArgs e)
  107. {
  108. base.ultraGrid1_AfterCellUpdate(sender, e);
  109. try
  110. {
  111. if (!e.Cell.Column.Hidden && e.Cell.Column.CellActivation == Activation.AllowEdit)
  112. {
  113. string strKey = e.Cell.Column.Key.ToUpper();
  114. UltraGridRow row = e.Cell.Row;
  115. if (strKey.Equals("PFBALEWGT") || strKey.Equals("BALELEAVEWGT"))
  116. {
  117. if (ultraGrid1.ActiveRow.Cells["PFBALEWGT"].Value == DBNull.Value || ultraGrid1.ActiveRow.Cells["BALELEAVEWGT"].Value == DBNull.Value)
  118. {
  119. allowSave = true;
  120. }
  121. try
  122. {
  123. if (Convert.ToDouble(ultraGrid1.ActiveRow.Cells["BALELEAVEWGT"].Value) > Convert.ToDouble(ultraGrid1.ActiveRow.Cells["PFBALEWGT"].Value))
  124. {
  125. e.Cell.Appearance.BackColor = Color.Red;
  126. MessageBox.Show("大包下台重量不能大于大包上台重量!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  127. allowSave = false;
  128. return;
  129. }
  130. else
  131. {
  132. if (ultraGrid1.ActiveRow.Cells["BALELEAVEWGT"].Appearance.BackColor == Color.Red)
  133. {
  134. ultraGrid1.ActiveRow.Cells["BALELEAVEWGT"].Appearance.BackColor = Color.Orange;
  135. }
  136. if (ultraGrid1.ActiveRow.Cells["PFBALEWGT"].Appearance.BackColor == Color.Red)
  137. {
  138. ultraGrid1.ActiveRow.Cells["PFBALEWGT"].Appearance.BackColor = Color.Orange;
  139. }
  140. allowSave = true;
  141. }
  142. }
  143. catch { }
  144. ClsBusinessPack.GetNetWeightfromUI(row.Cells["PFBALEWGT"], row.Cells["BALELEAVEWGT"], row.Cells["MOULDWGT"]);
  145. }
  146. if (strKey.Equals("BALEPFTIME") || strKey.Equals("BALELEAVETIME"))
  147. {
  148. if ((DateTime)ultraGrid1.ActiveRow.Cells["BALEPFTIME"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["BALELEAVETIME"].Value)
  149. {
  150. e.Cell.Appearance.BackColor = Color.Red;
  151. MessageBox.Show("大包上台时刻不能早于上包离台时刻!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  152. allowSave1 = false;
  153. return;
  154. }
  155. else
  156. {
  157. if (ultraGrid1.ActiveRow.Cells["BALEPFTIME"].Appearance.BackColor == Color.Red)
  158. {
  159. ultraGrid1.ActiveRow.Cells["BALEPFTIME"].Appearance.BackColor = Color.Orange;
  160. }
  161. if (ultraGrid1.ActiveRow.Cells["BALELEAVETIME"].Appearance.BackColor == Color.Red)
  162. {
  163. ultraGrid1.ActiveRow.Cells["BALELEAVETIME"].Appearance.BackColor = Color.Orange;
  164. }
  165. allowSave1 = true;
  166. }
  167. }
  168. if (strKey.Equals("BALESTARTTIME") || strKey.Equals("BALEENDTIME"))
  169. {
  170. if ((DateTime)ultraGrid1.ActiveRow.Cells["BALESTARTTIME"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["BALEENDTIME"].Value)
  171. {
  172. e.Cell.Appearance.BackColor = Color.Red;
  173. MessageBox.Show("大包开浇时刻不能早于大包停浇时刻!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  174. allowSave2 = false;
  175. return;
  176. }
  177. else
  178. {
  179. if (ultraGrid1.ActiveRow.Cells["BALESTARTTIME"].Appearance.BackColor == Color.Red)
  180. {
  181. ultraGrid1.ActiveRow.Cells["BALESTARTTIME"].Appearance.BackColor = Color.Orange;
  182. }
  183. if (ultraGrid1.ActiveRow.Cells["BALEENDTIME"].Appearance.BackColor == Color.Red)
  184. {
  185. ultraGrid1.ActiveRow.Cells["BALEENDTIME"].Appearance.BackColor = Color.Orange;
  186. }
  187. allowSave2 = true;
  188. }
  189. }
  190. if (strKey.Equals("MWRAPSTARTTIME") || strKey.Equals("MWRAPENDTIME"))
  191. {
  192. if ((DateTime)ultraGrid1.ActiveRow.Cells["MWRAPSTARTTIME"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["MWRAPENDTIME"].Value)
  193. {
  194. e.Cell.Appearance.BackColor = Color.Red;
  195. MessageBox.Show("中包开浇时刻不能早于中包停浇时刻!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  196. allowSave3 = false;
  197. return;
  198. }
  199. else
  200. {
  201. if (ultraGrid1.ActiveRow.Cells["MWRAPSTARTTIME"].Appearance.BackColor == Color.Red)
  202. {
  203. ultraGrid1.ActiveRow.Cells["MWRAPSTARTTIME"].Appearance.BackColor = Color.Orange;
  204. }
  205. if (ultraGrid1.ActiveRow.Cells["MWRAPENDTIME"].Appearance.BackColor == Color.Red)
  206. {
  207. ultraGrid1.ActiveRow.Cells["MWRAPENDTIME"].Appearance.BackColor = Color.Orange;
  208. }
  209. allowSave3 = true;
  210. }
  211. }
  212. }
  213. }
  214. catch { }
  215. }
  216. protected override void ultraGrid1_CellChange(object sender, CellEventArgs e)
  217. {
  218. base.ultraGrid1_CellChange(sender, e);
  219. try
  220. {
  221. if (!e.Cell.Column.Hidden && e.Cell.Column.CellActivation == Activation.AllowEdit)
  222. {
  223. string strKey = e.Cell.Column.Key.ToUpper();
  224. UltraGridRow row = e.Cell.Row;
  225. if (strKey.Equals("PFBALEWGT") || strKey.Equals("BALELEAVEWGT"))
  226. ClsBusinessPack.GetNetWeightfromUI(row.Cells["PFBALEWGT"], row.Cells["BALELEAVEWGT"], row.Cells["MOULDWGT"]);
  227. }
  228. }
  229. catch { }
  230. }
  231. protected override void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)
  232. {
  233. base.ultraGrid1_ClickCellButton(sender, e);
  234. try
  235. {
  236. string strKey = e.Cell.Column.Key.ToUpper();
  237. if (e.Cell.Column.DataType != typeof(DateTime))
  238. {
  239. frmInputDecimal frm = new frmInputDecimal(Convert.ToString(e.Cell.Text));
  240. frm.Location = ClsControlPack.GetChildWindowLocation(frm.Size);
  241. if (frm.ShowDialog() == DialogResult.OK)
  242. {
  243. if (!frm.ValueChanged) return;
  244. e.Cell.Value = frm.Value;
  245. ultraGrid1.UpdateData();
  246. }
  247. }
  248. }
  249. catch { }
  250. }
  251. }
  252. }