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 Infragistics.Win.UltraWinGrid; using System.Collections; using Infragistics.Win; using System.IO; namespace Core.LZMes.Client.QCM { public partial class QCM0107 : FrmBase { public QCM0107() { InitializeComponent(); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": this.DoQuery(); break; case "Add": this.Add(); break; case "Edit": this.Edit(); break; } } private void DoQuery() { //查询 try { this.dataSet1.Clear(); string prod_line = ""; if (this.comboBox3.Text.ToString() == "卷板") { prod_line = "JB1"; } else if (this.comboBox3.Text.ToString() == "中厚板") { prod_line = "ZHB"; } else if (this.comboBox3.Text.ToString() == "线棒") { prod_line = "XB1"; } else if (this.comboBox3.Text.ToString() == "炼钢") { prod_line = "LG"; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.QCM01.QCM0106.QueryDefect"; ccp.MethodName = "QueryMemo"; ccp.ServerParams = new object[] { prod_line }; ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void Add() { try { string prod_line = ""; if (this.comboBox1.Text.ToString() == "卷板") { prod_line = "JB1"; } else if (this.comboBox1.Text.ToString() == "中厚板") { prod_line = "ZHB"; } else if (this.comboBox1.Text.ToString() == "线棒") { prod_line = "XB1"; } else if (this.comboBox1.Text.ToString() == "炼钢") { prod_line = "LG"; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.QCM01.QCM0106.QueryDefect"; ccp.MethodName = "AddMemo"; ccp.ServerParams = new object[] { prod_line, this.textBox3.Text.ToString(),this.UserInfo.GetUserName().ToString(), this.textBox1.Text.ToString()}; //ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == 1) { MessageBox.Show("处理备注添加成功", "提示"); } this.DoQuery(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } private void Edit() { try { string prod_line = ""; if (this.comboBox1.Text.ToString() == "卷板") { prod_line = "JB1"; } else if (this.comboBox1.Text.ToString() == "中厚板") { prod_line = "ZHB"; } else if (this.comboBox1.Text.ToString() == "线棒") { prod_line = "XB1"; } else if (this.comboBox1.Text.ToString() == "炼钢") { prod_line = "LG"; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "QCM.QCM01.QCM0106.QueryDefect"; ccp.MethodName = "EMemo"; ccp.ServerParams = new object[] { prod_line, this.textBox3.Text.ToString(),this.UserInfo.GetUserName().ToString(), this.textBox1.Text.ToString()}; //ccp.SourceDataTable = this.dataSet1.Tables[0]; this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode == 1) { MessageBox.Show("处理备注修改成功", "提示"); } this.DoQuery(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } } /*public string memo = ""; private void button1_Click(object sender, EventArgs e) { foreach (UltraGridRow ugr in this.ultraGrid1.Rows) { if (ugr.Cells["CHK"].Text.ToLower() == "true") { if (memo == "") { memo = ugr.Cells["MEMO"].Value.ToString(); } else if (memo != "") { memo +=";"+ ugr.Cells["MEMO"].Value.ToString(); } } } this.DialogResult = DialogResult.OK; } private void button2_Click(object sender, EventArgs e) { this.Close(); } private void button3_Click(object sender, EventArgs e) { this.DoQuery(); } private void button4_Click(object sender, EventArgs e) { this.Add(); }*/ private void QCM0107_Load(object sender, EventArgs e) { this.comboBox3.Text = "卷板"; this.comboBox1.Text = "卷板"; } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { this.comboBox1.Text = this.ultraGrid1.ActiveRow.Cells["PLINE_CODE"].Text.ToString(); this.textBox1.Text = this.ultraGrid1.ActiveRow.Cells["MEMO_CODE"].Text.ToString(); this.textBox3.Text = this.ultraGrid1.ActiveRow.Cells["MEMO"].Text.ToString(); } private void button1_Click(object sender, EventArgs e) { try { OpenFileDialog Ofd = new OpenFileDialog(); Ofd.Title = "选择文件"; //Ofd.Filter = "文件 (*.doc;*;docx;*.xls;*.xlsx;*.et;*.png;*.xml;*.jpg)|*.doc;*;docx;*.xls;*.xlsx;*.et;*.png;*.xml;*.jpg"; Ofd.Filter = "文件 (*.xls;*.xlsx)|*.xls;*.xlsx"; //Ofd.Filter = "文件 (*.*)|*.*"; if (Ofd.ShowDialog() == DialogResult.OK) { this.textBox2.Text = Ofd.FileName.ToString();//选取文件路径 } if (MessageBox.Show("确定上传?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return; FileStream read = new FileStream(this.textBox2.Text.Trim(), FileMode.Open, FileAccess.Read); byte[] byData = new byte[read.Length]; read.Read(byData, 0, (int)read.Length); read.Close(); if (byData == null) { MessageBox.Show("请先选择需要上传的文件!", "提示"); return; } //获取文件扩展名 string[] str = this.textBox2.Text.Trim().Split('.'); string extName = "." + str[str.Length - 1]; CoreClientParam ccp = new CoreClientParam(); //ccp.ServerName = "QCM.QCM01.QCM0106.ImportExcelUtil"; ccp.ServerName = "QCM.QCM01.QCM0107.ImportEasyExcelUtil"; ccp.MethodName = "dateImport"; ccp.ServerParams = new object[] { byData, this.textBox2.Text.Trim(),this.UserInfo.GetUserName() }; this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if(ccp.ReturnCode == 1){ MessageBox.Show("导入成功", "提示"); } this.textBox2.Text = ""; //this.DoQuery(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("上传失败,请选择正确的文件路径", "提示"); } } } }