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.IO;
using System.Collections;
namespace Core.LZMes.Client.UIM.UIM02
{
public partial class UIM020090:FrmBase
{
private string yardAddr = "";//上料钢卷垛位
private string l_coilNo = "";//冷轧卷号
private int coil_no_index = -1;//冷轧卷在轧制计划的下标位置
public UIM020090()
{
InitializeComponent();
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
this.DoQuery();
break;
case "Save":
this.DoSave();
break;
case "Exit":
this.Close();
break;
case "Export":
this.DoExport();
break;
}
}
///
/// 查询连退作业计划
///
private void DoQuery()
{
this.dataSet1.Tables[0].Clear();
this.dataSet3.Tables[0].Clear();
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM02.UIM020030";
ccp.MethodName = "queryCalPlan2";
ccp.SourceDataTable = this.dataSet1.Tables[0];
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
DataRowCollection drs = dataSet1.Tables[0].Rows;
for (int i = 0; i < drs.Count; i++)
{
if (drs[i]["STATUS_CD"].ToString().Equals("上鞍座"))
{
ultraGrid1.Rows[i].Appearance.BackColor = Color.FromArgb(192, 255, 192);
}
else if (drs[i]["STATUS_CD"].ToString().Equals("吊销钢卷"))
{
ultraGrid1.Rows[i].Appearance.BackColor = Color.Red;
}
else if (drs[i]["STATUS_CD"].ToString().Equals("焊接"))
{
ultraGrid1.Rows[i].Appearance.BackColor = Color.SpringGreen;
}
else if (drs[i]["STATUS_CD"].ToString().Equals("生产完成"))
{
ultraGrid1.Rows[i].Appearance.BackColor = Color.Green;
}
else if (drs[i]["STATUS_CD"].ToString().Equals("预备吊销钢卷"))
{
ultraGrid1.Rows[i].Appearance.BackColor = Color.Pink;
}
}
CoreClientParam ccp3 = new CoreClientParam();
ccp3.ServerName = "UIM.UIM02.UIM020030";
ccp3.MethodName = "queryAddClassInf2";
ccp3.SourceDataTable = this.dataSet3.Tables[0];
this.ExecuteQueryToDataTable(ccp3, CoreInvokeType.Internal);
}
///
/// 连退上料操作
///
private void DoSave()
{
if (null == this.ultraDateTimeEditor1.Value)
{
MessageBox.Show("上料时间为空,请选择相应的上料时间后再进行上料操作!");
return;
}
string calNo = textBox1.Text.Trim();
string coilNo = this.textBox3.Text.Trim();
if ("".Equals(coilNo))
{
MessageBox.Show("上料钢卷为空,请选择相应的原料卷后再进行上料操作!");
return;
}
if (string.IsNullOrEmpty(l_coilNo))
{
MessageBox.Show("连退计划还未下发,不能进行上料操作!");
return;
}
CoreClientParam ccp = new CoreClientParam();
System.Data.DataTable dt = new System.Data.DataTable();
ccp.ServerName = "UIM.UIM02.UIM020030";
ccp.MethodName = "isReceivedL2";
ccp.ServerParams = new object[] { calNo,coilNo };
ccp.SourceDataTable = dt;
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
if (dt.Rows.Count <= 0)
{
CoreClientParam ccp1 = new CoreClientParam();
ccp1.ServerName = "UIM.UIM02.UIM020030";
ccp1.MethodName = "hasCoilOnYardAddr";
ccp1.ServerParams = new Object[] { yardAddr };
ccp1 = this.ExecuteQuery(ccp1, CoreInvokeType.Internal);
int count = int.Parse(ccp1.ReturnObject.ToString());
if (count > 0 && DialogResult.No == MessageBox.Show("选择的钢卷堆放位置上方有其他钢卷,是否继续上料?", "提示", MessageBoxButtons.YesNo))
{
return;
}
string trnfRegId = this.UserInfo.GetUserID();
string trnfShift = this.UserInfo.GetUserOrder();
string trnfGroup = this.UserInfo.GetUserGroup();
string trnfDTime = this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd");
CoreClientParam ccp2 = new CoreClientParam();
ccp2.ServerName = "UIM.UIM02.UIM020030";
ccp2.MethodName = "outStockByCal";
ccp2.ServerParams = new Object[] { calNo, coilNo, l_coilNo, "T", trnfRegId, trnfShift, trnfGroup, trnfDTime };
this.ExecuteNonQuery(ccp2, CoreInvokeType.Internal);
if (0 != ccp2.ReturnCode)
{
MessageBox.Show("上料失败");
return;
}
else
{
MessageBox.Show("上料成功");
}
}
else
{
string trnfRegId = this.UserInfo.GetUserID();
string trnfShift = this.UserInfo.GetUserOrder();
string trnfGroup = this.UserInfo.GetUserGroup();
string trnfDTime = this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd");
CoreClientParam ccp3 = new CoreClientParam();
System.Data.DataTable dt1 = new System.Data.DataTable();
ccp3.ServerName = "UIM.UIM02.UIM020030";
ccp3.MethodName = "insertInformation";
ccp3.ServerParams = new object[] { trnfRegId, trnfShift, trnfGroup, trnfDTime,coilNo};
this.ExecuteNonQuery(ccp3, CoreInvokeType.Internal);
if (0 != ccp3.ReturnCode)
{
MessageBox.Show("插入失败");
return;
}
else
{
MessageBox.Show("插入成功");
}
}
//this.DoPrint();
this.DoQuery();
}
///
/// 导出
///
private void DoExport()
{
try
{
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());
}
}
private void ultraGrid1_DoubleClickRow(object sender, Infragistics.Win.UltraWinGrid.DoubleClickRowEventArgs e)
{
Infragistics.Win.UltraWinGrid.UltraGrid uGrid = (Infragistics.Win.UltraWinGrid.UltraGrid)sender;
int index = uGrid.ActiveRow.Index;
/*
if (index > 0)
{
string statusCd = uGrid.Rows[index - 1].Cells["STATUS_CD"].Text.Trim();
if ("计划中".Equals(statusCd))
{
MessageBox.Show("必须按照连退计划顺序上料,请确认后重新选择!");
return;
}
}
*/
string coilNo = uGrid.ActiveRow.Cells["C_COIL_NO"].Text.Trim();
this.textBox3.Text = coilNo;
string calNo = uGrid.ActiveRow.Cells["CAL_SEQ"].Text.Trim().Substring(0, uGrid.ActiveRow.Cells["CAL_SEQ"].Text.Trim().IndexOf('-'));
textBox1.Text = calNo;
yardAddr = uGrid.ActiveRow.Cells["YARD_ADDR"].Text.Trim();
l_coilNo = uGrid.ActiveRow.Cells["L_COIL_NO"].Text.Trim();
coil_no_index = uGrid.ActiveRow.VisibleIndex;
dataSet2.Tables[0].Clear();
DataRow dr = dataSet2.Tables[0].NewRow();
dr["COIL_NO"] = coilNo;
dr["COIL_LEN"] = uGrid.ActiveRow.Cells["COIL_LEN"].Text.Trim();
dr["COIL_WGT"] = uGrid.ActiveRow.Cells["COIL_WGT"].Text.Trim();
dr["LEN_DET"] = 1;
dr["YARD_ADDR"] = yardAddr;
this.textBox2.Text = yardAddr;
dataSet2.Tables[0].Rows.Add(dr);
}
///
/// 酸轧上吊销
///
///
///
private void pictureBox1_Click(object sender, EventArgs e)
{
if ("".Equals(this.textBox3.Text.Trim()))
{
MessageBox.Show("请选择需要吊销的钢卷!");
return;
}
if (0 > this.ultraComboEditor2.SelectedIndex)
{
MessageBox.Show("请选择吊销类型!");
return;
}
if (null == this.ultraDateTimeEditor2.Value)
{
MessageBox.Show("请选择吊销时间!");
return;
}
if ("".Equals(textBox2.Text.Trim()))
{
MessageBox.Show("请输入吊销后堆放的位置!");
return;
}
if (ultraGrid1.Rows[coil_no_index].Cells["STATUS_CD"].Text.ToString().Equals("计划中"))
{
MessageBox.Show("钢卷还未上料,不能吊销!");
return;
}
else if (!ultraGrid1.Rows[coil_no_index].Cells["STATUS_CD"].Text.ToString().Equals("上鞍座") && !ultraGrid1.Rows[coil_no_index].Cells["STATUS_CD"].Text.ToString().Equals("预备吊销钢卷"))
{
MessageBox.Show("钢卷已经生产,不能吊销!");
return;
}
//钢卷入库
string coilNo = textBox3.Text.Trim();
string yardAddr = textBox2.Text.Trim();
string calNo = textBox1.Text.Trim();
try
{
string stock = yardAddr.Substring(0, 1);
yardAddr = yardAddr.Substring(2);
string row = yardAddr.Substring(0, yardAddr.IndexOf('-') - 1);
if (row.Length < 2)
{
row = "0" + row;
}
string fl = yardAddr.Substring(yardAddr.IndexOf('-') - 1,1);
string col = yardAddr.Substring(yardAddr.IndexOf('-')+1);
if (col.Length < 2)
{
col = "0" + col;
}
yardAddr = stock + "-" + row + fl + "-" + col;
}
catch (Exception ex)
{
MessageBox.Show("垛位输入错误,请重新输入!");
textBox2.Focus();
return;
}
string entryShift = this.UserInfo.GetUserOrder();
string entryGroup = this.UserInfo.GetUserGroup();
string reg_id = this.UserInfo.GetUserID();
string entryDtime = ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd");
MessageBox.Show("请确认退卷信息:钢卷号:"+coilNo );
if (MessageBox.Show("您确认要退卷吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
{
CoreClientParam ccp = new CoreClientParam();
System.Data.DataTable dt = new System.Data.DataTable();
ccp.ServerName = "UIM.UIM02.UIM020030";
ccp.MethodName = "selectCoilYard";
ccp.ServerParams = new object[] { yardAddr };
ccp.SourceDataTable = dt;
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
if (dt.Rows.Count > 0 && !string.IsNullOrEmpty(dt.Rows[0]["COIL_NO"].ToString()))
{
MessageBox.Show("该垛位上已有钢卷,请重新输入垛位信息!");
return;
}
else
{
CoreClientParam ccp2 = new CoreClientParam();
ccp2.ServerName = "UIM.UIM02.UIM020030";
ccp2.MethodName = "saveCoilYard";
ccp2.ServerParams = new object[] { calNo, coilNo, yardAddr, entryShift, entryGroup, entryDtime, reg_id, "C" };
this.ExecuteNonQuery(ccp2, CoreInvokeType.Internal);
if (0 == ccp2.ReturnCode)
{
MessageBox.Show("退回成功");
DoQuery();
}
}
}
//修改轧制计划、取消取样标识
}
private void UIM020030_Load(object sender, EventArgs e)
{
this.ultraComboEditor2.SelectedIndex = 0;
this.ultraComboEditor6.SelectedIndex = 0;
this.ultraComboEditor6.Text = "";
this.ultraGrid2.DisplayLayout.ValueLists.Add("List1");
this.ultraGrid2.DisplayLayout.ValueLists["List1"].ValueListItems.Add(1, "合格");
this.ultraGrid2.DisplayLayout.ValueLists["List1"].ValueListItems.Add(2, "不合格");
this.ultraGrid2.DisplayLayout.ValueLists["List1"].DisplayStyle = Infragistics.Win.ValueListDisplayStyle.DisplayText;
this.ultraGrid2.DisplayLayout.Bands[0].Columns[3].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
this.ultraGrid2.DisplayLayout.Bands[0].Columns[3].ValueList = this.ultraGrid2.DisplayLayout.ValueLists["List1"];
}
private void ultraComboEditor2_ValueChanged(object sender, EventArgs e)
{
if (0 == this.ultraComboEditor2.SelectedIndex)
{
this.ultraComboEditor6.ReadOnly = true;
this.ultraComboEditor6.Text = "";
}
else
{
this.ultraComboEditor6.ReadOnly = false;
}
}
private void ultraGrid3_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
{
if (e.Cell.Column.Key == "SELECT_ITEM" && Convert.ToBoolean(e.Cell.Text))
{
if (MessageBox.Show("是否确认添加班组信息?","提示",MessageBoxButtons.YesNo) == DialogResult.Yes)
{
string coilNo = e.Cell.Row.Cells["C_COIL_NO"].Text;
/*for循环控制单选*/
int i = this.ultraGrid3.Rows.Count;
for (int j = 0; j < i; j++)
{
if (this.ultraGrid3.Rows[j].Cells["C_COIL_NO"].Text != coilNo)
{
this.ultraGrid3.Rows[j].Cells["SELECT_ITEM"].Value = false;
}
}
string trnfRegId = this.UserInfo.GetUserID();
string trnfShift = this.UserInfo.GetUserOrder();
string trnfGroup = this.UserInfo.GetUserGroup();
string trnfDTime = this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd");
CoreClientParam ccp3 = new CoreClientParam();
System.Data.DataTable dt1 = new System.Data.DataTable();
ccp3.ServerName = "UIM.UIM02.UIM020030";
ccp3.MethodName = "insertInformation";
ccp3.ServerParams = new object[] { trnfRegId, trnfShift, trnfGroup, trnfDTime, coilNo };
this.ExecuteNonQuery(ccp3, CoreInvokeType.Internal);
if (0 != ccp3.ReturnCode)
{
MessageBox.Show("插入失败");
return;
}
else
{
MessageBox.Show("插入成功");
}
}
DoQuery();
}
}
}
}