using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Collections;
using System.Windows.Forms;
using CoreFS.CA06;
namespace Core.LZMes.Client.UIJ
{
public partial class UIJ040030 : FrmBase
{
public UIJ040030()
{
InitializeComponent();
}
private void UIJ040030_Load(object sender, EventArgs e)
{
this.ultraDateTimeEditor1.Value = null;
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
this.DoQuery();
break;
case "Save":
this.DoSave();
break;
case "Print":
this.DoPrint();
break;
case "Exit":
this.Close();
break;
}
}
///
/// 查询发货实绩
///
private void DoQuery()
{
string coilProgCd = "";
if (this.ultraComboEditor2.SelectedIndex >= 0)
{
if (ultraComboEditor2.Value.ToString().Equals("06"))
{
coilProgCd = "SFB";
}
else
{
coilProgCd = "SFF";
if (ultraDateTimeEditor1.Value == null)
{
MessageBox.Show("需要选择出库时间,否则数据量过大,不便于查找!");
return;
}
}
}
else
{
MessageBox.Show("状态区分必须选择,否则导致数据量过大!");
return;
}
string dlivTp = this.ultraComboEditor1.SelectedIndex < 0 ? "" : this.ultraComboEditor1.Value.ToString();
string transCarNo = this.textBox2.Text.Trim();
string dlivDirNo = this.textBox3.Text.Trim();
string shipProgCd = this.ultraComboEditor2.SelectedIndex < 0 ? "" : this.ultraComboEditor2.Value.ToString();
string trnfDTime = this.ultraDateTimeEditor1.Value == null ? "" : this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdds");
this.dataSet1.Tables[0].Clear();
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIJ.UIJ04.UIJ040030";
ccp.MethodName = "queryShippingResult";
ccp.ServerParams = new Object[] { dlivTp, coilProgCd, transCarNo, dlivDirNo, shipProgCd, trnfDTime };
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++)
{
ultraGrid1.Rows[i].Cells[0].Value = false;
}
}
///
///
///
private void DoSave()
{
if (this.ultraComboEditor3.SelectedIndex < 0)
{
MessageBox.Show("出库班次信息不能为空,请选择相应的出库班次!");
return;
}
if (this.ultraComboEditor4.SelectedIndex < 0)
{
MessageBox.Show("出库班组信息不能为空,请选择相应的出库班组!");
return;
}
if (this.ultraComboEditor5.Text.Trim().Equals(""))
{
MessageBox.Show("出库人信息不能为空,请选择相应的出库人!");
return;
}
if (this.ultraDateTimeEditor1.Value == null)
{
MessageBox.Show("出库时间信息不能为空,请选择相应的出库时间!");
return;
}
if (this.textBox1.Text.Trim().Equals(""))
{
MessageBox.Show("草支垫重量信息不能为空,请输入相应的草支垫重量!");
return;
}
Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows;
for (int i = 0; i < rs.Count; i++)
{
if ("TRUE".Equals(rs[i].Cells["CHK"].Text.ToUpperInvariant()))
{
string coilWgt = rs[i].Cells["COIL_WGT"].Text;
string transCarNo = rs[i].Cells["TRANS_CAR_NO"].Text;
if (coilWgt.Equals(""))
{
MessageBox.Show("第" + (i + 1) + "行卷重数据为空,请核对后再点击保存!");
return;
}
if (transCarNo.Equals(""))
{
MessageBox.Show("第" + (i + 1) + "行车辆号为空,请核对后再点击保存!");
return;
}
}
}
ArrayList list = new ArrayList();
string[] param = null;
string regId = this.UserInfo.GetUserID();
for (int i = 0; i < rs.Count; i++)
{
if ("TRUE".Equals(rs[i].Cells["CHK"].Text.ToUpperInvariant()) && "06".Equals(rs[i].Cells["SHIP_PROG_CD"].Text))
{
param = new string[30];
param[0] = rs[i].Cells["SHIP_DIRNO"].Text; ;//发货指示号
param[1] = rs[i].Cells["DLIV_DIRNO"].Text;//运输指示号
param[2] = rs[i].Cells["TRANS_CAR_NO"].Text;//车辆号
param[3] = rs[i].Cells["GET_ON_PCD"].Text;//装车地点
param[4] = rs[i].Cells["DEST_PCD"].Text;//目的地
param[5] = rs[i].Cells["EXLV_LINE_CD"].Text;//专用线
param[6] = rs[i].Cells["GET_OFF_PCD"].Text;//卸车地点
param[7] = rs[i].Cells["BY_SEA_YN"].Text;//水运区分
param[8] = rs[i].Cells["DEPARTURE_CD"].Text;//出发港
param[9] = rs[i].Cells["ARRIVAL_CD"].Text;//到达港
param[10] = rs[i].Cells["COIL_NO"].Text;//生产钢卷号
param[11] = rs[i].Cells["TOT_DEC_GRD"].Text;//综合判定等级
param[12] = rs[i].Cells["COIL_WGT"].Text;//钢卷重量
param[13] = rs[i].Cells["COIL_OUTDIA"].Text;//钢卷外径
param[14] = rs[i].Cells["SHIP_INVNO"].Text;//发货清单号码
param[15] = rs[i].Cells["CRET_NO"].Text;//品质保证书号
param[16] = rs[i].Cells["TRNF_DTIME"].Text;//发货时间
param[17] = "07";//钢卷公共表中的状态字段 SHIP_PROG_CD
param[18] = rs[i].Cells["SPEC_STL_GRD"].Text;//标冷牌号
param[19] = rs[i].Cells["BEF_PROG_CD"].Text;//钢卷公共表中当前状态做前状态使用
param[20] = rs[i].Cells["BEF_PROG_CD_DTIME"].Text;//状态改变时间
param[21] = rs[i].Cells["BEF_PROG_CD_PGM"].Text;//状态改变人
param[22] = rs[i].Cells["ORD_NO"].Text;//合同号
param[23] = rs[i].Cells["ORD_SEQ"].Text;//订单号
param[24] = rs[i].Cells["SHIP_COMP_CD"].Text;//运输公司编码
param[25] = rs[i].Cells["COIL_STAT"].Text;//钢卷状态
param[26] = rs[i].Cells["CUR_PROG_CD"].Text;//当前状态
param[27] = rs[i].Cells["CUR_PROG_CD_PGM"].Text;//当前状态修改人
param[28] = regId;//登录人
param[29] = rs[i].Cells["DLIV_TP"].Text;//火运汽运标志
list.Add(param);
}
}
if (list.Count > 0)
{
//出库班次、出库班组、出库人、出库时间、草支垫重量
string trnfShift = this.ultraComboEditor3.Value.ToString(); ;
string trnfGroup = this.ultraComboEditor4.Value.ToString();
string trnfRegId = this.ultraComboEditor5.Text.Trim();
string trnfDtime = this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd");
string czdWgt = this.textBox1.Text.Trim();
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIJ.UIJ04.UIJ040030";
ccp.MethodName = "saveShippingResult";
ccp.ServerParams = new Object[] { trnfShift, trnfGroup, trnfRegId, trnfDtime, czdWgt, list };
this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
}
//生成发货实绩后再次查询
this.DoQuery();
}
///
/// 打印发货明细
///
private void DoPrint()
{
if (this.ultraComboEditor3.SelectedIndex < 0)
{
MessageBox.Show("出库班次信息不能为空,请选择相应的出库班次!");
return;
}
if (this.ultraComboEditor4.SelectedIndex < 0)
{
MessageBox.Show("出库班组信息不能为空,请选择相应的出库班组!");
return;
}
if (this.ultraComboEditor5.Text.Trim().Equals(""))
{
MessageBox.Show("出库人信息不能为空,请选择相应的出库人!");
return;
}
if (this.ultraDateTimeEditor1.Value == null)
{
MessageBox.Show("出库时间信息不能为空,请选择相应的出库时间!");
return;
}
if (this.textBox1.Text.Trim().Equals(""))
{
MessageBox.Show("草支垫重量信息不能为空,请输入相应的草支垫重量!");
return;
}
Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows;
//发货明细打印必须是同一客户同合同号、发运指示号
string befOrdNo = "";//前运输号
string befDlivDirNo = "";//前运输指示号
ArrayList coils = new ArrayList();//钢卷信息
int coilCount = 0;//钢卷个数
double coilWgtSum = 0;//钢卷重量合计
for (int i = 0; i < rs.Count; i++)
{
if ("TRUE".Equals(rs[i].Cells["CHK"].Text.ToUpperInvariant()))
{
string[] coilInfo = new string[8];
string ordNoTmp = rs[i].Cells["ORD_NO"].Text;
string dlivDirNoTmp = rs[i].Cells["DLIV_DIRNO"].Text;
if (!"".Equals(befDlivDirNo) && !"".Equals(befOrdNo))
{
if (!befDlivDirNo.Equals(dlivDirNoTmp))
{
MessageBox.Show("不同运输指示号下的卷不能生成同一张发货明细,请确认后重新选择!");
return;
}
if (!befOrdNo.Equals(ordNoTmp))
{
MessageBox.Show("同发运指示号下的卷,合同号不一样需要分开打印发货明细!");
return;
}
}
befDlivDirNo = dlivDirNoTmp;
befOrdNo = ordNoTmp;
coilCount++;
coilInfo[0] = rs[i].Cells["OLD_SAMPL_NO"].Text;//钢卷号
coilInfo[1] = rs[i].Cells["SPEC_STL_GRD"].Text;//牌号
coilInfo[2] = rs[i].Cells["T_W"].Text;//规格
coilInfo[3] = rs[i].Cells["TOT_DEC_GRD_DESC"].Text;//等级
coilInfo[4] = rs[i].Cells["MATLQLTY_DEC_GRD_DESC"].Text;//性能
coilInfo[5] = coilInfo[0].Length > 10 ? coilInfo[0].Substring(0, 10) : "";//轧批号
coilInfo[6] = (double.Parse(rs[i].Cells["COIL_WGT"].Text.Trim()) / 1000).ToString();//重量
coilInfo[7] = "";//备注
coilWgtSum += double.Parse(coilInfo[6]);
coils.Add(coilInfo);
}
}
//取出明细打印需要的数据
string dlivDirNo = "";//发运指示号
string ordNo = "";//合同号
string dlivTp = "";//运输方式
string shipInnNo = "";//发货清单号
string custNm = "";//客户名称
string ordNm = "";//合同单位
string destPcdDesc = "";//到站
string transCarNo = "";//车号
string prodNm = "";//产品名称
string specAbbsym = "";//标准
string hColorRem = "";//外贸合同钢卷颜色备注
for (int i = 0; i < rs.Count; i++)
{
if ("TRUE".Equals(rs[i].Cells["CHK"].Text.ToUpperInvariant()))
{
dlivDirNo = rs[i].Cells["DLIV_DIRNO"].Text;
ordNo = rs[i].Cells["ORD_NO"].Text;
dlivTp = rs[i].Cells["DLIV_TP"].Text;
shipInnNo = rs[i].Cells["SHIP_INVNO"].Text;
custNm = rs[i].Cells["CUST_NM"].Text;
ordNo = rs[i].Cells["ORD_NM"].Text;
destPcdDesc = rs[i].Cells["DEST_PCD_DESC"].Text;
transCarNo = rs[i].Cells["TRANS_CAR_NO"].Text;
prodNm = rs[i].Cells["SM_CFNM"].Text;
specAbbsym = rs[i].Cells["SPEC_ABBSYM"].Text;
hColorRem = rs[i].Cells["HCOLOUR_REM"].Text;
break;
}
}
//导出EXCEL
//打印后修改发货状态
print();
}
///
/// 打印后修改发货状态
///
private void print()
{
ArrayList list = new ArrayList();
string[] param = null;
string regId = this.UserInfo.GetUserID();
Infragistics.Win.UltraWinGrid.RowsCollection rs = this.ultraGrid1.Rows;
for (int i = 0; i < rs.Count; i++)
{
if ("TRUE".Equals(rs[i].Cells["CHK"].Text.ToUpperInvariant()) && "06".Equals(rs[i].Cells["SHIP_PROG_CD"].Text))
{
param = new string[30];
param[0] = rs[i].Cells["SHIP_DIRNO"].Text; ;//发货指示号
param[1] = rs[i].Cells["DLIV_DIRNO"].Text;//运输指示号
param[2] = rs[i].Cells["TRANS_CAR_NO"].Text;//车辆号
param[3] = rs[i].Cells["GET_ON_PCD"].Text;//装车地点
param[4] = rs[i].Cells["DEST_PCD"].Text;//目的地
param[5] = rs[i].Cells["EXLV_LINE_CD"].Text;//专用线
param[6] = rs[i].Cells["GET_OFF_PCD"].Text;//卸车地点
param[7] = rs[i].Cells["BY_SEA_YN"].Text;//水运区分
param[8] = rs[i].Cells["DEPARTURE_CD"].Text;//出发港
param[9] = rs[i].Cells["ARRIVAL_CD"].Text;//到达港
param[10] = rs[i].Cells["COIL_NO"].Text;//生产钢卷号
param[11] = rs[i].Cells["TOT_DEC_GRD"].Text;//综合判定等级
param[12] = rs[i].Cells["COIL_WGT"].Text;//钢卷重量
param[13] = rs[i].Cells["COIL_OUTDIA"].Text;//钢卷外径
param[14] = rs[i].Cells["SHIP_INVNO"].Text;//发货清单号码
param[15] = rs[i].Cells["CRET_NO"].Text;//品质保证书号
param[16] = rs[i].Cells["TRNF_DTIME"].Text;//发货时间
param[17] = "08";//钢卷公共表中的状态字段 SHIP_PROG_CD
param[18] = rs[i].Cells["SPEC_STL_GRD"].Text;//标冷牌号
param[19] = rs[i].Cells["BEF_PROG_CD"].Text;//钢卷公共表中当前状态做前状态使用
param[20] = rs[i].Cells["BEF_PROG_CD_DTIME"].Text;//状态改变时间
param[21] = rs[i].Cells["BEF_PROG_CD_PGM"].Text;//状态改变人
param[22] = rs[i].Cells["ORD_NO"].Text;//合同号
param[23] = rs[i].Cells["ORD_SEQ"].Text;//订单号
param[24] = rs[i].Cells["SHIP_COMP_CD"].Text;//运输公司编码
param[25] = rs[i].Cells["COIL_STAT"].Text;//钢卷状态
param[26] = rs[i].Cells["CUR_PROG_CD"].Text;//当前状态
param[27] = rs[i].Cells["CUR_PROG_CD_PGM"].Text;//当前状态修改人
param[28] = regId;//登录人
param[29] = rs[i].Cells["DLIV_TP"].Text;//火运汽运标志
list.Add(param);
}
}
if (list.Count > 0)
{
//出库班次、出库班组、出库人、出库时间、草支垫重量
string trnfShift = this.ultraComboEditor3.Value.ToString(); ;
string trnfGroup = this.ultraComboEditor4.Value.ToString();
string trnfRegId = this.ultraComboEditor5.Text.Trim();
string trnfDtime = this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd");
string czdWgt = this.textBox1.Text.Trim();
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIJ.UIJ04.UIJ040030";
ccp.MethodName = "printShippingResult";
ccp.ServerParams = new Object[] { trnfShift, trnfGroup, trnfRegId, trnfDtime, czdWgt, list };
this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
}
}
}
}