Beispiel #1
0
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="bd"></param>
        /// <param name="vouchid"></param>
        /// <returns></returns>
        public override Model.DealResult MakeAudit(BaseData bd, Model.Synergismlogdt dt)
        {
            Model.DealResult dr           = new Model.DealResult();
            Model.APIData    apidata      = bd as Model.APIData;
            string           vouchid      = GetCodeorID(dt.Cvoucherno, apidata, "id");
            string           auditaddress = SetApiAddressAudit();

            U8Login.clsLogin u8Login = new U8Login.clsLogin();
            GetU8Login(apidata, u8Login);
            U8ApiBroker broker = null;

            dr = GetU8ApiBroker(apidata, u8Login, out broker, "audit");
            broker.AssignNormalValue("sVouchType", apidata.SVouchType);
            broker.AssignNormalValue("VouchId", vouchid);
            broker.AssignNormalValue("cnnFrom", null);
            broker.AssignNormalValue("TimeStamp", DAL.Common.GetUtfsByID(vouchid, SetTableName(), apidata.ConnectInfo.Constring));
            MSXML2.IXMLDOMDocument2 domMsg = new MSXML2.DOMDocument();
            broker.AssignNormalValue("domMsg", domMsg);
            broker.AssignNormalValue("bCheck", false);
            broker.AssignNormalValue("bBeforCheckStock", false);
            broker.AssignNormalValue("bList", null);
            dr = BrokerInvoker(broker);
            if (!DAL.Common.SetVerifyDate(bd.ConnectInfo, dt))
            {
                U8.Interface.Bus.Log.WriteWinLog("设置单据审核日期失败,Cvouchertype:" + dt.Cvouchertype + ";Cvoucherno:" + dt.Cvoucherno + ".");
            }

            return(dr);
        }
Beispiel #2
0
        /// <summary>
        /// 弃审
        /// </summary>
        /// <param name="bd"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public override Model.DealResult CancelAudit(Model.APIData bd, Model.Synergismlogdt dt)
        {
            Model.DealResult dr      = new Model.DealResult();
            Model.APIData    apidata = bd as Model.APIData;

            if (CheckAuditStatus(dt.Cvoucherno, apidata.ConnectInfo.Constring) == false)
            {
                return(dr);
            }

            string vouchid      = GetCodeorID(dt.Cvoucherno, apidata, "id");
            string auditaddress = SetApiAddressCancelAudit();

            U8Login.clsLogin u8Login = new U8Login.clsLogin();
            GetU8Login(apidata, u8Login);
            U8ApiBroker broker = null;

            dr = GetU8ApiBroker(apidata, u8Login, out broker, "cancelaudit");

            broker.AssignNormalValue("sVouchType", apidata.SVouchType);
            broker.AssignNormalValue("VouchId", vouchid);
            broker.AssignNormalValue("cnnFrom", null);
            broker.AssignNormalValue("TimeStamp", DAL.Common.GetUtfsByID(vouchid, SetTableName(), apidata.ConnectInfo.Constring));
            MSXML2.IXMLDOMDocument2 domMsg = new MSXML2.DOMDocument();
            broker.AssignNormalValue("domMsg", domMsg);
            broker.AssignNormalValue("bCheck", false);
            broker.AssignNormalValue("bBeforCheckStock", false);
            broker.AssignNormalValue("bList", null);
            dr = BrokerInvoker(broker);
            return(dr);
        }
Beispiel #3
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="bd"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public override Model.DealResult UndoMake(BaseData bd, Model.Synergismlogdt dt)
        {
            Model.DealResult dr      = new Model.DealResult();
            Model.APIData    apidata = bd as Model.APIData;
            try
            {
                dr = CancelAudit(apidata, dt);
            }
            catch (Exception ex)
            {
                U8.Interface.Bus.Log.WriteWinLog("stockop_cancelaudit:" + ex.ToString());
                dr.ResultNum = -1;
                dr.ResultMsg = ex.Message;
                return(dr);
            }
            string vouchid      = GetCodeorID(dt.Cvoucherno, apidata, "id");
            string auditaddress = SetApiAddressDelete();

            U8Login.clsLogin u8Login = new U8Login.clsLogin();
            GetU8Login(apidata, u8Login);
            U8ApiBroker broker = null;

            dr = GetU8ApiBroker(apidata, u8Login, out broker, "delete");
            broker.AssignNormalValue("sVouchType", apidata.SVouchType);
            broker.AssignNormalValue("VouchId", vouchid);
            broker.AssignNormalValue("cnnFrom", null);
            broker.AssignNormalValue("TimeStamp", DAL.Common.GetUtfsByID(vouchid, SetTableName(), apidata.ConnectInfo.Constring));
            MSXML2.IXMLDOMDocument2 domMsg = new MSXML2.DOMDocument();
            broker.AssignNormalValue("domMsg", domMsg);
            broker.AssignNormalValue("bCheck", false);
            broker.AssignNormalValue("bBeforCheckStock", false);
            broker.AssignNormalValue("bList", null);
            dr = BrokerInvoker(broker);
            return(dr);
        }
Beispiel #4
0
        public static void FormatDom(ref MSXML2.DOMDocument SourceDom, string editprop)
        {
            //IXMLDOMElement element;
            //IXMLDOMElement ele_head;
            IXMLDOMElement ele_body;
            //IXMLDOMNode nd;
            //MSXML2.DOMDocument tempnd;
            IXMLDOMNodeList ndheadlist;
            IXMLDOMNodeList ndbodylist;
            //DistDom.loadXML("SourceDom.xml");
            String Filedname;

            //'格式部分
            ndheadlist = SourceDom.selectNodes("//s:Schema/s:ElementType/s:AttributeType");
            ndbodylist = SourceDom.selectNodes("//rs:data/z:row");
            if (ndbodylist.length == 0)
            {
                ele_body = SourceDom.createElement("z:row");
                SourceDom.selectSingleNode("//rs:data").appendChild(ele_body);
            }
            ndbodylist = SourceDom.selectNodes("//rs:data/z:row");
            foreach (IXMLDOMElement body in ndbodylist)
            {
                foreach (IXMLDOMElement head in ndheadlist)
                {
                    Filedname = head.attributes.getNamedItem("name").nodeValue + "";
                    if (body.attributes.getNamedItem(Filedname) == null)
                    {
                        //  '若没有当前元素,就增加当前元素
                        body.setAttribute(Filedname, "");
                    }
                    switch (head.lastChild.attributes.getNamedItem("dt:type").nodeValue.ToString())
                    {
                    case "number":
                    case "float":
                    case "boolean":
                        if (body.attributes.getNamedItem(Filedname).nodeValue.ToString().ToUpper() == "false".ToUpper())
                        {
                            body.setAttribute(Filedname, 0);
                        }
                        break;

                    default:


                        if (body.attributes.getNamedItem(Filedname).nodeValue.ToString().ToUpper() == "否".ToUpper())
                        {
                            body.setAttribute(Filedname, 0);
                        }
                        break;
                    }
                }
                if (editprop != "")
                {
                    body.setAttribute("editprop", editprop);
                }
            }
        }
Beispiel #5
0
 public override Model.DealResult AssignNormalValues(Model.APIData apidata, UFIDA.U8.U8APIFramework.U8ApiBroker broker)
 {
     Model.DealResult dr = new Model.DealResult();
     broker.AssignNormalValue("VoucherState", 2);
     MSXML2.IXMLDOMDocument2 CurDom = new MSXML2.DOMDocument();
     broker.AssignNormalValue("CurDom", CurDom);
     broker.AssignNormalValue("UserMode", 0);
     return(dr);
 }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="apidata"></param>
        /// <param name="broker"></param>
        /// <returns></returns>
        public override Model.DealResult AssignNormalValues(Model.APIData apidata, UFIDA.U8.U8APIFramework.U8ApiBroker broker)
        {
            Model.DealResult dr = new Model.DealResult();
            broker.AssignNormalValue("VoucherState", 0);
            string vnewid = string.Empty;

            broker.AssignNormalValue("vNewID", vnewid);
            MSXML2.IXMLDOMDocument2 domMsg = new MSXML2.DOMDocument();
            broker.AssignNormalValue("DomConfig", domMsg);
            return(dr);
        }
