| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using System.Collections;
- using System.IO;
- using System.Diagnostics;
- using Infragistics.Win.UltraWinGrid;
- using CoreFS.CA06;
- using Core.Mes.Client.Common;
- using Core.LgMes.Client.Comm;
- namespace Core.LgMes.Client.LgResMgt
- {
- public partial class frmCutInfoAssit : frmStyleBase
- {
- private bool bAddNow, bEditNow, bDelNow; //是否在进行新增、修改或者删除操作
- private UltraGridRow currRow = null;
- private CoreClientParam par;
- private string strReturn = "ExecuteCommand_Return";
- public frmCutInfoAssit()
- {
- InitializeComponent();
- }
- private void frmCutInfoAssit_Load(object sender, EventArgs e)
- {
- proc_Init();
- proc_Query("", -1);
- proc_SetToolbarButtons();
- }
- private void proc_Init()
- {
- try
- {
- ultraDateTimeEditor1.DateTime = DateTime.Today;
- ultraDateTimeEditor2.DateTime = DateTime.Today;
- par = new CoreClientParam();
- par.ServerName = "lgResMgt.Core.LgMes.Server.LgResMgt";
- par.MethodName = "classResCommonModule";
- //par.ClassName = "Core.LgMes.Server.LgResMgt.classResCommonModule";
- }
- catch (Exception ex)
- {
- MessageBox.Show("初始化失败!\r\n" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
- if (MessageBox.Show("点击[是]将重新初始化,强烈建议执行此操作!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- proc_Init();
- }
- }
- }
- private void proc_SetToolbarButtons()
- {
- try
- {
- ultraToolbarsManager1.Toolbars[0].Tools["QUERY"].SharedProps.Enabled = !(bAddNow || bEditNow || bDelNow);
- ultraToolbarsManager1.Toolbars[0].Tools["NEW"].SharedProps.Enabled = !(bAddNow || bEditNow || bDelNow);
- ultraToolbarsManager1.Toolbars[0].Tools["MODIFY"].SharedProps.Enabled = (!(bAddNow || bEditNow || bDelNow) && (ultraGrid1.ActiveRow != null));
- ultraToolbarsManager1.Toolbars[0].Tools["DEL"].SharedProps.Enabled = (!(bAddNow || bEditNow || bDelNow) && (ultraGrid1.ActiveRow != null));
- ultraToolbarsManager1.Toolbars[0].Tools["EXPORT"].SharedProps.Enabled = (!(bAddNow || bEditNow || bDelNow) && ultraGrid1.Rows.Count > 0);
- ultraToolbarsManager1.Toolbars[0].Tools["SAVE"].SharedProps.Enabled = (bAddNow || bEditNow);
- ultraToolbarsManager1.Toolbars[0].Tools["CANCEL"].SharedProps.Enabled = (bAddNow || bEditNow);
- ultraToolbarsManager1.Toolbars[0].Tools["SAVE"].SharedProps.Visible = (bAddNow || bEditNow);
- ultraToolbarsManager1.Toolbars[0].Tools["CANCEL"].SharedProps.Visible = (bAddNow || bEditNow);
- }
- catch { }
- }
- private void proc_SetUltraGridReadOnly(Infragistics.Win.UltraWinGrid.UltraGridBase ultGrid)
- {
- foreach (UltraGridRow row in ultGrid.Rows)
- {
- row.Activation = Activation.ActivateOnly;
- }
- }
- private void proc_setCellReadOnly(UltraGridRow row, bool bReadOnly)
- {
- try
- {
- if (row == null)
- return;
- if (bReadOnly)
- {
- row.Activation = Activation.ActivateOnly;
- row.CellAppearance.BackColor = Color.White;
- foreach (Infragistics.Win.UltraWinGrid.UltraGridCell cell in row.Cells)
- {
- cell.CancelUpdate();
- }
- }
- else
- {
- row.Activation = Activation.AllowEdit;
- row.CellAppearance.BackColor = Color.Khaki;
- row.Cells["CATEGORY"].Activation = Activation.AllowEdit;
- row.Cells["LENGTH"].Activation = Activation.AllowEdit;
- row.Cells["THICKNESS"].Activation = Activation.AllowEdit;
- row.Cells["WIDTH"].Activation = Activation.AllowEdit;
- row.Cells["WEIGHT"].Activation = Activation.AllowEdit;
- row.Cells["CUTTIME"].Activation = Activation.AllowEdit;
- row.Cells["BILLETNO"].Activation = Activation.ActivateOnly;
- row.Cells["SERIALNUM"].Activation = Activation.ActivateOnly;
- row.Cells["HEATNO"].Activation = Activation.ActivateOnly;
- row.Cells["BOOKER"].Activation = Activation.ActivateOnly;
- row.Cells["OPTDATE"].Activation = Activation.ActivateOnly;
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void proc_Query(string strBilletNo, int iSerialNum)
- {
- Cursor oldCursor = this.Cursor;
- this.Cursor = Cursors.WaitCursor;
- try
- {
- string strFrom = ultraDateTimeEditor1.DateTime.ToString("yyyy-MM-dd");
- string strTo = ultraDateTimeEditor2.DateTime.ToString("yyyy-MM-dd");
- string strWhere = "where to_char(CUTTIME, 'yyyy-MM-dd') between '" + strFrom + "' and '" + strTo + "'";
- string str = "";
- str = ultraTextEditor1.Text.Trim();
- if (str.Length > 0)
- strWhere += " and BILLETNO = '" + str + "'";
- str = ultraTextEditor2.Text.Trim();
- if (str.Length > 0)
- strWhere += " and HEATNO = '" + str + "'";
- string strErr = "";
- string strSql = "select BILLETNO, HEATNO, CATEGORY, "
- + "LENGTH, THICKNESS, WIDTH, WEIGHT, CUTTIME, BOOKER, OPTDATE, SERIALNUM "
- + "from JOB_INCISION_ASSIST " + strWhere + " order by CUTTIME desc, BILLETNO, SERIALNUM desc";
- par.MethodName = strReturn;
- par.ServerParams = new object[] { strSql };
- DataSet ds = null;//hengxing ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr) as DataSet;
- if (strErr != "" || !(ds != null && ds.Tables.Count > 0))
- {
- MessageBox.Show("数据加载失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- if (MessageBox.Show("是否重新加载数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- proc_Query(strBilletNo, iSerialNum);
- return;
- }
- if (ds != null && ds.Tables.Count > 0)
- {
- this.dataTable1.Rows.Clear();
- DataRow dr;
- for (int iRow = 0; iRow < ds.Tables[0].Rows.Count; iRow++)
- {
- dr = this.dataTable1.NewRow();
- for (int jCol = 0; jCol < ds.Tables[0].Columns.Count; jCol++)
- {
- dr[ds.Tables[0].Columns[jCol].ColumnName] = Convert.ToString(ds.Tables[0].Rows[iRow][jCol]);
- }
- this.dataTable1.Rows.Add(dr);
- }
- ultraGrid1.UpdateData();
- }
- this.proc_SetUltraGridReadOnly(ultraGrid1);
- if (ultraGrid1.Rows.Count > 0)
- {
- ultraGrid1.ActiveCell = ultraGrid1.Rows[0].Cells["HEATNO"];
- ultraGrid1.Rows[0].Cells["HEATNO"].Selected = false;
- }
- if (strBilletNo.Trim().Length == 0) return;
- int iNum = 0;
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- str = Convert.ToString(ultraGrid1.Rows[i].Cells["BILLETNO"].Value);
- iNum = Convert.ToInt32(ultraGrid1.Rows[i].Cells["SERIALNUM"].Value);
- if (str == strBilletNo && iNum == iSerialNum)
- {
- ultraGrid1.ActiveCell = ultraGrid1.Rows[i].Cells["BILLETNO"];
- ultraGrid1.Rows[i].Cells["BILLETNO"].Selected = false;
- return;
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- finally
- {
- this.Cursor = oldCursor;
- }
- }
- private bool proc_CheckData(ref UltraGridRow row, out string strErr, out ArrayList alist)
- {
- strErr = "";
- alist = new ArrayList();
- try
- {
- if (row == null)
- {
- strErr = "未明确定义数据!";
- return false;
- }
- string str = "";
- decimal dValue = 0.0M;
- str = Convert.ToString(row.Cells["BILLETNO"].Value).Trim();
- if (str.Length == 0)
- {
- strErr = "请选择坯料号!";
- ultraGrid1.ActiveCell = row.Cells["BILLETNO"];
- return false;
- }
- alist.Add(str);
- str = Convert.ToString(row.Cells["SERIALNUM"].Value).Trim();
- alist.Add(str);
- str = Convert.ToString(row.Cells["HEATNO"].Value).Trim();
- alist.Add(str);
- str = Convert.ToString(row.Cells["CATEGORY"].Value).Trim();
- if (str.Length == 0)
- {
- strErr = "请选择类别!";
- ultraGrid1.ActiveCell = row.Cells["CATEGORY"];
- return false;
- }
- alist.Add(str);
- str = Convert.ToString(row.Cells["LENGTH"].Value).Trim();
- if (str.Length > 0 && !decimal.TryParse(str, out dValue))
- {
- strErr = "长度不正确!";
- ultraGrid1.ActiveCell = row.Cells["LENGTH"];
- return false;
- }
- alist.Add(str);
- str = Convert.ToString(row.Cells["THICKNESS"].Value).Trim();
- if (str.Length > 0 && !decimal.TryParse(str, out dValue))
- {
- strErr = "厚度不正确!";
- ultraGrid1.ActiveCell = row.Cells["THICKNESS"];
- return false;
- }
- alist.Add(str);
- str = Convert.ToString(row.Cells["WIDTH"].Value).Trim();
- if (str.Length > 0 && !decimal.TryParse(str, out dValue))
- {
- strErr = "宽度不正确!";
- ultraGrid1.ActiveCell = row.Cells["WIDTH"];
- return false;
- }
- alist.Add(str);
- str = Convert.ToString(row.Cells["WEIGHT"].Value).Trim();
- if (str.Length > 0 && !decimal.TryParse(str, out dValue))
- {
- strErr = "重量不正确!";
- ultraGrid1.ActiveCell = row.Cells["WEIGHT"];
- return false;
- }
- alist.Add(str);
- str = Convert.ToString(row.Cells["CUTTIME"].Value).Trim();
- if (str.Length == 0)
- {
- strErr = "请录入切割时间!";
- ultraGrid1.ActiveCell = row.Cells["CUTTIME"];
- return false;
- }
- alist.Add(str);
- alist.Add(this.UserInfo.GetUserName());
- }
- catch (Exception ex)
- {
- strErr = ex.Message.ToString();
- return false;
- }
- return true;
- }
- private void proc_Add()
- {
- try
- {
- if (currRow == null) return;
- ultraGrid1.UpdateData();
- string strMsg = "";
- ArrayList alist;
- if (!this.proc_CheckData(ref currRow, out strMsg, out alist))
- {
- MessageBox.Show(strMsg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- this.ultraGrid1.Focus();
- this.ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false);
- return;
- }
- par.MethodName = "CutInfoAssit_Add";
- par.ServerParams = new object[] { alist };
- int iNum = 0;//hengxing (int)ClientCommon._RemotingHelp.ExecuteMethod(par, out strMsg);
- if (iNum < 0)
- {
- MessageBox.Show("实绩信息保存失败!\r\n" + strMsg, "出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- this.proc_setCellReadOnly(currRow, true);
- this.proc_Query(alist[0].ToString(), iNum);
- currRow = null;
- bAddNow = false;
- this.proc_SetToolbarButtons();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void proc_Edit()
- {
- try
- {
- if (currRow == null) return;
- ultraGrid1.UpdateData();
- string strMsg = "";
- ArrayList alist;
- if (!this.proc_CheckData(ref currRow, out strMsg, out alist))
- {
- MessageBox.Show(strMsg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- this.ultraGrid1.Focus();
- this.ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false);
- return;
- }
- par.MethodName = "CutInfoAssit_Edit";
- par.ServerParams = new object[] { alist };
- int iFlag = 0;//hengxing (int)ClientCommon._RemotingHelp.ExecuteMethod(par, out strMsg);
- if (iFlag < 0)
- {
- MessageBox.Show("实绩信息保存失败!\r\n" + strMsg, "出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- this.proc_setCellReadOnly(currRow, true);
- this.proc_Query(alist[0].ToString(), Convert.ToInt32(alist[1].ToString()));
- currRow = null;
- bEditNow = false;
- this.proc_SetToolbarButtons();
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void proc_Delete()
- {
- try
- {
- if (this.ultraGrid1.Rows.Count == 0) return;
- if (this.ultraGrid1.ActiveRow == null)
- {
- MessageBox.Show("请选择要删除的实绩信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (MessageBox.Show("确定要删除所选实绩信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- return;
- UltraGridRow row = ultraGrid1.ActiveRow;
- ArrayList alist = new ArrayList();
- alist.Add(Convert.ToString(row.Cells["BILLETNO"].Value));
- alist.Add(Convert.ToString(row.Cells["SERIALNUM"].Value));
- par.MethodName = "CutInfoAssit_Del";
- par.ServerParams = new object[] { alist };
- string strMsg = "";
- int iFlag = 0;//hengxing (int)ClientCommon._RemotingHelp.ExecuteMethod(par, out strMsg);
- if (iFlag < 0)
- {
- MessageBox.Show("实绩信息删除失败!\r\n" + strMsg, "出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- this.proc_Query("", -1);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- base.ToolBar_Click(sender, ToolbarKey);
- switch (ToolbarKey)
- {
- case "Exit":
- this.Close();
- break;
- default:
- break;
- }
- }
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "QUERY":
- {
- if (bAddNow || bEditNow || bDelNow)
- return;
- proc_Query("", -1);
- proc_SetToolbarButtons();
- break;
- }
- case "NEW":
- {
- if (bAddNow || bEditNow || bDelNow)
- return;
- currRow = this.ultraGrid1.DisplayLayout.Bands[0].AddNew();
- this.proc_setCellReadOnly(currRow, false);
- currRow.Cells["CUTTIME"].Value = DateTime.Now;
- bAddNow = true;
- ultraGrid1.ActiveCell = currRow.Cells["BILLETNO"];
- currRow.Cells["BILLETNO"].Selected = false;
- this.proc_SetToolbarButtons();
- break;
- }
- case "MODIFY":
- {
- if (ultraGrid1.ActiveRow == null || (bAddNow || bEditNow || bDelNow))
- return;
- currRow = ultraGrid1.ActiveRow;
- this.proc_setCellReadOnly(currRow, false);
- bEditNow = true;
- ultraGrid1.ActiveCell = currRow.Cells["BILLETNO"];
- currRow.Cells["BILLETNO"].Selected = false;
- currRow.Cells["BILLETNO"].Tag = currRow.Cells["BILLETNO"].Value;
- currRow.Cells["HEATNO"].Tag = currRow.Cells["HEATNO"].Value;
- currRow.Cells["CATEGORY"].Tag = currRow.Cells["CATEGORY"].Value;
- currRow.Cells["LENGTH"].Tag = currRow.Cells["LENGTH"].Value;
- currRow.Cells["THICKNESS"].Tag = currRow.Cells["THICKNESS"].Value;
- currRow.Cells["WIDTH"].Tag = currRow.Cells["WIDTH"].Value;
- currRow.Cells["WEIGHT"].Tag = currRow.Cells["WEIGHT"].Value;
- currRow.Cells["CUTTIME"].Tag = currRow.Cells["CUTTIME"].Value;
- this.proc_SetToolbarButtons();
- break;
- }
- case "DEL":
- {
- if (ultraGrid1.ActiveRow == null || (bAddNow || bEditNow || bDelNow))
- return;
- bDelNow = true;
- this.proc_SetToolbarButtons();
- proc_Delete();
- bDelNow = false;
- this.proc_SetToolbarButtons();
- break;
- }
- case "SAVE":
- {
- if (bAddNow)
- {
- proc_Add();
- }
- else if (bEditNow)
- {
- proc_Edit();
- }
- break;
- }
- case "CANCEL":
- {
- if (!(bAddNow || bEditNow)) return;
- string strOpt = " [" + (bAddNow ? "新增" : (bEditNow ? "修改" : "")) + "]";
- if (MessageBox.Show("确定要取消" + strOpt + "操作吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- return;
- if (bAddNow)
- {
- currRow.Delete(false);
- currRow = null;
- if (ultraGrid1.Rows.Count > 0)
- {
- ultraGrid1.ActiveCell = ultraGrid1.Rows[ultraGrid1.Rows.Count - 1].Cells["BILLETNO"];
- ultraGrid1.Rows[ultraGrid1.Rows.Count - 1].Cells["BILLETNO"].Selected = false;
- }
- bAddNow = false;
- }
- else if (bEditNow)
- {
- this.proc_setCellReadOnly(currRow, true);
- currRow.Cells["BILLETNO"].Value = currRow.Cells["BILLETNO"].Tag;
- currRow.Cells["HEATNO"].Value = currRow.Cells["HEATNO"].Tag;
- currRow.Cells["CATEGORY"].Value = currRow.Cells["CATEGORY"].Tag;
- currRow.Cells["LENGTH"].Value = currRow.Cells["LENGTH"].Tag;
- currRow.Cells["THICKNESS"].Value = currRow.Cells["THICKNESS"].Tag;
- currRow.Cells["WIDTH"].Value = currRow.Cells["WIDTH"].Tag;
- currRow.Cells["WEIGHT"].Value = currRow.Cells["WEIGHT"].Tag;
- currRow.Cells["CUTTIME"].Value = currRow.Cells["CUTTIME"].Tag;
- ultraGrid1.ActiveCell = currRow.Cells["BILLETNO"];
- currRow.Cells["BILLETNO"].Selected = false;
- currRow = null;
- bEditNow = false;
- }
- this.proc_SetToolbarButtons();
- break;
- }
- case "EXPORT":
- {
- if ((bAddNow || bEditNow || bDelNow) || ultraGrid1.Rows.Count <= 0)
- return;
- bool bInstalled = (Type.GetTypeFromProgID("Excel.Application") != null);
- if (!bInstalled)
- {
- MessageBox.Show("系统没有安装EXCEL组件,无法导出数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- return;
- }
- string strFileName = Application.StartupPath + "\\Report\\切头、切尾、边角料实绩表.xls";
- ultraGridExcelExporter1.Export(ultraGrid1, strFileName);
- ProcessStartInfo p = new ProcessStartInfo(strFileName);
- p.WorkingDirectory = Path.GetDirectoryName(strFileName);
- Process.Start(p);
- break;
- }
- case "CLOSE":
- {
- this.Close();
- break;
- }
- }
- }
- private void frmCutInfoAssit_FormClosing(object sender, FormClosingEventArgs e)
- {
- try
- {
- if (bAddNow)
- {
- if (MessageBox.Show("[新增]操作尚未完成,确定要关闭吗?", "提示", MessageBoxButtons.OKCancel,
- MessageBoxIcon.Question) == DialogResult.Cancel)
- e.Cancel = true;
- else
- bAddNow = false;
- }
- else if (bEditNow)
- {
- if (MessageBox.Show("[修改]操作尚未完成,确定要关闭吗?", "提示", MessageBoxButtons.OKCancel,
- MessageBoxIcon.Question) == DialogResult.Cancel)
- e.Cancel = true;
- else
- bEditNow = false;
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void ultraTextEditor_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- try
- {
- Infragistics.Win.UltraWinEditors.UltraTextEditor ultraTextEditor = (Infragistics.Win.UltraWinEditors.UltraTextEditor)sender;
- if (ultraTextEditor == null) return;
- if (ultraTextEditor.Text.Trim().Length > 0)
- {
- ultraTextEditor.Tag = ultraTextEditor.Text.Trim();
- ultraTextEditor.Text = "";
- }
- else
- {
- if (ultraTextEditor.Tag != null)
- {
- ultraTextEditor.Text = Convert.ToString(ultraTextEditor.Tag);
- }
- }
- }
- catch { }
- }
- private void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)
- {
- try
- {
- if (!(bAddNow || bEditNow)) return;
- if (e.Cell == null) return;
- if (e.Cell != currRow.Cells[e.Cell.Column.Key]) return;
- if (e.Cell.Row.Index < 0) return;
- switch (e.Cell.Column.Key)
- {
- case "BILLETNO":
- {
- if (bAddNow) //修改记录时不能修改坯料号
- {
- frmSelBillet frm = new frmSelBillet();
- frm.ShowDialog();
- if (frm.DialogResult == DialogResult.OK &&
- frm.alstReturn != null)
- {
- this.currRow.Cells["BILLETNO"].Value = frm.alstReturn[0];
- this.currRow.Cells["HEATNO"].Value = frm.alstReturn[1];
- if (Convert.ToString(this.currRow.Cells["CATEGORY"].Value) == "01" ||
- Convert.ToString(this.currRow.Cells["CATEGORY"].Value) == "02")
- {
- this.currRow.Cells["THICKNESS"].Value = frm.alstReturn[2];
- this.currRow.Cells["WIDTH"].Value = frm.alstReturn[3];
- }
- this.currRow.Cells["THICKNESS"].Tag = frm.alstReturn[2];
- this.currRow.Cells["WIDTH"].Tag = frm.alstReturn[3];
- }
- }
- break;
- }
- case "CUTTIME":
- {
- frmSetTime frm = new frmSetTime(e.Cell.Value);
- frm.Location = CStaticMethod.GetChildWindowLocation(frm.Size);
- frm.ShowDialog();
- if (frm._returnTime > new DateTime(2000, 1, 1, 0, 0, 0))
- e.Cell.Value = frm._returnTime;
- break;
- }
- }
- }
- catch { }
- }
- private void ultraGrid_CellListSelect(object sender, CellEventArgs e)
- {
- try
- {
- if (!bAddNow) return;
- if (e.Cell == null) return;
- if (e.Cell.Row.Index < 0) return;
- if (e.Cell.Column.Key != "CATEGORY") return;
- ultraGrid1.UpdateData();
- if (Convert.ToString(e.Cell.Value) == "01" ||
- Convert.ToString(e.Cell.Value) == "02")
- {
- if (this.currRow.Cells["THICKNESS"].Tag != null)
- this.currRow.Cells["THICKNESS"].Value = Convert.ToString(this.currRow.Cells["THICKNESS"].Tag);
- if (this.currRow.Cells["WIDTH"].Tag != null)
- this.currRow.Cells["WIDTH"].Value = Convert.ToString(this.currRow.Cells["WIDTH"].Tag);
- }
- }
- catch { }
- }
- private void ultraGrid_CellChange(object sender, CellEventArgs e)
- {
- try
- {
- if (!bAddNow && !bEditNow) return;
- if (e.Cell == null) return;
- if (e.Cell.Row.Index < 0) return;
- if (e.Cell.Column.Key != "LENGTH" &&
- e.Cell.Column.Key != "THICKNESS" &&
- e.Cell.Column.Key != "WIDTH" &&
- e.Cell.Column.Key != "WEIGHT")
- return;
- string strText = Convert.ToString(e.Cell.Text.Trim());
- if (strText.Length > 0)
- {
- decimal dValue = 0.0M;
- if (!decimal.TryParse(strText, out dValue))
- {
- MessageBox.Show("无效数字!", e.Cell.Column.Header.Caption, MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- e.Cell.CancelUpdate();
- }
- }
- }
- catch { }
- }
- private void ultraGrid_AfterCellActivate(object sender, EventArgs e)
- {
- try
- {
- if (!bAddNow && !bEditNow) return;
- this.ultraGrid1.PerformAction(UltraGridAction.EnterEditMode, false, false);
- }
- catch { }
- }
- }
- }
|