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;
namespace Core.LZMes.Client.UIM
{
public partial class UIM010260 : FrmBase
{
private string COIL_NO = "";
public UIM010260()
{
InitializeComponent();
this.dteTime.DateTime = DateTime.Now;
}
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;
}
}
///
/// 查询钢卷信息
///
private void DoQuery()
{
try
{
string coilNo = this.txtCoilNo.Text.Trim();
this.dataSet1.Tables[0].Clear();
COIL_NO = coilNo;
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010260";
ccp.MethodName = "queryCoilInfo";
ccp.ServerParams = new object[] { coilNo };
ccp.SourceDataTable = this.dataSet1.Tables[0];
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
if (this.ultraGrid1.Rows.Count == 0)
{
this.txtCoilNoOUT.Text = "查无此卷";
this.txtCoilNoStat.Text = "";
}
else
{
this.txtCoilNoOUT.Text = this.ultraGrid1.Rows[0].Cells["CUR_LOAD_LOC"].Text;
this.txtCoilNoStat.Text = this.ultraGrid1.Rows[0].Cells["COIL_STAT"].Text;
}
}
catch (Exception EX)
{
MessageBox.Show(EX.ToString());
}
}
///
/// 盘入盘出操作
///
private void DoSave()
{
if (this.txtCoilNo.Text != this.COIL_NO)
{
MessageBox.Show("输入钢卷号在上次查询后已经更改; \n请再次输入确定进行操作的钢卷号,并做查询后再进行操作。");
return;
}
try
{
if (this.dataTable1.Rows.Count < 1)
{
MessageBox.Show("钢卷信息不能为空,请先查询出钢卷信息再进行盘入盘出操作!");
return;
}
Infragistics.Win.UltraWinGrid.RowsCollection rs = null;
rs = this.ultraGrid1.Rows;
string wdlivno = "";
foreach (UltraGridRow ugr in rs)
{
wdlivno = rs[0].Cells["wdlivno"].Text.ToString(); //获取提货单号
}
string curLoadLoc = this.yardCtl.GetYardFlag();
int type = 0;
if (checkBox2.Checked)
{
type = 1;
}
else if(checkBox3.Checked || checkBox4.Checked)
{
type = 2;//外卖或者废钢
}
else if(!checkBox1.Checked)
{
MessageBox.Show("请选择盘入盘出类型!");
return;
}
else if ("".Equals(curLoadLoc) && checkBox1.Checked)
{
MessageBox.Show("盘入操作需要垛位信息,请输入相应的垛位信息!");
return;
}
else if (this.dteTime.DateTime == null)
{
MessageBox.Show("请选择操作时间!");
return;
}
else if ("".Equals(wdlivno) && (checkBox3.Checked || checkBox4.Checked))
{
MessageBox.Show("外卖或者废钢提货单号不能为空!");
return;
}
curLoadLoc = this.yardAnalysisForQuerry(curLoadLoc);
string regId = this.UserInfo.GetUserID();
string regShift = this.UserInfo.GetUserOrder();
string regGroup = this.UserInfo.GetUserGroup();
string coilInDtime = this.dteTime.DateTime.ToString("yyyyMMddHHmmss");
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010260";
ccp.MethodName = "save";
ccp.ServerParams = new object[] { type, COIL_NO, curLoadLoc, regId, regShift, regGroup, coilInDtime, wdlivno};
ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
this.DoQuery();
}
catch (Exception EX)
{
MessageBox.Show(EX.ToString());
}
}
///
/// 把经过上面检测后的字符串补0 转为数据库通用字符串
///
///
///
private string yardAnalysisForQuerry(string yardIN)
{
try
{
string[] strs = yardIN.Split('-');
if (strs[1].Length < 3)
{
for (int i = strs[1].Length; i < 3; i++)
{
strs[1] = "0" + strs[1];
}
}
if (strs[2].Length < 3)
{
for (int i = strs[2].Length; i < 3; i++)
{
strs[2] = "0" + strs[2];
}
}
return strs[0] + "-" + strs[1].ToUpper() + "-" + strs[2];
}
catch
{
return "";
}
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (this.checkBox1.Checked)
{
this.checkBox2.Checked = false;
this.checkBox3.Checked = false;
this.checkBox4.Checked = false;
}
}
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
if (this.checkBox2.Checked)
{
this.checkBox1.Checked = false;
this.checkBox3.Checked = false;
this.checkBox4.Checked = false;
}
}
private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
if (this.checkBox3.Checked)
{
this.checkBox1.Checked = false;
this.checkBox2.Checked = false;
this.checkBox4.Checked = false;
}
}
private void checkBox4_CheckedChanged(object sender, EventArgs e)
{
if (this.checkBox4.Checked)
{
this.checkBox1.Checked = false;
this.checkBox2.Checked = false;
this.checkBox3.Checked = false;
}
}
}
}