| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- 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 QCM0108 : FrmBase
- {
- public QCM0108()
- {
- InitializeComponent();
- }
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case "Query":
- this.DoQuery();
- break;
- case "Add":
- this.Add();
- break;
- case "Del":
- this.Del();
- break;
- }
- }
- private void DoQuery()
- {
- //查询
- try
- {
- this.dataSet1.Clear();
- Hashtable ht = new Hashtable();
- ht.Add("USERNAME", this.UserInfo.GetUserName());
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "QCM.JHY01.JHY0102.QuerryJhyQtly";
- ccp.MethodName = "getLWGSTEEL";
- ccp.ServerParams = new object[] { ht };
- ccp.SourceDataTable = this.dataSet1.Tables[0];
- this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- }
- }
- public void doSteel()
- {
- this.dataSet2.Clear();
- Hashtable ht = new Hashtable();
- ht.Add("USERNAME", this.UserInfo.GetUserName());
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "QCM.JHY01.JHY0102.QuerryJhyQtly";//调用java地址
- ccp.MethodName = "getBZSTEEL";//调用的方法
- ccp.ServerParams = new object[] { ht };
- ccp.SourceDataTable = this.dataSet2.Tables[0];
- this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
- DataTable dt = new DataTable();
- dt.Columns.Add("STEEL_CODE");
- dt.Columns.Add("STEEL_NAME");
- for (int i = 0; i < ccp.SourceDataTable.Rows.Count; i++)
- {
- DataRow dr = dt.NewRow();
- dr[0] = ccp.SourceDataTable.Rows[i]["STEEL_CODE"].ToString();
- dr[1] = ccp.SourceDataTable.Rows[i]["STEEL_NAME"].ToString();
- dt.Rows.Add(dr);
- }
- this.comboBox1.DataSource = dt;
- this.comboBox1.DisplayMember = "STEEL_CODE";
- this.comboBox1.ValueMember = "STEEL_NAME";
- }
- private void Add()
- {
- try
- {
- string steel = this.comboBox1.Text.Trim().ToString();
- if (String.IsNullOrEmpty(steel))
- {
- this.alert("请输入新增的牌号!!!");
- return;
- }
- Hashtable ht = new Hashtable();
- ht.Add("USERID", this.UserInfo.GetUserID());
- ht.Add("USERNAME", this.UserInfo.GetUserName());
- ht.Add("STEEL", steel);
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "QCM.JHY01.JHY0102.UpdateInfo";
- ccp.MethodName = "AddLWGSTEEL";
- ccp.ServerParams = new object[] { ht };
- this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageBox.Show("新增成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
- }
- this.DoQuery();
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- }
-
- }
- private void Del()
- {
- try
- {
- UltraGridRow row = this.ultraGrid1.ActiveRow;
- if (row == null)
- {
- this.alert("没有牌号可删除!");
- return;
- }
- Hashtable ht = new Hashtable();
- ht.Add("USERID", this.UserInfo.GetUserID());
- ht.Add("USERNAME", this.UserInfo.GetUserName());
- ht.Add("STEEL", row.Cells["STEEL_NAME"].Value.ToString());
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "QCM.JHY01.JHY0102.UpdateInfo";
- ccp.MethodName = "delLWGSTEEL";
- ccp.ServerParams = new object[] { ht, };
-
- this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageBox.Show("删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.None);
- }
-
- this.DoQuery();
- }
- catch (Exception ex)
- {
- System.Diagnostics.Debug.WriteLine(ex.ToString());
- }
- }
-
- private void QCM0108_Load(object sender, EventArgs e)
- {
- this.comboBox3.Text = "螺纹钢";
- ValueList v1 = new ValueList();
- v1.ValueListItems.Add("1", "有效");
- v1.ValueListItems.Add("0", "无效");
- this.ultraGrid1.DisplayLayout.Bands[0].Columns["YN_LOG"].ValueList = v1.Clone();
- }
- 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.QCM0108.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("上传失败,请选择正确的文件路径", "提示");
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.doSteel();
- }
- }
- }
|