private static string f_GetRecordValue(Cl_RecordValue cur, Cl_RecordValue last) { StringBuilder sBuild = new StringBuilder(); Cl_Element baseElement = cur.p_Element; if (baseElement.p_IsText) { if (baseElement.p_IsPartLocations) { if (Cl_EntityCompare.f_IsCompare(typeof(Array), cur.p_PartLocations, last.p_PartLocations) == false) { sBuild.AppendLine("Локация \"" + baseElement.p_Name + "\". " + f_GetRecordParamsValue(cur.p_PartLocations, last.p_PartLocations)); } } if (baseElement.p_IsTextFromCatalog) { if (Cl_EntityCompare.f_IsCompare(typeof(Array), cur.p_ValuesCatalog, last.p_ValuesCatalog) == false) { sBuild.AppendLine("Локация \"" + baseElement.p_Name + "\". " + f_GetRecordParamsValue(cur.p_ValuesCatalog, last.p_ValuesCatalog)); } if (baseElement.p_Symmetrical && Cl_EntityCompare.f_IsCompare(typeof(Array), last.p_ValuesDopCatalog, cur.p_ValuesDopCatalog) == false) { sBuild.AppendLine("Локация \"" + baseElement.p_Name + "\". " + f_GetRecordParamsValue(cur.p_ValuesDopCatalog, last.p_ValuesDopCatalog)); } } else { if (Cl_EntityCompare.f_IsCompare(typeof(String), last.p_ValueUser, cur.p_ValueUser) == false) { sBuild.AppendLine("Значение \"" + baseElement.p_Name + "\"" + (baseElement.p_Symmetrical ? " (" + baseElement.p_SymmetryParamLeft + ")" : "") + ". " + "Старое значение: \"" + last.p_ValueUser + "\". Новое значение: \"" + cur.p_ValueUser + "\""); } if (baseElement.p_Symmetrical && Cl_EntityCompare.f_IsCompare(typeof(String), last.p_ValueDopUser, cur.p_ValueDopUser) == false) { sBuild.AppendLine("Значение \"" + baseElement.p_Name + "\"" + (baseElement.p_Symmetrical ? " (" + baseElement.p_SymmetryParamRight + ")" : "") + ". " + "Старое значение: \"" + last.p_ValueDopUser + "\". Новое значение: \"" + cur.p_ValueDopUser + "\""); } } } else if (baseElement.p_IsImage) { sBuild.Append("Картинка \"" + baseElement.p_Name + "\" изменилась"); } else { throw new NotImplementedException(); } return(sBuild.ToString().Trim()); }
/// <summary>Инициализация пользовательских контролов</summary> private void f_AddControlsTemplate(Cl_Template a_Template, ControlCollection a_Controls = null) { if (m_Record != null && a_Template != null) { if (a_Template.p_TemplateElements == null) { var cTe = Cl_App.m_DataContext.Entry(a_Template).Collection(g => g.p_TemplateElements).Query().Include(te => te.p_ChildElement).Include(te => te.p_ChildElement.p_Default).Include(te => te.p_ChildElement.p_ParamsValues).Include(te => te.p_ChildElement.p_PartAgeNorms).Include(te => te.p_ChildTemplate); cTe.Load(); } if (a_Template.p_TemplateElements != null && a_Template.p_TemplateElements.Count > 0) { int top = 0; ControlCollection controls = null; if (a_Controls != null) { controls = a_Controls; } else { controls = ctrlContent.Controls; } foreach (var te in a_Template.p_TemplateElements) { if (te.p_ChildElement != null) { var ctrlEl = new Ctrl_Element(); ctrlEl.p_Element = te.p_ChildElement; ctrlEl.e_ValueChanged += CtrlEl_e_ValueChanged; Cl_RecordValue recval = m_Record.p_Values.FirstOrDefault(v => v.p_ElementID == te.p_ChildElement.p_ID); if (recval == null) { recval = new Cl_RecordValue(); recval.p_ElementID = ctrlEl.p_Element.p_ID; recval.p_Element = ctrlEl.p_Element; recval.p_RecordID = m_Record.p_ID; recval.p_Record = m_Record; } if (controls is TableLayoutControlCollection && controls.Owner is TableLayoutPanel) { var table = (TableLayoutPanel)controls.Owner; table.RowCount++; table.RowStyles.Add(new RowStyle(SizeType.AutoSize)); ctrlEl.f_SetRecordElementValues(recval, table, table.RowCount - 1); } else { ctrlEl.f_SetRecordElementValues(recval); controls.Add(ctrlEl); } ctrlEl.Top = top; ctrlEl.Left = m_PaddingX; top += ctrlEl.Height + m_PaddingY; m_Elements.Add(ctrlEl); } else if (te.p_ChildTemplate != null) { if (te.p_ChildTemplate.p_Type == Cl_Template.E_TemplateType.Block) { var ctrlGroup = new GroupBox(); ctrlGroup.Text = te.p_ChildTemplate.p_Name; ctrlGroup.AutoSize = true; ctrlGroup.Top = top; FlowLayoutPanel panel = new FlowLayoutPanel(); panel.Top = 20; panel.Left = 3; panel.WrapContents = false; panel.AutoSize = true; panel.FlowDirection = FlowDirection.TopDown; ctrlGroup.Controls.Add(panel); controls.Add(ctrlGroup); f_AddControlsTemplate(te.p_ChildTemplate, panel.Controls); top += ctrlGroup.Height + m_PaddingY; } else if (te.p_ChildTemplate.p_Type == Cl_Template.E_TemplateType.Table) { var ctrlTable = f_GetControlTable(); ctrlTable.AutoSize = true; top += 10; ctrlTable.Top = top; ctrlTable.CellBorderStyle = TableLayoutPanelCellBorderStyle.InsetDouble; ctrlTable.RowCount = 1; ctrlTable.Controls.Add(new Label() { Text = "Показатель", TextAlign = System.Drawing.ContentAlignment.MiddleLeft }, 0, 0); //ctrlTable.Controls.Add(new Label() { Text = "Локация", TextAlign = System.Drawing.ContentAlignment.MiddleLeft }, 1, 0); ctrlTable.Controls.Add(new Label() { Text = "Значение", TextAlign = System.Drawing.ContentAlignment.MiddleLeft }, 1, 0); ctrlTable.Controls.Add(new Label() { Text = "Ед. изм.", TextAlign = System.Drawing.ContentAlignment.MiddleLeft }, 2, 0); ctrlTable.Controls.Add(new Label() { Text = "Нормa", TextAlign = System.Drawing.ContentAlignment.MiddleLeft }, 3, 0); controls.Add(ctrlTable); f_AddControlsTemplate(te.p_ChildTemplate, ctrlTable.Controls); top += ctrlTable.Height + m_PaddingY; } } } } } }