internal static DataTotalLoss LoadFromXml(System.Xml.XmlNode props, DataBase par, ReceptVersion curVer) { DataTotalLoss curRec = new DataTotalLoss(par); curRec.BeginUpdate(); switch (curVer) { case ReceptVersion.Version0: foreach (XmlNode curNode in props.ChildNodes) { switch (curNode.Name) { case "number": curRec.Id = int.Parse(curNode.InnerText, CultureInfo.CurrentCulture); break; case "name": curRec.Name = curNode.InnerText; break; case "value": curRec.Quantity = Convert.ToDecimal(curNode.InnerText, CultureInfo.CurrentCulture); break; case "comment": curRec.Comment = curNode.InnerText; break; } } break; case ReceptVersion.Version1: curRec.Id = int.Parse(props.Attributes["id"].Value, CultureInfo.CurrentCulture); foreach (XmlNode curnode in props.ChildNodes) { switch (curnode.Name) { case "comment": curRec.Comment = curnode.InnerText; break; case "name": curRec.Name = curnode.InnerText; break; case "quantity": curRec.Quantity = Convert.ToDecimal(curnode.InnerText, CultureInfo.CurrentCulture); break; } } break; default: throw new NotImplementedException("Not implemented"); } curRec.IsChanged = false; curRec.EndUpdate(false); DataTotalLoss ret = Config.DP.FindTotalLoss(curRec); if (ret == null) { FormCompare frm = new FormCompare(curRec, Config.DP.FindSimilarTotalLoss(curRec), DataBaseType.TotalLossType); frm.ShowDialog(); ret = (DataTotalLoss)frm.UserRec; ret.IsChanged = true; } else { ret.IsChanged = false; } return(ret); }
public static DataRawStruct LoadFromXml(XmlNode root, DataBase par, DataBaseType curType) { DataRawStruct curRaw = new DataRawStruct(par); curRaw.BeginUpdate(); curRaw.Id = int.Parse(root.Attributes["id"].Value, CultureInfo.CurrentCulture); foreach (XmlNode curRawNode in root.ChildNodes) { switch (curRawNode.Name) { case "brutto": curRaw.pBrutto = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "caloric": curRaw.myCaloric = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "starch": curRaw._starch = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "saccharides": curRaw._saccharides = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "cellulose": curRaw._cellulose = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "cholesterol": curRaw._cholesterol = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "comment": curRaw.Comment = curRawNode.InnerText.ToString(); break; case "fat": curRaw._fat = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "acid": curRaw._acid = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "ash": curRaw._ash = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "mineralCa": curRaw.m_mineralCA = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "mineralFe": curRaw.m_mineralFE = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "mineralK": curRaw.m_mineralK = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "mineralMg": curRaw.m_mineralMG = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "mineralNa": curRaw.m_mineralNA = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "mineralP": curRaw.m_mineralP = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "normativDoc": curRaw.m_normativDoc = curRawNode.InnerText.ToString(); break; case "protein": curRaw._protein = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "vitaminA": curRaw._vitaminA = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "vitaminB": curRaw._vitaminB = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "vitaminB1": curRaw._vitaminB1 = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "vitaminB2": curRaw._vitaminB2 = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "vitaminC": curRaw.m_vitaminC = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "vitaminPP": curRaw._vitaminPP = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "water": curRaw.myWater = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "name": curRaw.Name = curRawNode.InnerText; break; case "inRecept": curRaw.pInRecept = Convert.ToBoolean(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "inSostav": curRaw.pInSostav = Convert.ToBoolean(curRawNode.InnerText, CultureInfo.CurrentCulture); break; //case "quantity": curRaw._quantity = Convert.ToDecimal(curRawNode.InnerText); break; } } curRaw.EndUpdate(false); curRaw.IsChanged = false; // ищем эту или похожую компоненту в БД DataRawStruct ret; switch (curType) { case DataBaseType.RawType: ret = Config.DP.FindRaw(curRaw); if (ret == null) { FormCompare frm = new FormCompare(curRaw, Config.DP.FindSimilarRaw(curRaw), curType); frm.ShowDialog(); ret = (DataRawStruct)frm.UserRec; } break; case DataBaseType.ProcessLossType: ret = Config.DP.FindProcessLoss(curRaw); if (ret == null) { FormCompare frm = new FormCompare(curRaw, Config.DP.FindSimilarProcessLoss(curRaw), curType); frm.ShowDialog(); ret = (DataRawStruct)frm.UserRec; } break; default: throw new NotImplementedException("Не реализовано"); } //ret.Add(curRaw); return(ret); }