| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698 |
- 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;
- namespace Core.LgMes.Client.LgIntegrationQuery
- {
- public partial class frmSteelCode : frmStyleBase
- {
- private bool bAddNow, bEditNow, bDelNow; //是否在进行新增、修改或者删除操作
- private UltraGridRow currRow = null;
- // private CallingMessage par;
- private string strReturn = "ExecuteCommand_Return", strNonReturn = "ExecuteCommand_NonReturn";
- public frmSteelCode()
- {
- InitializeComponent();
- }
- private void frmSteelCode_Load(object sender, EventArgs e)
- {
- proc_Init();
- proc_BindData();
- proc_Query("");
- proc_SetToolbarButtons();
- }
- private void proc_Init()
- {
- try
- {
- //hengxing
- //par = new CallingMessage();
- //par.ServerName = "Report";
- //par.AssemblyName = "Core.LgMes.Server.Report";
- //par.ClassName = "Core.LgMes.Server.Report.reportMethod";
- }
- 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.NoEdit;
- }
- }
- private void proc_setCellReadOnly(UltraGridRow row, bool bReadOnly)
- {
- try
- {
- if (row == null)
- return;
- if (bReadOnly)
- {
- row.Activation = Activation.NoEdit;
- row.Cells["STEELCODE"].CancelUpdate();
- row.Cells["STEELNAME"].CancelUpdate();
- }
- else
- {
- row.Activation = Activation.AllowEdit;
- row.Cells["STEELCODE"].Activation = Activation.AllowEdit;
- row.Cells["STEELNAME"].Activation = Activation.AllowEdit;
- row.Cells["RECORDER"].Activation = Activation.NoEdit;
- row.Cells["OPTDATE"].Activation = Activation.NoEdit;
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void cbxCode_CheckedChanged(object sender, EventArgs e)
- {
- cbbCode.Enabled = cbxCode.Checked;
- if (!cbxCode.Checked)
- {
- cbbCode.Text = "";
- }
- }
- private void cbxName_CheckedChanged(object sender, EventArgs e)
- {
- cbbName.Enabled = cbxName.Checked;
- if (!cbxName.Checked)
- {
- cbbName.Text = "";
- }
- }
- private void proc_BindData()
- {
- Cursor oldCursor = this.Cursor;
- this.Cursor = Cursors.WaitCursor;
- try
- {
- string strErr = "";
- string strSql = "select STEELCODE STEELCODE, STEELNAME STEELNAME from BSA_ISTEELCODE order by STEELNAME";
- //hengxing
- //par.MethodName = strReturn;
- //par.args = 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_BindData();
- return;
- }
- DataView dvCode = ds.Tables[0].DefaultView;
- DataView dvName = ds.Tables[0].Copy().DefaultView;
- dvCode.Sort = "STEELCODE";
- dvName.Sort = "STEELNAME";
- cbbCode.DataSource = dvCode;
- cbbCode.DisplayMember = "STEELCODE";
- cbbCode.SelectedIndex = -1;
- cbbName.DataSource = dvName;
- cbbName.DisplayMember = "STEELNAME";
- cbbName.SelectedIndex = -1;
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- finally
- {
- this.Cursor = oldCursor;
- }
- }
- private void proc_Query(string strCode)
- {
- Cursor oldCursor = this.Cursor;
- this.Cursor = Cursors.WaitCursor;
- try
- {
- string strWhere = "where 1 = 1";
- if (cbxCode.Checked && cbbCode.Text.Trim().Length > 0)
- {
- strWhere += " and STEELCODE = '" + cbbCode.Text.Trim() + "'";
- }
- if (cbxName.Checked && cbbName.Text.Trim().Length > 0)
- {
- strWhere += " and STEELNAME = '" + cbbName.Text.Trim() + "'";
- }
- string strErr = "";
- string strSql = "select STEELCODE STEELCODE, STEELNAME STEELNAME, "
- + "RECORDER RECORDER, to_char(OPTDATE,'yyyy-MM-dd HH24:mi:ss') OPTDATE "
- + "from BSA_ISTEELCODE " + strWhere + " order by STEELNAME";
- //hengxing
- //par.MethodName = strReturn;
- //par.args = 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(strCode);
- 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["STEELCODE"];
- ultraGrid1.Rows[0].Cells["STEELCODE"].Selected = false;
- }
- if (strCode.Trim().Length == 0) return;
- string str = "";
- for (int i = 0; i < ultraGrid1.Rows.Count; i++)
- {
- str = Convert.ToString(ultraGrid1.Rows[i].Cells["STEELCODE"].Value);
- if (str == strCode)
- {
- ultraGrid1.ActiveCell = ultraGrid1.Rows[i].Cells["STEELCODE"];
- ultraGrid1.Rows[i].Cells["STEELCODE"].Selected = false;
- return;
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- finally
- {
- this.Cursor = oldCursor;
- }
- }
- private void proc_Add()
- {
- try
- {
- if (currRow == null) return;
- ultraGrid1.UpdateData();
- string strCode = currRow.Cells["STEELCODE"].Text.Trim();
- string strName = currRow.Cells["STEELNAME"].Text.Trim();
- if (strCode.Length == 0)
- {
- MessageBox.Show("请输入钢种代码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- ultraGrid1.ActiveCell = currRow.Cells["STEELCODE"];
- currRow.Cells["STEELCODE"].Selected = false;
- return;
- }
- if (strName.Length == 0)
- {
- MessageBox.Show("请输入钢种名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- ultraGrid1.ActiveCell = currRow.Cells["STEELNAME"];
- currRow.Cells["STEELNAME"].Selected = false;
- return;
- }
- string strErr = "";
- string strSql = "select count(1) from BSA_ISTEELCODE where STEELCODE = '" + strCode + "'";
- //hengxing
- //par.MethodName = strReturn;
- //par.args = new object[] { strSql };
- DataSet ds = null;//hengxing ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr) as DataSet;
- if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
- {
- MessageBox.Show("新增钢种代码[" + strCode + "/" + strName + "]失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
- if (iCnt > 0)
- {
- MessageBox.Show("钢种代码[" + strCode + "]重复,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- ultraGrid1.ActiveCell = currRow.Cells["STEELCODE"];
- currRow.Cells["STEELCODE"].Selected = false;
- return;
- }
- strErr = "";
- strSql = "select count(1) from BSA_ISTEELCODE where STEELNAME = '" + strName + "'";
- //hengxing
- //par.MethodName = strReturn;
- //par.args = new object[] { strSql };
- ds = null;//hengxing ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr) as DataSet;
- if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
- {
- MessageBox.Show("新增钢种代码[" + strCode + "/" + strName + "]失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
- if (iCnt > 0)
- {
- MessageBox.Show("钢种名称[" + strName + "]重复,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- ultraGrid1.ActiveCell = currRow.Cells["STEELNAME"];
- currRow.Cells["STEELNAME"].Selected = false;
- return;
- }
- strErr = "";
- strSql = "insert into BSA_ISTEELCODE (STEELCODE, STEELNAME, RECORDER, OPTDATE) values "
- + "('" + strCode + "', '" + strName + "', '" + this.UserInfo.GetUserName() + "', sysdate)";
- //hengxing
- //par.MethodName = strNonReturn;
- //par.args = new object[] { strSql };
- //ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr);
- if (!(strErr == null || strErr == ""))
- {
- MessageBox.Show("新增钢种代码[" + strCode + "/" + strName + "]失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- this.proc_setCellReadOnly(currRow, true);
- this.proc_Query(strCode);
- currRow = null;
- bAddNow = false;
- this.proc_SetToolbarButtons();
- MessageBox.Show("新增钢种代码[" + strCode + "/" + strName + "]成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void proc_Edit()
- {
- try
- {
- if (currRow == null) return;
- ultraGrid1.UpdateData();
- string strOldCode = Convert.ToString(currRow.Cells["STEELCODE"].Tag);
- string strOldName = Convert.ToString(currRow.Cells["STEELNAME"].Tag);
- string strCode = currRow.Cells["STEELCODE"].Text.Trim();
- string strName = currRow.Cells["STEELNAME"].Text.Trim();
- if (strCode.Length == 0)
- {
- MessageBox.Show("请输入钢种代码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- ultraGrid1.ActiveCell = currRow.Cells["STEELCODE"];
- currRow.Cells["STEELCODE"].Selected = false;
- return;
- }
- if (strName.Length == 0)
- {
- MessageBox.Show("请输入钢种名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- ultraGrid1.ActiveCell = currRow.Cells["STEELNAME"];
- currRow.Cells["STEELNAME"].Selected = false;
- return;
- }
- string strErr = "";
- string strSql = "select count(1) from BSA_ISTEELCODE "
- + "where STEELCODE = '" + strCode + "' and STEELCODE <> '" + strOldCode + "'";
- //par.MethodName = strReturn;
- //par.args = new object[] { strSql };
- DataSet ds = null;//hengxing ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr) as DataSet;
- if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
- {
- MessageBox.Show("钢种代码[" + strOldCode + "/" + strOldName + "]信息修改失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
- if (iCnt > 0)
- {
- MessageBox.Show("钢种代码[" + strCode + "]重复,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- ultraGrid1.ActiveCell = currRow.Cells["STEELCODE"];
- currRow.Cells["STEELCODE"].Selected = false;
- return;
- }
- strErr = "";
- strSql = "select count(1) from BSA_ISTEELCODE "
- + "where STEELNAME = '" + strName + "' and STEELCODE <> '" + strOldCode + "'";
- //hengxing
- //par.MethodName = strReturn;
- //par.args = new object[] { strSql };
- ds = null;//hengxing ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr) as DataSet;
-
- if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
- {
- MessageBox.Show("钢种代码[" + strOldCode + "/" + strOldName + "]信息修改失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
- if (iCnt > 0)
- {
- MessageBox.Show("钢种名称[" + strName + "]重复,请重新输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- ultraGrid1.ActiveCell = currRow.Cells["STEELNAME"];
- currRow.Cells["STEELNAME"].Selected = false;
- return;
- }
- strErr = "";
- strSql = "update BSA_ISTEELCODE set "
- + "STEELCODE = '" + strCode + "', STEELNAME = '" + strName + "', "
- + "RECORDER = '" + this.UserInfo.GetUserName() + "', OPTDATE = sysdate "
- + "where STEELCODE = '" + strOldCode + "'";
- //hengxing
- //par.MethodName = strNonReturn;
- //par.args = new object[] { strSql };
- //ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr);
- if (!(strErr == null || strErr == ""))
- {
- MessageBox.Show("钢种代码[" + strOldCode + "/" + strOldName + "]信息修改失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- this.proc_setCellReadOnly(currRow, true);
- this.proc_Query(strCode);
- currRow = null;
- bEditNow = false;
- this.proc_SetToolbarButtons();
- MessageBox.Show("钢种代码[" + strOldCode + "/" + strOldName + "]信息修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void proc_Delete()
- {
- try
- {
- if (ultraGrid1.Rows.Count <= 0) return;
- if (ultraGrid1.ActiveRow == null)
- {
- MessageBox.Show("请选择要删除的钢种代码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- UltraGridRow row = ultraGrid1.ActiveRow;
- string strCode = Convert.ToString(row.Cells["STEELCODE"].Value);
- string strName = Convert.ToString(row.Cells["STEELNAME"].Value);
- if (MessageBox.Show("确定要删除钢种代码[" + strCode + "/" + strName + "]信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
- return;
- string strErr = "";
- string strSql = "select count(1) from BSA_ISTEELCODE where STEELCODE = '" + strCode + "' and STEELNAME = '" + strName + "'";
- //hengxing
- //par.MethodName = strReturn;
- //par.args = new object[] { strSql };
- DataSet ds = null;//hengxing ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr) as DataSet;
- if (strErr != "" || !(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0))
- {
- MessageBox.Show("钢种代码[" + strCode + "/" + strName + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- int iCnt = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
- if (iCnt == 0)
- {
- MessageBox.Show("不存在钢种代码[" + strCode + "/" + strName + "]信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- proc_Query("");
- return;
- }
- strErr = "";
- strSql = "delete from BSA_ISTEELCODE where STEELCODE = '" + strCode + "' and STEELNAME = '" + strName + "'";
- //hengxing
- //par.MethodName = strNonReturn;
- //par.args = new object[] { strSql };
- //ClientCommon._RemotingHelp.ExecuteMethod(par, out strErr);
- if (!(strErr == null || strErr == ""))
- {
- MessageBox.Show("钢种代码[" + strCode + "/" + strName + "]信息删除失败!\r\n" + strErr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- this.proc_Query("");
- MessageBox.Show("钢种代码[" + strCode + "/" + strName + "]信息删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
- {
- switch (e.Tool.Key)
- {
- case "QUERY":
- {
- if (bAddNow || bEditNow || bDelNow)
- return;
- proc_Query("");
- proc_SetToolbarButtons();
- break;
- }
- case "NEW":
- {
- if (bAddNow || bEditNow || bDelNow)
- return;
- currRow = this.ultraGrid1.DisplayLayout.Bands[0].AddNew();
- this.proc_setCellReadOnly(currRow, false);
- ultraGrid1.ActiveCell = currRow.Cells["STEELCODE"];
- currRow.Cells["STEELCODE"].Selected = false;
- bAddNow = true;
- this.proc_SetToolbarButtons();
- break;
- }
- case "MODIFY":
- {
- if (ultraGrid1.ActiveRow == null || (bAddNow || bEditNow || bDelNow))
- return;
- currRow = ultraGrid1.ActiveRow;
- this.proc_setCellReadOnly(currRow, false);
- ultraGrid1.ActiveCell = currRow.Cells["STEELCODE"];
- currRow.Cells["STEELCODE"].Selected = false;
- currRow.Cells["STEELCODE"].Tag = currRow.Cells["STEELCODE"].Value;
- currRow.Cells["STEELNAME"].Tag = currRow.Cells["STEELNAME"].Value;
- bEditNow = true;
- 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["STEELCODE"];
- ultraGrid1.Rows[ultraGrid1.Rows.Count - 1].Cells["STEELCODE"].Selected = false;
- }
- bAddNow = false;
- }
- else if (bEditNow)
- {
- this.proc_setCellReadOnly(currRow, true);
- currRow.Cells["STEELCODE"].Value = currRow.Cells["STEELCODE"].Tag;
- currRow.Cells["STEELNAME"].Value = currRow.Cells["STEELNAME"].Tag;
- ultraGrid1.ActiveCell = currRow.Cells["STEELCODE"];
- currRow.Cells["STEELCODE"].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 frmSteelCode_FormClosing(object sender, FormClosingEventArgs e)
- {
- try
- {
- if (bAddNow)
- {
- if (MessageBox.Show("[新增]操作尚未完成,确定要关闭吗?", "提示", MessageBoxButtons.OKCancel,
- MessageBoxIcon.Question) == DialogResult.Cancel)
- e.Cancel = true;
- else
- {
- bAddNow = false;
- e.Cancel = false;
- }
- }
- else if (bEditNow)
- {
- if (MessageBox.Show("[修改]操作尚未完成,确定要关闭吗?", "提示", MessageBoxButtons.OKCancel,
- MessageBoxIcon.Question) == DialogResult.Cancel)
- e.Cancel = true;
- else
- {
- bEditNow = false;
- e.Cancel = false;
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- }
|