ucResCast.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. using System;
  2. using System.Windows.Forms;
  3. using CoreFS.CA06;
  4. using Infragistics.Win;
  5. using Infragistics.Win.UltraWinGrid;
  6. namespace Core.StlMes.Client.LgCommon
  7. {
  8. public partial class ucResCast : ucResBase
  9. {
  10. public ucResCast()
  11. {
  12. InitializeComponent();
  13. }
  14. private void ultraGrid1_KeyPress(object sender, KeyPressEventArgs e)
  15. {
  16. string strKey = this.ultraGrid1.ActiveCell.Column.ToString();
  17. if (strKey == "S1CRYSTALCODE" || strKey == "S2CRYSTALCODE" || strKey == "S3CRYSTALCODE" ||
  18. strKey == "S4CRYSTALCODE" || strKey == "S5CRYSTALCODE" || strKey == "S6CRYSTALCODE")
  19. {
  20. if (!(Char.IsNumber(e.KeyChar)&& ultraGrid1.ActiveRow.Cells[strKey].Value.ToString().Length <= 6)&& e.KeyChar != '\b')
  21. {
  22. e.Handled = true;
  23. }
  24. }
  25. if (strKey == "MWRAPNO")
  26. {
  27. if (!(Char.IsNumber(e.KeyChar) && ultraGrid1.ActiveRow.Cells[strKey].Value.ToString().Length <= 10) && e.KeyChar != '\b')
  28. {
  29. e.Handled = true;
  30. }
  31. }
  32. if (strKey == "S1CRPASSSTEELWEIGHT" || strKey == "S2CRPASSSTEELWEIGHT" || strKey == "S3CRPASSSTEELWEIGHT" ||
  33. strKey == "S4CRPASSSTEELWEIGHT" || strKey == "S5CRPASSSTEELWEIGHT" || strKey == "S6CRPASSSTEELWEIGHT" ||
  34. strKey == "S1CUTFRONT" || strKey == "S2CUTFRONT" || strKey == "S3CUTFRONT"||
  35. strKey == "S4CUTFRONT" || strKey == "S5CUTFRONT" || strKey == "S6CUTFRONT"||
  36. strKey == "S1CUTBACK" || strKey == "S2CUTBACK" || strKey == "S3CUTBACK"||
  37. strKey == "S4CUTBACK" || strKey == "S5CUTBACK" || strKey == "S6CUTBACK"||
  38. strKey == "MWRAPBESTROWDOSAGE")
  39. {
  40. if (!(e.KeyChar == '\b') && ultraGrid1.ActiveRow.Cells[strKey].Value.ToString().Length >= 6)
  41. {
  42. e.Handled = true;
  43. }
  44. if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.'))
  45. {
  46. e.Handled = true;
  47. }
  48. if (e.KeyChar == '.')
  49. {
  50. char[] arrary = ultraGrid1.ActiveRow.Cells[strKey].Text.ToCharArray();
  51. if (arrary.Length == 0)
  52. {
  53. ultraGrid1.ActiveRow.Cells[strKey].Value = "0.";
  54. ultraGrid1.ActiveRow.Cells[strKey].SelStart = ultraGrid1.ActiveRow.Cells[strKey].Value.ToString().Length;
  55. e.Handled = true;
  56. }
  57. else
  58. {
  59. for (int i = 0; i < arrary.Length; i++)
  60. {
  61. if (arrary[i] == '.')
  62. e.Handled = true;
  63. }
  64. }
  65. }
  66. }
  67. if (strKey == "MWRAPBESTROWNAME")
  68. {
  69. char[] arrary = ultraGrid1.ActiveRow.Cells[strKey].Text.ToCharArray();
  70. if (!(e.KeyChar == '\b') && arrary.Length > 10)
  71. {
  72. // MessageBox.Show("中包覆盖剂名不能超过一十个字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  73. e.Handled = true;
  74. }
  75. }
  76. if (strKey == "MEMO")
  77. {
  78. char[] arrary = ultraGrid1.ActiveRow.Cells[strKey].Text.ToCharArray();
  79. if (!(e.KeyChar == '\b') && arrary.Length > 200)
  80. {
  81. MessageBox.Show("生产记事的不能超过二百个字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  82. e.Handled = true;
  83. }
  84. }
  85. }
  86. protected override void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)
  87. {
  88. base.ultraGrid1_ClickCellButton(sender, e);
  89. try
  90. {
  91. string strKey = e.Cell.Column.Key.ToUpper();
  92. if (e.Cell.Column.DataType != typeof(DateTime))
  93. {
  94. frmInputDecimal frm = new frmInputDecimal(Convert.ToString(e.Cell.Text));
  95. frm.Location = ClsControlPack.GetChildWindowLocation(frm.Size);
  96. if (frm.ShowDialog() == DialogResult.OK)
  97. {
  98. if (!frm.ValueChanged) return;
  99. e.Cell.Value = frm.Value;
  100. ultraGrid1.UpdateData();
  101. }
  102. }
  103. }
  104. catch { }
  105. }
  106. }
  107. }