private void tsmiImport_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.DefaultExt = "rcp"; dlg.Filter = "Рабочая рецептура (*.rcp)|*.rcp"; dlg.Multiselect = false; DialogResult res = dlg.ShowDialog(); if (res == DialogResult.OK && !dlg.FileName.Equals("")) { try { XmlDocument doc = new XmlDocument(); doc.Load(CommonFunctions.AbsolutePathFromAnyPath(Application.StartupPath, dlg.FileName)); XmlNode root = doc.DocumentElement; DataRecept rcp = DataRecept.LoadFromXml(root, DataBook.Book, ReceptVersion.Version0); if (rcp != null) { DataBook.Book.Components.Add(rcp); } } catch (System.Exception ex) { MessageBox.Show("Невозможно импортировать файл:\n" + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0); } } }
private void tsmiAddRecept_Click(object sender, EventArgs e) { DataRecept newRecept = new DataRecept(DataBook.Book); DataBook.Book.Components.Add(newRecept); panelBrouse1.SelectTreeNode(newRecept); }
/// <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 void LoadData(DataRecept data) { _data = data; lblReceptName.Text = _data.Name; //rtbFactor.Text = _data.MicroBiology; _data.Changed += new EventHandler <DataBaseEventArgs>(_data_Changed); }
internal void LoadData(DataRecept data) { _data = data; lblReceptName.Text = _data.Name; rtbProcess.Text = _data.process; _data.Changed += new EventHandler <DataBaseEventArgs>(_data_Changed); }
internal void LoadData(DataRecept dataRecept) { _data = dataRecept; lblReceptName.Text = _data.Name; _mode = ViewMode.None; _data.Changed += new EventHandler <DataBaseEventArgs>(_data_Changed); //throw new Exception("The method or operation is not implemented."); }
private void tsmiClearRecept_Click(object sender, EventArgs e) { DataRecept i = panelBrouse1.GetSelectedRecept(); if (i != null) { i.Components.Clear(); } else { MessageBox.Show("Выберите рецептуру", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0); } }
/// <summary> /// Загрузка дерева рецептур в таблицу /// </summary> /// <param name="nodes">коллекция строк</param> /// <param name="data">рецептура</param> private void LoadReceptData(TreeGridNodeCollection nodes, DataRecept data) { TreeGridNode curNode = null; foreach (DataBase dr in data.Components) { //MessageBox.Show("Start Load: " + dr.name); // если компонента рецептуры есть сама рецептура, то делаем рекурсию if (dr is DataRecept) { DataRecept rec = dr as DataRecept; curNode = new TreeGridNode(); curNode.DefaultCellStyle.BackColor = Color.LightGray; curNode.Tag = rec; nodes.Add(curNode); curNode.Cells[dgvRecName.Index].Value = rec.Name; curNode.Cells[dgvRecCountNetto.Index].Value = rec.TotalExit; LoadReceptData(curNode.Nodes, rec); continue; } // иначе это обычная компонента и мы ее загружаем в корень DataRaw curRaw = dr as DataRaw; curNode = new TreeGridNode(); curNode.Tag = curRaw; nodes.Add(curNode); curNode.Cells[dgvRecCountNetto.Index].Value = (curRaw.Quantity != 0 ? curRaw.Quantity.ToString(CultureInfo.CurrentCulture) : string.Empty); curNode.Cells[dgvRecCountBrutto.Index].Value = (curRaw.Brutto != 0 ? curRaw.Brutto.ToString(CultureInfo.CurrentCulture) : string.Empty); curNode.Cells[dgvRecComment.Index].Value = curRaw.Comment; if (curRaw.RawStruct != null) { curNode.Cells[dgvRecName.Index].Value = curRaw.RawStruct.DisplayMember; if (curRaw.Brutto == 0 && curRaw.Quantity != 0 && curRaw.RawStruct.Brutto != 0) { curNode.Cells[dgvRecCountBrutto.Index].Value = CommonFunctions.Round(curRaw.Quantity * curRaw.RawStruct.Brutto); } if (curRaw.Quantity == 0 && curRaw.RawStruct.Brutto != 0 && curRaw.Brutto != 0) { curNode.Cells[dgvRecCountNetto.Index].Value = CommonFunctions.Round(curRaw.Brutto / curRaw.RawStruct.Brutto); } } if (curRaw.ProcessLoss != null) { (curNode.Cells[dgvRecProcessLoss.Index] as DataGridViewComboBoxCell).Value = curRaw.ProcessLoss.ValueMember; } } // добавляем пустую новую строку для каждой рецептуры nodes.Add(new TreeGridNode()); }
/// <summary> /// Загрузка дерева рецептур /// </summary> /// <param name="root">текущие листья узла</param> /// <param name="curRec">рецептура</param> private void LoadRecepts(TreeNodeCollection root, DataRecept curRec) { TreeNode curnode = new TreeNode(curRec.Name + " (" + CommonFunctions.Round(curRec.PercentFilling()) + "%)"); curnode.Tag = curRec; root.Add(curnode); foreach (DataBase rec in curRec.Components) { if (rec is DataRecept) { LoadRecepts(curnode.Nodes, rec as DataRecept); } } }
private void TsmiReportTkClick(object sender, EventArgs e) { DataRecept i = panelBrouse1.GetSelectedRecept(); if (i != null) { FormPreview frm = new FormPreview(i, PreviewReport.FormTK); frm.Show(); } else { MessageBox.Show("Выберите рецептуру", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0); } }
internal void SelectTreeNode(DataRecept newRecept, TreeNodeCollection nodes) { foreach (TreeNode curNode in nodes) { if (newRecept.Equals(curNode.Tag)) { tvBook.SelectedNode = curNode; return; } if (curNode.Nodes.Count > 0) { SelectTreeNode(newRecept, curNode.Nodes); } } }
private void PrintReceptBody(StringBuilder ret, DataRecept rec, int cols) { foreach (DataBase curRaw in rec.Components) { if (curRaw is DataRecept) { ret.Append("<tr><td colspan=" + cols + " align=\"center\">" + curRaw.Name + "</tr>"); PrintReceptBody(ret, (DataRecept)curRaw, cols); //ret.Append("<tr><td> Итого:</tr>"); continue; } DataRaw craw = (DataRaw)curRaw; ret.Append("<tr><td>" + craw.Name); if (!String.IsNullOrEmpty(craw.Comment)) { ret.Append(" (" + craw.Comment + ")"); } if (Config.Cfg.ReportIsShowOriginal) { ret.Append("<td>" + Math.Round(craw.Brutto, Config.Cfg.Precision)); if (craw.Brutto != craw.Quantity) { ret.Append(" / " + Math.Round(craw.Quantity, Config.Cfg.Precision)); } } for (int i = 0; i < Config.Cfg.ReportUseCounts.Count; i++) { ret.Append("<td>" + Math.Round(craw.Brutto / rec.CountExit * Config.Cfg.ReportUseCounts[i], Config.Cfg.Precision)); if (craw.Brutto != craw.Quantity) { ret.Append(" / " + Math.Round(craw.Quantity / rec.CountExit * Config.Cfg.ReportUseCounts[i], Config.Cfg.Precision)); } } for (int i = 0; i < Config.Cfg.ReportUseExits.Count; i++) { ret.Append("<td>" + Math.Round(craw.Brutto / rec.CalcExitNetto * Config.Cfg.ReportUseExits[i], Config.Cfg.Precision)); if (craw.Brutto != craw.Quantity) { ret.Append(" / " + Math.Round(craw.Quantity / rec.CalcExitNetto * Config.Cfg.ReportUseExits[i], Config.Cfg.Precision)); } } ret.Append("</tr>"); } }
/// <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); }
private void tsmiDeleteReceptRaw_Click(object sender, EventArgs e) { DataRecept i = panelBrouse1.GetSelectedRecept(); if (i != null) { DataBase delRaw = panelReceptData1.GetSelectedComponent(); if (!i.DeleteComponent(delRaw)) { MessageBox.Show("Выберите компоненту для удаления", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0); } } else { MessageBox.Show("Выберите рецептуру для удаления", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0); } }
static StringBuilder makeReceptProperty(DataRecept curRec) { StringBuilder curElem = new StringBuilder(); if (!String.IsNullOrEmpty(curRec.extView)) { curElem.Append("<b>Внешний вид:</b> " + TextFormatting(curRec.extView) + "<br>"); } if (!String.IsNullOrEmpty(curRec.color)) { curElem.Append("<b>Цвет:</b> " + TextFormatting(curRec.color) + "<br>"); } if (!String.IsNullOrEmpty(curRec.consistence)) { curElem.Append("<b>Консистенция:</b> " + TextFormatting(curRec.consistence) + "<br>"); } if (!String.IsNullOrEmpty(curRec.taste)) { curElem.Append("<b>Вкус и запах:</b> " + TextFormatting(curRec.taste)); } return(curElem); }
/// <summary> /// Создание технологической карты. /// </summary> /// <param name="curRec">текущая рецептура</param> /// <param name="useOriginal">флаг использования оригинальных данных</param> /// <param name="countVals">перечень значений выхода в шт.</param> /// <param name="exitVals">перечень значений выхода в гр.</param> /// <returns>HTML документ в виде строки</returns> internal string PrintTK(DataRecept curRec) { if ((Config.Cfg.ReportUseCounts == null || Config.Cfg.ReportUseCounts.Count == 0) && (Config.Cfg.ReportUseExits == null || Config.Cfg.ReportUseExits.Count == 0) && !Config.Cfg.ReportIsShowOriginal) { if (MessageBox.Show("Не указан выход, хотите настроить?", "Предупреждение", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, 0) == DialogResult.Yes) { this.BtnSettingsClick(null, EventArgs.Empty); } } StringBuilder ret = new StringBuilder("<html><style>h3{text-align:center;}</style>"); try { curRec.CalcRecept(); //Hashtable groupRaws = curRec.GroupRaws(true); } catch (OverflowException ex) { ret.Append("<p align=center>Невозможно сосчитать рецептуру: " + ex.Message + ". Проверьте правильность заполнения</p></html>"); return(ret.ToString()); } // шапка ret.Append(makeHeader(false, true)); ret.Append("<p align=center><b><font size=4>ТЕХНОЛОГИЧЕСКАЯ КАРТА № " + curRec.Id.ToString(CultureInfo.CurrentCulture) + "</font><br><font size=5> на " + curRec.Name + "</font></b>"); if (!String.IsNullOrEmpty(curRec.normativDoc)) { ret.Append("<br>Изготовлено по " + curRec.normativDoc); } ret.Append("</p>"); if (!String.IsNullOrEmpty(curRec.preview)) { ret.Append("<h3>Описание изделия</h3><p>" + TextFormatting(curRec.preview) + "</p>"); } ret.Append("<h3>Рецептура</h3>"); // Шапка ret.Append("<table width=\"100%\" border><thead align=center><td> Наименование сырья"); int cols = 1; if (Config.Cfg.ReportIsShowOriginal) { ret.Append("<td>" + curRec.TotalExit + " г./" + curRec.CountExit + " шт."); cols++; } for (int i = 0; i < Config.Cfg.ReportUseCounts.Count; i++) { ret.Append("<td>" + Config.Cfg.ReportUseCounts[i] + " шт."); cols++; } for (int i = 0; i < Config.Cfg.ReportUseExits.Count; i++) { ret.Append("<td>" + Config.Cfg.ReportUseExits[i] + " г."); cols++; } ret.Append("</thead>"); // тело PrintReceptBody(ret, curRec, cols); ret.Append("</table>"); ret.Append("<h3>Технология приготовления</h3><p>" + TextFormatting(curRec.process) + "</p>"); StringBuilder curElem = makeReceptProperty(curRec); if (curElem.Length > 0) { ret.Append("<h3>Характеристика изделия</h3>"); ret.Append("<p>" + curElem + "</p>"); } ret.Append(makeFooter()); // автозамены ReplaceSymbols(ret); return(ret.ToString()); }
/// <summary> /// Проверка данных формы и данных рецептуры /// </summary> /// <param name="root">дерево строк формы</param> /// <param name="curRec">рецептура</param> private void CheckReceptData(TreeGridNodeCollection root, DataRecept curRec) { ArrayList toDelete = new ArrayList(); TreeGridNode lastNode = null; // собираем строчки для удаления if (dgvRawList.Nodes.Count > 0) { foreach (TreeGridNode dr in root) { // если это пустая последняя строчка, то пропускаем if (dr.Tag == null) { if (lastNode == null) { lastNode = dr; } else { toDelete.Add(dr); } continue; } DataBase curBase = (DataBase)dr.Tag; if (!curRec.Components.Contains(curBase)) { toDelete.Add(dr); continue; } // если это рецептура, то рекурсия проверки if (curBase is DataRecept) { CheckReceptData(dr.Nodes, curBase as DataRecept); continue; } DataRaw curRaw = curBase as DataRaw; if (curRaw.RawStruct != null) { if (!curRaw.RawStruct.DisplayMember.Equals(dr.Cells[dgvRecName.Index].Value)) { dr.Cells[dgvRecName.Index].Value = curRaw.RawStruct.DisplayMember; } } if (!((Decimal)curRaw.Brutto).Equals(dr.Cells[dgvRecCountBrutto.Index].Value)) { dr.Cells[dgvRecCountBrutto.Index].Value = curRaw.Brutto; } if (curRaw.ProcessLoss != null) { if (!curRaw.ProcessLoss.ValueMember.Equals((dr.Cells[dgvRecProcessLoss.Index] as DataGridViewComboBoxCell).Value)) { dr.Cells[dgvRecProcessLoss.Index].Value = curRaw.ProcessLoss.ValueMember; } } if (!curRaw.Quantity.Equals(dr.Cells[dgvRecCountNetto.Index].Value)) { dr.Cells[dgvRecCountNetto.Index].Value = curRaw.Quantity; } if (!curRaw.Comment.Equals(dr.Cells[dgvRecComment.Index].Value)) { dr.Cells[dgvRecComment.Index].Value = curRaw.Comment; } if (curRaw.RawStruct != null) { if (curRaw.Brutto == 0 && curRaw.Quantity != 0) { dr.Cells[dgvRecCountBrutto.Index].Value = CommonFunctions.Round(curRaw.Quantity * curRaw.RawStruct.Brutto); } if (curRaw.Quantity == 0 && curRaw.Brutto != 0 && curRaw.RawStruct.Brutto != 0) { dr.Cells[dgvRecCountNetto.Index].Value = CommonFunctions.Round(curRaw.Brutto / curRaw.RawStruct.Brutto); } } } } if (toDelete.Count > 0) { foreach (TreeGridNode dr in toDelete) { root.Remove(dr); } } // добавление новых if (curRec.Components.Count > 0) { foreach (DataBase newRec in curRec.Components) { Boolean isExists = false; foreach (TreeGridNode dr in root) { if (newRec.Equals(dr.Tag)) { isExists = true; break; } } if (!isExists) { TreeGridNode node = new TreeGridNode(); node.Tag = newRec; root.Add(node); if (newRec is DataRecept) { //TreeGridNode curNode = root.Add(null, newRec.name, null, null, (newRec as DataRecept).totalExit, newRec.comment); node.Cells[dgvRecName.Index].Value = newRec.Name; node.Cells[dgvRecCountNetto.Index].Value = (newRec as DataRecept).TotalExit; node.DefaultCellStyle.BackColor = Color.LightGray; LoadReceptData(node.Nodes, newRec as DataRecept); continue; } DataRaw curRaw = newRec as DataRaw; //TreeGridNode newNode = root.Add(curRaw.id, null, null, curRaw.brutto, curRaw.quantity, curRaw.comment); node.Cells[dgvRecCountBrutto.Index].Value = curRaw.Brutto; node.Cells[dgvRecCountNetto.Index].Value = curRaw.Quantity; node.Cells[dgvRecComment.Index].Value = curRaw.Comment; if (curRaw.RawStruct != null) { node.Cells[dgvRecName.Index].Value = curRaw.RawStruct.DisplayMember; if (curRaw.Brutto == 0 && curRaw.Quantity != 0 && curRaw.RawStruct.Brutto != 0) { node.Cells[dgvRecCountBrutto.Index].Value = CommonFunctions.Round(curRaw.Quantity * curRaw.RawStruct.Brutto); } if (curRaw.Brutto != 0 && curRaw.Quantity == 0 && curRaw.RawStruct.Brutto != 0) { node.Cells[dgvRecCountNetto.Index].Value = CommonFunctions.Round(curRaw.Brutto / curRaw.RawStruct.Brutto); } } if (curRaw.ProcessLoss != null) { (node.Cells[dgvRecProcessLoss.Index] as DataGridViewComboBoxCell).Value = curRaw.ProcessLoss.ValueMember; } } } } // проверяем, чтобы последняя строчка была последней if (dgvRawList.Nodes.Count > 0 && (lastNode == null || !lastNode.IsLastSibling)) { root.Add(new TreeGridNode()); if (lastNode != null) { root.Remove(lastNode); } } }
internal void LoadData(DataRecept data) { this.tbName.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbNum.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbWater.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbWaterPlus.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbWaterMinus.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbTotalExit.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbNormativDoc.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbSource.TextChanged -= new System.EventHandler(this.tbTextChanged); this.tbPreview.TextChanged -= new System.EventHandler(this.tbTextChanged); this.cbTotalLoss.TextChanged -= new System.EventHandler(this.cbTextChanged); this.tbAcidity.TextChanged -= new System.EventHandler(this.tbTextChanged); dgvRawList.CellValueChanged -= new DataGridViewCellEventHandler(dgvRawList_CellValueChanged); myData = data; // настраиваем список потерь if (myTotalLoss == null) { myTotalLoss = Config.DP.TotalLossList; cbTotalLoss.Items.Clear(); if (myTotalLoss != null && myTotalLoss.Count > 0) { cbTotalLoss.Items.AddRange(myTotalLoss.ToArray()); } } // настраиваем список компонент if (myRaw == null) { myRaw = Config.DP.RawList; cbName.Items.Clear(); cbSetWater.Items.Clear(); if (myRaw != null && myRaw.Count > 0) { cbName.Items.AddRange(myRaw.ToArray()); cbSetWater.Items.AddRange(myRaw.ToArray()); } } // настраиваем список производственных потерь if (myProcessLoss == null) { myProcessLoss = Config.DP.ProcessLossList; dgvRecProcessLoss.Items.Clear(); if (myProcessLoss != null && myProcessLoss.Count > 0) { dgvRecProcessLoss.Items.AddRange(myProcessLoss.ToArray()); } } // шапка формы tbName.Text = data.Name; tbNum.Text = data.Id.ToString(CultureInfo.CurrentCulture); tbWater.Text = data.water.ToString(CultureInfo.CurrentCulture); tbWaterPlus.Text = data.waterPlus.ToString(CultureInfo.CurrentCulture); tbWaterMinus.Text = data.waterMinus.ToString(CultureInfo.CurrentCulture); tbTotalExit.Text = data.TotalExit.ToString(CultureInfo.CurrentCulture); tbCountExit.Text = data.CountExit.ToString(CultureInfo.CurrentCulture); tbPreview.Text = data.preview; tbSource.Text = data.source; tbNormativDoc.Text = data.normativDoc; if (data.totalLoss != null) { cbTotalLoss.SelectedIndex = data.totalLoss.TotalLossNum; } else { cbTotalLoss.SelectedIndex = 0; } tbAcidity.Text = data.Acidity.ToString(CultureInfo.CurrentCulture); // TODO: добавить хранение элемента "вода" в настройках проги и включить отображение пункта когда он будет готов // тело формы dgvRawList.Nodes.Clear(); //dgvRawList.Rows.Clear(); LoadReceptData(dgvRawList.Nodes, data); //MessageBox.Show("Start Load2: " + dgvRawList.Nodes.Count); rbCalcExit.Checked = data.isCalcExit; rbCalcWater.Checked = data.isCalcWater; rbSetWater.Checked = data.isSetWater; this.tbName.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbNum.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbWater.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbWaterPlus.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbWaterMinus.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbTotalExit.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbNormativDoc.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbSource.TextChanged += new System.EventHandler(this.tbTextChanged); this.tbPreview.TextChanged += new System.EventHandler(this.tbTextChanged); this.cbTotalLoss.TextChanged += new System.EventHandler(this.cbTextChanged); dgvRawList.CellValueChanged += new DataGridViewCellEventHandler(dgvRawList_CellValueChanged); this.tbAcidity.TextChanged += new System.EventHandler(this.tbTextChanged); // Устанавливаем радиокнопки выбора // this.rbCalcWater.CheckedChanged -= new System.EventHandler(this.RbCheckedChanged); // this.rbCalcExit.CheckedChanged -= new System.EventHandler(this.RbCheckedChanged); // this.rbSetWater.CheckedChanged -= new System.EventHandler(this.RbCheckedChanged); // rbCalcExit.Checked = data.isCalcExit; // rbCalcWater.Checked = data.isCalcWater; // rbSetWater.Checked = data.isSetWater; // this.rbCalcWater.CheckedChanged += new System.EventHandler(this.RbCheckedChanged); // this.rbCalcExit.CheckedChanged += new System.EventHandler(this.RbCheckedChanged); // this.rbSetWater.CheckedChanged += new System.EventHandler(this.RbCheckedChanged); myData.Changed += new EventHandler <DataBaseEventArgs> (_data_Changed); }
/// <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> /// расчет рецептуры /// </summary> /// <returns>результаты расчета</returns> internal void CalcRecept() { // инициализация this.myCalcProperty = new DataRawStruct(null); this.myCalcSumNetto = 0; this.myCalcSumSuhie = 0; // Потери текущего элемента. DataRawStruct prLoss; // расчет закладки по количеству и сухим веществам foreach (DataBase curRec in Components) { Decimal netto = 0; DataRawStruct curRaw = null; if (curRec is DataRecept) { // расчет вложенной рецептуры DataRecept introRec = (DataRecept)curRec; introRec.CalcRecept(); netto = introRec.CalcSumNetto; curRaw = introRec.CalcProperty; prLoss = new DataRawStruct(null); this.myCalcSumSuhie += introRec.CalcSumSuhie; } else { // Расчет компоненты DataRaw dr = (DataRaw)curRec; netto = dr.Quantity; curRaw = dr.RawStruct; // если элемент пустой, то пропускаем его if (curRaw == null) { continue; } if (dr.Brutto == 0 && netto != 0 && curRaw.Brutto != 0) { dr.Brutto = netto * curRaw.Brutto; } if (dr.Brutto != 0 && netto == 0 && curRaw.Brutto != 0) { netto = dr.Brutto / curRaw.Brutto; } // если не заданы потери, то создаем пустые (без потерь) if (dr.ProcessLoss != null) { prLoss = dr.ProcessLoss; } else { prLoss = new DataRawStruct(null); } // добавление сухих веществ this.myCalcSumSuhie += netto * (100 - curRaw.Water) * (100 - prLoss.Brutto) / 10000; } // расчет = сумма (количество, уменьшенное на потерю при термической обработке и умноженное на присутствие // исходные данные указаны в % (кроме веса и калорийности) this.myCalcSumNetto += netto * (100 - prLoss.Brutto) / 100; this.myCalcProperty.Water += curRaw.Water * netto * (100 - prLoss.Water) / 10000; this.myCalcProperty.Caloric += curRaw.Caloric * netto * (100 - prLoss.Caloric) / 10000; // калории на 100г., поэтому еще делим и на 100 this.myCalcProperty.starch += curRaw.starch * netto * (100 - prLoss.starch) / 10000; this.myCalcProperty.saccharides += curRaw.saccharides * netto * (100 - prLoss.saccharides) / 10000; this.myCalcProperty.cellulose += curRaw.cellulose * netto * (100 - prLoss.cellulose) / 10000; this.myCalcProperty.cholesterol += curRaw.cholesterol * netto * (100 - prLoss.cholesterol) / 10000; this.myCalcProperty.fat += curRaw.fat * netto * (100 - prLoss.fat) / 10000; this.myCalcProperty.acid += curRaw.acid * netto * (100 - prLoss.acid) / 10000; this.myCalcProperty.ash += curRaw.ash * netto * (100 - prLoss.ash) / 10000; this.myCalcProperty.MineralCA += curRaw.MineralCA * netto * (100 - prLoss.MineralCA) / 10000; this.myCalcProperty.MineralFE += curRaw.MineralFE * netto * (100 - prLoss.MineralFE) / 10000; this.myCalcProperty.MineralK += curRaw.MineralK * netto * (100 - prLoss.MineralK) / 10000; this.myCalcProperty.MineralMG += curRaw.MineralMG * netto * (100 - prLoss.MineralMG) / 10000; this.myCalcProperty.MineralNA += curRaw.MineralNA * netto * (100 - prLoss.MineralNA) / 10000; this.myCalcProperty.MineralP += curRaw.MineralP * netto * (100 - prLoss.MineralP) / 10000; this.myCalcProperty.protein += curRaw.protein * netto * (100 - prLoss.protein) / 10000; this.myCalcProperty.vitaminA += curRaw.vitaminA * netto * (100 - prLoss.vitaminA) / 10000; this.myCalcProperty.VitaminB += curRaw.VitaminB * netto * (100 - prLoss.VitaminB) / 10000; this.myCalcProperty.VitaminB1 += curRaw.VitaminB1 * netto * (100 - prLoss.VitaminB1) / 10000; this.myCalcProperty.VitaminB2 += curRaw.VitaminB2 * netto * (100 - prLoss.VitaminB2) / 10000; this.myCalcProperty.VitaminC += curRaw.VitaminC * netto * (100 - prLoss.VitaminC) / 10000; this.myCalcProperty.VitaminPP += curRaw.VitaminPP * netto * (100 - prLoss.VitaminPP) / 10000; } // Расчет по выходу if (myIsCalcExit && this.myTotalExit > 0) { if (this._totalLoss != null) { this.myCalcExitSuhie = this.myCalcSumSuhie * (100 - this._totalLoss.Quantity) / 100; } else { this.myCalcExitSuhie = this.myCalcSumSuhie; } this.myCalcExitNetto = this.myTotalExit; } else // расчет по воде if (myIsCalcWater && this.water > 0) { if (this._totalLoss != null) { this.myCalcExitSuhie = this.myCalcSumSuhie * (100 - this._totalLoss.Quantity) / 100; } else { this.myCalcExitSuhie = this.myCalcSumSuhie; } this.myCalcExitNetto = this.myCalcExitSuhie / (100 - this._water) * 100; } else // расчет воды по выходу и влажности if (myIsSetWater && this._water > 0 && this.myTotalExit > 0) { DataRawStruct waterRaw = Config.DP.GetRawByNum(Config.Cfg.WaterId); if (waterRaw == null) { throw new InvalidDataException("Не задана вода для расчета в рецептуре"); } if (this._totalLoss != null) { this.myCalcExitSuhie = this.myCalcSumSuhie * (100 - this._totalLoss.Quantity) / 100; } else { this.myCalcExitSuhie = this.myCalcSumSuhie; } this.myCalcExitNetto = this.myTotalExit; //decimal waterVal = this.myCalcExitSuhie / (100 - this._water) * 100 - this.myCalcExitNetto; throw new NotImplementedException("Дописать расчет воды по выходу и влажности"); } else { // Просто без расчета this.myCalcExitNetto = this.myCalcSumNetto; this.myCalcExitSuhie = this.myCalcSumSuhie; } if (this.myCalcExitNetto <= 0) { throw new OverflowException("Выход у рецептуры меньше или равен нулю"); } // пересчет значений в процентах this.myCalcProperty.Water /= this.myCalcExitNetto / 100; this.myCalcProperty.Caloric /= this.myCalcExitNetto / 100; this.myCalcProperty.starch /= this.myCalcExitNetto / 100; this.myCalcProperty.saccharides /= this.myCalcExitNetto / 100; this.myCalcProperty.cellulose /= this.myCalcExitNetto / 100; this.myCalcProperty.cholesterol /= this.myCalcExitNetto / 100; this.myCalcProperty.fat /= this.myCalcExitNetto / 100; this.myCalcProperty.acid /= this.myCalcExitNetto / 100; this.myCalcProperty.ash /= this.myCalcExitNetto / 100; this.myCalcProperty.MineralCA /= this.myCalcExitNetto / 100; this.myCalcProperty.MineralFE /= this.myCalcExitNetto / 100; this.myCalcProperty.MineralK /= this.myCalcExitNetto / 100; this.myCalcProperty.MineralMG /= this.myCalcExitNetto / 100; this.myCalcProperty.MineralNA /= this.myCalcExitNetto / 100; this.myCalcProperty.MineralP /= this.myCalcExitNetto / 100; this.myCalcProperty.protein /= this.myCalcExitNetto / 100; this.myCalcProperty.vitaminA /= this.myCalcExitNetto / 100; this.myCalcProperty.VitaminB /= this.myCalcExitNetto / 100; this.myCalcProperty.VitaminB1 /= this.myCalcExitNetto / 100; this.myCalcProperty.VitaminB2 /= this.myCalcExitNetto / 100; this.myCalcProperty.VitaminC /= this.myCalcExitNetto / 100; this.myCalcProperty.VitaminPP /= this.myCalcExitNetto / 100; }
/// <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); }
private void dgvRawList_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0 || e.ColumnIndex < 0) { return; } TreeGridNode curNode = dgvRawList.GetNodeForRow(e.RowIndex); object curValue = dgvRawList[e.ColumnIndex, e.RowIndex].Value; DataBase curRec = curNode.Tag as DataBase; bool isNew = curNode.Tag == null ? true : false; if (curValue == null && isNew) { return; } dgvRawList.CellValueChanged -= new DataGridViewCellEventHandler(dgvRawList_CellValueChanged); // родительский объект DataBase par = curRec == null ? myData : curRec.Parent; if (curRec == null && curNode.Parent != null && curNode.Parent.Index >= 0 && curNode.Parent.Tag != null) { par = curNode.Parent.Tag as DataBase; } // если это последняя строчка, то добавляем следующую пустую, а для этой делаем структуру if (isNew) { curRec = new DataRaw(par); } if (curRec is DataRecept) { DataRecept curRecept = (DataRecept)curRec; // изменение имени if (e.ColumnIndex == dgvRecName.Index && !curRecept.Name.Equals(curValue)) { if (curValue == null || curValue.ToString().Length == 0) { dgvRawList[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.Yellow; } else { curRecept.Name = curValue.ToString(); dgvRawList[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.LightGray; } } // изменение выхода if (e.ColumnIndex == dgvRecCountNetto.Index) { try { curRecept.TotalExit = Convert.ToDecimal(curValue, CultureInfo.CurrentCulture); dgvRawList[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.LightGray; } catch (System.Exception) { dgvRawList[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.Yellow; } } // обработка компоненты } else { DataRaw curData = (DataRaw)curRec; // изменение потерь if (e.ColumnIndex == dgvRecProcessLoss.Index) { curData.ProcessLoss = Config.DP.GetProcessLossByNum(Convert.ToInt32(curValue, CultureInfo.CurrentCulture)); } decimal brutto = 0; if (curData.RawStruct != null && curData.RawStruct.Brutto != 0) { brutto = curData.RawStruct.Brutto; } // изменение нетто if (e.ColumnIndex == dgvRecCountNetto.Index) { try { curData.Quantity = Convert.ToDecimal(curValue, CultureInfo.CurrentCulture); if (curData.Brutto == 0 && curData.Quantity != 0 && brutto != 0) { dgvRawList[dgvRecCountBrutto.Index, e.RowIndex].Value = CommonFunctions.Round(curData.Quantity * brutto); } dgvRawList[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.White; } catch (System.Exception) { dgvRawList[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.Yellow; } } // изменение брутто if (e.ColumnIndex == dgvRecCountBrutto.Index) { try { ((DataRaw)curData).Brutto = Convert.ToDecimal(curValue, CultureInfo.CurrentCulture); if (curData.Quantity == 0 && curData.Brutto != 0 && brutto != 0) { dgvRawList[dgvRecCountNetto.Index, e.RowIndex].Value = CommonFunctions.Round(((DataRaw)curData).Brutto / brutto); } dgvRawList[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.White; } catch (System.Exception) { dgvRawList[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.Yellow; } } // изменение коммента if (e.ColumnIndex == dgvRecComment.Index) { curData.Comment = Convert.ToString(dgvRawList[e.ColumnIndex, e.RowIndex].Value, CultureInfo.CurrentCulture); } } if (isNew) { par.Components.Add(curRec); } dgvRawList.CellValueChanged += new DataGridViewCellEventHandler(dgvRawList_CellValueChanged); }
internal void SelectTreeNode(DataRecept newRecept) { SelectTreeNode(newRecept, tvBook.Nodes); }
/// <summary> /// Создание технико-технологической карты /// </summary> /// <returns></returns> internal string PrintTTK(DataRecept curRec) { Hashtable groupRaws = curRec.GroupRaws(true); FormCounter cc = new FormCounter(); StringBuilder ret = new StringBuilder("<html><style>h3{text-align:center;}</style>"); try{ curRec.CalcRecept(); }catch (OverflowException ex) { ret.Append("<p align=center>Невозможно сосчитать рецептуру:" + ex.Message + ". Проверьте правильность заполнения</p></html>"); return(ret.ToString()); } // шапка ret.Append(makeHeader(true, true)); ret.Append("<p align=center><b><font size=4>ТЕХНИКО-ТЕХНОЛОГИЧЕСКАЯ КАРТА № " + curRec.Id.ToString(CultureInfo.CurrentCulture) + "</font><br><font size=5> на " + curRec.Name + "</font></b>"); if (!String.IsNullOrEmpty(curRec.normativDoc)) { ret.Append("<br>Изготовлено по " + curRec.normativDoc); } ret.Append("</p>"); // область применения ret.Append("<h3>" + cc.moveUp() + " Область применения</h3>" + "<p align=justify>" + cc.next() + " Настоящая технико-технологическая карта распространяется на изделие \"" + curRec.Name + "\", вырабатываемое " + DataBook.Book.company + "."); if (!String.IsNullOrEmpty(curRec.preview)) { ret.Append("<br>" + cc.next() + " Описание изделия. " + curRec.preview); } ret.Append("</p>"); // перечень сырья и гостов ret.Append("<h3>" + cc.moveUp() + " Перечень сырья</h3>"); StringBuilder curElem = new StringBuilder(); foreach (DataRawStruct curRaw in groupRaws.Keys) { if (String.IsNullOrEmpty(curRaw.NormativDoc) || !curRaw.InRecept) { continue; } curElem.Append("<tr><td><span>" + curRaw.Name + "</span><td><span>" + curRaw.NormativDoc + "</span></tr>"); } if (curElem.Length > 0) { ret.Append("<p align=justify>" + cc.next() + " Для приготовления \"" + curRec.Name + "\" используют следующее сырье: <table>"); ret.Append(curElem); ret.Append("</table>или продукты зарубежных фирм, имеющие сертификаты и удостоверения качества РФ.</p>"); } ret.Append("<p align=justify>" + cc.next() + " Сырье, используемое для приготовления \"" + curRec.Name + "\", должно соответствовать требованиям" + " нормативной документации, иметь сертификаты и удостоверения качества.</p>"); // рецептура ret.Append("<h3>" + cc.moveUp() + " Рецептура</h3><p align=justify>Рецептура изделия \"" + curRec.Name + "\"<table width=\"100%\" border><tr><td align=center> Наименование сырья <td align=center>Масса брутто, г<td align=center> Масса нетто, г</tr>"); decimal brSum = 0, ntSum = 0; // пробегаем по вложенным рецептурам foreach (DataBase dbase in curRec.Components) { if (dbase is DataRecept) { groupRaws = (dbase as DataRecept).GroupRaws(false); Decimal curbrSum = 0; Decimal curntSum = 0; foreach (DataRawStruct curRaw in groupRaws.Keys) { if (!curRaw.InRecept) { continue; } decimal brutto = (groupRaws[curRaw] as DataRaw).Brutto * Config.Cfg.TotalExit / curRec.CalcExitNetto; decimal netto = (groupRaws[curRaw] as DataRaw).Quantity * Config.Cfg.TotalExit / curRec.CalcExitNetto; ret.Append("<tr><td>" + curRaw.Name + "<td align=center>" + CommonFunctions.Round(brutto) + "<td align=center>" + CommonFunctions.Round(netto) + "</tr>"); curbrSum += brutto; curntSum += netto; } ret.Append("<tr style=\"background-color: #808080\"><td>Итого " + dbase.Name + "<td align=center>" + CommonFunctions.Round(curbrSum) + "<td align=center>" + CommonFunctions.Round(curntSum) + "</tr>"); brSum += curbrSum; ntSum += curntSum; } } // отстатки основной рецептуры groupRaws = curRec.GroupRaws(false); foreach (DataRawStruct curRaw in groupRaws.Keys) { if (!curRaw.InRecept) { continue; } decimal brutto = (groupRaws[curRaw] as DataRaw).Brutto * Config.Cfg.TotalExit / curRec.CalcExitNetto; decimal netto = (groupRaws[curRaw] as DataRaw).Quantity * Config.Cfg.TotalExit / curRec.CalcExitNetto; ret.Append("<tr><td>" + curRaw.Name + "<td align=center>" + CommonFunctions.Round(brutto) + "<td align=center>" + CommonFunctions.Round(netto) + "</tr>"); brSum += brutto; ntSum += netto; } ret.Append("<tr><td>Итого<td align=center>" + CommonFunctions.Round(brSum) + "<td align=center>" + CommonFunctions.Round(ntSum) + "</tr>"); ret.Append("<tr><td>Выход<td> <td align=center>" + CommonFunctions.Round(Config.Cfg.TotalExit) + "</tr>"); ret.Append("</table></p>"); // технологический процесс ret.Append("<h3>" + cc.moveUp() + " Технологический процесс</h3>"); ret.Append("<p align=justify> " + cc.next() + " Подготовка сырья к производству изделия \"" + curRec.Name + "\" производится в соответствии со \"Сборником рецептур блюд и кулинарных изделий для предприятий общественного питания\" (1996 г.).</p>"); if (!String.IsNullOrEmpty(curRec.process)) { ret.Append("<p align=justify> " + cc.next() + " " + curRec.process + "</p>"); } // оформление подача и т.д. if (!String.IsNullOrEmpty(curRec.design) || !String.IsNullOrEmpty(curRec.delivery) || !String.IsNullOrEmpty(curRec.sale) || !String.IsNullOrEmpty(curRec.storage)) { ret.Append("<h3>" + cc.moveUp() + " Оформление, подача, реализация и хранение</h3>"); if (!String.IsNullOrEmpty(curRec.design)) { ret.Append("<p align=justify> " + cc.next() + " " + curRec.design + "</p>"); } if (!String.IsNullOrEmpty(curRec.delivery)) { ret.Append("<p align=justify> " + cc.next() + " " + curRec.delivery + "</p>"); } if (!String.IsNullOrEmpty(curRec.sale)) { ret.Append("<p align=justify> " + cc.next() + " " + curRec.sale + "</p>"); } if (!String.IsNullOrEmpty(curRec.storage)) { ret.Append("<p align=justify> " + cc.next() + " " + curRec.storage + "</p>"); } } // физ-хим показатели ret.Append("<h3>" + cc.moveUp() + " Показатели качества и безопасности</h3>"); curElem = makeReceptProperty(curRec); if (curElem.Length > 0) { ret.Append("<p align=justify>" + cc.next() + " Органолептические показатели изделия:<br>"); ret.Append(curElem + "</p>"); } ret.Append("<p align=justify>" + cc.next() + " Физико-химические показатели:<br>"); if (curRec.CalcWater != 0) { string waterApp = ""; if (curRec.waterPlus == curRec.waterMinus) { if (curRec.waterPlus != 0) { waterApp = " ±" + curRec.waterPlus; } } else { waterApp = " +" + curRec.waterPlus + " -" + curRec.waterMinus; } ret.AppendLine("Влажность: " + CommonFunctions.Round(curRec.CalcWater) + "%" + waterApp + "<br>"); } if (curRec.Acidity != 0) { ret.AppendLine("Кислотность: " + CommonFunctions.Round(curRec.Acidity) + "Ph<br>"); } if (curRec.CalcProperty.starch != 0) { ret.AppendLine("Крахмал: " + CommonFunctions.Round(curRec.CalcProperty.starch) + "%<br>"); } if (curRec.CalcProperty.saccharides != 0) { ret.Append("Моно и дисахариды: " + CommonFunctions.Round(curRec.CalcProperty.saccharides) + "%<br>"); } if (curRec.CalcProperty.acid != 0) { ret.Append("Жирные кислоты: " + CommonFunctions.Round(curRec.CalcProperty.acid) + "%<br>"); } if (curRec.CalcProperty.ash != 0) { ret.Append("Зола: " + CommonFunctions.Round(curRec.CalcProperty.ash) + "%<br>"); } if (curRec.CalcProperty.cellulose != 0) { ret.Append("Целлюлоза: " + CommonFunctions.Round(curRec.CalcProperty.cellulose) + "%<br>"); } if (curRec.CalcProperty.cholesterol != 0) { ret.Append("Холестерин: " + CommonFunctions.Round(curRec.CalcProperty.cholesterol) + "%<br>"); } if (curRec.CalcProperty.protein != 0) { ret.Append("Протеины: " + CommonFunctions.Round(curRec.CalcProperty.protein) + "%<br>"); } // макроэлементы curElem = new StringBuilder(); if (curRec.CalcProperty.MineralK != 0) { curElem.Append("<li>Калий (K): " + CommonFunctions.Round(curRec.CalcProperty.MineralK)); } if (curRec.CalcProperty.MineralCA != 0) { curElem.Append("<li>Кальций (Ca): " + CommonFunctions.Round(curRec.CalcProperty.MineralCA)); } if (curRec.CalcProperty.MineralMG != 0) { curElem.Append("<li>Магний (Mg): " + CommonFunctions.Round(curRec.CalcProperty.MineralMG)); } if (curRec.CalcProperty.MineralNA != 0) { curElem.Append("<li>Натрий (Na): " + CommonFunctions.Round(curRec.CalcProperty.MineralNA)); } if (curRec.CalcProperty.MineralP != 0) { curElem.Append("<li>Фосфор (P): " + CommonFunctions.Round(curRec.CalcProperty.MineralP)); } if (curElem.Length > 0) { ret.Append("<div>Макроэлементы, мг<ul>"); ret.Append(curElem); ret.Append("</ul></div>"); } // микроэлементы curElem = new StringBuilder(); if (curRec.CalcProperty.MineralFE != 0) { curElem.Append("<li>Железо (Fe): " + CommonFunctions.Round(curRec.CalcProperty.MineralFE)); } if (curElem.Length > 0) { ret.Append("<div>Микроэлементы, мкг<ul>"); ret.Append(curElem); ret.Append("</ul></div>"); } // витамины curElem = new StringBuilder(); if (curRec.CalcProperty.vitaminA != 0) { curElem.Append("<li>Ретинол (А): " + CommonFunctions.Round(curRec.CalcProperty.vitaminA)); } if (curRec.CalcProperty.VitaminB != 0) { curElem.Append("<li>Бета-каротин (B): " + CommonFunctions.Round(curRec.CalcProperty.VitaminB)); } if (curRec.CalcProperty.VitaminB1 != 0) { curElem.Append("<li>Тиамин (B1): " + CommonFunctions.Round(curRec.CalcProperty.VitaminB1)); } if (curRec.CalcProperty.VitaminB2 != 0) { curElem.Append("<li>Рибофлавин (B2): " + CommonFunctions.Round(curRec.CalcProperty.VitaminB2)); } if (curRec.CalcProperty.VitaminC != 0) { curElem.Append("<li>Аскорбиновая кислота (C): " + CommonFunctions.Round(curRec.CalcProperty.VitaminC)); } if (curRec.CalcProperty.VitaminPP != 0) { curElem.Append("<li>Ниацин (PP): " + CommonFunctions.Round(curRec.CalcProperty.VitaminPP)); } if (curElem.Length > 0) { ret.Append("<div>Витамины<ul>"); ret.Append(curElem); ret.Append("</ul></div>"); } if (curRec.MicroBiology != null) { ret.Append("<p align=justify>" + cc.next() + " Микробиологические показатели:" + "</p>"); throw new NotImplementedException("Нарисовать табличку с микробиологией"); } ret.Append("<h3>" + cc.moveUp() + " Пищевая и энергетическая ценность</h3>"); ret.Append("<p><table width=\"100%\" border><tr><td align=\"center\"><span>Белки</span><td align=\"center\"><span>Жиры</span><td align=\"center\"><span>Углеводы</span><td align=\"center\"><span>Энергетическая ценность, ккал/кДж</span></tr>"); ret.Append("<tr><td align=\"center\"><span>" + CommonFunctions.Round((Decimal)curRec.CalcProperty.protein) + "</span>" + "<td align=\"center\"><span>" + CommonFunctions.Round((Decimal)curRec.CalcProperty.fat) + "</span>" + "<td align=\"center\"><span>" + CommonFunctions.Round((Decimal)(curRec.CalcProperty.saccharides + curRec.CalcProperty.starch)) + "</span>" + "<td align=\"center\"><span>" + CommonFunctions.Round((Decimal)curRec.CalcProperty.Caloric) + "/" + CommonFunctions.Round((Decimal)curRec.CalcProperty.Caloric * (Decimal)4.184) + "</span>" + "</tr></table></p>"); ret.Append(makeFooter()); // автозамены ReplaceSymbols(ret); return(ret.ToString()); }