using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using U9ISV.U9ISVCreateMiscShip;
using System.Collections;
namespace U9ISV
{
class U9ISVCreateMiscShipSub
{
public static string CreateMiscDO(DataTable dt)
{
string msg = "";
CommonCreateMiscShipStub cmisc = new CommonCreateMiscShipStub();
MessageBase[] messageBase = null;
List<UFIDAU9ISVMiscShipISVIC_MiscShipmentDTOData> headList = new List<UFIDAU9ISVMiscShipISVIC_MiscShipmentDTOData>();
UFIDAU9ISVMiscShipISVIC_MiscShipmentDTOData head = new UFIDAU9ISVMiscShipISVIC_MiscShipmentDTOData();
UFIDAU9CBOPubControllerContextDTOData context = new UFIDAU9CBOPubControllerContextDTOData();
context.m_entCode = U9Context.EntCode;
context.m_orgCode = U9Context.OrgCode;
context.m_userCode = U9Context.UserName;
//头
//单据类型
head.m_miscShipDocType = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
head.m_miscShipDocType.m_code = dt.Rows[0]["MiscShipDocType"].ToString();//"MiscShip101";
head.m_miscShipDocType.m_iDSpecified = true;
head.m_businessDate = DateTime.Now;
head.m_businessDateSpecified = true;
head.m_benefitOrg = long.Parse(dt.Rows[0]["BenefitOrg"].ToString());
head.m_benefitOrgSpecified = true;
if (dt.Rows[0]["Memo"] != null && dt.Rows[0]["Memo"].ToString() != "")
{
head.m_memo = dt.Rows[0]["Memo"].ToString();
}
head.m_miscShipLs = new UFIDAU9ISVMiscShipISVIC_MiscShipmentLDTOData[] { };
//行
List<UFIDAU9ISVMiscShipISVIC_MiscShipmentLDTOData> bom_linearr = new List<UFIDAU9ISVMiscShipISVIC_MiscShipmentLDTOData>();
{
for (int i = 0; i < 1; i++)
{
UFIDAU9ISVMiscShipISVIC_MiscShipmentLDTOData bom_line = new UFIDAU9ISVMiscShipISVIC_MiscShipmentLDTOData();
if (dt.Rows[i]["BenefitDept"] != null && dt.Rows[i]["BenefitDept"].ToString() != "")
{
bom_line.m_benefitDept = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
bom_line.m_benefitDept.m_code = dt.Rows[i]["BenefitDept"].ToString();//受益部门
}
if (dt.Rows[i]["CustomerInfo_Code"] != null && dt.Rows[i]["CustomerInfo_Code"].ToString() != "")
{
bom_line.m_customerInfo = new UFIDAU9CBOSCMCustomerCustomerMISCInfoData();
bom_line.m_customerInfo.m_code = dt.Rows[i]["CustomerInfo_Code"].ToString();
}
bom_line.m_itemInfo = new UFIDAU9CBOSCMItemItemInfoData();
bom_line.m_itemInfo.m_itemCode = dt.Rows[i]["ItemInfo_ItemCode"].ToString();//料品编码
if (dt.Rows[i]["Wh"] != null && dt.Rows[i]["Wh"].ToString() != "")
{
bom_line.m_wh = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
bom_line.m_wh.m_code = dt.Rows[i]["Wh"].ToString();
}
bom_line.m_storeUOMQty = decimal.Parse(dt.Rows[i]["StoreUOMQty"].ToString());//出库数量
bom_line.m_storeUOMQtySpecified = true;
bom_linearr.Add(bom_line);
}
}
head.m_miscShipLs = bom_linearr.ToArray();
headList.Add(head);
try
{
UFIDAU9CBOPubControllerCommonArchiveDataDTOData[] li = cmisc.Do(U9Context.GetContext(), headList.ToArray(), context, out messageBase);
if (li[0].m_code != null)
{
msg = msg + "杂发单 " + (li[0].m_code ?? "").ToString() + " 创建成功!";
}
else
{
msg = msg + "杂发单" + (li[0].m_code ?? "").ToString() + "创建失败!";
}
}
catch (System.Web.Services.Protocols.SoapException ex)
{
var rtn = ex.Detail.InnerXml;
msg = msg + "杂发单创建失败:" +rtn;
}
return msg;
}
}
}