Beispiel #7
0
 public override Model.DealResult AssignNormalValues(Model.APIData apidata, U8ApiBroker broker)
 {
     Model.DealResult dr = new Model.DealResult();
     broker.AssignNormalValue("sVouchType", SetVouchType());
     broker.AssignNormalValue("domPosition", null);
     broker.AssignNormalValue("cnnFrom", null);
     broker.AssignNormalValue("VouchId", "");
     MSXML2.IXMLDOMDocument2 domMsg = new MSXML2.DOMDocument();
     broker.AssignNormalValue("domMsg", domMsg);
     broker.AssignNormalValue("bCheck", true);
     broker.AssignNormalValue("bBeforCheckStock", true);
     broker.AssignNormalValue("bIsRedVouch", false);
     broker.AssignNormalValue("sAddedState", null);
     broker.AssignNormalValue("bReMote", false);
     return(dr);
 }
Beispiel #8
0
        public override Model.DealResult UndoMake(BaseData bd, Model.Synergismlogdt dt)
        {
            Model.DealResult dr      = new Model.DealResult();
            Model.APIData    apidata = bd as Model.APIData;
            try
            {
                CancelAudit(apidata, dt);
            }
            catch (Exception ex)
            {
                Log.WriteWinLog("purchaseop_cancelaudit:" + ex.ToString());
                dr.ResultNum = -1;
                dr.ResultMsg = ex.Message;
                return(dr);
            }
            BusinessObject domHead = null;
            BusinessObject domBody = null;

            LoadVouch(apidata, dt, out domHead, out domBody);
            string vouchid = GetCodeorID(dt.Cvoucherno, apidata, "id");

            U8Login.clsLogin u8Login = new U8Login.clsLogin();
            dr = GetU8Login(apidata, u8Login);
            if (dr.ResultNum < 0)
            {
                return(dr);
            }
            U8ApiBroker broker = null;

            dr = GetU8ApiBroker(apidata, u8Login, out broker, "delete");
            if (dr.ResultNum < 0)
            {
                return(dr);
            }
            broker.SetBoParam("domHead", domHead);
            try
            {
                broker.SetBoParam("domBody", domBody);
            }
            catch { }

            MSXML2.IXMLDOMDocument2 CurDom = new MSXML2.DOMDocument();
            broker.AssignNormalValue("CurDom", CurDom);
            if (!broker.Invoke())
            {
                Exception apiEx = broker.GetException();
                if (apiEx != null)
                {
                    if (apiEx is MomSysException)
                    {
                        MomSysException sysEx = apiEx as MomSysException;

                        dr.ResultNum = -1;
                        dr.ResultMsg = "系统异常:" + sysEx.Message;
                    }
                    else if (apiEx is MomBizException)
                    {
                        MomBizException bizEx = apiEx as MomBizException;


                        dr.ResultNum = -1;
                        dr.ResultMsg = "API异常:" + bizEx.Message;
                    }

                    String exReason = broker.GetExceptionString();
                    if (exReason.Length != 0)
                    {
                        dr.ResultNum = -1;
                        dr.ResultMsg = " 异常原因:" + exReason;
                    }
                }

                broker.Release();

                return(dr);
            }
            System.String result = broker.GetReturnValue() as System.String;
            if (result != null)
            {
                dr.ResultNum = -1;
                dr.ResultMsg = "API错误:" + result;
                throw new Exception("API错误:" + result);
            }
            broker.Release();

            DAL.Regist   registdal = new DAL.Regist();
            Model.Regist regist    = registdal.GetModel(dt.Accid); //acccode 转 accid
            return(dr);
        }
Beispiel #9
0
        /// <summary>
        /// 激发API操作
        /// </summary>
        /// <param name="broker"></param>
        /// <returns></returns>
        public override Model.DealResult BrokerInvoker(UFIDA.U8.U8APIFramework.U8ApiBroker broker)
        {
            Model.DealResult        dr        = new Model.DealResult();
            MSXML2.IXMLDOMDocument2 domResult = new MSXML2.DOMDocument();

            MSXML2.IXMLDOMNodeList lstx;
            string sResult = "";

            if (!broker.Invoke())
            {
                //错误处理
                Exception apiEx = broker.GetException();
                if (apiEx != null)
                {
                    if (apiEx is MomSysException)
                    {
                        MomSysException sysEx = apiEx as MomSysException;
                        dr.ResultNum = -1;
                        dr.ResultMsg = "系统异常:" + sysEx.Message;
                    }
                    else if (apiEx is MomBizException)
                    {
                        MomBizException bizEx = apiEx as MomBizException;
                        dr.ResultNum = -1;
                        dr.ResultMsg = "API异常:" + bizEx.Message;
                    }

                    String exReason = broker.GetExceptionString();
                    if (exReason.Length != 0)
                    {
                        dr.ResultNum = -1;
                        dr.ResultMsg = " 异常原因:" + exReason;
                    }
                }

                broker.Release();

                return(dr);
            }
            System.String result    = broker.GetReturnValue() as System.String;
            string        vNewIDRet = broker.GetResult("vNewID") as string;

            broker.Release();


            if (result != null)
            {
                dr.ResultNum = -1;
                dr.ResultMsg = result;
                sResult      = result.ToString();

                //增加可用量不足的提示,通过读取返回的DOM信息解析可用量不足的信息
                if (sResult.IndexOf("<rs:data") > 0)
                {
                    string sInvCode = "";
                    string sInvName = "";
                    string sWhCode  = "";
                    string sWhName  = "";
                    string sError   = "";
                    sResult = sResult.Substring(sResult.IndexOf("<rs:data"));
                    if (domResult.loadXML(sResult) == true)
                    {
                        lstx = domResult.selectNodes("//z:row");
                        foreach (MSXML2.IXMLDOMNode xmle in lstx)
                        {
                            sInvCode = xmle.attributes.getNamedItem("cinvcode").nodeValue.ToString();
                            sInvName = xmle.attributes.getNamedItem("cinvname").nodeValue.ToString();
                            sWhCode  = xmle.attributes.getNamedItem("cwhcode").nodeValue.ToString();
                            sWhName  = xmle.attributes.getNamedItem("cwhname").nodeValue.ToString();

                            sError = sError + "存货编码[" + sInvCode + "] 存货名称[" + sInvName + "] 仓库[" + sWhName + "]\r\n";
                        }
                        if (sError != "")
                        {
                            sError       = sError + "可用量不足";
                            result       = sError;
                            dr.ResultMsg = result;
                        }
                    }
                }

                throw new Exception("API错误:" + result);
            }
            dr.VouchIdRet = vNewIDRet;
            return(dr);
        }
Beispiel #10
0
 /// <summary>
 /// domxml的方法加载数据--表体
 /// </summary>
 /// <param name="apidata"></param>
 /// <param name="broker"></param>
 /// <param name="dombodyxml"></param>
 /// <returns></returns>
 public Model.DealResult SetDomBody(Model.APIData apidata, U8ApiBroker broker, MSXML2.DOMDocument dombodyxml)
 {
     Model.DealResult   dr   = new Model.DealResult();
     MSXML2.IXMLDOMNode node = dombodyxml.selectSingleNode("//rs:data");
     foreach (List <Model.U8NameValue> lunv in apidata.BodyData)
     {
         MSXML2.IXMLDOMElement element = dombodyxml.createElement("z:row");
         foreach (Model.U8NameValue unv in lunv)
         {
             element.setAttribute(unv.U8FieldName.ToLower(), unv.U8FieldValue);
         }
         node.appendChild(element);
     }
     return(dr);
 }
