private static DataMicroBiology LoadFromXmlVer1(XmlNode root, DataBase par, ReceptVersion curVer) { DataMicroBiology ret = new DataMicroBiology(par); ret.BeginUpdate(); ret.Id = int.Parse(root.Attributes["id"].Value, CultureInfo.CurrentCulture); foreach (XmlNode curNode in root.ChildNodes) { switch (curNode.Name) { case "name": ret.Name = curNode.InnerText; break; case "comment": ret.Comment = curNode.InnerText; break; case "items": foreach (XmlNode itemNode in curNode.ChildNodes) { ret.Components.Add(DataMicroBiologyIndicator.LoadFromXml(itemNode, ret, curVer)); } break; } } ret.EndUpdate(false); ret.IsChanged = false; return(ret); }
/// <summary> /// загрузка из файла старого формата /// </summary> /// <param name="curnode"></param> /// <param name="par"></param> /// <param name="curVer"></param> /// <returns></returns> private static DataRecept LoadFromXmlVer0(XmlNode curnode, DataBase par, ReceptVersion curVer) { DataRecept curRec = new DataRecept(par); curRec.BeginUpdate(); XmlNode rootNode = curnode.SelectSingleNode("recept"); foreach (XmlNode props in rootNode.ChildNodes) { switch (props.Name) { case "name": curRec.Name = props.InnerText; break; case "number": curRec.Id = int.Parse(props.InnerText, CultureInfo.CurrentCulture); break; case "water": curRec._water = Convert.ToDecimal(props.InnerText, CultureInfo.CurrentCulture); break; case "deflect": { curRec._waterPlus = Convert.ToDecimal(props.InnerText, CultureInfo.CurrentCulture); curRec._waterMinus = curRec._waterPlus; break; } case "description": curRec._design = props.InnerText; break; case "poteri": curRec._totalLoss = DataTotalLoss.LoadFromXml(props, curRec, curVer); break; case "component": curRec.Components.Add(DataRaw.LoadOneFromXml(props, curRec, curVer)); break; } } curRec.IsChanged = false; curRec.EndUpdate(false); return(curRec); }
internal static DataMicroBiology LoadFromXml(XmlNode root, DataBase par, ReceptVersion curVer) { switch (curVer) { case ReceptVersion.Version0: throw new NotImplementedException("The method or operation is not implemented."); case ReceptVersion.Version1: return(LoadFromXmlVer1(root, par, curVer)); default: throw new NotImplementedException("The method or operation is not implemented."); } }
//public override bool Contains(DataBase child) //{ // return false; // //throw new Exception("The method or operation is not implemented."); //} public static DataRaw LoadOneFromXml(XmlNode root, DataBase par, ReceptVersion curVer) { DataRaw ret = new DataRaw(par); ret.BeginUpdate(); switch (curVer) { case ReceptVersion.Version0: foreach (XmlNode props in root.ChildNodes) { switch (props.Name) { case "name": ret.Name = props.InnerText; break; case "number": ret.RawStruct.Id = int.Parse(props.InnerText, CultureInfo.CurrentCulture); break; case "water": ret.RawStruct.Water = Convert.ToDecimal(props.InnerText, CultureInfo.CurrentCulture); break; case "gir": ret.RawStruct.fat = Convert.ToDecimal(props.InnerText, CultureInfo.CurrentCulture); break; case "belki": ret.RawStruct.protein = Convert.ToDecimal(props.InnerText, CultureInfo.CurrentCulture); break; case "sahar": ret.RawStruct.saccharides = Convert.ToDecimal(props.InnerText, CultureInfo.CurrentCulture); break; case "kkal": ret.RawStruct.Caloric = Convert.ToDecimal(props.InnerText, CultureInfo.CurrentCulture); break; case "comment": ret.Comment = props.InnerText; break; case "value": ret.Quantity = Convert.ToDecimal(props.InnerText, CultureInfo.CurrentCulture); break; } } break; case ReceptVersion.Version1: throw new NotImplementedException("not implemented"); default: throw new NotImplementedException("not implemented"); } ret.EndUpdate(false); ret.IsChanged = false; return(ret); }
/// <summary> /// загрузка книги из файла /// </summary> private void LoadFromFile(string file, bool isVerbose) { this.BeginUpdate(); XmlDocument doc = new XmlDocument(); try { doc.Load(CommonFunctions.AbsolutePathFromAnyPath(Application.StartupPath, file)); XmlNode root = doc.DocumentElement; if (root.Attributes.Count > 0) { int curVer = int.Parse(root.Attributes["version"].Value, CultureInfo.CurrentCulture); if (curVer == 0) { myVersion = ReceptVersion.Version0; } if (curVer == 1) { myVersion = ReceptVersion.Version1; } } else { myVersion = ReceptVersion.CurrentVersion; // нет версии (rcp) } foreach (XmlNode rootProps in root.ChildNodes) { switch (rootProps.Name) { case "chief": m_chiefName = rootProps.InnerText; break; case "chiefPost": m_chiefPost = rootProps.InnerText; break; case "company": _company = rootProps.InnerText; break; case "developer": _developer = rootProps.InnerText; break; case "developerCompany": _developerCompany = rootProps.InnerText; break; case "recepts": foreach (XmlNode curNode in rootProps.ChildNodes) { Components.Add(DataRecept.LoadFromXml(curNode, this, myVersion)); } break; case "name": Name = rootProps.InnerText; break; } } } catch (XmlException ex) { if (isVerbose) { MessageBox.Show("Ошибка: " + ex.Message + "\n" + ex.StackTrace, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0); } } catch (FileNotFoundException ex) { if (isVerbose) { MessageBox.Show("Ошибка: " + ex.Message + "\n" + ex.StackTrace, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0); } } // сортировка элементов Components.Sort(new DataBaseComparer()); //Array.Sort(Components, new IfDataBaseNumSort()); RenumberRecepts(); EndUpdate(false); this.Changed += new EventHandler <DataBaseEventArgs>(DataBook_Changed); this.IsChanged = false; }
/// <summary> /// загрузка файла версии программы "2" /// </summary> /// <param name="curnode">узел дерева XML</param> /// <param name="par">родительский объект</param> /// <returns>структуру данных рецептуры</returns> private static DataRecept LoadFromXmlVer1(XmlNode curnode, DataBase par, ReceptVersion curVer) { DataRecept curRec = new DataRecept(par); curRec.BeginUpdate(); curRec.Id = int.Parse(curnode.Attributes["id"].Value, CultureInfo.CurrentCulture); foreach (XmlNode props in curnode.ChildNodes) { switch (props.Name) { case "color": curRec._color = props.InnerText; break; case "components": curRec.Components.AddRange(DataRaw.LoadManyFromXml(props, curRec, curVer)); break; case "consistence": curRec._consistence = props.InnerText; break; case "delivery": curRec._delivery = props.InnerText; break; case "design": curRec._design = props.InnerText; break; case "extView": curRec._extView = props.InnerText; break; case "totalLoss": curRec._totalLoss = DataTotalLoss.LoadFromXml(props, curRec, curVer); break; case "process": curRec._process = props.InnerText; break; case "sale": curRec._sale = props.InnerText; break; case "storage": curRec._storage = props.InnerText; break; case "taste": curRec._taste = props.InnerText; break; case "water": curRec._water = Convert.ToDecimal(props.InnerText, CultureInfo.CurrentCulture); break; case "waterPlus": curRec._waterPlus = Convert.ToDecimal(props.InnerText, CultureInfo.CurrentCulture); break; case "waterMinus": curRec._waterMinus = Convert.ToDecimal(props.InnerText, CultureInfo.CurrentCulture); break; case "acidity": curRec.myAcidity = Convert.ToDecimal(props.InnerText, CultureInfo.CurrentCulture); break; case "name": curRec.Name = props.InnerText; break; case "source": curRec._source = props.InnerText; break; case "normativDoc": curRec._normativDoc = props.InnerText; break; case "preview": curRec._preview = props.InnerText; break; case "quantity": curRec.Quantity = Convert.ToDecimal(props.InnerText, CultureInfo.CurrentCulture); break; case "totalExit": curRec.myTotalExit = Convert.ToDecimal(props.InnerText, CultureInfo.CurrentCulture); break; case "countExit": curRec.myCountExit = Convert.ToDecimal(props.InnerText, CultureInfo.CurrentCulture); break; case "microbiology": curRec.myMicroBiology = DataMicroBiology.LoadFromXml(props, curRec, curVer); break; case "isCalcExit": curRec.myIsCalcExit = Convert.ToBoolean(props.InnerText, CultureInfo.CurrentCulture); break; case "isCalcWater": curRec.myIsCalcWater = Convert.ToBoolean(props.InnerText, CultureInfo.CurrentCulture); break; case "isSetWater": curRec.myIsSetWater = Convert.ToBoolean(props.InnerText, CultureInfo.CurrentCulture); break; } } curRec.IsChanged = false; curRec.EndUpdate(false); return(curRec); }
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); }
/// <summary> /// загрузка данных по сырью из xml файла /// </summary> /// <param name="root">узел со списком компонент</param> /// <param name="par">родительская структура</param> /// <returns></returns> public static BindingList <DataBase> LoadManyFromXml(XmlNode root, DataBase par, ReceptVersion curVer) { BindingList <DataBase> ret = new BindingList <DataBase>(); switch (curVer) { case ReceptVersion.Version0: throw new NotImplementedException("not implemented"); case ReceptVersion.Version1: foreach (XmlNode curNode in root.ChildNodes) { if (curNode.Name.Equals("recept")) { ret.Add(DataRecept.LoadFromXml(curNode, par, curVer)); } else // это лист с сырьем { DataRaw curRaw = new DataRaw(par); curRaw.BeginUpdate(); foreach (XmlNode curRawNode in curNode.ChildNodes) { switch (curRawNode.Name) { case "quantity": curRaw.Quantity = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "comment": curRaw.Comment = curRawNode.InnerText; break; case "brutto": curRaw.myBrutto = Convert.ToDecimal(curRawNode.InnerText, CultureInfo.CurrentCulture); break; case "rawStruct": curRaw.myRawStruct = DataRawStruct.LoadFromXml(curRawNode, curRaw, DataBaseType.RawType); break; case "processLoss": curRaw.myProcessLoss = DataRawStruct.LoadFromXml(curRawNode, curRaw, DataBaseType.ProcessLossType); break; } } curRaw.EndUpdate(false); curRaw.IsChanged = false; ret.Add(curRaw); } } break; default: throw new NotImplementedException("not implemented"); } return(ret); }
public static DataMicroBiologyIndicator LoadFromXml(XmlNode root, DataBase parent, ReceptVersion ver) { throw new NotImplementedException(); }