| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- 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 ucResLfs : ucResBase
- {
- public bool allowSave = true; //是否允许修改实绩
- public bool allowSave1 = true; //是否允许修改实绩
- public bool allowSave2 = true; //是否允许修改实绩
- public ucResLfs()
- {
- InitializeComponent();
- }
- 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["REFINETIME"]);
- ClsBusinessPack.GetTimeSpanfromUI(row.Cells["BEGINBLOWAR"], row.Cells["ENDBLOWAR"], row.Cells["BLOWARTIME"]);
- ClsBusinessPack.GetTimeSpanfromUI(row.Cells["REPOSEBEGINTIME"], row.Cells["REPOSECLOSETIME"], row.Cells["REPOSETIME"]);
- }
- catch { }
- }
- private void ultraGrid1_KeyPress(object sender, KeyPressEventArgs e)
- {
- string strKey = this.ultraGrid1.ActiveCell.Column.ToString();
- if (strKey == "ARRIVETEMPT" || strKey == "LEAVETEMPT" || strKey == "ARRIVEO2" ||
- strKey == "LEAVEO2" || strKey == "ARCONSUME" || strKey == "MRTCONSUME" ||
- strKey == "SELETIME" || strKey == "FLEXIBLEBLOWTIME" || strKey == "RESIDUETHICKNESS")
- {
- 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 >= 100)
- {
- MessageBox.Show("生产记事的不能超过一百个字!", "提示", 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("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["REFINETIME"]);
- }
- else if (strKey.Equals("BEGINBLOWAR") || strKey.Equals("ENDBLOWAR"))
- {
- if ((DateTime)ultraGrid1.ActiveRow.Cells["BEGINBLOWAR"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["ENDBLOWAR"].Value)
- {
- e.Cell.Appearance.BackColor = Color.Red;
- MessageBox.Show("吹氩结束时间不能早于吹氩开始时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- allowSave1 = false;
- return;
- }
- else
- {
- if (ultraGrid1.ActiveRow.Cells["BEGINBLOWAR"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["BEGINBLOWAR"].Appearance.BackColor = Color.Orange;
- }
- if (ultraGrid1.ActiveRow.Cells["ENDBLOWAR"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["ENDBLOWAR"].Appearance.BackColor = Color.Orange;
- }
- allowSave1 = true;
- }
- ClsBusinessPack.GetTimeSpanfromUI(row.Cells["BEGINBLOWAR"], row.Cells["ENDBLOWAR"], row.Cells["BLOWARTIME"]);
- }
- else if (strKey.Equals("REPOSEBEGINTIME") || strKey.Equals("REPOSECLOSETIME"))
- {
- if ((DateTime)ultraGrid1.ActiveRow.Cells["REPOSEBEGINTIME"].Value > (DateTime)ultraGrid1.ActiveRow.Cells["REPOSECLOSETIME"].Value)
- {
- e.Cell.Appearance.BackColor = Color.Red;
- MessageBox.Show("处理结束时间不能早于处理开始时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- allowSave2 = false;
- return;
- }
- else
- {
- if (ultraGrid1.ActiveRow.Cells["REPOSEBEGINTIME"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["REPOSEBEGINTIME"].Appearance.BackColor = Color.Orange;
- }
- if (ultraGrid1.ActiveRow.Cells["REPOSECLOSETIME"].Appearance.BackColor == Color.Red)
- {
- ultraGrid1.ActiveRow.Cells["REPOSECLOSETIME"].Appearance.BackColor = Color.Orange;
- }
- allowSave2 = true;
- }
- ClsBusinessPack.GetTimeSpanfromUI(row.Cells["REPOSEBEGINTIME"], row.Cells["REPOSECLOSETIME"], row.Cells["REPOSETIME"]);
- }
- }
- }
- 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 { }
- }
- }
- }
|