| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- using System;
- using System.Collections;
- using System.Windows.Forms;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- using System.Drawing;
- namespace Core.StlMes.Client.LgCommon
- {
- public partial class ucResCas : ucResBase
- {
- public ucResCas()
- {
- InitializeComponent();
- }
- public bool allowSave = true; //是否允许修改实绩
- public bool allowSave1 = true; //是否允许修改实绩
- public bool allowSave2 = true; //是否允许修改实绩
- public bool allowSave3 = true; //是否允许修改实绩
- protected override void InitValuelist()
- {
- base.InitValuelist();
- try
- {
- ValueList vlist = ClsBusinessPack.GetValuelistLogic();
- ClsControlPack.SetGridValuelist(ref ultraGrid1, "DESLAGGFLAG", ref vlist);
- }
- catch { }
- }
- public override void SetData(Hashtable ar)
- {
- base.SetData(ar);
- try
- {
- UltraGridRow row = ultraGrid1.Rows[0];
- ClsBusinessPack.GetTimeSpanfromUI(row.Cells["ARRIVETIME"], row.Cells["LEAVETIME"], row.Cells["STAYTIME"]);
- ClsBusinessPack.GetTimeSpanfromUI(row.Cells["BLOWARSTARTTIME"], row.Cells["BLOWARENDTIME"], row.Cells["BLOWARTIME"]);
- ClsBusinessPack.GetTimeSpanfromUI(row.Cells["FEEDSILKBEGINTIME"], row.Cells["FEEDSILKCLOSETIME"], row.Cells["FEEDSILKTIME"]);
- ClsBusinessPack.GetNetWeightfromUI(row.Cells["LEAVEWGT"], row.Cells["ARRIVEWGT"], row.Cells["NETWGT"]);
- }
- catch { }
- }
- 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("ARRIVETIME") || strKey.Equals("LEAVETIME"))
- {
- if ((DateTime)ultraGrid1.ActiveRow.Cells["ARRIVETIME"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["LEAVETIME"].Value)
- {
- e.Cell.Appearance.BackColor = Color.Red;
- MessageBox.Show("出站时间不能早于入站时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- allowSave = false;
- return;
- }
- else
- {
- if (ultraGrid1.ActiveRow.Cells["ARRIVETIME"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["ARRIVETIME"].Appearance.BackColor = Color.Orange;
- }
- if (ultraGrid1.ActiveRow.Cells["LEAVETIME"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["LEAVETIME"].Appearance.BackColor = Color.Orange;
- }
- allowSave = true;
- }
- ClsBusinessPack.GetTimeSpanfromUI(row.Cells["ARRIVETIME"], row.Cells["LEAVETIME"], row.Cells["STAYTIME"]);
- }
- else if (strKey.Equals("BLOWARSTARTTIME") || strKey.Equals("BLOWARENDTIME"))
- {
- if ((DateTime)ultraGrid1.ActiveRow.Cells["BLOWARSTARTTIME"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["BLOWARENDTIME"].Value)
- {
- e.Cell.Appearance.BackColor = Color.Red;
- MessageBox.Show("吹氩结束时间不能早于吹氩开始时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- allowSave1 = false;
- return;
- }
- else
- {
- if (ultraGrid1.ActiveRow.Cells["BLOWARSTARTTIME"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["BLOWARSTARTTIME"].Appearance.BackColor = Color.Orange;
- }
- if (ultraGrid1.ActiveRow.Cells["BLOWARENDTIME"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["BLOWARENDTIME"].Appearance.BackColor = Color.Orange;
- }
- allowSave1 = true;
- }
- ClsBusinessPack.GetTimeSpanfromUI(row.Cells["BLOWARSTARTTIME"], row.Cells["BLOWARENDTIME"], row.Cells["BLOWARTIME"]);
- }
- else if (strKey.Equals("FEEDSILKBEGINTIME") || strKey.Equals("FEEDSILKCLOSETIME"))
- {
- if ((DateTime)ultraGrid1.ActiveRow.Cells["FEEDSILKBEGINTIME"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["FEEDSILKCLOSETIME"].Value)
- {
- e.Cell.Appearance.BackColor = Color.Red;
- MessageBox.Show("喂丝结束时间不能早于喂丝开始时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- allowSave2 = false;
- return;
- }
- else
- {
- if (ultraGrid1.ActiveRow.Cells["FEEDSILKBEGINTIME"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["FEEDSILKBEGINTIME"].Appearance.BackColor = Color.Orange;
- }
- if (ultraGrid1.ActiveRow.Cells["FEEDSILKCLOSETIME"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["FEEDSILKCLOSETIME"].Appearance.BackColor = Color.Orange;
- }
- allowSave2 = true;
- }
- ClsBusinessPack.GetTimeSpanfromUI(row.Cells["FEEDSILKBEGINTIME"], row.Cells["FEEDSILKCLOSETIME"], row.Cells["FEEDSILKTIME"]);
- }
- else if (strKey.Equals("ARRIVEWGT") || strKey.Equals("LEAVEWGT"))
- {
- if (ultraGrid1.ActiveRow.Cells["ARRIVEWGT"].Value == DBNull.Value || ultraGrid1.ActiveRow.Cells["LEAVEWGT"].Value == DBNull.Value)
- {
- allowSave3 = true;
- }
- try
- {
- if (Convert.ToDouble(ultraGrid1.ActiveRow.Cells["ARRIVEWGT"].Value) > Convert.ToDouble(ultraGrid1.ActiveRow.Cells["LEAVEWGT"].Value))
- {
- e.Cell.Appearance.BackColor = Color.Red;
- MessageBox.Show("空包重量不能大于重包重量!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- allowSave3 = false;
- return;
- }
- else
- {
- if (ultraGrid1.ActiveRow.Cells["ARRIVEWGT"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["ARRIVEWGT"].Appearance.BackColor = Color.Orange;
- }
- if (ultraGrid1.ActiveRow.Cells["LEAVEWGT"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["LEAVEWGT"].Appearance.BackColor = Color.Orange;
- }
- allowSave3 = true;
- }
- }
- catch { }
-
- ClsBusinessPack.GetNetWeightfromUI(row.Cells["LEAVEWGT"], row.Cells["ARRIVEWGT"], row.Cells["NETWGT"]);
- }
- }
- }
- 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("ARRIVEWGT") || strKey.Equals("LEAVEWGT"))
- ClsBusinessPack.GetNetWeightfromUI(row.Cells["LEAVEWGT"], row.Cells["ARRIVEWGT"], row.Cells["NETWGT"]);
- }
- }
- catch { }
- }
- private void ultraGrid1_KeyPress(object sender, KeyPressEventArgs e)
- {
- string strKey = this.ultraGrid1.ActiveCell.Column.ToString();
- if (strKey == "ARRIVEWGT" || strKey == "LEAVEWGT" || strKey == "ARCONSUME" ||
- strKey == "ARRIVEO2"|| strKey == "LEAVEO2" || strKey == "RESIDUETHICKNESS" ||
- strKey == "MANTLENUM"|| strKey == "FLEXIBLEBLOWTIME" || strKey == "BLOWARPRESS" ||
- strKey == "TWSTEELWGT"|| strKey == "ARFTEMPT" || strKey == "ARBTEMPT" )
- {
- 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;
- }
- }
- }
- }
- }
- 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 { }
- }
- }
- }
|