| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- using System;
- using System.Collections;
- using System.Windows.Forms;
- using CoreFS.CA06;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- using System.Drawing;
- namespace Core.StlMes.Client.LgCommon
- {
- public partial class ucResCcm : ucResBase
- {
- public bool allowSave = true; //是否允许修改实绩
- public bool allowSave1 = true; //是否允许修改实绩
- public bool allowSave2 = true; //是否允许修改实绩
- public bool allowSave3 = true; //是否允许修改实绩
- public ucResCcm()
- {
- InitializeComponent();
- }
- protected override void InitValuelist()
- {
- base.InitValuelist();
- try
- {
- ValueList vlist = ClsBusinessPack.GetValuelistLogic();
- ClsControlPack.SetGridValuelist(ref ultraGrid1, "BALEFLOWFLAG", ref vlist);
- ValueList vlist1 = ClsBusinessPack.GetValuelistDigital(5);
- ClsControlPack.SetGridValuelist(ref ultraGrid1, "BALEFLOWTIEMS", ref vlist1);
- }
- catch { }
- }
- public void GetValuelistProtectiveSlag(OpeBase ob)
- {
- try
- {
- ValueList vlist = ClsBusinessPack.GetValuelistProtectiveSlag(ob);
- ClsControlPack.SetGridValuelist(ref ultraGrid1, "PROTECTDTEG", ref vlist);
- }
- catch { }
- }
- public override void SetData(Hashtable ar)
- {
- base.SetData(ar);
- try
- {
- UltraGridRow row = ultraGrid1.Rows[0];
- ClsBusinessPack.GetNetWeightfromUI(row.Cells["PFBALEWGT"], row.Cells["BALELEAVEWGT"], row.Cells["MOULDWGT"]);
- }
- catch { }
- }
- private void ultraGrid1_KeyPress(object sender, KeyPressEventArgs e)
- {
- string strKey = this.ultraGrid1.ActiveCell.Column.ToString();
- if (strKey == "PFBALEWGT" || strKey == "BALELEAVEWGT" || strKey == "RSMOLSTLWGT" ||
- strKey == "BALEMOULDTIME" || strKey == "BALEFLOWTIEMS" || strKey == "BAKEO2TIEMS" ||
- strKey == "MWRAPTEMPT" || strKey == "MOULDWGT" || strKey == "MOULDWGT"||
- strKey == "PFBALETEMPT" || strKey == "MOULDBALEWGT" || strKey == "PROTECTDTEGDOSAGE" ||
- strKey == "RESIDUETHICKNESS" || strKey == "SWRAPREMAINWGT")
- {
- 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 == "MEMO")
- {
- char[] arrary = ultraGrid1.ActiveRow.Cells[strKey].Text.ToCharArray();
- if (!(e.KeyChar == '\b') && arrary.Length >= 40)
- {
- // MessageBox.Show("生产记事不能超过40个字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- e.Handled = true;
- }
- }
- if (strKey == "PROTECTDTEG")
- {
- char[] arrary = ultraGrid1.ActiveRow.Cells[strKey].Text.ToCharArray();
- if (!(e.KeyChar == '\b') && arrary.Length >= 10)
- {
- // MessageBox.Show("保护渣名称不能超过10个字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- e.Handled = true;
- }
- }
- }
- protected override void ultraGrid1_AfterCellUpdate(object sender, CellEventArgs e)
- {
- base.ultraGrid1_AfterCellUpdate(sender, e);
- try
- {
- if (!e.Cell.Column.Hidden && e.Cell.Column.CellActivation == Activation.AllowEdit)
- {
- string strKey = e.Cell.Column.Key.ToUpper();
- UltraGridRow row = e.Cell.Row;
- if (strKey.Equals("PFBALEWGT") || strKey.Equals("BALELEAVEWGT"))
- {
- if (ultraGrid1.ActiveRow.Cells["PFBALEWGT"].Value == DBNull.Value || ultraGrid1.ActiveRow.Cells["BALELEAVEWGT"].Value == DBNull.Value)
- {
- allowSave = true;
- }
- try
- {
- if (Convert.ToDouble(ultraGrid1.ActiveRow.Cells["BALELEAVEWGT"].Value) > Convert.ToDouble(ultraGrid1.ActiveRow.Cells["PFBALEWGT"].Value))
- {
- e.Cell.Appearance.BackColor = Color.Red;
- MessageBox.Show("大包下台重量不能大于大包上台重量!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- allowSave = false;
- return;
- }
- else
- {
- if (ultraGrid1.ActiveRow.Cells["BALELEAVEWGT"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["BALELEAVEWGT"].Appearance.BackColor = Color.Orange;
- }
- if (ultraGrid1.ActiveRow.Cells["PFBALEWGT"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["PFBALEWGT"].Appearance.BackColor = Color.Orange;
- }
- allowSave = true;
- }
- }
- catch { }
- ClsBusinessPack.GetNetWeightfromUI(row.Cells["PFBALEWGT"], row.Cells["BALELEAVEWGT"], row.Cells["MOULDWGT"]);
- }
- if (strKey.Equals("BALEPFTIME") || strKey.Equals("BALELEAVETIME"))
- {
- if ((DateTime)ultraGrid1.ActiveRow.Cells["BALEPFTIME"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["BALELEAVETIME"].Value)
- {
- e.Cell.Appearance.BackColor = Color.Red;
- MessageBox.Show("大包上台时刻不能早于上包离台时刻!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- allowSave1 = false;
- return;
- }
- else
- {
- if (ultraGrid1.ActiveRow.Cells["BALEPFTIME"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["BALEPFTIME"].Appearance.BackColor = Color.Orange;
- }
- if (ultraGrid1.ActiveRow.Cells["BALELEAVETIME"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["BALELEAVETIME"].Appearance.BackColor = Color.Orange;
- }
- allowSave1 = true;
- }
- }
- if (strKey.Equals("BALESTARTTIME") || strKey.Equals("BALEENDTIME"))
- {
- if ((DateTime)ultraGrid1.ActiveRow.Cells["BALESTARTTIME"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["BALEENDTIME"].Value)
- {
- e.Cell.Appearance.BackColor = Color.Red;
- MessageBox.Show("大包开浇时刻不能早于大包停浇时刻!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- allowSave2 = false;
- return;
- }
- else
- {
- if (ultraGrid1.ActiveRow.Cells["BALESTARTTIME"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["BALESTARTTIME"].Appearance.BackColor = Color.Orange;
- }
- if (ultraGrid1.ActiveRow.Cells["BALEENDTIME"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["BALEENDTIME"].Appearance.BackColor = Color.Orange;
- }
- allowSave2 = true;
- }
- }
- if (strKey.Equals("MWRAPSTARTTIME") || strKey.Equals("MWRAPENDTIME"))
- {
- if ((DateTime)ultraGrid1.ActiveRow.Cells["MWRAPSTARTTIME"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["MWRAPENDTIME"].Value)
- {
- e.Cell.Appearance.BackColor = Color.Red;
- MessageBox.Show("中包开浇时刻不能早于中包停浇时刻!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- allowSave3 = false;
- return;
- }
- else
- {
- if (ultraGrid1.ActiveRow.Cells["MWRAPSTARTTIME"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["MWRAPSTARTTIME"].Appearance.BackColor = Color.Orange;
- }
- if (ultraGrid1.ActiveRow.Cells["MWRAPENDTIME"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["MWRAPENDTIME"].Appearance.BackColor = Color.Orange;
- }
- allowSave3 = true;
- }
- }
- }
- }
- catch { }
- }
- protected override void ultraGrid1_CellChange(object sender, CellEventArgs e)
- {
- base.ultraGrid1_CellChange(sender, e);
- try
- {
- if (!e.Cell.Column.Hidden && e.Cell.Column.CellActivation == Activation.AllowEdit)
- {
- string strKey = e.Cell.Column.Key.ToUpper();
- UltraGridRow row = e.Cell.Row;
- if (strKey.Equals("PFBALEWGT") || strKey.Equals("BALELEAVEWGT"))
- ClsBusinessPack.GetNetWeightfromUI(row.Cells["PFBALEWGT"], row.Cells["BALELEAVEWGT"], row.Cells["MOULDWGT"]);
- }
- }
- catch { }
- }
- 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 { }
- }
- }
- }
|