| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using Core.Mes.Client.Common;
- using Infragistics.Win.UltraWinGrid;
- using System.Collections;
- using CoreFS.CA06;
- using System.Diagnostics;
- using System.IO;
- namespace Core.LgMes.Client.lgIntegrationQuery
- {
- public partial class frmSteelTemp : Core.Mes.Client.Common.frmStyleBase
- {
- string strMess = "";
- string username = "";
- DataSet ds = new DataSet();
- DataSet dsSteel = new DataSet();
- public frmSteelTemp()
- {
- InitializeComponent();
- }
- private void frmSteelTemp_Load(object sender, EventArgs e)
- {
- InitSteel();
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- GetDataSource();
- break;
- case "Add":
- Add(urGridLTemp);
- strMess = "钢水温度范围标准保存成功!";
- break;
- case "Update":
- UpdateGrid();
- break;
- case "Delete":
- username = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID().Trim();
- if ("jsk02".Equals(username))
- {
- DeleteGrid();
- }
- else
- {
- strMess = "您的权限不足!\r\n请联系技术科!";
- MessageBox.Show(strMess);
- }
- break;
- case "Save":
- username = CoreFS.SA06.CoreUserInfo.UserInfo.GetUserID().Trim();
- if ("jsk02".Equals(username))
- {
- urGridLTemp.UpdateData();
- SaveData();
- }
- else
- {
- strMess = "您的权限不足!\r\n请联系技术科!";
- MessageBox.Show(strMess);
- }
- break;
-
- case "Export":
- if (urGridLTemp.Rows.Count > 0) ExportDataWithSaveDialog(ref this.urGridLTemp,"钢水温度范围标准");
- break;
- case "Rollback"://cancel
- JJBStaticFunction.dataCancel(urGridLTemp, dataTable1);
- break;
- case "Exit":
- this.Close();
- break;
- default:
- break;
- }
- }
- private void GetDataSource()
- {
- string strErr = "";
- string strSteel = "";
- string _strWhere2 = "";
- if (chkSteel.Checked && ultcboSteel.SelectedIndex > -1)
- {
- strSteel = Convert.ToString(ultcboSteel.Text);
- _strWhere2 = String.Format(" where t.steelname = '{0}'", strSteel);
- }
- else
- {
- _strWhere2 = "";
- }
- ArrayList arry = new ArrayList();
- ArrayList sqlList = new ArrayList();
- arry.Add("frmSTemp.select");
- sqlList.Add(_strWhere2);
- //调用服务端方法
- CoreClientParam CCP_LgEts = new CoreClientParam();
- DataTable dt = new DataTable();
- CCP_LgEts.ServerName = "Core.LgMes.Server.Common.ComDBQuery";
- CCP_LgEts.MethodName = "doQuery";
- CCP_LgEts.ServerParams = new object[] { arry, sqlList };
- CCP_LgEts.SourceDataTable = dt;
- this.ExecuteQueryToDataTable(CCP_LgEts, CoreInvokeType.Internal);
- ds.Tables.Add(dt);
- dsSTemp.Clear();
- this.dataTable1.Rows.Clear();
- if (strErr == "" && ds != null)
- {
- DataRow dr;
- for (int iRow = 0; iRow < dt.Rows.Count; iRow++)
- {
- dr = this.dataTable1.NewRow();
- for (int jCol = 0; jCol < dt.Columns.Count; jCol++)
- {
- try
- {
- if (this.dataTable1.Columns.Contains(dt.Columns[jCol].ColumnName))
- {
- dr[dt.Columns[jCol].ColumnName] = Convert.ToString(dt.Rows[iRow][jCol]);
- }
- }
- catch { }
- }
- this.dataTable1.Rows.Add(dr);
- }
- urGridLTemp.UpdateData();
- dataTable1.AcceptChanges();
- }
- JJBStaticFunction.SetRowEdit(urGridLTemp);//Grid可编辑性
- }
- /// <summary>
- /// 更新数据
- /// </summary>
- private void UpdateGrid()
- {
- JJBStaticFunction.Update(urGridLTemp);
- strMess = "钢水温度范围标准修改成功!";
- if (urGridLTemp.ActiveRow != null)
- {
- for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
- {
- if (ds.Tables[0].Columns[i].ColumnName == "STEELNAME")
- {
- urGridLTemp.ActiveRow.Cells["STEELNAME"].Activation = Infragistics.Win.UltraWinGrid.Activation.NoEdit;
- }
- else
- {
- urGridLTemp.ActiveRow.Cells[ds.Tables[0].Columns[i].ColumnName].Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- }
- }
- }
- else
- MessageBox.Show("请选择需要修改的数据行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- private void DeleteGrid()
- {
- if (urGridLTemp.ActiveRow != null)
- {
- string strMCode = urGridLTemp.ActiveRow.Cells["STEELNAME"].Text.Trim();
- JJBStaticFunction.Delete(urGridLTemp);
- DelData(strMCode);
- }
- else
- MessageBox.Show("请选择需要删除的数据行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- /// <summary>
- /// 删除钢水温度范围标准标准
- /// </summary>
- private void DelData(string strMCode)
- {
- string strErr = "";
- if (dataTable1.GetChanges() != null)
- {
- ArrayList arry = new ArrayList();
- arry.Add("frmSTemp_Del.select");
- arry.Add(strMCode);
- CommonClientToServer cctos = new CommonClientToServer();
- cctos.ob = this.ob;
- DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
- "doSimpleSave", arry, out strErr);
- if (strErr != "" && ds != null)
- {
- MessageBox.Show(strErr);
- }
- else
- {
- MessageBox.Show("钢水温度范围标准删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- }
- }
- /// <summary>
- /// 新增数据
- /// </summary>
- /// <param name="Grid"></param>
- public static void Add(Infragistics.Win.UltraWinGrid.UltraGridBase Grid)
- {
- Grid.UpdateData();
- UltraGridRow ur = Grid.DisplayLayout.Bands[0].AddNew();
- ur.Activation = Infragistics.Win.UltraWinGrid.Activation.AllowEdit;
- }
- /// <summary>
- /// 保存钢水温度范围标准
- /// </summary>
- private void SaveData()
- {
- try
- {
- urGridLTemp.UpdateData();
- if (dataTable1.Rows.Count > 0)
- {
- string strErr = "";
- ArrayList arry = new ArrayList();
- string STEELNAME = urGridLTemp.ActiveRow.Cells["STEELNAME"].Text;
- string LEAVETEMPTC_D = urGridLTemp.ActiveRow.Cells["LEAVETEMPTC_D"].Text;
- string ARRIVETEMPTD_D = urGridLTemp.ActiveRow.Cells["ARRIVETEMPTD_D"].Text;
- string LEAVETEMPTD_D = urGridLTemp.ActiveRow.Cells["LEAVETEMPTD_D"].Text;
- string ARRIVETEMPTG_D = urGridLTemp.ActiveRow.Cells["ARRIVETEMPTG_D"].Text;
- string LEAVETEMPTC_E = urGridLTemp.ActiveRow.Cells["LEAVETEMPTC_E"].Text;
- string ARRIVETEMPTD_E = urGridLTemp.ActiveRow.Cells["ARRIVETEMPTD_E"].Text;
- string LEAVETEMPTE_E = urGridLTemp.ActiveRow.Cells["LEAVETEMPTE_E"].Text;
- string ARRIVETEMPTG_E = urGridLTemp.ActiveRow.Cells["ARRIVETEMPTG_E"].Text;
- string LEAVETEMPTC_F = urGridLTemp.ActiveRow.Cells["LEAVETEMPTC_F"].Text;
- string ARRIVETEMPTD_F = urGridLTemp.ActiveRow.Cells["ARRIVETEMPTD_F"].Text;
- string ARRIVETEMPTF_F = urGridLTemp.ActiveRow.Cells["ARRIVETEMPTF_F"].Text;
- string LEAVETEMPTF_F = urGridLTemp.ActiveRow.Cells["LEAVETEMPTF_F"].Text;
- string ARRIVETEMPTG_F = urGridLTemp.ActiveRow.Cells["ARRIVETEMPTG_F"].Text;
- string LEAVETEMPTC_EF = urGridLTemp.ActiveRow.Cells["LEAVETEMPTC_EF"].Text;
- string ARRIVETEMPTD_EF = urGridLTemp.ActiveRow.Cells["ARRIVETEMPTD_EF"].Text;
- string LEAVETEMPTE_EF = urGridLTemp.ActiveRow.Cells["LEAVETEMPTE_EF"].Text;
- string LEAVETEMPTF_EF = urGridLTemp.ActiveRow.Cells["LEAVETEMPTF_EF"].Text;
- string ARRIVETEMPTG_EF = urGridLTemp.ActiveRow.Cells["ARRIVETEMPTG_EF"].Text;
- string LEAVETEMPTC_EI = urGridLTemp.ActiveRow.Cells["LEAVETEMPTC_EI"].Text;
- string ARRIVETEMPTD_EI = urGridLTemp.ActiveRow.Cells["ARRIVETEMPTD_EI"].Text;
- string LEAVETEMPTE_EI = urGridLTemp.ActiveRow.Cells["LEAVETEMPTE_EI"].Text;
- string LEAVETEMPTI_EI = urGridLTemp.ActiveRow.Cells["LEAVETEMPTI_EI"].Text;
- string ARRIVETEMPTG_EI = urGridLTemp.ActiveRow.Cells["ARRIVETEMPTG_EI"].Text;
- if (strMess == "钢水温度范围标准保存成功!")
- {
- arry.Add("frmSTemp_Save.select");
- arry.Add(STEELNAME);
- }
- if (strMess == "钢水温度范围标准修改成功!")
- {
- arry.Add("frmSTemp_Update.select");
- }
- arry.Add(LEAVETEMPTC_D);
- arry.Add(ARRIVETEMPTD_D);
- arry.Add(LEAVETEMPTD_D);
- arry.Add(ARRIVETEMPTG_D);
- arry.Add(LEAVETEMPTC_E);
- arry.Add(ARRIVETEMPTD_E);
- arry.Add(LEAVETEMPTE_E);
- arry.Add(ARRIVETEMPTG_E);
- arry.Add(LEAVETEMPTC_F);
- arry.Add(ARRIVETEMPTD_F);
- arry.Add(ARRIVETEMPTF_F);
- arry.Add(LEAVETEMPTF_F);
- arry.Add(ARRIVETEMPTG_F);
- arry.Add(LEAVETEMPTC_EF);
- arry.Add(ARRIVETEMPTD_EF);
- arry.Add(LEAVETEMPTE_EF);
- arry.Add(LEAVETEMPTF_EF);
- arry.Add(ARRIVETEMPTG_EF);
- arry.Add(LEAVETEMPTC_EI);
- arry.Add(ARRIVETEMPTD_EI);
- arry.Add(LEAVETEMPTE_EI);
- arry.Add(LEAVETEMPTI_EI);
- arry.Add(ARRIVETEMPTG_EI);
- if (strMess == "钢水温度范围标准修改成功!")
- {
- arry.Add(STEELNAME);
- }
- CommonClientToServer cctos = new CommonClientToServer();
- cctos.ob = this.ob;
- DataSet ds = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
- "doSimpleSave", arry, out strErr);
- if (strErr == "" && ds != null)
- {
- dataTable1.AcceptChanges();
- JJBStaticFunction.SetRowEdit(urGridLTemp);
- if (!string.IsNullOrEmpty(strMess))
- MessageBox.Show(strMess, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
- }
- else
- {
- MessageBox.Show("保存失败!输入信息已经存在或数据无效。", "错误");
- }
- if (urGridLTemp.ActiveCell != null)
- urGridLTemp.ActiveCell.Activated = false;
- }
- }
- catch (System.Exception ex)
- {
- Console.WriteLine(ex.ToString());
- }
- }
- private void InitSteel()
- {
- try
- {
- string strErr = "";
- //获取钢种
- ArrayList arrySteel = new ArrayList();
- arrySteel.Add("GetSteelInfo.select");
- CommonClientToServer cctos = new CommonClientToServer();
- cctos.ob = this.ob;
- dsSteel = cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBQuery",
- "doSimpleQuery", arrySteel, out strErr);
- if (strErr == "" && dsSteel != null)
- {
- Core.Mes.Client.Common.Globals.FillUltraComboItems(ultcboSteel, dsSteel);
- }
- }
- catch { }
- }
- private void chkSteel_CheckedChanged(object sender, EventArgs e)
- {
- ultcboSteel.Enabled = chkSteel.Checked;
- if (chkSteel.Checked == true)
- {
- InitSteel();
- }
- }
- public void ExportDataWithSaveDialog(ref UltraGrid ultGrid, string strFileName)
- {
- try
- {
- if (ultGrid.Rows.Count == 0) return;
- if (strFileName.Length == 0)
- strFileName = "未命名";
- SaveFileDialog dlg = new SaveFileDialog();
- dlg.Title = "保存";
- dlg.OverwritePrompt = true;
- dlg.Filter = "Excel文件(*.xls)|*.xls";
- dlg.AddExtension = true;
- dlg.FileName = strFileName;
- if (dlg.ShowDialog() == DialogResult.OK)
- {
- strFileName = dlg.FileName;
- ultraGridExcelExporter1.Export(ultGrid, strFileName);
- if (MessageBox.Show("数据导出成功!\r\n需要打开所导出文件吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
- {
- ultraGridExcelExporter1.Export(ultGrid, strFileName);
- ProcessStartInfo p = new ProcessStartInfo(strFileName);
- p.WorkingDirectory = Path.GetDirectoryName(strFileName);
- Process.Start(p);
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- }
|