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 Core.Mes.Client.Comm.Server;
using Core.Mes.Client.Comm.Control;
using Infragistics.Win.UltraWinGrid;
using Core.Mes.Client.Comm.Tool;
using System.Collections;
using Core.StlMes.Client.YdmPipeManage.Controls;
using Core.StlMes.Client.YdmBase;
using Infragistics.Win.UltraWinEditors;
namespace Core.StlMes.Client.YdmPipeManage
{
public partial class frmPipRedDashed : FrmBase
{
public frmPipRedDashed(OpeBase ob)
{
this.ob = ob;
InitializeComponent();
}
string strInbound = "800704";//入库类型(缴库红冲)
//质保ID
private string rccid;
public string Rccid
{
get { return rccid; }
set { rccid = value; }
}
//钢种id
private string gradeCode;
public string GradeCode
{
get { return gradeCode; }
set { gradeCode = value; }
}
//钢种名称
private string gradeName;
public string GradeName
{
get { return gradeName; }
set { gradeName = value; }
}
//产线代码
private string plineCode;
public string PlineCode
{
get { return plineCode; }
set { plineCode = value; }
}
//产线名称
private string plineName;
public string PlineName
{
get { return plineName; }
set { plineName = value; }
}
UltraComboEditor ucePro = new UltraComboEditor();
UltraComboEditor uceSpec = new UltraComboEditor();
UltraComboEditor uceSteel = new UltraComboEditor();
UltraComboEditor uceModel = new UltraComboEditor();
public string buttonValue;
private void frmPipRedDashed_Load(object sender, EventArgs e)
{
querySqlServerData(Rccid);
InitStorage();
}
///
/// 下拉框绑定数据
///
private void InitStorage()
{
//YdmBaseClass.InitComboEditor(cmbSteel, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getGradeDetail", "GRADECODE", this.ob, false);
//YdmBaseClass.InitComboEditor(cmbFactory, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getFactoryDetail", "PLINE_CODE", this.ob, false);
//YdmBaseClass.InitComboEditor(cmbStorager, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getStorageDetail", "STORAGE_NO", this.ob, false);
//YdmBaseClass.InitComboEditor(cmbStorage, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getStorageDetail", "STORAGE_NO", this.ob, false);
//YdmBaseClass.InitComboEditorWithParm(cmbJudge, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getStoveNo", "lcode", this.ob, false, new object[] { time1, time });
//YdmBaseClass.InitComboEditor(cmbOrder, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getOrderNo", "ORDER_NO", this.ob, false);
YdmBaseClass.InitComboEditor(ucePro, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getKind", "PRODUCCODE", this.ob, true);
YdmBaseClass.InitComboEditor(uceSpec, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getSpec", "SPEC_CODE", this.ob, true);
YdmBaseClass.InitComboEditor(uceSteel, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getSteel", "STEELCODE", this.ob, true);
YdmBaseClass.InitComboEditor(uceModel, "com.steering.pss.ydm.pipemanage.CorePipeInTemp.getModel", "MODEL_CODE", this.ob, true);
YdmBaseClass.BindColumn(ucePro, "CXKIND", this.Controls, ultraGrid1, 0);
YdmBaseClass.BindColumn(uceSpec, "CXGG", this.Controls, ultraGrid1, 0);
YdmBaseClass.BindColumn(uceSteel, "CXSTEELLEVEL", this.Controls, ultraGrid1, 0);
YdmBaseClass.BindColumn(uceModel, "CXTYPEOFTHREAD", this.Controls, ultraGrid1, 0);
}
private void ultraToolbarsManager_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
{
switch (e.Tool.Key)
{
case"pipRedDashed":
pipRedDashed();
break;
case"Close":
this.Close();
buttonValue = "0";
break;
default:
break;
}
}
///
/// 缴库红冲
///
private void pipRedDashed()
{
string instockDoc = "";
string instockDocList = "";
string strInMemo = "";
int count = 0;
UltraGridRow row = ultraGrid1.ActiveRow;
ArrayList matParm = new ArrayList();//材料表
ArrayList statusUpdate = new ArrayList();//质保
ArrayList plnSpale = new ArrayList();//销售合同提报
int pipNum = 0;
double pipWgt = 0.0;
double pipLength = 0.0;
int m = 0;
int mun = 0;
int n = 0;
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid4.Rows)
{
if (Convert.ToBoolean(uRow.Cells["CHK"].Text) == true)
{
mun = int.Parse(uRow.Cells["ACT_COUNT"].Text);
if (mun + int.Parse(row.Cells["hgunit"].Text.Trim()) > 0)
{
n++;
}
}
}
if (n > 1)
{
MessageUtil.ShowTips("已缴库记录有多条支数大于红冲支数,你到底要冲哪条记录,请选择相应缴库记录!");
return;
}
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow uRow in ultraGrid4.Rows)
{
if (Convert.ToBoolean(uRow.Cells["CHK"].Text) == true)
{
//instockDocList = uRow.Cells["INSTOCK_DOC"].Text.Trim();
//if (instockDoc != instockDocList)
//{
// MessageUtil.ShowTips("您选择的入库单号不一致,请重新选择!");
// uRow.Cells["CHK"].Value = false;
// return;
//}
pipNum += int.Parse(uRow.Cells["ACT_COUNT"].Text.Trim());
pipWgt += double.Parse(uRow.Cells["ACT_WEIGHT"].Text.Trim());
pipLength += double.Parse(uRow.Cells["ACT_LEN"].Text.Trim());
}
}
if (int.Parse(row.Cells["hgunit"].Text) + pipNum < 0)
{
MessageUtil.ShowTips("缴库红冲支数大于已缴库支数,不允许红冲!");
return;
}
else if (int.Parse(row.Cells["hgunit"].Text) + pipNum > 0)
{
if (pipWgt + double.Parse(row.Cells["hgweight"].Text.Trim()) < 0)
{
MessageUtil.ShowTips("缴库红冲支数小于已缴库支数,红冲重量大于已缴库重量不允许红冲!");
return;
}
else if (pipWgt + double.Parse(row.Cells["hgweight"].Text.Trim()) > 0)
{
if (pipLength + double.Parse(row.Cells["hgm"].Text.Trim()) < 0)
{
MessageUtil.ShowTips("缴库红冲支数小于已缴库支数,红冲长度大于已缴库长度不允许红冲!");
}
}
}
else if (int.Parse(row.Cells["hgunit"].Text) + pipNum == 0)
{
}
if (MessageUtil.ShowYesNoAndQuestion("是否确认缴库红冲?") == DialogResult.No) return;
foreach (UltraGridRow gridRow in ultraGrid4.Rows)
{
if (Convert.ToBoolean(gridRow.Cells["CHK"].Text) == true)
{
ArrayList matList = new ArrayList();
#region 要缴库的每一炉重量小于要缴库的重量
matList.Add(row.Cells["lcode"].Value.ToString()); //炉号
matList.Add(row.Cells["lotno"].Value.ToString());//批号
matList.Add(row.Cells["hgunit"].Value.ToString());//支数
matList.Add(row.Cells["cxkind"].Value.ToString());//品名代码
matList.Add(row.Cells["cxkind"].Text.ToString());//品名名称
matList.Add(row.Cells["cxsteellevel"].Value.ToString());//钢级(牌号)代码
matList.Add(row.Cells["cxsteellevel"].Text.ToString());//钢级名称
matList.Add(row.Cells["cxgg"].Value.ToString());//产品规格代码
matList.Add(row.Cells["cxgg"].Text.ToString());//产品规格描述
matList.Add(row.Cells["cxtypeofthread"].Value.ToString());//扣型代码
matList.Add(row.Cells["cxtypeofthread"].Text.ToString());//扣型描述 10
matList.Add(gridRow.Cells["STD_CODE"].Value.ToString());//标准代码
matList.Add(gridRow.Cells["STD_NAME"].Value.ToString());//标准名称
matList.Add("");
matList.Add("");
matList.Add("");//标准类别代码
matList.Add(row.Cells["STDSTYLE"].Value.ToString());//标准类别描述
matList.Add(gridRow.Cells["ORDER_NO"].Value.ToString());//合同号
matList.Add(gridRow.Cells["ORDER_SEQ"].Value.ToString());//合同行号
matList.Add(gridRow.Cells["DELIVERY_NO"].Value.ToString());//交货行号
matList.Add(gridRow.Cells["ORD_PK"].Value.ToString());//合同主键
matList.Add(gridRow.Cells["ORD_LN_PK"].Value.ToString());//合同行主键
matList.Add(gridRow.Cells["ORD_LN_DLY_PK"].Value.ToString());//交货行主键
matList.Add(gridRow.Cells["ACT_DIMATER"].Value.ToString());// 外径
matList.Add(gridRow.Cells["ACT_HEIGHT"].Value.ToString());//壁厚
matList.Add("");//长度编码(订货)
matList.Add("");//长度描述(订货)
matList.Add("");//长度单位 27
matList.Add(gridRow.Cells["ACT_LEN_MIN"].Value.ToString());//下限
matList.Add(gridRow.Cells["ACT_LEN_MAX"].Value.ToString());//上限
matList.Add(this.UserInfo.GetUserName());//操作人
matList.Add("0");
matList.Add("1");
matList.Add(row.Cells["testidea"].Value.ToString());//备注
matList.Add(row.Cells["hgweight"].Value.ToString());//重量
//double weight = Convert.ToDouble(row.Cells["HGWEIGHT"].Value.ToString());
//double unit = Convert.ToDouble(row.Cells["HGUNIT"].Value.ToString());
DataTable dtMemo = PipeManageClass.getComTypeInfo(strInbound, ob);
if (dtMemo.Rows.Count >= 1)
{
strInMemo = dtMemo.Rows[0]["MEMO"].ToString();
}
matList.Add(strInMemo);
matList.Add(this.UserInfo.GetDeptid());
matList.Add(this.UserInfo.GetDepartment());//37
matList.Add(strInbound);
matList.Add(gridRow.Cells["STORAGE_NO"].Value.ToString());//仓库号
matList.Add(gridRow.Cells["BELONG_CODE"].Value.ToString());//所属单位代码
matList.Add(gridRow.Cells["BELONG_NAME"].Value.ToString());// 所属单位
matList.Add(row.Cells["hgunit"].Value.ToString());
matList.Add(row.Cells["rcdid"].Value.ToString());
matList.Add(row.Cells["hgm"].Value.ToString());//长度
matList.Add(ClsBaseInfo.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob));
matList.Add(ClsBaseInfo.GetDepartBySectionId(this.UserInfo.GetDeptid(), this.ob));
matList.Add(row.Cells["standard"].Value.ToString());//判定标准
matList.Add(row.Cells["testdate"].Value.ToString().Substring(0, 4) + row.Cells["testdate"].Value.ToString().Substring(5, 2));// 判定时间
matList.Add(plineCode);
matList.Add(plineName);//50
matList.Add(gradeCode);
matList.Add(gradeName);
matList.Add(gridRow.Cells["PRODUCT_FLAG"].Value.ToString());//勾选入库记录的材料类别
matList.Add(gridRow.Cells["BATCH_GROUD_NO"].Value.ToString());//组号
matList.Add((double.Parse(gridRow.Cells["ACT_WEIGHT"].Text) + double.Parse(row.Cells["hgweight"].Text.Trim())).ToString());
matList.Add((int.Parse(gridRow.Cells["ACT_COUNT"].Text) + int.Parse(row.Cells["hgunit"].Text.Trim())).ToString());
if (gridRow.Cells["ACT_LEN"].Text != "" && row.Cells["hgm"].Text.Trim() != "")
{
matList.Add((double.Parse(gridRow.Cells["ACT_LEN"].Text) + double.Parse(row.Cells["hgm"].Text.Trim())).ToString());
}
else
{
matList.Add("");
}
matList.Add("AI" + gridRow.Cells["INSTOCK_DOC"].Text.ToString().Substring(2));//红冲单号
matParm.Add(matList);
#endregion
ArrayList plnList = new ArrayList();
plnList.Add(gridRow.Cells["ACT_WEIGHT"].Text);
plnList.Add(gridRow.Cells["ACT_COUNT"].Text);
plnList.Add(this.UserInfo.GetUserName());
plnList.Add(gridRow.Cells["ORDER_NO"].Value.ToString());
plnList.Add(gridRow.Cells["ORDER_SEQ"].Value.ToString());
plnList.Add(gridRow.Cells["DELIVERY_NO"].Value.ToString());
plnList.Add(row.Cells["lcode"].Text.Trim());
plnList.Add(row.Cells["lotno"].Text.Trim());
plnList.Add(gridRow.Cells["BATCH_GROUD_NO"].Text);
plnList.Add(gridRow.Cells["PRODUCT_FLAG"].Value.ToString());
plnSpale.Add(plnList);
ArrayList statusList = new ArrayList();
statusList.Add(row.Cells["RCDID"].Value.ToString());
statusUpdate.Add(statusList);
}
}
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "com.steering.pss.ydm.pipemanage.CorePipeInTemp";
ccp.MethodName = "pipRedDashed";
ccp.ServerParams = new object[] { matParm, plnSpale, statusUpdate };
ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
if (ccp.ReturnCode != -1)
{
// MessageUtil.ShowTips(ccp.ReturnInfo);
if (ccp.ReturnInfo.Equals("缴库红冲成功!"))
{
buttonValue = "1";
this.Close();
}
}
}
///
/// 查询质保红冲数据
///
///
private void querySqlServerData(string rccid)
{
DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.CorePipeInTemp.getSqlServerData", new object[] { rccid }, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref dataTable3, true);
}
///
/// 查询已缴库记录
///
private void queryInList(string heatNo,string bacthNo)
{
DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.CorePipeInTemp.getInListData", new object[] { heatNo, bacthNo }, this.ob);
GridHelper.CopyDataToDatatable(ref dt, ref dataTable4, true);
}
private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
{
ultraGrid1.UpdateData();
string heatNo = this.ultraGrid1.ActiveRow.Cells["lcode"].Text;//炉号
string bacthNo = this.ultraGrid1.ActiveRow.Cells["lotno"].Text;//批号
queryInList(heatNo, bacthNo);
}
}
}