Пример #1
0
        protected void btnNC_Click(object sender, EventArgs e)
        {
            ApiWL_SJ apiwl_sj = new ApiWL_SJ();

            List <ApiDispDto> apiDispList = new List <ApiDispDto>();
            string            strmsg      = string.Empty;
            string            fileName    = ltlfyd.Text + ".xml";
            string            filePath    = "~/FileInterface/" + fileName;
            string            xmlFileName = Server.MapPath(filePath);
            bool result = apiwl_sj.SendXml_DM(xmlFileName, ltlfyd.Text, apiDispList);

            if (result)
            {
                this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", "<script language='javascript'> _closemsg('导入NC成功');</script>", false);
            }
            else
            {
                this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", "<script language='javascript'> _closemsg('导入NC失败');</script>", false);
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.RequestType == "POST")
            {
                //接收并读取POST过来的XML文件流
                StreamReader reader = new StreamReader(Request.InputStream);

                String            xmlData     = reader.ReadToEnd();
                List <ApiDispDto> apiDispList = new List <ApiDispDto>();
                #region //读取WL实绩XML
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xmlData);

                string      sendcode = string.Empty;//发运单号
                XmlNodeList headlist = xmlDoc.SelectNodes("//bill/bill_head");
                foreach (XmlNode item in headlist)
                {
                    sendcode = item["vdelivbillcode"].InnerText;
                }

                XmlNodeList ndlist = xmlDoc.SelectNodes("//bill/bill_body"); //xmlDoc.GetElementsByTagName("bill_body");
                foreach (XmlNode item1 in ndlist)
                {
                    XmlNodeList ndlist2 = item1.ChildNodes;
                    foreach (XmlNode item2 in ndlist2)
                    {
                        if (item2["nnetwgt"].InnerText != "")
                        {
                            ApiDispDto mod = new ApiDispDto();
                            mod.sendcode = sendcode;                            //发运单
                            mod.pkid     = item2["vfree10"].InnerText;          //发运单表体主键
                            mod.matcode  = item2["vinvcode"].InnerText;         //存货编码
                            mod.mzdate   = item2["vuserdef1"].InnerText;        //毛重日期
                            mod.mztime   = item2["vuserdef6"].InnerText;        //毛重时间
                            mod.mwgt     = item2["vuserdef2"].InnerText;        //毛重
                            mod.pzdate   = item2["vuserdef3"].InnerText;        //皮重日期
                            mod.pztime   = item2["vuserdef7"].InnerText.Trim(); //皮重时间
                            mod.pwgt     = item2["vuserdef4"].InnerText;        //皮重
                            mod.jwgt     = item2["nnetwgt"].InnerText;          //净重
                            apiDispList.Add(mod);
                        }
                    }
                }

                string ss        = "ss" + DateTime.Now.Second.ToString();
                string filePath2 = "~/FileInterface/download/wlsj" + sendcode + ss + ".xml";
                string xmlfile2  = Server.MapPath(filePath2);
                xmlDoc.Save(xmlfile2);
                #endregion

                //更新物流实绩到发运单明细并钢种库存与发运单NC中间表

                if (apiDispList.Count > 0)
                {
                    #region //检测发运单物流实绩是否导入NC
                    Mod_TMD_DISPATCH modDisp = tmd_dispatch.GetModel(sendcode);
                    if (modDisp != null)
                    {
                        if (modDisp.C_STATUS == "9")//钢坯实绩已导入NC
                        {
                            BackMsg("N", "异常信息:钢坯实绩已导入NC", sendcode);
                        }
                        else
                        {
                            int result = tmd_dispatchdetails.WL_SJ(apiDispList);

                            #region //钢坯
                            bool res = true;

                            DataTable dt = tmd_dispatchdetails.GetZJBList(sendcode).Tables[0];
                            if (dt.Rows.Count > 0)//有实绩
                            {
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    if (string.IsNullOrEmpty(dt.Rows[i]["N_JZ"].ToString()))
                                    {
                                        res = false;
                                    }
                                }
                                if (res)
                                {
                                    //发运实绩净重,导入NC
                                    ApiWL_SJ apiwl_sj = new ApiWL_SJ();
                                    string   filename = "wlsj_nc" + sendcode;
                                    string   filePath = "~/FileInterface/download/" + filename + ".xml";
                                    string   xmlfile  = Server.MapPath(filePath);
                                    apiwl_sj.SendXml_DM(xmlfile, sendcode, apiDispList);
                                    BackMsg("Y", "接收成功", sendcode);
                                }
                                else
                                {
                                    BackMsg("Y", "接收成功", sendcode);
                                }
                            }
                            else
                            {
                                BackMsg("Y", "接收成功", sendcode);
                            }
                            #endregion

                            #region //副产品
                            //if(modDisp.C_EXTEND5=="6")//钢坯
                            //{

                            //}
                            //else
                            //{
                            //    if(tmd_dispatchdetails.WL_SJ_F(apiDispList))
                            //    {
                            //        #region //辅产品 发运实绩净重,导入NC

                            //        ApiWL_SJ_F apiwl_sj_f = new ApiWL_SJ_F();
                            //        string filename = "wlsj_nc" + sendcode;
                            //        string filePath = "~/FileInterface/download/" + filename + ".xml";
                            //        string xmlfile = Server.MapPath(filePath);
                            //        apiwl_sj_f.SendXml_DM(xmlfile, sendcode);
                            //        #endregion

                            //        BackMsg("Y", "接收成功", sendcode);
                            //    }
                            //}
                            #endregion
                        }
                    }
                    else
                    {
                        BackMsg("N", "当前发运单系统不存在", sendcode);
                    }
                    #endregion
                }
                else
                {
                    BackMsg("N", "异常信息:没有重量", sendcode);
                }
            }
        }