ucResLfs.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 ucResLfs : ucResBase
  10. {
  11. public bool allowSave = true; //是否允许修改实绩
  12. public bool allowSave1 = true; //是否允许修改实绩
  13. public bool allowSave2 = true; //是否允许修改实绩
  14. public ucResLfs()
  15. {
  16. InitializeComponent();
  17. }
  18. public override void SetData(Hashtable ar)
  19. {
  20. base.SetData(ar);
  21. try
  22. {
  23. UltraGridRow row = ultraGrid1.Rows[0];
  24. ClsBusinessPack.GetTimeSpanfromUI(row.Cells["ARRIVETIME"], row.Cells["LEAVETIME"], row.Cells["REFINETIME"]);
  25. ClsBusinessPack.GetTimeSpanfromUI(row.Cells["BEGINBLOWAR"], row.Cells["ENDBLOWAR"], row.Cells["BLOWARTIME"]);
  26. ClsBusinessPack.GetTimeSpanfromUI(row.Cells["REPOSEBEGINTIME"], row.Cells["REPOSECLOSETIME"], row.Cells["REPOSETIME"]);
  27. }
  28. catch { }
  29. }
  30. private void ultraGrid1_KeyPress(object sender, KeyPressEventArgs e)
  31. {
  32. string strKey = this.ultraGrid1.ActiveCell.Column.ToString();
  33. if (strKey == "ARRIVETEMPT" || strKey == "LEAVETEMPT" || strKey == "ARRIVEO2" ||
  34. strKey == "LEAVEO2" || strKey == "ARCONSUME" || strKey == "MRTCONSUME" ||
  35. strKey == "SELETIME" || strKey == "FLEXIBLEBLOWTIME" || strKey == "RESIDUETHICKNESS")
  36. {
  37. if (!(e.KeyChar == '\b') && ultraGrid1.ActiveRow.Cells[strKey].Value.ToString().Length >= 6)
  38. {
  39. e.Handled = true;
  40. }
  41. if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.'))
  42. {
  43. e.Handled = true;
  44. }
  45. if (e.KeyChar == '.')
  46. {
  47. char[] arrary = ultraGrid1.ActiveRow.Cells[strKey].Text.ToCharArray();
  48. if (arrary.Length == 0)
  49. {
  50. ultraGrid1.ActiveRow.Cells[strKey].Value = "0.";
  51. ultraGrid1.ActiveRow.Cells[strKey].SelStart = ultraGrid1.ActiveRow.Cells[strKey].Value.ToString().Length;
  52. e.Handled = true;
  53. }
  54. else
  55. {
  56. for (int i = 0; i < arrary.Length; i++)
  57. {
  58. if (arrary[i] == '.')
  59. e.Handled = true;
  60. }
  61. }
  62. }
  63. }
  64. if (strKey == "MEMO")
  65. {
  66. char[] arrary = ultraGrid1.ActiveRow.Cells[strKey].Text.ToCharArray();
  67. if (!(e.KeyChar == '\b')&&arrary.Length >= 100)
  68. {
  69. MessageBox.Show("生产记事的不能超过一百个字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  70. e.Handled = true;
  71. }
  72. }
  73. }
  74. protected override void ultraGrid1_AfterCellUpdate(object sender, CellEventArgs e)
  75. {
  76. base.ultraGrid1_AfterCellUpdate(sender, e);
  77. try
  78. {
  79. if (!e.Cell.Column.Hidden && e.Cell.Column.CellActivation == Activation.AllowEdit)
  80. {
  81. string strKey = e.Cell.Column.Key.ToUpper();
  82. UltraGridRow row = e.Cell.Row;
  83. if (strKey.Equals("ARRIVETIME") || strKey.Equals("LEAVETIME"))
  84. {
  85. if ((DateTime)ultraGrid1.ActiveRow.Cells["ARRIVETIME"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["LEAVETIME"].Value)
  86. {
  87. e.Cell.Appearance.BackColor = Color.Red;
  88. MessageBox.Show("出站时间不能早于入站时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  89. allowSave = false;
  90. return;
  91. }
  92. else
  93. {
  94. if (ultraGrid1.ActiveRow.Cells["ARRIVETIME"].Appearance.BackColor == Color.Red)
  95. {
  96. ultraGrid1.ActiveRow.Cells["ARRIVETIME"].Appearance.BackColor = Color.Orange;
  97. }
  98. if (ultraGrid1.ActiveRow.Cells["LEAVETIME"].Appearance.BackColor == Color.Red)
  99. {
  100. ultraGrid1.ActiveRow.Cells["LEAVETIME"].Appearance.BackColor = Color.Orange;
  101. }
  102. allowSave = true;
  103. }
  104. ClsBusinessPack.GetTimeSpanfromUI(row.Cells["ARRIVETIME"], row.Cells["LEAVETIME"], row.Cells["REFINETIME"]);
  105. }
  106. else if (strKey.Equals("BEGINBLOWAR") || strKey.Equals("ENDBLOWAR"))
  107. {
  108. if ((DateTime)ultraGrid1.ActiveRow.Cells["BEGINBLOWAR"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["ENDBLOWAR"].Value)
  109. {
  110. e.Cell.Appearance.BackColor = Color.Red;
  111. MessageBox.Show("吹氩结束时间不能早于吹氩开始时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  112. allowSave1 = false;
  113. return;
  114. }
  115. else
  116. {
  117. if (ultraGrid1.ActiveRow.Cells["BEGINBLOWAR"].Appearance.BackColor == Color.Red)
  118. {
  119. ultraGrid1.ActiveRow.Cells["BEGINBLOWAR"].Appearance.BackColor = Color.Orange;
  120. }
  121. if (ultraGrid1.ActiveRow.Cells["ENDBLOWAR"].Appearance.BackColor == Color.Red)
  122. {
  123. ultraGrid1.ActiveRow.Cells["ENDBLOWAR"].Appearance.BackColor = Color.Orange;
  124. }
  125. allowSave1 = true;
  126. }
  127. ClsBusinessPack.GetTimeSpanfromUI(row.Cells["BEGINBLOWAR"], row.Cells["ENDBLOWAR"], row.Cells["BLOWARTIME"]);
  128. }
  129. else if (strKey.Equals("REPOSEBEGINTIME") || strKey.Equals("REPOSECLOSETIME"))
  130. {
  131. if ((DateTime)ultraGrid1.ActiveRow.Cells["REPOSEBEGINTIME"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["REPOSECLOSETIME"].Value)
  132. {
  133. e.Cell.Appearance.BackColor = Color.Red;
  134. MessageBox.Show("处理结束时间不能早于处理开始时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  135. allowSave2 = false;
  136. return;
  137. }
  138. else
  139. {
  140. if (ultraGrid1.ActiveRow.Cells["REPOSEBEGINTIME"].Appearance.BackColor == Color.Red)
  141. {
  142. ultraGrid1.ActiveRow.Cells["REPOSEBEGINTIME"].Appearance.BackColor = Color.Orange;
  143. }
  144. if (ultraGrid1.ActiveRow.Cells["REPOSECLOSETIME"].Appearance.BackColor == Color.Red)
  145. {
  146. ultraGrid1.ActiveRow.Cells["REPOSECLOSETIME"].Appearance.BackColor = Color.Orange;
  147. }
  148. allowSave2 = true;
  149. }
  150. ClsBusinessPack.GetTimeSpanfromUI(row.Cells["REPOSEBEGINTIME"], row.Cells["REPOSECLOSETIME"], row.Cells["REPOSETIME"]);
  151. }
  152. }
  153. }
  154. catch { }
  155. }
  156. protected override void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)
  157. {
  158. base.ultraGrid1_ClickCellButton(sender, e);
  159. try
  160. {
  161. string strKey = e.Cell.Column.Key.ToUpper();
  162. if (e.Cell.Column.DataType != typeof(DateTime))
  163. {
  164. frmInputDecimal frm = new frmInputDecimal(Convert.ToString(e.Cell.Text));
  165. frm.Location = ClsControlPack.GetChildWindowLocation(frm.Size);
  166. if (frm.ShowDialog() == DialogResult.OK)
  167. {
  168. if (!frm.ValueChanged) return;
  169. e.Cell.Value = frm.Value;
  170. ultraGrid1.UpdateData();
  171. }
  172. }
  173. }
  174. catch { }
  175. }
  176. }
  177. }