| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- using System;
- using System.Windows.Forms;
- using CoreFS.CA06;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- namespace Core.StlMes.Client.LgCommon
- {
- public partial class ucResCast : ucResBase
- {
- public ucResCast()
- {
- InitializeComponent();
- }
- private void ultraGrid1_KeyPress(object sender, KeyPressEventArgs e)
- {
- string strKey = this.ultraGrid1.ActiveCell.Column.ToString();
- if (strKey == "S1CRYSTALCODE" || strKey == "S2CRYSTALCODE" || strKey == "S3CRYSTALCODE" ||
- strKey == "S4CRYSTALCODE" || strKey == "S5CRYSTALCODE" || strKey == "S6CRYSTALCODE")
- {
- if (!(Char.IsNumber(e.KeyChar)&& ultraGrid1.ActiveRow.Cells[strKey].Value.ToString().Length <= 6)&& e.KeyChar != '\b')
- {
- e.Handled = true;
- }
-
- }
- if (strKey == "MWRAPNO")
- {
- if (!(Char.IsNumber(e.KeyChar) && ultraGrid1.ActiveRow.Cells[strKey].Value.ToString().Length <= 10) && e.KeyChar != '\b')
- {
- e.Handled = true;
- }
- }
- if (strKey == "S1CRPASSSTEELWEIGHT" || strKey == "S2CRPASSSTEELWEIGHT" || strKey == "S3CRPASSSTEELWEIGHT" ||
- strKey == "S4CRPASSSTEELWEIGHT" || strKey == "S5CRPASSSTEELWEIGHT" || strKey == "S6CRPASSSTEELWEIGHT" ||
- strKey == "S1CUTFRONT" || strKey == "S2CUTFRONT" || strKey == "S3CUTFRONT"||
- strKey == "S4CUTFRONT" || strKey == "S5CUTFRONT" || strKey == "S6CUTFRONT"||
- strKey == "S1CUTBACK" || strKey == "S2CUTBACK" || strKey == "S3CUTBACK"||
- strKey == "S4CUTBACK" || strKey == "S5CUTBACK" || strKey == "S6CUTBACK"||
- strKey == "MWRAPBESTROWDOSAGE")
- {
- if (!(e.KeyChar == '\b') && ultraGrid1.ActiveRow.Cells[strKey].Value.ToString().Length >= 6)
- {
- e.Handled = true;
- }
- if (!(Char.IsNumber(e.KeyChar) || e.KeyChar == '\b' || e.KeyChar == '.'))
- {
- e.Handled = true;
- }
- if (e.KeyChar == '.')
- {
- char[] arrary = ultraGrid1.ActiveRow.Cells[strKey].Text.ToCharArray();
- if (arrary.Length == 0)
- {
- ultraGrid1.ActiveRow.Cells[strKey].Value = "0.";
- ultraGrid1.ActiveRow.Cells[strKey].SelStart = ultraGrid1.ActiveRow.Cells[strKey].Value.ToString().Length;
- e.Handled = true;
- }
- else
- {
- for (int i = 0; i < arrary.Length; i++)
- {
- if (arrary[i] == '.')
- e.Handled = true;
- }
- }
- }
- }
- if (strKey == "MWRAPBESTROWNAME")
- {
- char[] arrary = ultraGrid1.ActiveRow.Cells[strKey].Text.ToCharArray();
- if (!(e.KeyChar == '\b') && arrary.Length > 10)
- {
- // MessageBox.Show("中包覆盖剂名不能超过一十个字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- e.Handled = true;
- }
- }
- if (strKey == "MEMO")
- {
- char[] arrary = ultraGrid1.ActiveRow.Cells[strKey].Text.ToCharArray();
- if (!(e.KeyChar == '\b') && arrary.Length > 200)
- {
- MessageBox.Show("生产记事的不能超过二百个字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- e.Handled = true;
- }
- }
- }
- protected override void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)
- {
- base.ultraGrid1_ClickCellButton(sender, e);
- try
- {
- string strKey = e.Cell.Column.Key.ToUpper();
- if (e.Cell.Column.DataType != typeof(DateTime))
- {
- frmInputDecimal frm = new frmInputDecimal(Convert.ToString(e.Cell.Text));
- frm.Location = ClsControlPack.GetChildWindowLocation(frm.Size);
- if (frm.ShowDialog() == DialogResult.OK)
- {
- if (!frm.ValueChanged) return;
- e.Cell.Value = frm.Value;
- ultraGrid1.UpdateData();
- }
- }
- }
- catch { }
- }
- }
- }
|