public string LoadXML2Bom(string xml) //加载订单数据 { int id = 1; int slino = 1; int cid = 0; string name, mat, color, des, gcb, extra, pricecalctype, spaceflag; int l, d, h, bh; UnloadBom(false); if (bomlist == null) { bomlist = new List <BomOrderItem>(); } //for (int i = 0; i < bomlist.Length; i++) //{ // BomOrderItem poi = bomlist[i]; //} XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); XmlNode root = xmlDoc.DocumentElement; if ((root.Name != "产品") && (root.ChildNodes.Count <= 0)) { return(""); } InitSysVariantValue(); name = ""; l = 0; d = 0; h = 0; bh = 18; mat = ""; color = ""; des = ""; gcb = ""; spaceflag = ""; pricecalctype = ""; extra = ""; XmlAttribute attri = root.Attributes["Extra"]; if (attri != null) { extra = attri.Value; //int startrow = int.Parse(attri.Value); } if (root.ChildNodes[0].Name == "产品") { attri = root.Attributes["板材厚度"]; if (attri != null) { bh = int.Parse(attri.Value); //int startrow = int.Parse(attri.Value); } } name = Myutil.GetAttributeValue(root, "名称", "", ""); des = Myutil.GetAttributeValue(root, "描述", "", ""); gcb = Myutil.GetAttributeValue(root, "CB", "", ""); l = Myutil.GetAttributeValue(root, "宽", 0, 0); d = Myutil.GetAttributeValue(root, "深", 0, 0); h = Myutil.GetAttributeValue(root, "高", 0, 0); gcb = Myutil.GetAttributeValue(root, "材料", "", ""); gcb = Myutil.GetAttributeValue(root, "颜色", "", ""); gcb = Myutil.GetAttributeValue(root, "基础图形", "", ""); spaceflag = Myutil.GetAttributeValue(root, "SpaceFlag", "", ""); pricecalctype = Myutil.GetAttributeValue(root, "板材单价", "", ""); mVName = new string[16]; mVValue = new string[16]; mC = new int[16]; for (int j = 0; j <= 15; j++) { mVName[j] = ""; mVValue[j] = ""; mC[j] = 0; //Myutil.GetAttributeValue(root, "参数" + j.ToString(), "", ""); MyVariant(Myutil.GetAttributeValue(root, "参数" + j.ToString(), "", ""), ref mVName[j], ref mVValue[j]); mC[j] = MyStrToInt(mVValue[j]); } TProductItem p = new TProductItem(); mProductList = new List <TProductItem>(); p.id = cid; p.name = name; p.gno = name; p.mat = mat; p.color = color; p.des = des; p.gcb = gcb; p.Extra = extra; p.l = l; p.d = d; p.h = h; p.bh = bh; mProductList.Add(p); BomParam param = new BomParam(); param.productid = mProductList.Count - 1; param.cid = cid - 1; param.boardheight = bh; param.blist = bomlist; param.gno = name; param.gdes = des; param.gcb = gcb; param.extra = extra; param.pname = ""; param.subspace = ""; param.sozflag = ""; param.xml = root.ChildNodes[0].OuterXml; param.textureclass = ""; param.pmat = mat; param.pcolor = color; param.pid = -1; param.pl = l; param.pd = d; param.ph = h; param.px = 0; param.py = 0; param.pz = 0; param.space_x = 0; param.space_y = 0; param.space_z = 0; if (spaceflag == "1") { param.space_id = 0; } else { param.space_id = -1; } param.outputtype = ""; param.num = 1; //param.parent = null; param.blockmemo = ""; param.number_text = ""; param.rootnode = root.ChildNodes[0]; param.xdoc = xmlDoc; ImportXomItemForBom(ref param, ref id, ref slino); return(""); }
public int ImportXomItemForBom(ref BomParam param0, ref int id, ref int slino) { int Result = 0; string ls = "", childxml = ""; XmlNode node = null; BomParam param = new BomParam(); TExpress exp = new TExpress(); param.blockmemo = ""; XmlNode root = param0.rootnode; string str = GetAttributeValue(root, "模块备注", "", ""); if (str != "") { param0.blockmemo = str; param0.blockmemo = param0.blockmemo.Replace("[宽]", param0.pl.ToString()); param0.blockmemo = param0.blockmemo.Replace("[深]", param0.pd.ToString()); param0.blockmemo = param0.blockmemo.Replace("[高]", param0.ph.ToString()); } str = GetAttributeValue(root, "类别", "", ""); if ((str == "趟门,趟门") || (str == "掩门,掩门")) { node = root.SelectSingleNode("模板"); if (node != null) { childxml = ""; if (node.ChildNodes.Count > 0) { childxml = node.ChildNodes[0].OuterXml; } return(0); } } node = root.SelectSingleNode("我的模块"); if (node != null) { for (int i = 0; i <= node.ChildNodes.Count - 1; i++) { XmlNode cnode = node.ChildNodes[i]; if ((cnode.Name != "板件") && (cnode.Name != "五金") && (cnode.Name != "型材五金") && (cnode.Name != "模块") && (cnode.Name != "门板")) { continue; } childxml = ""; if (cnode.ChildNodes.Count > 0) { childxml = cnode.ChildNodes[0].OuterXml; } if (childxml != "") { param = param0; if (cnode.ChildNodes.Count > 0) { param.rootnode = cnode.ChildNodes[0]; param.xdoc = param0.xdoc; int childnum = ImportXomItemForBom(ref param, ref id, ref slino); } } } } return(0); }