public void f_SetRecord(Cl_Record a_Record) { m_Record = a_Record; if (m_Record != null) { if (m_Record.p_MedicalCard != null) { ctrlPatientFIO.Text = string.Format("{0}, {1}, {2} ({3})", m_Record.p_MedicalCard.p_PatientFIO, m_Record.p_MedicalCard.p_PatientSex == Core.Permision.Cl_User.E_Sex.Man ? "М" : m_Record.p_MedicalCard.p_PatientSex == Core.Permision.Cl_User.E_Sex.Female ? "Ж" : "Нет данных", m_Record.p_MedicalCard.p_PatientDateBirth.ToShortDateString(), m_Record.p_MedicalCard.f_GetPatientAgeByMonthText(m_Record.p_DateCreate)); ctrlTitle.Text = m_Record.p_Title; if (m_Record.p_DateReception.Year >= 1980) { ctrlDTPDateReception.Value = m_Record.p_DateReception; ctrlDTPTimeReception.Value = m_Record.p_DateReception; } else { ctrlDTPDateReception.Value = DateTime.Now; ctrlDTPTimeReception.Value = DateTime.Now; } if (m_Record.p_Version == 0) { ctrl_Version.Text = "Черновик"; } else { ctrl_Version.Text = m_Record.p_Version.ToString(); } } if (m_Record.p_Template != null) { try { Cl_TemplatesFacade.f_GetInstance().f_LoadTemplatesElements(m_Record.p_Template); Text = string.Format("Запись \"{0}\" v{1}", m_Record.p_Template.p_Name, ConfigurationManager.AppSettings["Version"]); f_UpdateControls(); } catch (Exception er) { MonitoringStub.Error("Error_Editor", "Не удалось установить запись", er, null, null); } } else if (m_Record.p_Type == E_RecordType.FinishedFile) { try { Text = string.Format("Запись c готовым файлом v{0}", ConfigurationManager.AppSettings["Version"]); f_UpdateControls(); } catch (Exception er) { MonitoringStub.Error("Error_Editor", "Не удалось установить запись", er, null, null); } } m_Log.f_SetEntity(m_Record); } }
private void Ctrl_ElementNew_Click(object sender, EventArgs e) { using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction()) { try { Cl_EntityLog eLog = new Cl_EntityLog(); Cl_Element newElement = (Cl_Element)Activator.CreateInstance(typeof(Cl_Element)); eLog.f_SetEntity(newElement); Cl_Group group = null; if (p_SelectedGroup != null && p_SelectedGroup.p_Group != null) { group = p_SelectedGroup.p_Group; } Dlg_EditorElement dlg = new Dlg_EditorElement(); dlg.Text = "Новый элемент"; if (group != null) { newElement.p_ParentGroup = p_SelectedGroup.p_Group; dlg.ctrl_LGroupValue.Text = p_SelectedGroup.p_Group.p_Name; } if (dlg.ShowDialog() != DialogResult.OK) { return; } newElement.p_Name = dlg.ctrl_TBName.Text; newElement.p_Comment = dlg.ctrl_TBDecs.Text; newElement.p_ElementType = (Cl_Element.E_ElementsTypes)dlg.ctrl_CB_ControlType.f_GetSelectedItem(); newElement.p_IsPartPre = true; if (dlg.ctrl_TBName.Text.Length > 0) { newElement.p_PartPre = dlg.ctrl_TBName.Text[0].ToString().ToUpper(); if (dlg.ctrl_TBName.Text.Length > 1) { newElement.p_PartPre += dlg.ctrl_TBName.Text.Substring(1, dlg.ctrl_TBName.Text.Length - 1); } } newElement.p_SymmetryParamLeft = "Слева"; newElement.p_SymmetryParamRight = "Справа"; Cl_App.m_DataContext.p_Elements.Add(newElement); Cl_App.m_DataContext.SaveChanges(); newElement.p_ElementID = newElement.p_ID; Cl_App.m_DataContext.SaveChanges(); eLog.f_SaveEntity(newElement); transaction.Commit(); Ctrl_TreeNodeElement newNode = new Ctrl_TreeNodeElement(group, newElement); SelectedNode.Nodes.Add(newNode); SelectedNode = newNode; e_AfterCreateElement?.Invoke(this, new TreeViewEventArgs(newNode)); } catch (Exception ex) { transaction.Rollback(); MonitoringStub.Error("Error_Tree", "При создании нового элемента произошла ошибка", ex, null, null); return; } } }
private void Ctrl_ElementDelete_Click(object sender, EventArgs e) { if (p_SelectedElement == null && p_SelectedElement.p_Element == null) { return; } if (MessageBox.Show($"Удалить элемент \"{p_SelectedElement.p_Element.p_Name}\"?", "Удаление элемента", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction()) { try { Cl_EntityLog eLog = new Cl_EntityLog(); var els = Cl_App.m_DataContext.p_Elements.Where(el => el.p_ElementID == p_SelectedElement.p_Element.p_ElementID).OrderByDescending(v => v.p_Version); if (els != null) { Cl_Element lastVersion = els.FirstOrDefault(); eLog.f_SetEntity(lastVersion); bool isChange = false; foreach (Cl_Element el in els) { el.p_IsDelete = true; isChange = true; } if (isChange) { Cl_App.m_DataContext.SaveChanges(); eLog.f_SaveEntity(lastVersion); transaction.Commit(); if (!p_IsShowDeleted) { SelectedNode.Remove(); } else { p_SelectedElement.p_Element = p_SelectedElement.p_Element; } } } else { MonitoringStub.Error("Error_Tree", "Не найдена элемент", new Exception("EX ERROR"), "p_SelectedElement.p_Element.p_ElementID = " + p_SelectedElement.p_Element.p_ElementID, null); } } catch (Exception ex) { transaction.Rollback(); MonitoringStub.Error("Error_Tree", "При удалении элемента произошла ошибка", ex, null, null); return; } } }
private void Ctrl_ImageNew_Click(object sender, EventArgs e) { using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction()) { try { Cl_EntityLog eLog = new Cl_EntityLog(); Cl_Element newElement = (Cl_Element)Activator.CreateInstance(typeof(Cl_Element)); eLog.f_SetEntity(newElement); Cl_Group group = null; if (p_SelectedGroup != null && p_SelectedGroup.p_Group != null) { group = p_SelectedGroup.p_Group; } Dlg_EditorImage dlg = new Dlg_EditorImage(); dlg.Text = "Новый рисунок"; if (group != null) { newElement.p_ParentGroup = p_SelectedGroup.p_Group; dlg.ctrl_LGroupValue.Text = p_SelectedGroup.p_Group.p_Name; } if (dlg.ShowDialog() != DialogResult.OK) { return; } newElement.p_Name = dlg.ctrl_TBName.Text; newElement.p_Comment = dlg.ctrl_TBDecs.Text; newElement.p_ElementType = Cl_Element.E_ElementsTypes.Image; Cl_App.m_DataContext.p_Elements.Add(newElement); Cl_App.m_DataContext.SaveChanges(); newElement.p_ElementID = newElement.p_ID; Cl_App.m_DataContext.SaveChanges(); eLog.f_SaveEntity(newElement); transaction.Commit(); Ctrl_TreeNodeElement newNode = new Ctrl_TreeNodeElement(group, newElement); SelectedNode.Nodes.Add(newNode); SelectedNode = newNode; e_AfterCreateElement?.Invoke(this, new TreeViewEventArgs(newNode)); } catch (Exception ex) { transaction.Rollback(); MonitoringStub.Error("Error_Tree", "При создании нового элемента произошла ошибка", ex, null, null); return; } } }
protected override void f_TreeView_DragDrop(object sender, DragEventArgs e, Ctrl_TreeNodeGroup a_TargetNodeGroup) { if (a_TargetNodeGroup != null) { using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction()) { try { Ctrl_TreeNodeElement draggedNodeElement = (Ctrl_TreeNodeElement)e.Data.GetData(typeof(Ctrl_TreeNodeElement)); if (e.Effect == DragDropEffects.Move) { Cl_EntityLog eLog = new Cl_EntityLog(); eLog.f_SetEntity(draggedNodeElement.p_Element); var elsDraggeds = Cl_App.m_DataContext.p_Elements.Where(el => el.p_ElementID == draggedNodeElement.p_Element.p_ElementID); if (elsDraggeds != null) { bool isChange = false; foreach (Cl_Element el in elsDraggeds) { //el.p_ParentGroupID = a_TargetNodeGroup.p_Group.p_ID; el.p_ParentGroup = a_TargetNodeGroup.p_Group; isChange = true; } if (isChange) { Cl_App.m_DataContext.SaveChanges(); eLog.f_SaveEntity(draggedNodeElement.p_Element); transaction.Commit(); draggedNodeElement.Remove(); a_TargetNodeGroup.Nodes.Insert(f_GetFirstGroupInNode(a_TargetNodeGroup.Nodes), draggedNodeElement); } } else { MonitoringStub.Error("Error_Tree", "Не найдена элемент для шаблонов", new Exception("EX ERROR"), "elsDraggeds = null", null); } } } catch (Exception ex) { transaction.Rollback(); MonitoringStub.Error("Error_Tree", "При перемещении элемента произошла ошибка", ex, null, null); return; } } } }
public void f_SetRecordPattern(Cl_RecordPattern a_RecordPattern) { m_RecordPattern = a_RecordPattern; if (m_RecordPattern != null && m_RecordPattern.p_Template != null) { try { Cl_TemplatesFacade.f_GetInstance().f_LoadTemplatesElements(m_RecordPattern.p_Template); ctrlDoctorFIO.Text = m_RecordPattern.p_DoctorFIO; ctrlName.Text = m_RecordPattern.p_Name; Text = string.Format("Паттерн записей по шаблону \"{0}\" v{1}", m_RecordPattern.p_Template.p_Name, ConfigurationManager.AppSettings["Version"]); m_Record = Cl_RecordsFacade.f_GetInstance().f_GetNewRecord(m_RecordPattern); f_UpdateControls(); m_Log.f_SetEntity(m_Record); } catch (Exception er) { MonitoringStub.Error("Error_Editor", "Не удалось установить паттерн записей по шаблону", er, null, null); } } }
public void f_SetTemplate(Cl_Template a_Template) { if (a_Template == null) { return; } p_EditingTemplate = a_Template; if (p_EditingTemplate.p_Version == 0) { ctrl_Version.Text = "Черновик"; } else { ctrl_Version.Text = p_EditingTemplate.p_Version.ToString(); } Cl_TemplatesFacade.f_GetInstance().f_LoadTemplatesElements(a_Template); m_Log.f_SetEntity(a_Template); if (a_Template.p_TemplateElements != null) { ctrl_EditorPanel.f_SetTemplatesElements(a_Template.p_TemplateElements.ToArray()); } }
public void f_SetElement(Cl_Element a_Element) { m_Log.f_SetEntity(a_Element); if (a_Element == null || !a_Element.f_IsImage()) { return; } p_EditingElement = a_Element; if (p_EditingElement.p_Version == 0) { ctrl_Version.Text = "Черновик"; } else { ctrl_Version.Text = p_EditingElement.p_Version.ToString(); } ctrl_Name.Text = p_EditingElement.p_Name; ctrlTag.Text = p_EditingElement.p_Tag; ctrlImage.Image = p_EditingElement.p_Image; ctrl_Hint.Text = p_EditingElement.p_Help; ctrl_Note.Text = p_EditingElement.p_Comment; }
public void f_SetElement(Cl_Element a_Element) { if (a_Element == null || !a_Element.f_IsText()) { return; } m_Log.f_SetEntity(a_Element); p_EditingElement = a_Element; if (p_EditingElement.p_Version == 0) { ctrl_Version.Text = "Черновик"; } else { ctrl_Version.Text = p_EditingElement.p_Version.ToString(); } ctrl_ControlType.f_SetSelectedItem(p_EditingElement.p_ElementType); ctrl_Name.Text = p_EditingElement.p_Name; ctrlTag.Text = p_EditingElement.p_Tag; ctrl_Hint.Text = p_EditingElement.p_Help; ctrl_IsPartPre.Checked = ctrl_PartPreValue.Enabled = p_EditingElement.p_IsPartPre; ctrl_PartPreValue.Text = p_EditingElement.p_PartPre; ctrl_IsPartPost.Checked = ctrl_PartPostValue.Enabled = p_EditingElement.p_IsPartPost; ctrl_PartPostValue.Text = p_EditingElement.p_PartPost; ctrl_IsPartLocations.Checked = ctrl_PartLocationsValue.Enabled = ctrl_IsPartLocationsMulti.Enabled = p_EditingElement.p_IsPartLocations; ctrl_IsPartLocationsMulti.Checked = p_EditingElement.p_IsPartLocationsMulti; ctrl_IsPartNorm.Checked = ctrl_PartNormValue.Enabled = p_EditingElement.p_IsPartNorm; ctrl_PartNormValue.Text = p_EditingElement.p_PartNorm.ToString(); ctrl_IsPartNormRange.Checked = ctrl_TPartNormRangeValues.Enabled = p_EditingElement.p_IsPartNormRange; List <Cl_AgeNorm> ageNorms = Cl_App.m_DataContext.p_AgeNorms.Where(n => n.p_ElementID == a_Element.p_ID).ToList(); DataTable dt = new DataTable(); foreach (DataGridViewColumn col in ctrl_TPartNormRangeValues.Columns) { dt.Columns.Add(col.Name); col.DataPropertyName = col.Name; } ; foreach (var norm in ageNorms) { var row = dt.NewRow(); row["p_AgeFrom"] = norm.p_AgeFrom; row["p_AgeTo"] = norm.p_AgeTo; row["p_MaleMin"] = Math.Round(norm.p_MaleMin, p_EditingElement.p_NumberRound); row["p_MaleMax"] = Math.Round(norm.p_MaleMax, p_EditingElement.p_NumberRound); row["p_FemaleMin"] = Math.Round(norm.p_FemaleMin, p_EditingElement.p_NumberRound); row["p_FemaleMax"] = Math.Round(norm.p_FemaleMax, p_EditingElement.p_NumberRound); dt.Rows.Add(row); } ctrl_TPartNormRangeValues.DataSource = dt; ctrl_IsChangeNotNormValues.Checked = p_EditingElement.p_IsChangeNotNormValues; ctrl_IsVisible.Checked = p_EditingElement.p_Visible; ctrl_IsVisiblePatient.Checked = p_EditingElement.p_VisiblePatient; ctrl_IsRequiredFIeld.Checked = p_EditingElement.p_Required; ctrl_IsEditing.Checked = p_EditingElement.p_Editing; ctrl_IsMultiSelect.Checked = p_EditingElement.p_IsMultiSelect; ctrl_SymmetryVals.Visible = ctrl_IsSymmentry.Checked = p_EditingElement.p_Symmetrical; ctrl_Symmetry1.Text = p_EditingElement.p_SymmetryParamLeft; ctrl_Symmetry2.Text = p_EditingElement.p_SymmetryParamRight; ctrl_NumberParams.Visible = ctrl_IsNumber.Checked = p_EditingElement.p_IsNumber; ctrl_NumberRound.Value = p_EditingElement.p_NumberRound; ctrl_NumberFormula.Text = p_EditingElement.p_NumberFormula; ctrl_VisibilityFormula.Text = p_EditingElement.p_VisibilityFormula; ctrl_Note.Text = p_EditingElement.p_Comment; ctrl_PartLocationsValue.Text = string.Join("\n", p_EditingElement.p_PartLocations.ToList()); ctrl_NormValues.Text = string.Join("\n", p_EditingElement.p_NormValues.ToList()); ctrl_PatValues.Text = string.Join("\n", p_EditingElement.p_PatValues.ToList()); if (p_EditingElement.p_Default != null) { ctrl_Default.SelectedIndex = ctrl_Default.Items.IndexOf(p_EditingElement.p_Default.p_Value); } f_UpdateModeTextType((E_TextTypes)ctrl_ControlType.f_GetSelectedItem()); }
private void ctrl_TemplateDelete_Click(object sender, EventArgs e) { if (p_SelectedTemplate == null && p_SelectedTemplate.p_Template == null) { return; } string typeName = "шаблон"; string typeNameR = "шаблона"; if (p_SelectedTemplate.p_Template.p_Type == Cl_Template.E_TemplateType.Block) { typeName = "блок"; typeNameR = "блока"; } else if (p_SelectedTemplate.p_Template.p_Type == Cl_Template.E_TemplateType.Table) { typeName = "таблицу"; typeNameR = "таблицы"; } if (MessageBox.Show($"Удалить \"{typeName} {p_SelectedTemplate.p_Template.p_Name}\"?", $"Удаление {typeNameR}", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction()) { try { Cl_EntityLog eLog = new Cl_EntityLog(); var els = Cl_App.m_DataContext.p_Templates.Where(el => el.p_TemplateID == p_SelectedTemplate.p_Template.p_TemplateID).OrderByDescending(v => v.p_Version); if (els != null) { Cl_Template lastVersion = els.FirstOrDefault(); eLog.f_SetEntity(lastVersion); bool isChange = false; foreach (Cl_Template el in els) { el.p_IsDelete = true; isChange = true; } if (isChange) { Cl_App.m_DataContext.SaveChanges(); eLog.f_SaveEntity(lastVersion); transaction.Commit(); SelectedNode.Remove(); } } else { MonitoringStub.Error("Error_Tree", "Не найдена шаблон", new Exception("EX ERROR"), "p_SelectedTemplate.p_Template.p_TemplateID = " + p_SelectedTemplate.p_Template.p_TemplateID, null); } } catch (Exception ex) { transaction.Rollback(); MonitoringStub.Error("Error_Tree", "При удалении шаблона произошла ошибка", ex, null, null); return; } } }
private void f_TemplateNew(Cl_Template.E_TemplateType a_TemplateType) { using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction()) { try { Cl_EntityLog eLog = new Cl_EntityLog(); Cl_Template newTemplate = (Cl_Template)Activator.CreateInstance(typeof(Cl_Template)); eLog.f_SetEntity(newTemplate); Cl_Group group = null; if (p_SelectedGroup != null && p_SelectedGroup.p_Group != null) { group = p_SelectedGroup.p_Group; } Dlg_EditorTemplate dlg = new Dlg_EditorTemplate(); dlg.ctrlPCategories.Enabled = a_TemplateType == Cl_Template.E_TemplateType.Template; if (a_TemplateType == Cl_Template.E_TemplateType.Template) { dlg.Text = "Новый шаблон"; } else if (a_TemplateType == Cl_Template.E_TemplateType.Block) { dlg.Text = "Новый блок"; } else if (a_TemplateType == Cl_Template.E_TemplateType.Table) { dlg.Text = "Новая таблица"; } if (group != null) { newTemplate.p_ParentGroup = p_SelectedGroup.p_Group; dlg.ctrl_LGroupValue.Text = p_SelectedGroup.p_Group.p_Name; } if (dlg.ShowDialog() != DialogResult.OK) { return; } newTemplate.p_Name = dlg.ctrl_TBName.Text; newTemplate.p_Title = dlg.ctrlTitle.Text; newTemplate.p_Type = a_TemplateType; if (a_TemplateType == Cl_Template.E_TemplateType.Template) { var catTotal = (Cl_Category)dlg.ctrlCategoriesTotal.SelectedItem; newTemplate.p_CategoryTotalID = catTotal.p_ID; newTemplate.p_CategoryTotal = catTotal; var catClinic = (Cl_Category)dlg.ctrlCategoriesClinic.SelectedItem; newTemplate.p_CategoryClinicID = catClinic.p_ID; newTemplate.p_CategoryClinic = catClinic; } Cl_App.m_DataContext.p_Templates.Add(newTemplate); Cl_App.m_DataContext.SaveChanges(); newTemplate.p_TemplateID = newTemplate.p_ID; Cl_App.m_DataContext.SaveChanges(); eLog.f_SaveEntity(newTemplate); transaction.Commit(); SelectedNode.Nodes.Add(new Ctrl_TreeNodeTemplate(group, newTemplate)); } catch (Exception ex) { transaction.Rollback(); MonitoringStub.Error("Error_Tree", "При создании нового шаблона произошла ошибка", ex, null, null); return; } } }