private static DbHelperCmdObject PrePareOrdST(OrdST model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Jins_Ord_ST("); strSql.Append("ID,SubID,OPC,Qty)"); strSql.Append(" values ("); strSql.Append("@ID,@SubID,@OPC,@Qty)"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.VarChar, 25), new SqlParameter("@SubID", SqlDbType.Int, 4), new SqlParameter("@OPC", SqlDbType.VarChar, 50), new SqlParameter("@Qty", SqlDbType.Int, 4) }; parameters[0].Value = model.ID; parameters[1].Value = model.SubID; parameters[2].Value = model.OPC; parameters[3].Value = model.Qty; // DbHelperCmdObject obj = new DbHelperCmdObject(strSql.ToString(), parameters); return(obj); }
public static OrdMain ConvertXMLtoOrdModel(string xmlPath) { OrdMain model = new OrdMain(); var file = xmlPath.Substring(xmlPath.LastIndexOf("\\") + 1); model.OrdID = file.Substring(0, file.LastIndexOf(".")); model.ID = ""; try { using (XmlReader _XReader = XmlReader.Create(xmlPath)) { XElement _XElement = XElement.Load(_XReader); model.OrdHdID = _XElement.Element("purchase_order_header_id").Value; model.OrdType = _XElement.Element("po_type_id").Value; model.Address1 = _XElement.Element("address").Value; model.Postal = _XElement.Element("postal").Value; model.Tel = _XElement.Element("telephone").Value; model.Memo = _XElement.Element("memorandum").Value; var t = _XElement.Element("created").Value; try { model.Created = Convert.ToDateTime(t); } catch { model.Created = DateTime.Now; } model.SalesOfficeCode = _XElement.Element("salesOfficeCode").Value; model.SalesOfficeName = _XElement.Element("salesOfficeName").Value; try { model.Procurement_Type = _XElement.Element("procurement_type").Value; } catch { model.Procurement_Type = ""; } // switch (model.OrdType) { case "rx": model.SubRX = new OrdRX(); var modelrx = model.SubRX; var _detail = _XElement.Elements("detail").FirstOrDefault(); // modelrx.SpecialRight1 = _detail.Element("specialright1").Value; modelrx.SpecialRight2 = _detail.Element("specialright2").Value; modelrx.SpecialRight3 = _detail.Element("specialright3").Value; modelrx.SpecialRight4 = _detail.Element("specialright4").Value; modelrx.SpecialLeft1 = _detail.Element("specialleft1").Value; modelrx.SpecialLeft2 = _detail.Element("specialleft2").Value; modelrx.SpecialLeft3 = _detail.Element("specialleft3").Value; modelrx.SpecialLeft4 = _detail.Element("specialleft4").Value; // modelrx.Lens_Type = _detail.Element("lens_type").Value; modelrx.Tint_Type = _detail.Element("tint_type").Value; modelrx.Tint = _detail.Element("tint").Value; modelrx.Polarized = _detail.Element("polarized").Value; modelrx.Mirrored = _detail.Element("mirrored").Value; // modelrx.Oculus_Dexter_Sphere = _detail.Element("oculus_dexter_sphere").Value.GetDecimalStr(); modelrx.Oculus_Sinister_Sphere = _detail.Element("oculus_sinister_sphere").Value.GetDecimalStr(); modelrx.Oculus_Dexter_Cylinder = _detail.Element("oculus_dexter_cylinder").Value.GetDecimalStr(); modelrx.Oculus_Sinister_Cylinder = _detail.Element("oculus_sinister_cylinder").Value.GetDecimalStr(); modelrx.Oculus_Dexter_Axis = _detail.Element("oculus_dexter_axis").Value.GetDecimalStr(); modelrx.Oculus_Sinister_Axis = _detail.Element("oculus_sinister_axis").Value.GetDecimalStr(); modelrx.Oculus_Dexter_Add = _detail.Element("oculus_dexter_add").Value.GetDecimalStr(); modelrx.Oculus_Sinister_Add = _detail.Element("oculus_sinister_add").Value.GetDecimalStr(); // modelrx.Oculus_Dexter_Diameter = _detail.Element("oculus_dexter_diameter").Value.GetIntFromStr(); modelrx.Oculus_Sinister_Diameter = _detail.Element("oculus_sinister_diameter").Value.GetIntFromStr(); // modelrx.Oculus_Dexter_Quantity = _detail.Element("oculus_dexter_quantity").Value.GetIntFromStr(); modelrx.Oculus_Sinister_Quantity = _detail.Element("oculus_sinister_quantity").Value.GetIntFromStr(); //new column try { modelrx.Frame_Code = _detail.Element("frame_code").Value; } catch { modelrx.Frame_Code = ""; } try { modelrx.Polishing = _detail.Element("polishing").Value; } catch { modelrx.Polishing = ""; } try { modelrx.Oculus_Eye_Point = _detail.Element("oculus_eye_point").Value; } catch { modelrx.Oculus_Eye_Point = ""; } try { modelrx.Oculus_Dexter_Pupillary_Distance = _detail.Element("oculus_dexter_pupillary_distance").Value; } catch { modelrx.Oculus_Dexter_Pupillary_Distance = ""; } try { modelrx.Oculus_Sinister_Pupillary_Distance = _detail.Element("oculus_sinister_pupillary_distance").Value; } catch { modelrx.Oculus_Sinister_Pupillary_Distance = ""; } break; default: model.SubST = new List <OrdST>(); var modelst = model.SubST; OrdST ordst = null; var details = _XElement.Elements("detail"); foreach (var item in details) { ordst = new OrdST() { SubID = item.Attribute("id").Value.GetIntFromStr(), OPC = item.Element("opc").Value, Qty = item.Element("qty").Value.GetIntFromStr(), }; modelst.Add(ordst); } break; } } //ordz InitOrdZ(model); //ordzmain InitOrdZMain(model); return(model); } catch (Exception ex) { Jinsdb.AddLog(ex.Message); throw; } }