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 System.Collections;
using CoreFS.CA06;
using System.IO;
namespace Core.LZMes.Client.UIM
{
public partial class UIM010050 : FrmBase
{
//钢卷号
private string COIL_NO = "";
public UIM010050()
{
InitializeComponent();
}
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
this.DoQuery();
break;
case "Save":
this.DoSave();
break;
}
}
///
/// 查询钢卷在系统中的位置
///
private void DoQuery()
{
try
{
this.dataSet1.Tables[0].Clear();
string coilNo = this.textBox1.Text.Trim();
//外购卷入库可以直接调用热送入库查询钢卷信息
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010040";
ccp.MethodName = "queryCoilStatus";
ccp.ServerParams = new object[] { coilNo };
ccp.SourceDataTable = this.dataSet1.Tables[0];
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
COIL_NO = coilNo;
}
catch (Exception EX)
{
MessageBox.Show(EX.ToString());
}
}
///
/// 原料库外购卷入库
///
private void DoSave()
{
if (textBox1.Text.Trim().Equals(""))
{
MessageBox.Show("钢卷号不能为空,请输入钢卷号!");
textBox1.Focus();
return;
}
if (this.ultraComboEditor3.SelectedIndex < 0)
{
MessageBox.Show("标准号不能为空,请选择标准号!");
this.ultraComboEditor3.Focus();
return;
}
if (this.ultraComboEditor4.SelectedIndex < 0)
{
MessageBox.Show("标准牍号不能为空,请选择标准牌号!");
this.ultraComboEditor4.Focus();
return;
}
if (this.ultraComboEditor5.SelectedIndex < 0)
{
MessageBox.Show("订单用途不能为空,请选择订单用途!");
this.ultraComboEditor5.Focus();
return;
}
if (this.ultraComboEditor1.SelectedIndex < 0)
{
MessageBox.Show("交货状态不能为空,请选择交货状态!");
this.ultraComboEditor1.Focus();
return;
}
if (this.textBox11.Text.Trim().Equals(""))
{
MessageBox.Show("厚度不能为空,请输入厚度!");
this.textBox11.Focus();
return;
}
if (this.textBox9.Text.Trim().Equals(""))
{
MessageBox.Show("宽度不能为空,请输入宽度!");
this.textBox9.Focus();
return;
}
if (this.textBox13.Text.Trim().Equals(""))
{
MessageBox.Show("长度不能为空,请输入长度!");
this.textBox13.Focus();
return;
}
if (this.textBox12.Text.Trim().Equals(""))
{
MessageBox.Show("重量不能为空,请输入重量!");
this.textBox12.Focus();
return;
}
if (this.textBox14.Text.Trim().Equals(""))
{
MessageBox.Show("外径不能为空,请输入外径!");
this.textBox14.Focus();
return;
}
if (this.textBox15.Text.Trim().Equals(""))
{
MessageBox.Show("内径不能为空,请输入内径!");
this.textBox15.Focus();
return;
}
if (this.textBox4.Text.Trim().Equals(""))
{
MessageBox.Show("炉号不能为空,请输入炉号!");
this.textBox4.Focus();
return;
}
string coilNo = textBox1.Text.Trim();
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010050";
ccp.MethodName = "queryColdCoilNo";
ccp.ServerParams = new object[] { coilNo };
ccp = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnObject != null)
{
int haveCoil = int.Parse(ccp.ReturnObject.ToString());
if (haveCoil > 0)
{
MessageBox.Show("钢卷号在系统中已经存在,请重新输入!");
textBox1.Focus();
return;
}
}
UIM010051 dlg = new UIM010051(this, 1);
if (DialogResult.OK == dlg.ShowDialog(this))
{
string yardAddr = dlg.YARD_ADDR;//垛位
string entryShift = this.UserInfo.GetUserGroup();//入库班次
string entryGroup = this.UserInfo.GetUserOrder();//入库班组
string entryDtime = this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMddHHmmss");//入库时间
string reg_id = this.UserInfo.GetUserID();//操作人
//入库操作信息
string[] entryInfo = new string[] { yardAddr, entryShift, entryGroup, entryDtime, reg_id };
string specAbbssym = ultraComboEditor3.Value.ToString();
string specStlGrd = ultraComboEditor4.Value.ToString();
string ordUseTp = ultraComboEditor5.Value.ToString();
string prodNm = ultraComboEditor1.Value.ToString();
double thk = double.Parse(textBox11.Text.Trim());
double wth = double.Parse(textBox9.Text.Trim());
double len = double.Parse(textBox12.Text.Trim());
double wgt = double.Parse(textBox13.Text.Trim());
double outida = double.Parse(textBox14.Text.Trim());
double india = double.Parse(textBox15.Text.Trim());
string chargeNo = textBox4.Text.Trim();
//牌号 规格 炉号备注等信息
string[] coilInfo = new string[] { specAbbssym, specStlGrd, ordUseTp, prodNm
, thk.ToString(), wth.ToString(), len.ToString(), wgt.ToString(), outida.ToString(), india.ToString()
, chargeNo};
ArrayList qltyList = new ArrayList();//材质信息
int qltySize = dataSet1.Tables[0].Rows.Count;
for (int i = 0; i < qltySize; i++)
{
Infragistics.Win.UltraWinGrid.UltraGridRow uRow = ultraGrid1.Rows[i];
if (null != uRow.Cells["QLTY_VALUE1"].Text && !uRow.Cells["QLTY_VALUE1"].Text.Trim().Equals(""))
{
string[] param = new string[5];
param[0] = uRow.Cells["QLTY_CD_CFNM"].Text;
param[1] = uRow.Cells["QLTY_VALUE1"].Text.Trim();
param[2] = uRow.Cells["QLTY_VALUE2"].Text.Trim();
param[3] = uRow.Cells["QLTY_VALUE3"].Text.Trim();
param[4] = uRow.Cells["QLTY_VALUE4"].Text.Trim();
qltyList.Add(param);
}
}
ArrayList chemList = new ArrayList();//材质信息
int chemSize = dataSet2.Tables[0].Rows.Count;
for (int i = 0; i < chemSize; i++)
{
Infragistics.Win.UltraWinGrid.UltraGridRow uRow = ultraGrid2.Rows[i];
if (null != uRow.Cells["CHEM_DIS_VALUE"].Text && !uRow.Cells["CHEM_DIS_VALUE"].Text.Trim().Equals(""))
{
string[] param = new string[3];
param[0] = uRow.Cells["CHEM_CD"].Text;
param[1] = uRow.Cells["CHEM_DIS_VALUE"].Text.Trim();
param[2] = uRow.Cells["REMARK"].Text.Trim();
chemList.Add(param);
}
}
CoreClientParam ccp1 = new CoreClientParam();
ccp1.ServerName = "UIM.UIM010050";
ccp1.MethodName = "saveCoilYard";
ccp1.ServerParams = new object[] { coilNo, entryInfo, coilInfo, qltyList, chemList };
ccp1 = this.ExecuteNonQuery(ccp1, CoreInvokeType.Internal);
}
}
private void UIM010050_Load(object sender, EventArgs e)
{
int size = 0;
//标准号
ArrayList specAbbsymList = this.queryCommFun("UIM.UIM010050", "querySpecAbbsymList");
size = specAbbsymList.Count;
Infragistics.Win.ValueListItem[] valueListItems1 = new Infragistics.Win.ValueListItem[size];
for (int i = 0; i < size; i++)
{
Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem();
Hashtable ht = (Hashtable)specAbbsymList[i];
item.DataValue = ht["SPEC_ABBSYM"].ToString();
item.DisplayText = ht["SPEC_ABBSYM"].ToString(); ;
valueListItems1[i] = item;
}
this.ultraComboEditor3.Items.AddRange(valueListItems1);
//标准牌号
ArrayList specStlGrdList = this.queryCommFun("UIM.UIM010050", "querySpecStlGrdList");
size = specStlGrdList.Count;
Infragistics.Win.ValueListItem[] valueListItems2 = new Infragistics.Win.ValueListItem[size];
for (int i = 0; i < size; i++)
{
Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem();
Hashtable ht = (Hashtable)specStlGrdList[i];
item.DataValue = ht["SPEC_STL_GRD"].ToString();
item.DisplayText = ht["SPEC_STL_GRD"].ToString(); ;
valueListItems2[i] = item;
}
this.ultraComboEditor4.Items.AddRange(valueListItems2);
//订单用途
ArrayList ordUseTyList = this.queryCommFun("UIM.UIM010050", "queryOrdUseTyList");
size = ordUseTyList.Count;
Infragistics.Win.ValueListItem[] valueListItems3 = new Infragistics.Win.ValueListItem[size];
for (int i = 0; i < size; i++)
{
Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem();
Hashtable ht = (Hashtable)ordUseTyList[i];
item.DataValue = ht["SM_CD"].ToString();
item.DisplayText = ht["SM_CFNM"].ToString(); ;
valueListItems3[i] = item;
}
this.ultraComboEditor5.Items.AddRange(valueListItems3);
//交货状态
ArrayList prodNmList = this.queryCommFun("UIM.UIM010050", "queryProdNmList");
size = prodNmList.Count;
Infragistics.Win.ValueListItem[] valueListItems4 = new Infragistics.Win.ValueListItem[size];
for (int i = 0; i < size; i++)
{
Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem();
Hashtable ht = (Hashtable)prodNmList[i];
item.DataValue = ht["PRDNM_CD"].ToString();
item.DisplayText = ht["PRDNM_CD"].ToString(); ;
valueListItems4[i] = item;
}
this.ultraComboEditor1.Items.AddRange(valueListItems4);
//成份信息
this.dataSet2.Tables[0].Clear();
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010050";
ccp.MethodName = "queryChemList";
ccp.SourceDataTable = this.dataSet2.Tables[0];
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
}
private ArrayList queryCommFun(string serverName, string methodName)
{
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = serverName;
ccp.MethodName = methodName;
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
ArrayList list = (ArrayList)ccp.ReturnObject;
return list;
}
private void label2_Click(object sender, EventArgs e)
{
if (this.ultraComboEditor3.SelectedIndex < 0)
{
MessageBox.Show("标准号不能为空,请选择标准号!");
this.ultraComboEditor3.Focus();
return;
}
if (this.ultraComboEditor4.SelectedIndex < 0)
{
MessageBox.Show("标准牍号不能为空,请选择标准牌号!");
this.ultraComboEditor4.Focus();
return;
}
if (this.ultraComboEditor5.SelectedIndex < 0)
{
MessageBox.Show("订单用途不能为空,请选择订单用途!");
this.ultraComboEditor5.Focus();
return;
}
if (this.ultraComboEditor1.SelectedIndex < 0)
{
MessageBox.Show("交货状态不能为空,请选择交货状态!");
this.ultraComboEditor1.Focus();
return;
}
if (this.textBox11.Text.Trim().Equals(""))
{
MessageBox.Show("厚度不能为空,请输入厚度!");
this.textBox11.Focus();
return;
}
double thk = 0;
try
{
thk = double.Parse(textBox11.Text.Trim());
}
catch (Exception ex)
{
MessageBox.Show("厚度输入错误,请重新输入厚度!");
this.textBox11.Focus();
return;
}
string prdNmCd = this.ultraComboEditor1.Value.ToString();
string specAbbsym = this.ultraComboEditor3.Value.ToString();
string specStlGrd = this.ultraComboEditor4.Value.ToString();
string ordUseTp = this.ultraComboEditor5.Value.ToString();
this.dataSet1.Tables[0].Clear();
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010050";
ccp.MethodName = "queryQltyList";
ccp.ServerParams = new object[] { prdNmCd, specAbbsym, specStlGrd, ordUseTp, thk };
ccp.SourceDataTable = this.dataSet1.Tables[0];
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
}
///
/// 查询区域中一行的垛位信息
///
///
///
///
internal void queryYardRows(int areaType, int areaNo, string yardCol)
{
this.dataSet4.Tables[0].Clear();
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010070";
ccp.MethodName = "queryYardRows";
ccp.ServerParams = new object[] { areaType, areaNo, yardCol };
ccp.SourceDataTable = this.dataSet4.Tables[0];
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
}
///
/// 查询区域中一行的垛位中钢卷信息
///
///
///
///
internal void queryYardRowCoils(int areaType, int areaNo, string yardCol)
{
this.dataSet3.Tables[0].Clear();
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010070";
ccp.MethodName = "queryYardRowCoils";
ccp.ServerParams = new object[] { areaType, areaNo, yardCol };
ccp.SourceDataTable = this.dataSet3.Tables[0];
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
}
internal int queryMinYardRow(int areaType, int areaNo, string yardCol)
{
int minRow = 1;
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010070";
ccp.MethodName = "queryMinYardRow";
ccp.ServerParams = new object[] { areaType, areaNo, yardCol };
ccp = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnObject != null)
{
minRow = int.Parse(ccp.ReturnObject.ToString());
}
return minRow;
}
///
/// 查询库存区域
///
///
///
internal ArrayList queryYardAreas(int areaType)
{
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010040";
ccp.MethodName = "queryYardAreas";
ccp.ServerParams = new object[] { areaType };
ccp = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
ArrayList retList = (ArrayList)ccp.ReturnObject;
return retList;
}
///
/// 查询库存区分
///
///
///
internal ArrayList queryYardColsByArea(int areaNo)
{
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010040";
ccp.MethodName = "queryYardColsByArea";
ccp.ServerParams = new object[] { areaNo };
ccp = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
ArrayList retList = (ArrayList)ccp.ReturnObject;
return retList;
}
private void ultraGrid1_BeforeCellUpdate(object sender, Infragistics.Win.UltraWinGrid.BeforeCellUpdateEventArgs e)
{
Infragistics.Win.UltraWinGrid.UltraGrid grid = (Infragistics.Win.UltraWinGrid.UltraGrid)sender;
string colKey = grid.ActiveCell.Column.Key;
int index = grid.ActiveRow.Cells.IndexOf(colKey);
if (index > 3 && (null == grid.ActiveRow.Cells[index - 1].Text || grid.ActiveRow.Cells[index - 1].Text.Trim().Equals("")))
{
MessageBox.Show("请按照实际值1、2、3、4的顺序输入材质信息!");
return;
}
}
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 = "UIM.WGJ.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("上传失败,请选择正确的文件路径", "提示");
}
}
}
}