using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using System.Collections; using Infragistics.Win.UltraWinGrid; using System.IO; using System.Reflection; namespace Core.LZMes.Client.UIB { public partial class UIB010302 : FrmBase { public UIB010302() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoSearch(); break; case "Save": this.DoSave(); break; case "Delete": this.DoDelete(); break; case "Export": this.DoExport(); break; } } public void DoSearch() { try { //验证操作密码 if (verifyPass()) { this.DoQuery(); } } catch (Exception ex) { } } public void DoSave() { try { if (MessageBox.Show("确定保存?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; //验证操作密码 if (verifyPass()) { ArrayList list = null; ArrayList al = new ArrayList(); if (this.ultraTabControl1.Tabs[0].Selected)//厚度 界面 { foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { if (ugr.Cells["CHK"].Text == "True") { list = new ArrayList(); if (ugr.Cells["PRDNM_CD_1"].Text != "")//更新 { list.Add("UIB010302_01.UPDATE"); list.Add(ugr.Cells["USED_TP"].Text.ToString()); list.Add(ugr.Cells["PRDNM_CD"].Text.ToString()); list.Add(ugr.Cells["SPEC_ABBSYM"].Text.ToString()); list.Add(ugr.Cells["SPEC_STL_GRD"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MIN"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MAX"].Text.ToString()); list.Add(ugr.Cells["XI_SHU"].Text.ToString()); list.Add(ugr.Cells["THK_MIN"].Text.ToString()); list.Add(ugr.Cells["THK_MAX"].Text.ToString()); list.Add(this.UserInfo.GetUserName()); list.Add(ugr.Cells["P_YAN_SHEN"].Text.ToString()); list.Add(ugr.Cells["L_YAN_SHEN"].Text.ToString()); list.Add(ugr.Cells["C_JIAN_BO"].Text.ToString()); list.Add(ugr.Cells["RMK_DCS"].Text.ToString()); list.Add(ugr.Cells["PRDNM_CD_1"].Text.ToString()); list.Add(ugr.Cells["SPEC_ABBSYM_1"].Text.ToString()); list.Add(ugr.Cells["SPEC_STL_GRD_1"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MIN_1"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MAX_1"].Text.ToString()); al.Add(list); } else//插入 { list.Add("UIB010302_01.INSERT"); list.Add(ugr.Cells["USED_TP"].Text.ToString()); list.Add(ugr.Cells["PRDNM_CD"].Text.ToString()); list.Add(ugr.Cells["SPEC_ABBSYM"].Text.ToString()); list.Add(ugr.Cells["SPEC_STL_GRD"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MIN"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MAX"].Text.ToString()); list.Add(ugr.Cells["XI_SHU"].Text.ToString()); list.Add(ugr.Cells["THK_MIN"].Text.ToString()); list.Add(ugr.Cells["THK_MAX"].Text.ToString()); list.Add(this.UserInfo.GetUserName()); list.Add(ugr.Cells["P_YAN_SHEN"].Text.ToString()); list.Add(ugr.Cells["L_YAN_SHEN"].Text.ToString()); list.Add(ugr.Cells["C_JIAN_BO"].Text.ToString()); list.Add(ugr.Cells["RMK_DCS"].Text.ToString()); al.Add(list); } }//if end }//for end } else//宽度 { foreach (UltraGridRow ugr in this.ultraGrid2.Rows) { if (ugr.Cells["CHK"].Text == "True") { list = new ArrayList(); if (ugr.Cells["PRDNM_CD_1"].Text != "")//更新 { list.Add("UIB010302_02.UPDATE"); list.Add(ugr.Cells["USED_TP"].Text.ToString()); list.Add(ugr.Cells["PRDNM_CD"].Text.ToString()); list.Add(ugr.Cells["SPEC_ABBSYM"].Text.ToString()); list.Add(ugr.Cells["SPEC_STL_GRD"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MIN"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MAX"].Text.ToString()); list.Add(ugr.Cells["REQ_WTH_MIN"].Text.ToString()); list.Add(ugr.Cells["REQ_WTH_MAX"].Text.ToString()); list.Add(ugr.Cells["LZ_LIANG"].Text.ToString()); list.Add(ugr.Cells["SUAN_WTH_MIN"].Text.ToString()); list.Add(ugr.Cells["SUAN_WTH_MAX"].Text.ToString()); list.Add(ugr.Cells["RMK_DSC"].Text.ToString()); list.Add(this.UserInfo.GetUserName().ToString()); list.Add(ugr.Cells["LZ_LIANG_MIN"].Text.ToString()); list.Add(ugr.Cells["LZ_LIANG_MAX"].Text.ToString());//================================================= list.Add(ugr.Cells["LIAN_WTH_MIN"].Text.ToString()); list.Add(ugr.Cells["LIAN_WTH_MAX"].Text.ToString()); list.Add(ugr.Cells["PRDNM_CD_1"].Text.ToString()); list.Add(ugr.Cells["SPEC_ABBSYM_1"].Text.ToString()); list.Add(ugr.Cells["SPEC_STL_GRD_1"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MIN_1"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MAX_1"].Text.ToString()); list.Add(ugr.Cells["REQ_WTH_MIN_1"].Text.ToString()); list.Add(ugr.Cells["REQ_WTH_MAX_1"].Text.ToString()); al.Add(list); } else//插入 { list.Add("UIB010302_02.INSERT"); list.Add(ugr.Cells["USED_TP"].Text.ToString()); list.Add(ugr.Cells["PRDNM_CD"].Text.ToString()); list.Add(ugr.Cells["SPEC_ABBSYM"].Text.ToString()); list.Add(ugr.Cells["SPEC_STL_GRD"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MIN"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MAX"].Text.ToString()); list.Add(ugr.Cells["REQ_WTH_MIN"].Text.ToString()); list.Add(ugr.Cells["REQ_WTH_MAX"].Text.ToString()); list.Add(ugr.Cells["LZ_LIANG"].Text.ToString()); list.Add(ugr.Cells["SUAN_WTH_MIN"].Text.ToString()); list.Add(ugr.Cells["SUAN_WTH_MAX"].Text.ToString()); list.Add(ugr.Cells["RMK_DSC"].Text.ToString()); list.Add(this.UserInfo.GetUserName().ToString()); list.Add(ugr.Cells["LZ_LIANG_MIN"].Text.ToString()); list.Add(ugr.Cells["LZ_LIANG_MAX"].Text.ToString());//============================== list.Add(ugr.Cells["LIAN_WTH_MIN"].Text.ToString()); list.Add(ugr.Cells["LIAN_WTH_MAX"].Text.ToString()); al.Add(list); }// else end }//if end }//for end }//else 宽度 end if (al.Count == 0) return; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBSave"; ccp.MethodName = "doXmlSave"; ccp.ServerParams = new object[] { al }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.DoQuery(); } } catch (Exception ex) { } } public void DoQuery() { try { ArrayList al = new ArrayList(); string strTable = ""; if (this.ultraTabControl1.Tabs[0].Selected)//厚度 { this.dataSet1.Tables[0].Clear(); al.Add("UIB010302_01.SELECT"); strTable = "Table1"; } else//宽度 { this.dataSet1.Tables[1].Clear(); al.Add("UIB010302_02.SELECT"); strTable = "Table2"; } al.Add(this.textBox1.Text.ToString()); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { al }; ccp.SourceDataTable = this.dataSet1.Tables[strTable]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } catch (Exception ex) { } } public void DoDelete() { try { if (MessageBox.Show("确定删除?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; //验证操作密码 if (verifyPass()) { ArrayList list = null; ArrayList al = new ArrayList(); if (this.ultraTabControl1.Tabs[0].Selected)//厚度 界面 { foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { if (ugr.Cells["CHK"].Text == "True") { list = new ArrayList(); list.Add("UIB010302_01.DELETE"); list.Add(ugr.Cells["PRDNM_CD"].Text.ToString()); list.Add(ugr.Cells["SPEC_ABBSYM"].Text.ToString()); list.Add(ugr.Cells["SPEC_STL_GRD"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MIN"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MAX"].Text.ToString()); //list.Add(ugr.Cells["XI_SHU"].Text.ToString()); al.Add(list); }//if end }//for end }//if end else//宽度界面 { foreach (UltraGridRow ugr in this.ultraGrid2.Rows) { if (ugr.Cells["CHK"].Text == "True") { list = new ArrayList(); list.Add("UIB010302_02.DELETE"); list.Add(ugr.Cells["PRDNM_CD"].Text.ToString()); list.Add(ugr.Cells["SPEC_ABBSYM"].Text.ToString()); list.Add(ugr.Cells["SPEC_STL_GRD"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MIN"].Text.ToString()); list.Add(ugr.Cells["REQ_THK_MAX"].Text.ToString()); list.Add(ugr.Cells["REQ_WTH_MIN"].Text.ToString()); list.Add(ugr.Cells["REQ_WTH_MAX"].Text.ToString()); al.Add(list); }//if end }//for end }// else end if (al.Count == 0) return; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBSave"; ccp.MethodName = "doXmlSave"; ccp.ServerParams = new object[] { al }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); this.DoQuery(); } }catch(Exception ex) { } } private void DoExport() { try { if (verifyPass()) { saveFileDialog1.FileName = "冷硬卷尺寸对应关系"; if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK) { string fileName = this.saveFileDialog1.FileName; ultraGridExcelExporter1.Export(ultraGrid1, fileName); System.Diagnostics.Process.Start(fileName); } } } catch (Exception EX) { MessageBox.Show(EX.ToString()); } } //验证操作密码 public bool verifyPass() { bool returnBool = false; try { CUIB010302SP CWindow = new CUIB010302SP(); CWindow.ob = this.ob; //CWindow.frmdoquery += new CUIB030110.ddd(CWindow_frmdoquery);//委托 if (CWindow.ShowDialog() == DialogResult.OK) { string wPassWord = CWindow.ePassWord;//用户输入密码 string vPassWord = this.verifyPassWord.Text.ToString(); //修改密码 if (vPassWord.Equals(wPassWord)) { returnBool = true; } else { MessageBox.Show("操作密码错误,请重新输入正确密码才能操作!", "提示"); } } CWindow.Dispose(); } catch (Exception ex) { } return returnBool; } private void UIB010302_Load(object sender, EventArgs e) { try { ArrayList al = new ArrayList(); al.Add("UIB010302_01.INITSELECT"); //标准号 this.dataSet2.Tables[0].Clear(); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { al }; ccp.SourceDataTable = this.dataSet2.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); al = new ArrayList(); al.Add("UIB010302_02.INITSELECT"); //牌号 this.dataSet2.Tables[1].Clear(); ccp = new CoreClientParam(); ccp.ServerName = "UIB.COM.ComDBQuery"; ccp.MethodName = "doSimpleQuery"; ccp.ServerParams = new object[] { al }; ccp.SourceDataTable = this.dataSet2.Tables[1]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } catch (Exception ex) { } } private void button1_Click(object sender, EventArgs e) { try { string directoryPath = "C:\\Temp\\ZBS\\"; int indexFlag = 0; //foreach (UltraGridRow ugr in this.ultraGrid1.Rows) //{ // if (Convert.ToBoolean(ugr.Cells["CHK"].Text) && ugr.Cells["CRET_PRINT_TP"].Text == "Y") // { indexFlag++; CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "UIB.UIB03.TestPrint"; ccp.MethodName = "print"; ccp.ServerParams = new object[] { "G00001" };//发送时该参数才有值 CoreClientParam cx = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); byte[] byData = (byte[])cx.ReturnObject; System.DateTime dt = System.DateTime.Now; string TimeNow = string.Format("{0:yyyyMMddHHmmssffff}", dt); string sFile = directoryPath + "ABC" + ".xls"; FileStream fs = new FileStream(sFile, FileMode.OpenOrCreate, FileAccess.Write); fs.Write(byData, 0, byData.Length); fs.Close(); Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook workbook = app.Application.Workbooks.Add(sFile); Microsoft.Office.Interop.Excel._Worksheet ws = (Microsoft.Office.Interop.Excel._Worksheet)workbook.Worksheets[1]; ws.PrintOut(1, 1, 1, false, Missing.Value, false, false, Missing.Value);//"HP LaserJet P1505" workbook.Saved = true; workbook.Close(Missing.Value, Missing.Value, Missing.Value); app.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(ws); System.Runtime.InteropServices.Marshal.ReleaseComObject(app); app = null; GC.Collect(); // } //} } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void button2_Click(object sender, EventArgs e) { try { saveFileDialog1.FileName = "冷硬卷尺寸对应关系"; if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK) { string fileName = this.saveFileDialog1.FileName; ultraGridExcelExporter1.Export(ultraGrid2, fileName); System.Diagnostics.Process.Start(fileName); } } catch (Exception EX) { MessageBox.Show(EX.ToString()); } } } }