ucResCas.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. using System;
  2. using System.Collections;
  3. using System.Windows.Forms;
  4. using Infragistics.Win;
  5. using Infragistics.Win.UltraWinGrid;
  6. using System.Drawing;
  7. namespace Core.StlMes.Client.LgCommon
  8. {
  9. public partial class ucResCas : ucResBase
  10. {
  11. public ucResCas()
  12. {
  13. InitializeComponent();
  14. }
  15. public bool allowSave = true; //是否允许修改实绩
  16. public bool allowSave1 = true; //是否允许修改实绩
  17. public bool allowSave2 = true; //是否允许修改实绩
  18. public bool allowSave3 = true; //是否允许修改实绩
  19. protected override void InitValuelist()
  20. {
  21. base.InitValuelist();
  22. try
  23. {
  24. ValueList vlist = ClsBusinessPack.GetValuelistLogic();
  25. ClsControlPack.SetGridValuelist(ref ultraGrid1, "DESLAGGFLAG", ref vlist);
  26. }
  27. catch { }
  28. }
  29. public override void SetData(Hashtable ar)
  30. {
  31. base.SetData(ar);
  32. try
  33. {
  34. UltraGridRow row = ultraGrid1.Rows[0];
  35. ClsBusinessPack.GetTimeSpanfromUI(row.Cells["ARRIVETIME"], row.Cells["LEAVETIME"], row.Cells["STAYTIME"]);
  36. ClsBusinessPack.GetTimeSpanfromUI(row.Cells["BLOWARSTARTTIME"], row.Cells["BLOWARENDTIME"], row.Cells["BLOWARTIME"]);
  37. ClsBusinessPack.GetTimeSpanfromUI(row.Cells["FEEDSILKBEGINTIME"], row.Cells["FEEDSILKCLOSETIME"], row.Cells["FEEDSILKTIME"]);
  38. ClsBusinessPack.GetNetWeightfromUI(row.Cells["LEAVEWGT"], row.Cells["ARRIVEWGT"], row.Cells["NETWGT"]);
  39. }
  40. catch { }
  41. }
  42. protected override void ultraGrid1_AfterCellUpdate(object sender, CellEventArgs e)
  43. {
  44. base.ultraGrid1_AfterCellUpdate(sender, e);
  45. try
  46. {
  47. if (!e.Cell.Column.Hidden && e.Cell.Column.CellActivation == Activation.AllowEdit)
  48. {
  49. string strKey = e.Cell.Column.Key.ToUpper();
  50. UltraGridRow row = e.Cell.Row;
  51. if (strKey.Equals("ARRIVETIME") || strKey.Equals("LEAVETIME"))
  52. {
  53. if ((DateTime)ultraGrid1.ActiveRow.Cells["ARRIVETIME"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["LEAVETIME"].Value)
  54. {
  55. e.Cell.Appearance.BackColor = Color.Red;
  56. MessageBox.Show("出站时间不能早于入站时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  57. allowSave = false;
  58. return;
  59. }
  60. else
  61. {
  62. if (ultraGrid1.ActiveRow.Cells["ARRIVETIME"].Appearance.BackColor == Color.Red)
  63. {
  64. ultraGrid1.ActiveRow.Cells["ARRIVETIME"].Appearance.BackColor = Color.Orange;
  65. }
  66. if (ultraGrid1.ActiveRow.Cells["LEAVETIME"].Appearance.BackColor == Color.Red)
  67. {
  68. ultraGrid1.ActiveRow.Cells["LEAVETIME"].Appearance.BackColor = Color.Orange;
  69. }
  70. allowSave = true;
  71. }
  72. ClsBusinessPack.GetTimeSpanfromUI(row.Cells["ARRIVETIME"], row.Cells["LEAVETIME"], row.Cells["STAYTIME"]);
  73. }
  74. else if (strKey.Equals("BLOWARSTARTTIME") || strKey.Equals("BLOWARENDTIME"))
  75. {
  76. if ((DateTime)ultraGrid1.ActiveRow.Cells["BLOWARSTARTTIME"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["BLOWARENDTIME"].Value)
  77. {
  78. e.Cell.Appearance.BackColor = Color.Red;
  79. MessageBox.Show("吹氩结束时间不能早于吹氩开始时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  80. allowSave1 = false;
  81. return;
  82. }
  83. else
  84. {
  85. if (ultraGrid1.ActiveRow.Cells["BLOWARSTARTTIME"].Appearance.BackColor == Color.Red)
  86. {
  87. ultraGrid1.ActiveRow.Cells["BLOWARSTARTTIME"].Appearance.BackColor = Color.Orange;
  88. }
  89. if (ultraGrid1.ActiveRow.Cells["BLOWARENDTIME"].Appearance.BackColor == Color.Red)
  90. {
  91. ultraGrid1.ActiveRow.Cells["BLOWARENDTIME"].Appearance.BackColor = Color.Orange;
  92. }
  93. allowSave1 = true;
  94. }
  95. ClsBusinessPack.GetTimeSpanfromUI(row.Cells["BLOWARSTARTTIME"], row.Cells["BLOWARENDTIME"], row.Cells["BLOWARTIME"]);
  96. }
  97. else if (strKey.Equals("FEEDSILKBEGINTIME") || strKey.Equals("FEEDSILKCLOSETIME"))
  98. {
  99. if ((DateTime)ultraGrid1.ActiveRow.Cells["FEEDSILKBEGINTIME"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["FEEDSILKCLOSETIME"].Value)
  100. {
  101. e.Cell.Appearance.BackColor = Color.Red;
  102. MessageBox.Show("喂丝结束时间不能早于喂丝开始时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  103. allowSave2 = false;
  104. return;
  105. }
  106. else
  107. {
  108. if (ultraGrid1.ActiveRow.Cells["FEEDSILKBEGINTIME"].Appearance.BackColor == Color.Red)
  109. {
  110. ultraGrid1.ActiveRow.Cells["FEEDSILKBEGINTIME"].Appearance.BackColor = Color.Orange;
  111. }
  112. if (ultraGrid1.ActiveRow.Cells["FEEDSILKCLOSETIME"].Appearance.BackColor == Color.Red)
  113. {
  114. ultraGrid1.ActiveRow.Cells["FEEDSILKCLOSETIME"].Appearance.BackColor = Color.Orange;
  115. }
  116. allowSave2 = true;
  117. }
  118. ClsBusinessPack.GetTimeSpanfromUI(row.Cells["FEEDSILKBEGINTIME"], row.Cells["FEEDSILKCLOSETIME"], row.Cells["FEEDSILKTIME"]);
  119. }
  120. else if (strKey.Equals("ARRIVEWGT") || strKey.Equals("LEAVEWGT"))
  121. {
  122. if (ultraGrid1.ActiveRow.Cells["ARRIVEWGT"].Value == DBNull.Value || ultraGrid1.ActiveRow.Cells["LEAVEWGT"].Value == DBNull.Value)
  123. {
  124. allowSave3 = true;
  125. }
  126. try
  127. {
  128. if (Convert.ToDouble(ultraGrid1.ActiveRow.Cells["ARRIVEWGT"].Value) > Convert.ToDouble(ultraGrid1.ActiveRow.Cells["LEAVEWGT"].Value))
  129. {
  130. e.Cell.Appearance.BackColor = Color.Red;
  131. MessageBox.Show("空包重量不能大于重包重量!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  132. allowSave3 = false;
  133. return;
  134. }
  135. else
  136. {
  137. if (ultraGrid1.ActiveRow.Cells["ARRIVEWGT"].Appearance.BackColor == Color.Red)
  138. {
  139. ultraGrid1.ActiveRow.Cells["ARRIVEWGT"].Appearance.BackColor = Color.Orange;
  140. }
  141. if (ultraGrid1.ActiveRow.Cells["LEAVEWGT"].Appearance.BackColor == Color.Red)
  142. {
  143. ultraGrid1.ActiveRow.Cells["LEAVEWGT"].Appearance.BackColor = Color.Orange;
  144. }
  145. allowSave3 = true;
  146. }
  147. }
  148. catch { }
  149. ClsBusinessPack.GetNetWeightfromUI(row.Cells["LEAVEWGT"], row.Cells["ARRIVEWGT"], row.Cells["NETWGT"]);
  150. }
  151. }
  152. }
  153. catch { }
  154. }
  155. protected override void ultraGrid1_CellChange(object sender, CellEventArgs e)
  156. {
  157. base.ultraGrid1_CellChange(sender, e);
  158. try
  159. {
  160. if (!e.Cell.Column.Hidden && e.Cell.Column.CellActivation == Activation.AllowEdit)
  161. {
  162. string strKey = e.Cell.Column.Key.ToUpper();
  163. UltraGridRow row = e.Cell.Row;
  164. if (strKey.Equals("ARRIVEWGT") || strKey.Equals("LEAVEWGT"))
  165. ClsBusinessPack.GetNetWeightfromUI(row.Cells["LEAVEWGT"], row.Cells["ARRIVEWGT"], row.Cells["NETWGT"]);
  166. }
  167. }
  168. catch { }
  169. }
  170. private void ultraGrid1_KeyPress(object sender, KeyPressEventArgs e)
  171. {
  172. string strKey = this.ultraGrid1.ActiveCell.Column.ToString();
  173. if (strKey == "ARRIVEWGT" || strKey == "LEAVEWGT" || strKey == "ARCONSUME" ||
  174. strKey == "ARRIVEO2"|| strKey == "LEAVEO2" || strKey == "RESIDUETHICKNESS" ||
  175. strKey == "MANTLENUM"|| strKey == "FLEXIBLEBLOWTIME" || strKey == "BLOWARPRESS" ||
  176. strKey == "TWSTEELWGT"|| strKey == "ARFTEMPT" || strKey == "ARBTEMPT" )
  177. {
  178. if (!(e.KeyChar == '\b')&&ultraGrid1.ActiveRow.Cells[strKey].Value.ToString().Length >= 6)
  179. {
  180. e.Handled = true;
  181. }
  182. if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.'))
  183. {
  184. e.Handled = true;
  185. }
  186. if (e.KeyChar == '.')
  187. {
  188. char[] arrary = ultraGrid1.ActiveRow.Cells[strKey].Text.ToCharArray();
  189. if (arrary.Length == 0)
  190. {
  191. ultraGrid1.ActiveRow.Cells[strKey].Value = "0.";
  192. ultraGrid1.ActiveRow.Cells[strKey].SelStart = ultraGrid1.ActiveRow.Cells[strKey].Value.ToString().Length;
  193. e.Handled = true;
  194. }
  195. else
  196. {
  197. for (int i = 0; i < arrary.Length; i++)
  198. {
  199. if (arrary[i] == '.')
  200. e.Handled = true;
  201. }
  202. }
  203. }
  204. }
  205. }
  206. protected override void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)
  207. {
  208. base.ultraGrid1_ClickCellButton(sender, e);
  209. try
  210. {
  211. string strKey = e.Cell.Column.Key.ToUpper();
  212. if (e.Cell.Column.DataType != typeof(DateTime))
  213. {
  214. frmInputDecimal frm = new frmInputDecimal(Convert.ToString(e.Cell.Text));
  215. frm.Location = ClsControlPack.GetChildWindowLocation(frm.Size);
  216. if (frm.ShowDialog() == DialogResult.OK)
  217. {
  218. if (!frm.ValueChanged) return;
  219. e.Cell.Value = frm.Value;
  220. ultraGrid1.UpdateData();
  221. }
  222. }
  223. }
  224. catch { }
  225. }
  226. }
  227. }