Esempio n. 1
0
 /// <summary>
 /// 在本地保存Xml文件
 /// </summary>
 /// <param name="doc"></param>
 /// <param name="Aroottag"></param>
 /// <param name="Aysdh"></param>
 private void SaveLocalXml(DOMDocument doc, string Aroottag, string Aysdh)
 {
     try
     {
         IXMLDOMElement rootnode  = doc.documentElement;
         IXMLDOMNode    modelNode = rootnode.selectNodes(Aroottag + "/bill_body/item")[0].cloneNode(true);
         IXMLDOMNode    NewNode;
         IXMLDOMNode    NewSubNode;
         IXMLDOMNode    Parentnode;
         IXMLDOMNode    body = rootnode.selectSingleNode(Aroottag + "/bill_body");
         for (int i = 0; i < body.childNodes.length; i++)
         {
             body.removeChild(body.childNodes[i]);
         }
         DataSet ds = PDParam.GetXmldata(Aysdh);
         if (ds != null)
         {
             for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
             {
                 Parentnode = rootnode.selectSingleNode(Aroottag + "/bill_body");
                 if (i > 0)
                 {
                     modelNode = rootnode.selectNodes(Aroottag + "/bill_body/item")[0].cloneNode(true);
                 }
                 NewNode         = Parentnode.appendChild(modelNode);
                 NewSubNode      = NewNode.selectSingleNode("cinventorycode");
                 NewSubNode.text = ds.Tables[0].Rows[i]["wlh"].ToString();
                 NewSubNode      = NewNode.selectSingleNode("vbatchcode");
                 NewSubNode.text = ds.Tables[0].Rows[i]["pch"].ToString();
                 NewSubNode      = NewNode.selectSingleNode("vfree1");
                 NewSubNode.text = ds.Tables[0].Rows[i]["sx"].ToString();
                 NewSubNode      = NewNode.selectSingleNode("naccountastnum");
                 NewSubNode.text = ds.Tables[0].Rows[i]["sumzcsl"].ToString();
                 NewSubNode      = NewNode.selectSingleNode("naccountnum");
                 NewSubNode.text = ds.Tables[0].Rows[i]["sumzczl"].ToString();
                 NewSubNode      = NewNode.selectSingleNode("ncheckastnum");
                 NewSubNode.text = ds.Tables[0].Rows[i]["sumspsl"].ToString();
                 NewSubNode      = NewNode.selectSingleNode("nchecknum");
                 NewSubNode.text = ds.Tables[0].Rows[i]["sumspzl"].ToString();
             }
             string apppathxml = "../../webinfo/xml";
             string pathName   = Server.MapPath(apppathxml);
             if (!Directory.Exists(pathName))
             {
                 Directory.CreateDirectory(pathName);
             }
             string filename = "Wms-" + Aysdh + ".xml";
             doc.save(pathName + "/" + filename);
         }
     }
     catch
     {
         this.PrintfError("本地保存Xml文件时出现错误,请重试");
         return;
     }
 }