Beispiel #11
0
        public string InvokeU8Api(string method,string content)
        {
            string retstr = "";
            try
            {
                string AccCode = ReadXmlData("Detail", "AccCode");
                string User = ReadXmlData("Detail", "User");
                string Password = ReadXmlData("Detail", "Password");
                string Server = ReadXmlData("Detail", "Server");

                ulogin = new U8Login.clsLogin();
                U8Login.clsLogin u8Login = new U8Login.clsLogin();
                // string taskid = clslogin.GetTaskID("DP");
                String sSubId = "DP";//AS DP
                String sAccId = AccCode;
                String sYear = DateTime.Now.Year.ToString();
                String sUserID = User;
                String sPassword = Password;
                String sDate = DateTime.Now.ToShortDateString();
                String sServer = Server;//USER-20150630LA
                String sSerial = "";
                if (u8Login.Login(ref sSubId, ref sAccId, ref sYear, ref sUserID, ref sPassword, ref sDate, ref sServer, ref sSerial))
                {
                    setConnStr(u8Login.UfDbName);
                    //retstr = "login ok!";
                }
                else
                {
                    retstr = u8Login.ShareString;
                    Marshal.FinalReleaseComObject(u8Login);
                    return retstr;
                }

                string ServiceURL = ReadXmlData("Detail", "ServiceURL");
                string ServiceName = ReadXmlData("Detail", "ServiceName");

                if (method.Equals("InventoryQTY"))//对方来调
                {
                    DataTable dt = getSqlData("select cinvcode,cwhcode,iquantity,fAvaQuantity from currentstock where cinvcode='" + content + "'");
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        StringBuilder sb = new StringBuilder();
                        sb.Append("<?xml version='1.0' encoding='UTF-8'?>   <DATA>  ");
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            sb.Append("<RECORD>");

                            sb.Append("<CINVCODE>");
                            sb.Append(dt.Rows[i][0].ToString());
                            sb.Append("</CINVCODE>");

                            sb.Append("<CWHCODE>");
                            sb.Append(dt.Rows[i][1].ToString());
                            sb.Append("</CWHCODE>");

                            sb.Append("<IQUANTITY>");
                            sb.Append(dt.Rows[i][2].ToString());
                            sb.Append("</IQUANTITY>");

                            sb.Append("<FAVAQUANTITY>");
                            sb.Append(dt.Rows[i][3].ToString());
                            sb.Append("</FAVAQUANTITY>");

                            sb.Append("</RECORD>");
                        }
                        sb.Append("</DATA>");
                        return sb.ToString();
                    }
                    else
                        return "查不到现存量信息";
                }
                if (method.Equals("Inventory"))//U8触发器调用,再调用对方ws
                {
                    DataTable dt = getSqlData("select cinvcode,cinvname,cinvstd,ccomunitcode,cinvccode,cbarcode,'0' as cisgift,'0' as gd_is_gift,iinvsalecost from inventory with(nolock) where cinvcode='" + content + "'");
                    DataRow dr = dt.Rows[0];

                    StringBuilder sb = new StringBuilder();
                    sb.Append("<DATA><RECORD>");
                    ConcatXml(sb, dr, "CINVCODE", "cinvcode");
                    ConcatXml(sb, dr, "CINVNAME", "cinvname");
                    ConcatXml(sb, dr, "CINVSTD", "cinvstd");
                    ConcatXml(sb, dr, "CINVCCODE", "cinvccode");
                    ConcatXml(sb, dr, "CCOMUNITCODE", "ccomunitcode");
                    ConcatXml(sb, dr, "CBARCODE", "cbarcode");
                    ConcatXml(sb, dr, "CISGIFT", "cisgift");
                    ConcatXml(sb, dr, "iInvSaleCost", "iInvSaleCost");
                    ConcatXml(sb, dr, "gd_is_gift", "gd_is_gift");
                    sb.Append("</RECORD>");
                    sb.Append("</DATA>");
                    ZSNS.ZhengShanWsIClient client = new ZSNS.ZhengShanWsIClient(ServiceName,ServiceURL);
                    return client.inventory(sb.ToString());
                    //return sb.ToString();
                    //return "SUCC";
                }
                if (method.Equals("InventoryClass"))//暂时 不使用
                {
                    DataTable dt = getSqlData("select CINVCCODE,CINVCNAME,(select cInvCCode from InventoryClass b with(nolock) where b.iInvCGrade+1=h.iInvCGrade and LEFT(h.cinvccode,LEN(b.cinvccode))=b.cinvccode) as CINVCCODE_F from inventoryclass h with(nolock)");
                    string str = "";
                    str += "<DATA>";
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        str += "<RECORD>";
                        str += GetXmlTag("CINVCCODE", dt.Rows[i]["CINVCCODE"].ToString());
                        str += GetXmlTag("CINVCNAME", dt.Rows[i]["CINVCCODE"].ToString());
                        str += GetXmlTag("CINVCCODE_F", dt.Rows[i]["CINVCCODE_F"].ToString());
                        str += "</RECORD>";
                    }
                    str += "</DATA>";
                    ZSNS.ZhengShanWsIClient client = new ZSNS.ZhengShanWsIClient(ServiceName, ServiceURL);
                    return client.InventoryClass(str);
                }
                if (method.Equals("ST_AppTransVouchAdd"))//本地U8调拨申请单审核时触发
                {
                    StringBuilder sql = new StringBuilder();
                    sql.AppendLine("select h.cTVCode as vouchid,h.dtvdate as vouchdate,ow.cwhname as owhname,");
                    sql.AppendLine("iw.cwhname as iwhname,p.cPersonname as Person,");
                    sql.AppendLine("b.cinvcode,i.cinvname,b.fSaleCost as unitprice,b.itvquantity as qty,b.cbmemo as memo ");
                    sql.AppendLine("from ST_AppTransVouch h with(nolock) inner join ST_AppTransVouchs b with(nolock) on h.ID = b.ID");
                    sql.AppendLine("inner join Inventory i with(nolock) on i.cInvCode = b.cInvcode ");
                    sql.AppendLine("inner join warehouse ow with(nolock) on ow.cwhcode = h.cOWhCode");
                    sql.AppendLine("inner join warehouse iw with(nolock) on iw.cwhcode = h.cIWhCode");
                    sql.AppendLine("left join person p with(nolock) on p.cPersoncode = h.cPersonCode ");
                    sql.AppendLine("where h.cTVCode='"+content+"'");

                    DataTable dt = getSqlData(sql.ToString());
                    if (dt.Rows.Count == 0)
                        return "无此调拨申请单号"+content;
                    DataRow dr = dt.Rows[0];
                    StringBuilder sb = new StringBuilder();
                    sb.Append("<RECORD>");
                    sb.Append("<ORDER>");
                    sb.Append("<ORDERID>");
                    sb.Append("<HEADER>");
                    ConcatXml(sb, dr, "VOUCHID", "vouchid");
                    ConcatXml(sb, dr, "VOUCHDATE", "vouchdate");
                    ConcatXml(sb, dr, "OWHNAME", "owhname");
                    ConcatXml(sb, dr, "IWHNAME", "iwhname");
                    ConcatXml(sb, dr, "PERSON", "person");

                    sb.Append("</HEADER>");
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        sb.Append("<DETAIL>");
                        ConcatXml(sb, dt.Rows[i], "CINVCODE", "cinvcode");
                        ConcatXml(sb, dt.Rows[i], "CINVNAME", "cinvname");
                        ConcatXml(sb, dt.Rows[i], "UNITPRICE", "unitprice");
                        ConcatXml(sb, dt.Rows[i], "QTY", "qty");
                        ConcatXml(sb, dt.Rows[i], "MEMO", "memo");
                        sb.Append("</DETAIL>");
                    }
                    sb.Append("</ORDERID>");
                    sb.Append("</ORDER>");
                    sb.Append("</RECORD>");
                    sb.Append("</DATA>");
                    ZSNS.ZhengShanWsIClient c = new ZSNS.ZhengShanWsIClient(ServiceName, ServiceURL);
                    return c.ST_AppTransVouchAdd(sb.ToString());
                }

                string api = "";
                if (method.Equals("TransVouchAdd"))//调拨单生成
                {
                    api = "U8API/TransVouch/Add";
                }
                else if (method.Equals("audit"))//调拨单审核
                {
                    api = "U8API/TransVouch/Delete";
                }
                else if (method.Equals("load"))//调拨申请单查询,废弃
                {
                    api = "U8API/TransRequestVouch/Load";
                }else
                if (method.Equals("OutboundOrderAdd"))
                    api = "U8API/saleout/Add";
                if (method.Equals("OutboundOrderDone"))
                    api = "U8API/saleout/CancelAudit";//Delete

                U8EnvContext envContext = new U8EnvContext();
                envContext.U8Login = u8Login;

                //string method = "audit";

                U8ApiAddress myApiAddress = new U8ApiAddress(api);
                U8ApiBroker broker = new U8ApiBroker(myApiAddress, envContext);
                MSXML2.DOMDocument domMsg = new MSXML2.DOMDocument();
                if (method.Equals("TransVouchAdd"))//基本完成
                {
                    broker.AssignNormalValue("sVouchType", "12");

                    BusinessObject DomHead = broker.GetBoParam("DomHead");
                    DomHead.RowCount = 1;

                    XmlDocument xml = new XmlDocument();
                    //xml.LoadXml(content.Trim());
                    xml.Load("c:\\DATA.xml");

                    XmlNodeList xnList = xml.SelectNodes("/DATA/ORDER/ORDERID/DETAIL");
                    foreach (XmlNode xn in xnList)
                    {
                        retstr += "开始读取XML";
                        string VOUCHID = xn["VOUCHID"].InnerText;
                        string VOUCHDATE = xn["VOUCHDATE"].InnerText;

                        //DomHead[0]["id"] = "2"; //主关键字段,int类型
                        DomHead[0]["ctvcode"] = VOUCHID; //单据号,string类型
                        DomHead[0]["dtvdate"] = VOUCHDATE;  //日期,DateTime类型
                        DataTable dt = getSqlData("select cwhcode from warehouse where cwhname='" + xn["OWHNAME"].InnerText+"'");
                        if (dt.Rows.Count > 0)
                            DomHead[0]["cowhcode"] = dt.Rows[0][0].ToString();
                        dt = getSqlData("select cwhcode from warehouse where cwhname='" + xn["IWHNAME"].InnerText + "'");
                        if (dt.Rows.Count > 0)
                            DomHead[0]["ciwhcode"] = dt.Rows[0][0].ToString();

                        DomHead[0]["cwhname"] = xn["OWHNAME"].InnerText; //转出仓库,string类型
                        DomHead[0]["cwhname_1"] = xn["IWHNAME"].InnerText; //转入仓库,string类型

                        //DomHead[0]["ciwhcode"] = "2";//转入仓库编码,string类型
                        //DomHead[0]["cowhcode"] = "1"; //转出仓库编码,string类型

                        //DomHead[0]["cordcode"] = "2"; //出库类别编码,string类型
                        //DomHead[0]["cirdcode"] = "1"; //入库类别编码,string类型

                        //DomHead[0]["crdname_1"] = "销售出库";//出库类别
                        //DomHead[0]["crdname"] = "采购入库";//入库类别

                        //DomHead[0]["cdepname_1"] = "采购部";
                        //DomHead[0]["cdepname"] = "销售部";
                        //DomHead[0]["codepcode"] = "1";
                        //DomHead[0]["cidepcode"] = "2";

                        //DomHead[0]["cpersoncode"] = "1";
                        DomHead[0]["cpersonname"] = xn["PERSON"].InnerText;//经手人
                        dt = getSqlData("select cPersonCode from Person where cPersonName='" + xn["PERSON"].InnerText + "'");
                        if (dt.Rows.Count > 0)
                            DomHead[0]["cpersoncode"] = dt.Rows[0][0].ToString();

                        //DomHead[0]["iamount"] = "";//现存量
                        DomHead[0]["dnmaketime"] = DateTime.Now;
                        DomHead[0]["ctvmemo"] = xn["MEMO"].InnerText;
                        DomHead[0]["cinvname"] = xn["CINVNAME"].InnerText;
                        //DomHead[0]["iavaquantity"] = "80"; 可用量

                        DomHead[0]["csource"] = "1"; //1 -- 库存 2 -- 零售 3 -- 预留
                        DomHead[0]["cmaker"] = User;
                        DomHead[0]["csource"] = "1";
                        DomHead[0]["itransflag"] = "正向";
                        DomHead[0]["vt_id"] = 89;
                        DomHead[0]["dnmaketime"] = DateTime.Now.ToLongDateString();
                        //DomHead[0]["ufts"] = "                      275.5169";
                        DomHead[0]["btransflag"] = false;

                        BusinessObject domBody = broker.GetBoParam("domBody");
                        domBody.RowCount = 1;

                        //domBody[0]["autoid"] = "2"; //主关键字段,int类型
                        domBody[0]["cinvcode"] = xn["CINVCODE"].InnerText;//存货编码,string类型
                        domBody[0]["cinvname"] = xn["CINVNAME"].InnerText;
                        //domBody[0]["cinvstd"] = "";

                        domBody[0]["itvquantity"] =getDouble(xn["QTY"].InnerText); //数量,double类型

                        DataTable dt3 = getSqlData("select cComUnitCode from inventory where cinvcode='" + xn["CINVCODE"].InnerText + "'");

                        //domBody[0]["itvnum"] = 0.1;

                        domBody[0]["ctvbatch"] = "";
                        if (dt3.Rows.Count > 0)
                        {
                            domBody[0]["cinvm_unit"] = dt3.Rows[0][0].ToString();
                            //domBody[0]["cinva_unit"] = "4";
                            //domBody[0]["cassunit"] = "4";
                        }

                        domBody[0]["iexpiratdatecalcu"] = 0;
                        domBody[0]["issotype"] = 0;
                        domBody[0]["idsotype"] = 0;
                        domBody[0]["isoseq"] = "";
                        domBody[0]["idsoseq"] = "";
                        domBody[0]["issodid"] = "";
                        domBody[0]["idsodid"] = "";
                        domBody[0]["cinvaddcode"] = "";
                        domBody[0]["corufts"] = "                              ";
                        domBody[0]["cdsocode"] = "";
                        domBody[0]["csocode"] = "";

                        domBody[0]["bcosting"] = "1";
                        domBody[0]["cposition"] = "";

                        //domBody[0]["iinvexchrate"] = 100;
                        domBody[0]["ctvcode"] = VOUCHID;
                        domBody[0]["fsalecost"] = getDouble(xn["UNITPRICE"].InnerText) * getDouble(xn["QTY"].InnerText);
                        domBody[0]["fsaleprice"] = getDouble(xn["UNITPRICE"].InnerText);
                        //domBody[0]["itvpcost"] = getDouble(xn["itvpcost"].InnerText);
            ;
                        domBody[0]["itvaprice"] = 0;
                        domBody[0]["itvpprice"] = 0;
                        domBody[0]["itvacost"] = 0;

                        //domBody[0]["igrossweight"] = "3";
                        //domBody[0]["inetweight"] = "1";

                        domBody[0]["editprop"] = "A";
                        retstr += "读取XML完成";
                    }

                    broker.AssignNormalValue("domPosition", null);
                    broker.AssignNormalValue("errMsg", "");
                    broker.AssignNormalValue("cnnFrom", null);
                    broker.AssignNormalValue("VouchId", "");
                    broker.AssignNormalValue("domMsg", domMsg);

                    broker.AssignNormalValue("bCheck", false);
                    broker.AssignNormalValue("bBeforCheckStock", false);
                    broker.AssignNormalValue("bIsRedVouch", false);
                    broker.AssignNormalValue("sAddedState", "");
                    broker.AssignNormalValue("bReMote", false);

                }
                if (method.Equals("OutboundOrderAdd"))
                {
                    broker.AssignNormalValue("sVouchType", "32");//新增0 修改1
                    broker.AssignNormalValue("vNewID", "");
                }
                if (method.Equals("OutboundOrderDone"))//出库单审核
                {

                    DataTable dt = getSqlData("select CONVERT(money,ufts) as ufts from rdrecord32 where cCode='" + content + "'");
                    double ufts = 0;
                    if (dt.Rows.Count > 0)
                        ufts = double.Parse(dt.Rows[0][0].ToString());
                    else
                        return "找不到此销售出库单号:" + content;
                    broker.AssignNormalValue("sVouchType", "32");
                    broker.AssignNormalValue("VouchId", content);//单据号
                    broker.AssignNormalValue("errMsg", "");
                    broker.AssignNormalValue("cnnFrom", null);
                    broker.AssignNormalValue("TimeStamp", String.Format("{0,30}", String.Format("{0:0.0000}", ufts)));// "                      275.5210"
                    broker.AssignNormalValue("domMsg", domMsg);//new MSXML2.DOMDocument()
                    broker.AssignNormalValue("bCheck", false);
                    broker.AssignNormalValue("bBeforCheckStock", false);
                    broker.AssignNormalValue("bList", false);
                    //删除单据不需要下面三个参数
                    //broker.AssignNormalValue("MakeWheres", null);
                    //broker.AssignNormalValue("sWebXml", "");
                    //broker.AssignNormalValue("oGenVouchIds", null);
                }
                if (method.Equals("audit"))//调拨单审核,未解决
                {
                    DataTable dt = getSqlData("select CONVERT(money,ufts) as ufts from transvouch where cTVCode='" + content + "'");
                    double ufts = 0;
                    //string ts = "";
                    if (dt.Rows.Count > 0)
                    {
                        //DataTable dt2 = getSqlData("select convert(timestamp,CONVERT(money," + String.Format("{0,30}", String.Format("{0:0.0000}", ufts)) + ")) as ufts ");
                        ufts = double.Parse(dt.Rows[0][0].ToString());
                        //ts = dt2.Rows[0][0].ToString();
                    }
                    else
                        return "找不到此调拨单号:"+content;
                    broker.AssignNormalValue("sVouchType", "12");
                    broker.AssignNormalValue("VouchId", content);//单据号
                    broker.AssignNormalValue("errMsg", "");
                    broker.AssignNormalValue("cnnFrom", null);
                    broker.AssignNormalValue("TimeStamp", String.Format("{0,30}", String.Format("{0:0.0000}", ufts)));// "                      275.5210"
                    broker.AssignNormalValue("domMsg", domMsg);//new MSXML2.DOMDocument()
                    broker.AssignNormalValue("bCheck", false);
                    broker.AssignNormalValue("bBeforCheckStock", false);
                    broker.AssignNormalValue("bList", false);

                    //broker.AssignNormalValue("MakeWheres", null);
                    //broker.AssignNormalValue("sWebXml", "");
                    //broker.AssignNormalValue("oGenVouchIds", null);
                }
                if (method.Equals("load"))//deprecated. not in use
                {
                    broker.AssignNormalValue("sVouchType", "62");
                    broker.AssignNormalValue("sWhere", " VouchId='0000000001'");
                    broker.AssignNormalValue("bGetBlank", false);
                    broker.AssignNormalValue("sBodyWhere_Order", "cInvcode");
                    broker.AssignNormalValue("errMsg", "");
                    broker.AssignNormalValue("domPos", domMsg);
                    BusinessObject obj = broker.GetBoParam("domHead");
                    BusinessObject obj1 = broker.GetBoParam("domBody");
                }
                retstr += "开始调用";
                if (!broker.Invoke())
                {
                    retstr += "调用失败:";
                    //错误处理
                    Exception apiEx = broker.GetException();
                    if (apiEx != null)
                    {
                        if (apiEx is MomSysException)
                        {
                            MomSysException sysEx = apiEx as MomSysException;
                            //Console.WriteLine("系统异常:" + sysEx.Message);
                            retstr = sysEx.Message + "[MomSysException]";
                            //todo:异常处理
                        }
                        else if (apiEx is MomBizException)
                        {
                            MomBizException bizEx = apiEx as MomBizException;
                            //Console.WriteLine("API异常:" + bizEx.Message);
                            retstr = bizEx.Message + "[MomBizException]";
                            //todo:异常处理
                        }
                    }
                    //结束本次调用,释放API资源
                    broker.Release();
                    //return;
                }
                else
                {
                    retstr += "调用成功:";
                    if (method.Equals("load"))
                    {
                        System.String result = broker.GetReturnValue() as System.String;
                        if (string.IsNullOrEmpty(result))
                        {
                            retstr += "加载调拨申请单成功!";
                            //Console.WriteLine("加载销售订单成功!");

                            //获取out/inout参数值
                            //MSXML2.XMLDocument xmlResult = broker.GetResult("domHead") as MSXML2.XMLDocument;
                            MSXML2.DOMDocumentClass xmlHead = broker.GetResult("DomHead") as MSXML2.DOMDocumentClass;
                            xmlHead.save("TransRequestVouchHead.xml");

                            //out参数domBody为BO对象(表体),此BO对象的业务类型为销售订单。BO参数均按引用传递,具体请参考服务接口定义
                            //如果要取原始的XMLDOM对象结果,请使用GetResult()
                            MSXML2.DOMDocumentClass xmlBody = broker.GetResult("domBody") as MSXML2.DOMDocumentClass;
                            xmlBody.save("TransRequestVouchBody.xml");
                        }
                        else
                        {
                            retstr += "加载调拨申请单失败!";
                            //Console.WriteLine("加载销售订单失败!");
                        }
                    }
                    else
                    {
                        DOMDocument doc = (DOMDocument)broker.GetResult("domMsg");
                        if (doc != null)
                            retstr += doc.text + "|";
                        retstr += broker.GetResult("errMsg") + "|" + broker.GetResult("retval").ToString();
                    }
                }
            }
            catch (Exception e)
            {
                retstr += "异常:" + e.Message+"\n"+e.StackTrace;
                return retstr;
                //throw;
            }
            return retstr;
        }
