读XML文档

  #region RptTSZS003
  [WebMethod]
  public string RptTSZS003(string xmlStr) {
   SqlCommand cmd=new SqlCommand("",Con);
   XmlDocument Doc=new XmlDocument();
   XmlNode rNode,fNode,cNode=null;
   string tabID,memberID,re="";
   try{
    Doc.LoadXml(xmlStr);
    re+="LoadXML-OK/n";
   }catch(Exception e){
    re+=e.Message+"/n";
   }
   Con.Open();
   if(Doc!=null){
    rNode=Doc.DocumentElement;
    tabID=rNode.Attributes["tabID"].InnerText;
    memberID=rNode.Attributes["Reporter"].InnerText;
    try{
     fNode=rNode.ChildNodes[0];//people
     cmd.CommandText="Delete From People3 Where tabID='"+tabID+"'";
     cmd.ExecuteNonQuery();
     for(int i=0;i<fNode.ChildNodes.Count;i++){
      cNode=fNode.ChildNodes[i];//rec
      if (cNode==null||cNode.ChildNodes[0]==null) continue;
      cmd.CommandText="Insert into People3 (tabID,taskObj,peopleName,peopleID,taskType,taskStep) "+
       "Values ('"+tabID+"','"+cNode.ChildNodes[0].InnerText+"','"+
       cNode.ChildNodes[1].InnerText+"','"+
       cNode.ChildNodes[2].InnerText+"','"+
       cNode.ChildNodes[3].InnerText+"','"+
       cNode.ChildNodes[4].InnerText+"')";
      cmd.ExecuteNonQuery();
     }
     re+="WritePeople-OK/n";
    }catch(Exception e){
     re+=e.Message+"/n";
    }finally{}
    try{
     fNode=rNode.ChildNodes[1];//packge
     cmd.CommandText="Delete From Packge3 Where tabID='"+tabID+"'";
     cmd.ExecuteNonQuery();
     for(int i=0;i<fNode.ChildNodes.Count;i++){
      cNode=fNode.ChildNodes[i];//rec
      if (cNode==null||cNode.ChildNodes[0]==null) continue;
      cmd.CommandText="Insert into Packge3 (tabID,pakObj,pakCom,pakID) "+
       "Values ('"+tabID+"','"+cNode.ChildNodes[0].InnerText+"','"+
       cNode.ChildNodes[1].InnerText+"','"+
       cNode.ChildNodes[2].InnerText+"')";
      cmd.ExecuteNonQuery();
     }
     re+="WritePackge-OK/n";
    }catch(Exception e){
     re+=e.Message+"/n";
    }finally{}
    try{
     fNode=rNode.ChildNodes[2];//file
     cmd.CommandText="Delete From File3 Where tabID='"+tabID+"'";
     cmd.ExecuteNonQuery();
     for(int i=0;i<fNode.ChildNodes.Count;i++){
      cNode=fNode.ChildNodes[i];//rec
      if (cNode==null||cNode.ChildNodes[0]==null) continue;
      cmd.CommandText="Insert into File3 (tabID,fileName,fileSize) "+
       "Values ('"+tabID+"','"+cNode.ChildNodes[0].InnerText+"','"+
       cNode.ChildNodes[1].InnerText+"')";
      cmd.ExecuteNonQuery();
     }
     re+="WriteFile-OK/n";
    }catch(Exception e){
     re+=e.Message+"/n";
    }finally{}
    try{
     fNode=rNode.ChildNodes[3];//detail
     if (fNode.ChildNodes[0]!=null){
      if (IsReported(tabID)){
       cmd.CommandText="Delete From TSZS003 Where tabID='"+tabID+"'";
       cmd.ExecuteNonQuery();
      }
      cmd.CommandText="Insert into TSZS003 (tabID,workType,workObj,devType,"+
        "devClass,devStep,devKind,devName,devSize,devID,devComID,"+
        "devAddr,madeID,madeCom,madeComID,madeDate,useCom,useComAddr,"+
        "useComMan,useComPhone,contractID,contractDate,workCom,permitID,permitTime,"+
        "workComMan,workComID,workComMan2,workComMan2Phone,workComMan3,"+
        "workComMan3Phone,workComAddr,buildCom,buildComAddr,buildDate1,"+
        "buildDate2,buildCost1,buildCost2) Values ('"
        +tabID+"','"+
        fNode.ChildNodes[0].InnerText+"','"+
        fNode.ChildNodes[1].InnerText+"','"+
        fNode.ChildNodes[2].InnerText+"','"+
        fNode.ChildNodes[3].InnerText+"','"+
        fNode.ChildNodes[4].InnerText+"','"+
        fNode.ChildNodes[5].InnerText+"','"+
        fNode.ChildNodes[6].InnerText+"','"+
        fNode.ChildNodes[7].InnerText+"','"+
        fNode.ChildNodes[8].InnerText+"','"+
        fNode.ChildNodes[9].InnerText+"','"+
        fNode.ChildNodes[10].InnerText+"','"+
        fNode.ChildNodes[11].InnerText+"','"+
        fNode.ChildNodes[12].InnerText+"','"+
        fNode.ChildNodes[13].InnerText+"','"+
        fNode.ChildNodes[14].InnerText+"','"+
        fNode.ChildNodes[15].InnerText+"','"+
        fNode.ChildNodes[16].InnerText+"','"+
        fNode.ChildNodes[17].InnerText+"','"+
        fNode.ChildNodes[18].InnerText+"','"+
        fNode.ChildNodes[19].InnerText+"','"+
        fNode.ChildNodes[20].InnerText+"','"+
        fNode.ChildNodes[21].InnerText+"','"+
        fNode.ChildNodes[22].InnerText+"','"+
        fNode.ChildNodes[23].InnerText+"','"+
        fNode.ChildNodes[24].InnerText+"','"+
        fNode.ChildNodes[25].InnerText+"','"+
        fNode.ChildNodes[26].InnerText+"','"+
        fNode.ChildNodes[27].InnerText+"','"+
        fNode.ChildNodes[28].InnerText+"','"+
        fNode.ChildNodes[29].InnerText+"','"+
        fNode.ChildNodes[30].InnerText+"','"+
        fNode.ChildNodes[31].InnerText+"','"+
        fNode.ChildNodes[32].InnerText+"','"+
        fNode.ChildNodes[33].InnerText+"','"+
        fNode.ChildNodes[34].InnerText+"','"+
        fNode.ChildNodes[35].InnerText+"','"+
        fNode.ChildNodes[36].InnerText+"')";
      cmd.ExecuteNonQuery();
     }
     re+="WriteDetail-OK/n";
    }catch(Exception e){
     re+=e.Message+"/n";
    }finally{}
    try{
     cmd.CommandText="Update TSZS003 Set MemberID='"+memberID
      +"',Answer=0,ReportDate='"+DateTime.Now.ToString()
      +"' Where tabID='"+tabID+"'";
     cmd.ExecuteNonQuery();
     re+="UpDate-OK/n";
    }catch(Exception e){
     re+=e.Message+"/n";
    }finally{}
   }
   return re;
  }
  #endregion
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值