Beispiel #12
0
        public bool AddPO(PurchaseOrder purchase, ref string errMsg)
        {
            #region 采购订单

            IXMLDOMDocument2      domHead = new MSXML2.DOMDocument();
            IXMLDOMDocument2      domBody = new MSXML2.DOMDocument();
            MSXML2.IXMLDOMElement eleHead;
            MSXML2.IXMLDOMElement eleBody;
            MSXML2.IXMLDOMElement ele;
            string strSQL;
            strSQL  = "select * from zpurpoheader where 1=0";
            domHead = DomHelper.getDom(strSQL, g_oLogin.UfDbName);

            //增加表头数据节点z:row
            eleHead = domHead.selectSingleNode("//rs:data") as MSXML2.IXMLDOMElement;
            ele     = domHead.createElement("z:row");
            //'UPGRADE_WARNING: 未能解析对象 ele 的默认属性。 单击以获得更多信息:“ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"”
            eleHead.appendChild(ele);

            //方法二是构造BusinessObject对象,具体方法如下:
            //BusinessObject domHead = broker.GetBoParam("domHead");
            //domHead.RowCount = 1; //设置BO对象(表头)行数,只能为一行
            //给BO对象(表头)的字段赋值,值可以是真实类型,也可以是无类型字符串
            //以下代码示例只设置第一行值。各字段定义详见API服务接口定义

            /****************************** 以下是必输字段 ****************************/
            DomHelper.setAttribute(ele, "poid", "0");                                        //主关键字段,int类型
            DomHelper.setAttribute(ele, "cbustype", "普通采购");                                 //业务类型,int类型
            DomHelper.setAttribute(ele, "dpodate", g_oLogin.CurDate.ToString("yyyy-MM-dd")); //日期,DateTime类型
            DomHelper.setAttribute(ele, "cpoid", "0000000041");                              //订单编号,string类型
            DomHelper.setAttribute(ele, "cvenabbname", "辰环手机配件");                            //供货单位,string类型
            DomHelper.setAttribute(ele, "cexch_name", "人民币");                                //币种,string类型
            DomHelper.setAttribute(ele, "nflat", "1");                                       //汇率,double类型
            DomHelper.setAttribute(ele, "cmaker", "demo");                                   //制单人,string类型
            DomHelper.setAttribute(ele, "cvencode", "01002");                                //供货单位编号,string类型
            //DomHead[0]["ufts"] = ""; //时间戳,string类型
            DomHelper.setAttribute(ele, "idiscounttaxtype", "0");                            //扣税类别,int类型
            //DomHead[0]["contractcodet"] = ""; //合同号,string类型
            //DomHead[0]["iflowid"] = ""; //流程ID,string类型
            //DomHead[0]["cflowname"] = ""; //流程模式描述,string类型
            //DomHead[0]["dclosetime"] = ""; //关闭时间,string类型
            //DomHead[0]["dclosedate"] = ""; //关闭日期,string类型
            //DomHead[0]["ccontactcode"] = ""; //供方联系人编码,string类型
            //DomHead[0]["cmobilephone"] = ""; //供方联系人手机号,string类型
            //DomHead[0]["cappcode"] = ""; //请购单号,string类型
            //DomHead[0]["csysbarcode"] = ""; //单据条码,string类型
            //DomHead[0]["cchangverifier"] = ""; //变更审批人,string类型
            //DomHead[0]["cchangaudittime"] = ""; //变更审批时间,string类型
            //DomHead[0]["cchangauditdate"] = ""; //变更审批日期,string类型
            //DomHead[0]["controlresult"] = ""; //controlresult,string类型
            //DomHead[0]["ibg_overflag"] = ""; //预算审批状态,string类型
            //DomHead[0]["cbg_auditor"] = ""; //预算审批人,string类型
            //DomHead[0]["cbg_audittime"] = ""; //预算审批时间,string类型

            /***************************** 以下是非必输字段 ****************************/
            //DomHead[0]["ipresent"] = ""; //现存量,string类型
            //DomHead[0]["cmaketime"] = ""; //制单时间,DateTime类型
            //DomHead[0]["cmodifytime"] = ""; //修改时间,DateTime类型
            //DomHead[0]["caudittime"] = ""; //审核时间,DateTime类型
            //DomHead[0]["cauditdate"] = ""; //审核日期,DateTime类型
            //DomHead[0]["cmodifydate"] = ""; //修改日期,DateTime类型
            //DomHead[0]["creviser"] = ""; //修改人,string类型
            //DomHead[0]["cptname"] = ""; //采购类型,string类型
            //DomHead[0]["cvenname"] = ""; //供应商全称,string类型
            //DomHead[0]["iverifystateex"] = ""; //审核状态,string类型
            //DomHead[0]["ireturncount"] = ""; //打回次数,string类型
            //DomHead[0]["iswfcontrolled"] = "0"; //是否启用工作流,string类型
            //DomHead[0]["cdepname"] = ""; //部门,string类型
            //DomHead[0]["cpersonname"] = ""; //业务员,string类型
            DomHelper.setAttribute(ele, "itaxrate", "17");     //税率,double类型
            //DomHead[0]["cpayname"] = ""; //付款条件,string类型
            DomHelper.setAttribute(ele, "cmemo", "底层API测试");   //备注,string类型
            //DomHead[0]["dplanarrdate"] = ""; //计划到货日期,DateTime类型
            //DomHead[0]["cverifier"] = ""; //审核人,string类型
            //DomHead[0]["cchanger"] = ""; //变更人,string类型
            //DomHead[0]["ccloser"] = ""; //关闭人,string类型
            DomHelper.setAttribute(ele, "ivtid", "8173");     //单据模版号,int类型
            //DomHead[0]["cvenbank"] = ""; //供方银行名称,string类型
            //DomHead[0]["cptcode"] = ""; //采购类型编号,string类型
            //DomHead[0]["myname"] = ""; //地址,double类型
            //DomHead[0]["myphone"] = ""; //电话,double类型
            //DomHead[0]["myfax"] = ""; //传真,double类型
            //DomHead[0]["myzip"] = ""; //邮编,double类型
            //DomHead[0]["cvenaddress"] = ""; //供方地址,string类型
            //DomHead[0]["cvenphone"] = ""; //供方电话,string类型
            //DomHead[0]["cvenfax"] = ""; //供方传真,string类型
            //DomHead[0]["cvenpostcode"] = ""; //供方邮编,string类型
            //DomHead[0]["cvenperson"] = ""; //供方联系人,string类型
            //DomHead[0]["cvenaccount"] = ""; //供方银行账号,string类型
            //DomHead[0]["cvenregcode"] = ""; //供方纳税登记号,string类型
            //DomHead[0]["cstate"] = "1"; //状态(数据库),string类型
            //DomHead[0]["cperiod"] = ""; //计划周期,string类型
            //DomHead[0]["carrivalplace"] = ""; //到货地址,string类型
            //DomHead[0]["ibargain"] = ""; //订金,double类型
            //DomHead[0]["csccode"] = ""; //运输方式编号,string类型
            //DomHead[0]["icost"] = ""; //运费,double类型
            //DomHead[0]["cscname"] = ""; //运输方式,string类型
            //DomHead[0]["cpaycode"] = ""; //付款条件编号,string类型
            DomHelper.setAttribute(ele, "cpersoncode", "00043"); //业务员编号,string类型
            DomHelper.setAttribute(ele, "cdepcode", "0401");     //部门编号,string类型
            //DomHead[0]["cdefine1"] = ""; //表头自定义项1,string类型
            //DomHead[0]["cdefine2"] = ""; //表头自定义项2,string类型
            //DomHead[0]["cdefine3"] = ""; //表头自定义项3,string类型
            //DomHead[0]["cdefine4"] = ""; //表头自定义项4,DateTime类型
            //DomHead[0]["cdefine5"] = ""; //表头自定义项5,int类型
            //DomHead[0]["cdefine6"] = ""; //表头自定义项6,DateTime类型
            //DomHead[0]["cdefine7"] = ""; //表头自定义项7,double类型
            //DomHead[0]["cdefine8"] = ""; //表头自定义项8,string类型
            //DomHead[0]["cdefine9"] = ""; //表头自定义项9,string类型
            //DomHead[0]["cdefine10"] = ""; //表头自定义项10,string类型
            //DomHead[0]["cdefine11"] = ""; //表头自定义项11,string类型
            //DomHead[0]["cdefine12"] = ""; //表头自定义项12,string类型
            //DomHead[0]["cdefine13"] = ""; //表头自定义项13,string类型
            //DomHead[0]["cdefine14"] = ""; //表头自定义项14,string类型
            //DomHead[0]["cdefine15"] = ""; //表头自定义项15,int类型
            //DomHead[0]["cdefine16"] = ""; //表头自定义项16,double类型
            //DomHead[0]["cvendefine1"] = ""; //供应商自定义项1,string类型
            //DomHead[0]["cvendefine2"] = ""; //供应商自定义项2,string类型
            //DomHead[0]["cvendefine3"] = ""; //供应商自定义项3,string类型
            //DomHead[0]["cvendefine4"] = ""; //供应商自定义项4,string类型
            //DomHead[0]["cvendefine5"] = ""; //供应商自定义项5,string类型
            //DomHead[0]["cvendefine6"] = ""; //供应商自定义项6,string类型
            //DomHead[0]["cvendefine7"] = ""; //供应商自定义项7,string类型
            //DomHead[0]["cvendefine8"] = ""; //供应商自定义项8,string类型
            //DomHead[0]["cvendefine9"] = ""; //供应商自定义项9,string类型
            //DomHead[0]["cvendefine10"] = ""; //供应商自定义项10,string类型
            //DomHead[0]["cvenpuomprotocol"] = ""; //收付款协议编码,string类型
            //DomHead[0]["cvendefine11"] = ""; //供应商自定义项11,string类型
            //DomHead[0]["cvenpuomprotocolname"] = ""; //收付款协议名称,string类型
            //DomHead[0]["cvendefine12"] = ""; //供应商自定义项12,string类型
            //DomHead[0]["cvendefine13"] = ""; //供应商自定义项13,string类型
            //DomHead[0]["cvendefine14"] = ""; //供应商自定义项14,string类型
            //DomHead[0]["cvendefine15"] = ""; //供应商自定义项15,string类型
            //DomHead[0]["cvendefine16"] = ""; //供应商自定义项16,string类型
            //DomHead[0]["clocker"] = ""; //锁定人,string类型

            //broker.AssignNormalValue("domHead", domHead);

            //给BO表体参数domBody赋值,此BO参数的业务类型为销售订单,属表体参数。BO参数均按引用传递
            //提示:给BO表体参数domBody赋值有两种方法

            //方法一是直接传入MSXML2.DOMDocumentClass对象
            //broker.AssignNormalValue("domBody", new MSXML2.DOMDocumentClass())
            strSQL  = "select * from zpurpotail where 1=0";
            domBody = DomHelper.getDom(strSQL, g_oLogin.UfDbName);

            //增加表体数据节点z:row
            eleBody = domBody.selectSingleNode("//rs:data") as MSXML2.IXMLDOMElement;
            //方法二是构造BusinessObject对象,具体方法如下:
            //BusinessObject domBody = broker.GetBoParam("domBody");
            //domBody.RowCount = 1; //设置BO对象行数
            //可以自由设置BO对象行数为大于零的整数,也可以不设置而自动增加行数
            //给BO对象的字段赋值,值可以是真实类型,也可以是无类型字符串
            //以下代码示例只设置第一行值。各字段定义详见API服务接口定义

            /****************************** 以下是必输字段 ****************************/
            for (int i = 0; i < 2; i++)
            {
                decimal decQuantity = 20.00M;
                //含税单价
                decimal decprice = 10.00M;
                //含税金额
                decimal decamount = decimal.Round(decQuantity * decprice, 2);
                //税率
                decimal decTaxRate = 0.00M;
                //不含税金额
                decimal decNotTaxAmount = decimal.Round(decamount / (1 + decTaxRate), 2);
                if (decTaxRate == 0)
                {
                    decNotTaxAmount = decamount;
                }
                //不含税单价
                decimal decNotTaxPrice = decimal.Round(decNotTaxAmount / decQuantity, 2);
                if (decTaxRate == 0)
                {
                    decNotTaxPrice = decprice;
                }
                //税额
                decimal decTax = decamount - decNotTaxAmount;

                ele = domBody.createElement("z:row");
                eleBody.appendChild(ele);

                DomHelper.setAttribute(ele, "id", "0");     //主关键字段,int类型
                DomHelper.setAttribute(ele, "cfactorycode", "001");
                DomHelper.setAttribute(ele, "cfactoryname", "工厂一");
                DomHelper.setAttribute(ele, "cinvcode", "17001");                                    //存货编码,string类型
                DomHelper.setAttribute(ele, "iquantity", "1");                                       //数量,double类型
                DomHelper.setAttribute(ele, "darrivedate", g_oLogin.CurDate.ToString("yyyy-MM-dd")); //计划到货日期,DateTime类型
                DomHelper.setAttribute(ele, "ipertaxrate", "17");                                    //税率,double类型
                DomHelper.setAttribute(ele, "poid", "0");                                            //主表id,int类型
                DomHelper.setAttribute(ele, "bgsp", "0");                                            //是否检验,int类型
                DomHelper.setAttribute(ele, "editprop", "A");                                        //编辑属性:A表新增,M表修改,D表删除,string类型
                //domBody[0]["cbg_itemcode"] = ""; //预算项目编码,string类型
                //domBody[0]["cbg_itemname"] = ""; //预算项目,string类型
                //domBody[0]["cbg_caliberkey1"] = ""; //口径1类型编码,string类型
                //domBody[0]["cbg_caliberkeyname1"] = ""; //口径1类型名称,string类型
                //domBody[0]["cbg_caliberkey2"] = ""; //口径2类型编码,string类型
                //domBody[0]["cbg_caliberkeyname2"] = ""; //口径2类型名称,string类型
                //domBody[0]["cbg_caliberkey3"] = ""; //口径3类型编码,string类型
                //domBody[0]["cbg_caliberkeyname3"] = ""; //口径3类型名称,string类型
                //domBody[0]["cbg_calibercode1"] = ""; //口径1编码,string类型
                //domBody[0]["cbg_calibername1"] = ""; //口径1名称,string类型
                //domBody[0]["cbg_calibercode2"] = ""; //口径2编码,string类型
                //domBody[0]["cbg_calibername2"] = ""; //口径2名称,string类型
                //domBody[0]["cbg_calibercode3"] = ""; //口径3编码,string类型
                //domBody[0]["cbg_calibername3"] = ""; //口径3名称,string类型
                //domBody[0]["cbg_auditopinion"] = ""; //审批意见,string类型
                //domBody[0]["ibg_ctrl"] = ""; //是否预算控制,string类型
                //domBody[0]["fexquantity"] = ""; //累计出口数量,string类型
                DomHelper.setAttribute(ele, "ivouchrowno", i);     //行号,string类型
                //domBody[0]["cbg_caliberkeyname4"] = ""; //口径4类型名称,string类型
                //domBody[0]["cbg_caliberkey5"] = ""; //口径5类型编码,string类型
                //domBody[0]["cbg_caliberkeyname5"] = ""; //口径5类型名称,string类型
                //domBody[0]["cbg_caliberkey6"] = ""; //口径6类型编码,string类型
                //domBody[0]["cbg_caliberkeyname6"] = ""; //口径6类型名称,string类型
                //domBody[0]["cbg_calibercode4"] = ""; //口径4编码,string类型
                //domBody[0]["cbg_calibername4"] = ""; //口径4名称,string类型
                //domBody[0]["cbg_calibercode5"] = ""; //口径5编码,string类型
                //domBody[0]["cbg_calibername5"] = ""; //口径5名称,string类型
                //domBody[0]["cbg_calibercode6"] = ""; //口径6编码,string类型
                //domBody[0]["cbg_calibername6"] = ""; //口径6名称,string类型
                //domBody[0]["csrpolicy"] = ""; //供需政策,string类型
                //domBody[0]["irequiretrackstyle"] = ""; //存货需求跟踪方式,string类型
                //domBody[0]["ipresentb"] = ""; //现存量,string类型
                //domBody[0]["cbg_caliberkey4"] = ""; //口径4类型编码,string类型
                //domBody[0]["cxjspdids"] = ""; //采购比价审批单子表ID,string类型
                DomHelper.setAttribute(ele, "cbmemo", "cqz" + i.ToString());     //备注,string类型
                //domBody[0]["cbsysbarcode"] = ""; //单据行条码,string类型
                //domBody[0]["planlotnumber"] = ""; //计划批号,string类型
                //domBody[0]["cplanmethod"] = ""; //计划方法,string类型

                /***************************** 以下是非必输字段 ****************************/
                //domBody[0]["iinvexchrate"] = ""; //换算率,double类型
                //domBody[0]["cinvname"] = ""; //存货名称,string类型
                //domBody[0]["cinvstd"] = ""; //规格型号,string类型
                //domBody[0]["iquotedprice"] = ""; //报价,double类型
                //domBody[0]["inum"] = ""; //件数,double类型
                //domBody[0]["iunitprice"] = ""; //原币单价,double类型
                //domBody[0]["imoney"] = ""; //原币金额,double类型
                //domBody[0]["itax"] = ""; //原币税额,double类型
                //domBody[0]["idiscount"] = ""; //折扣额,double类型
                //domBody[0]["inatunitprice"] = ""; //本币单价,double类型
                //domBody[0]["inatmoney"] = ""; //本币金额,double类型
                //domBody[0]["inattax"] = ""; //本币税额,double类型
                //domBody[0]["inatsum"] = ""; //本币价税合计,double类型
                //domBody[0]["inatdiscount"] = ""; //本币折扣额,double类型
                //domBody[0]["isum"] = ""; //原币价税合计,double类型
                //domBody[0]["cfree2"] = ""; //自由项2,string类型
                //domBody[0]["cfree1"] = ""; //自由项1,string类型
                //domBody[0]["bmark"] = ""; //标志,double类型
                //domBody[0]["cdefine22"] = ""; //表体自定义项1,string类型
                //domBody[0]["cdefine23"] = ""; //表体自定义项2,string类型
                //domBody[0]["cdefine24"] = ""; //表体自定义项3,string类型
                //domBody[0]["cdefine25"] = ""; //表体自定义项4,string类型
                //domBody[0]["cdefine26"] = ""; //表体自定义项5,double类型
                //domBody[0]["cdefine27"] = ""; //表体自定义项6,double类型
                //domBody[0]["cinvdefine1"] = ""; //存货自定义项1,string类型
                //domBody[0]["cinvdefine4"] = ""; //存货自定义项4,string类型
                //domBody[0]["cinvdefine5"] = ""; //存货自定义项5,string类型
                //domBody[0]["cinvdefine6"] = ""; //存货自定义项6,string类型
                //domBody[0]["cinvdefine7"] = ""; //存货自定义项7,string类型
                //domBody[0]["cinvdefine8"] = ""; //存货自定义项8,string类型
                //domBody[0]["cinvdefine9"] = ""; //存货自定义项9,string类型
                //domBody[0]["cinvdefine10"] = ""; //存货自定义项10,string类型
                //domBody[0]["cinvdefine11"] = ""; //存货自定义项11,string类型
                //domBody[0]["cinvdefine12"] = ""; //存货自定义项12,string类型
                //domBody[0]["cinvdefine13"] = ""; //存货自定义项13,string类型
                //domBody[0]["cinvdefine14"] = ""; //存货自定义项14,string类型
                //domBody[0]["cinvdefine15"] = ""; //存货自定义项15,string类型
                //domBody[0]["cinvdefine16"] = ""; //存货自定义项16,string类型
                //domBody[0]["cinvdefine2"] = ""; //存货自定义项2,string类型
                //domBody[0]["cinvdefine3"] = ""; //存货自定义项3,string类型
                //domBody[0]["citemcode"] = ""; //项目编码,string类型
                //domBody[0]["citem_class"] = ""; //项目大类编码,string类型
                //domBody[0]["ppcids"] = ""; //采购计划子表ID,string类型
                //domBody[0]["citemname"] = ""; //项目名称,string类型
                //domBody[0]["citem_name"] = ""; //项目大类名称,string类型
                //domBody[0]["cfree3"] = ""; //自由项3,string类型
                //domBody[0]["cfree4"] = ""; //自由项4,string类型
                //domBody[0]["cfree5"] = ""; //自由项5,string类型
                //domBody[0]["cfree6"] = ""; //自由项6,string类型
                //domBody[0]["cfree7"] = ""; //自由项7,string类型
                //domBody[0]["cfree8"] = ""; //自由项8,string类型
                //domBody[0]["cfree9"] = ""; //自由项9,string类型
                //domBody[0]["cfree10"] = ""; //自由项10,string类型
                //domBody[0]["imainid"] = ""; //对应单据主表id,string类型
                //domBody[0]["btaxcost"] = ""; //单价标准,string类型
                //domBody[0]["corufts"] = ""; //对应单据时间戳,string类型
                //domBody[0]["itaxprice"] = ""; //含税单价,double类型
                //domBody[0]["cunitid"] = ""; //单位编码,string类型
                //domBody[0]["cinva_unit"] = ""; //采购单位,string类型
                //domBody[0]["cinvm_unit"] = ""; //主计量,string类型
                //domBody[0]["igrouptype"] = ""; //分组类型,string类型
                //domBody[0]["iappids"] = ""; //请购单子表id,int类型
                //domBody[0]["isosid"] = ""; //订单子表id,int类型
                //domBody[0]["cdefine28"] = ""; //表体自定义项7,string类型
                //domBody[0]["cdefine29"] = ""; //表体自定义项8,string类型
                //domBody[0]["cdefine30"] = ""; //表体自定义项9,string类型
                //domBody[0]["cdefine31"] = ""; //表体自定义项10,string类型
                //domBody[0]["cdefine32"] = ""; //表体自定义项11,string类型
                //domBody[0]["cdefine33"] = ""; //表体自定义项12,string类型
                //domBody[0]["cdefine34"] = ""; //表体自定义项13,int类型
                //domBody[0]["cdefine35"] = ""; //表体自定义项14,int类型
                //domBody[0]["cdefine36"] = ""; //表体自定义项15,DateTime类型
                //domBody[0]["cdefine37"] = ""; //表体自定义项16,DateTime类型
                //domBody[0]["csource"] = ""; //单据来源,string类型
                //domBody[0]["cinvaddcode"] = ""; //存货代码,string类型
                //domBody[0]["cbcloser"] = ""; //行关闭人,string类型
                //domBody[0]["cveninvcode"] = ""; //供应商存货编码,string类型
                //domBody[0]["cveninvname"] = ""; //供应商存货名称,string类型
                //domBody[0]["ippartid"] = ""; //母件Id,int类型
                //domBody[0]["ipquantity"] = ""; //母件数量,int类型
                //domBody[0]["iptoseq"] = ""; //选配序号,int类型
                //domBody[0]["contractrowno"] = ""; //合同标的编码,string类型
                //domBody[0]["contractrowguid"] = ""; //合同标的GUID,string类型
                //domBody[0]["contractcode"] = ""; //合同号,string类型
                //domBody[0]["sotype"] = ""; //需求跟踪方式,int类型
                //domBody[0]["csocode"] = ""; //需求跟踪号,string类型
                //domBody[0]["irowno"] = ""; //需求跟踪行号,string类型
                //domBody[0]["sodid"] = ""; //需求跟踪子表ID,string类型
                //domBody[0]["cbclosetime"] = ""; //关闭时间,DateTime类型
                //domBody[0]["cbclosedate"] = ""; //关闭日期,DateTime类型
                //domBody[0]["upsotype"] = ""; //上游单据类型,int类型
                //domBody[0]["cupsocode"] = ""; //上游单据号,string类型
                //domBody[0]["iinvmpcost"] = ""; //最高进价,double类型
                //domBody[0]["cdemandmemo"] = ""; //需求分类代号说明,string类型
                //domBody[0]["iorderdid"] = ""; //销售订单子表id,int类型
                //domBody[0]["iordertype"] = ""; //销售订单类型,int类型
                //domBody[0]["csoordercode"] = ""; //销售订单号,string类型
                //domBody[0]["iorderseq"] = ""; //销售订单行号,int类型
                //domBody[0]["bgift"] = ""; //赠品,string类型
                //

                //domHead.loadXML(strH);
                //domBody.loadXML(strB);
            }


            if (true)
            {
                VoucherCO_PU.clsVoucherCO_PU obj = new VoucherCO_PU.clsVoucherCO_PU();
                //
                bool   bPositive         = true;
                string sBillType         = "";
                string sBusType          = "普通采购";
                VoucherVerify.UseMode um = VoucherVerify.UseMode.CS;
                string sfBusType         = "普通采购";
                string sPtCode           = "07";
                //
                Info_PU.ClsS_Infor clsinfo = new Info_PU.ClsS_Infor();
                string             str     = clsinfo.Init(ref g_oLogin, sBusType, sPtCode);
                ADODB.Connection   oCon    = new ADODB.Connection();
                oCon.CursorLocation   = ADODB.CursorLocationEnum.adUseClient;
                oCon.ConnectionString = g_oLogin.UFDataConnstringForNet;
                oCon.Open(g_oLogin.UfDbName, "", "", -1);
                //
                obj.Init(VoucherCO_PU.vouchertype.采购订单, ref g_oLogin, ref oCon, ref clsinfo, ref bPositive, ref sBillType, ref sBusType, ref um, sfBusType, sPtCode);
                obj.bOutTrans = false;
                //
                short            VoucherState    = 2;//增加
                object           vNewID          = "";
                IXMLDOMDocument2 CurDom          = new MSXML2.DOMDocument();
                string           sOverDetailsXml = "";
                IXMLDOMDocument2 DomMsg          = new MSXML2.DOMDocument();
                Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                string strRet = obj.VoucherSave(domHead, domBody, VoucherState, ref vNewID, ref CurDom, um, ref sOverDetailsXml, ref DomMsg);
                Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                if (string.IsNullOrEmpty(strRet))
                {
                    return(true);
                }
                else
                {
                    errMsg = strRet;
                    return(false);
                }
            }

            #endregion
        }