private void f_SyncBMK() { if (m_SelectedRecord != null) { if (!m_SelectedRecord.p_IsSyncBMK) { using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction()) { try { m_SelectedRecord.p_DateSyncBMK = DateTime.Now; Cl_App.m_DataContext.SaveChanges(); Cl_EntityLog.f_CustomMessageLog(m_SelectedRecord, "Синхронизация записи с БМК"); transaction.Commit(); ctrlBReportSyncBMK.Visible = ctrlMISyncBMK.Visible = false; } catch { m_SelectedRecord.p_DateSyncBMK = null; transaction.Rollback(); MonitoringStub.Error("Error_Tree", "Не удалось синхронизировать запись с БМК", null, null, null); } } } } }
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 ctrlBSave_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(ctrlName.Text)) { MonitoringStub.Message("Заполните поле \"Название\"!"); return; } if (m_ControlTemplate != null) { using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction()) { try { var record = m_ControlTemplate.f_GetNewRecord(false); if (record != null) { if (m_SourceRecord == null && m_Log.f_IsChanged(record) == false) { MonitoringStub.Message("Паттерн не изменялся!"); transaction.Rollback(); return; } var recordPattern = Cl_RecordsFacade.f_GetInstance().f_GetNewRecordPattern(ctrlName.Text, record); if (recordPattern != null) { Cl_App.m_DataContext.p_RecordsPatterns.Add(recordPattern); Cl_App.m_DataContext.SaveChanges(); if (m_SourceRecord == null) { Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.RecordsPatterns, string.Format("Создан новый патерн \"{0}\" по шаблону \"{1}\"", recordPattern.p_Name, recordPattern.p_Template.p_Name), recordPattern.p_Template.p_TemplateID); } else { Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.RecordsPatterns, string.Format("Сформирован патерн по записи \"{0}\"", m_SourceRecord.p_Title), m_SourceRecord.p_RecordID); } transaction.Commit(); f_SetRecordPattern(recordPattern); e_Save?.Invoke(this, new EventArgs()); } else { transaction.Rollback(); return; } } else { return; } } catch (Exception ex) { transaction.Rollback(); MonitoringStub.Error("Error_Editor", "При сохранении изменений паттерна записей произошла ошибка", ex, null, null); } } } }
private void ctrlBReportAddRecord_Click(object sender, System.EventArgs e) { var dlg = new Dlg_RecordSelectSource(); if (dlg.ShowDialog(this) == DialogResult.OK) { try { if (dlg.p_SelectedTemplate != null) { Cl_Record record = new Cl_Record(); record.p_DateCreate = DateTime.Now; record.p_DateLastChange = record.p_DateCreate; record.f_SetTemplate(dlg.p_SelectedTemplate); record.p_MedicalCard = Cl_SessionFacade.f_GetInstance().p_MedicalCard; record.p_MedicalCardID = record.p_MedicalCard.p_ID; record.p_ClinicName = Cl_SessionFacade.f_GetInstance().p_Doctor.p_ClinicName; record.f_SetDoctor(Cl_SessionFacade.f_GetInstance().p_Doctor); var dlgRecord = new Dlg_Record(); dlgRecord.e_Save += DlgRecord_e_Save; dlgRecord.p_Record = record; Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.UIEvents, string.Format("Создание новой записи. Шаблон {0}", record.p_Template.p_Name)); dlgRecord.ShowDialog(this); } } catch (Exception er) { MonitoringStub.Error("Error_Editor", "Не удалось добавить запись", er, null, null); } } }
public F_Main(string[] args) { try { this.FormClosing += F_Main_FormClosing; Tag = string.Format("Мегашаблон v{0}", ConfigurationManager.AppSettings["Version"]); if (Cl_App.Initialize()) { if (f_InitSession(args)) { Cl_SessionFacade sess = Cl_SessionFacade.f_GetInstance(); Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.AppEvents, string.Format("Запуск ЭМК. Пользователь: {0}/({1}). Пациент: {2}/({3})", sess.p_Doctor.f_GetInitials(), sess.p_Doctor.p_UserID, sess.p_Patient.f_GetInitials(), sess.p_Patient.p_UserID)); this.Font = new System.Drawing.Font(ConfigurationManager.AppSettings["FontFamily"], float.Parse(ConfigurationManager.AppSettings["FontSize"]), (System.Drawing.FontStyle) int.Parse(ConfigurationManager.AppSettings["FontStyle"]), System.Drawing.GraphicsUnit.Point, ((byte)(204))); InitializeComponent(); string rolesVal = ""; var role = Cl_SessionFacade.f_GetInstance().p_Doctor.p_Permission.p_Role; var memInfo = typeof(E_Roles).GetMember(typeof(E_Roles).GetEnumName(role)); var descriptionAttributes = memInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false); if (descriptionAttributes.Length > 0) { rolesVal = ((DescriptionAttribute)descriptionAttributes[0]).Description; } ctrlSessionInfo.Text = string.Format("Пользователь: {0}, {1} | Расположение: {2}", Cl_SessionFacade.f_GetInstance().p_Doctor.p_FIO, rolesVal, Cl_SessionFacade.f_GetInstance().p_Doctor.p_ClinicName); p_PanelManager = new UI_PanelManager(ctrl_CustomControls); bool visibleEditor = false; visibleEditor |= menuMegaTemplate.Visible = Cl_SessionFacade.f_GetInstance().p_Doctor.p_Permission.p_IsEditMegaTemplates; visibleEditor |= menuTemplate.Visible = Cl_SessionFacade.f_GetInstance().p_Doctor.p_Permission.p_IsEditTemplates; visibleEditor |= menuMegaTemplateDeleted.Visible = Cl_SessionFacade.f_GetInstance().p_Doctor.p_Permission.p_IsShowDeleted; visibleEditor |= menuCatalogs.Visible = Cl_SessionFacade.f_GetInstance().p_Doctor.p_Permission.p_IsEditCatalogs; visibleEditor |= menuPatterns.Visible = Cl_SessionFacade.f_GetInstance().p_Doctor.p_Permission.p_IsEditAllRecords || Cl_SessionFacade.f_GetInstance().p_Doctor.p_Permission.p_IsEditSelfRecords; ctrlMIEditor.Visible = visibleEditor; ctrlMISettingsPrint.Checked = Cl_SessionFacade.f_GetInstance().p_SettingsPrintWithParams; f_SetControl <UC_Records>(); } else { Application.Exit(); } } else { Application.Exit(); } } catch (Exception er) { MonitoringStub.Error("Error_App", "В приложении возникла ошибка", er, null, null); } }
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 f_Rating() { if (m_SelectedRecord != null) { Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.UIEvents, string.Format("Экспертиза записи: {0}, дата записи: {1}, клиника: {2}", m_SelectedRecord.p_Title, m_SelectedRecord.p_DateCreate, m_SelectedRecord.p_ClinicName), m_SelectedRecord.p_RecordID); Dlg_RatingViewer viewer = new Dlg_RatingViewer(); viewer.f_LoadRating(m_SelectedRecord); viewer.ShowDialog(this); Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.UIEvents, "Выход из экспертизы", m_SelectedRecord.p_RecordID); } }
private void ctrl_BSave_Click(object sender, EventArgs e) { Cl_Element el = p_EditPanel.f_ConfirmChanges() as Cl_Element; if (el != null) { Cl_EntityLog.f_CustomMessageLog(p_EditableElement.p_Element, "Нажата кнопка \"Сохранить\""); m_EditableElement.p_Element = el; p_IsReadOnly = true; } }
private void f_PrintPatient() { if (m_SelectedRecord != null) { if (m_SelectedRecord.p_FileType == E_RecordFileType.HTML) { p_IsPrintDoctor = false; m_WebBrowserPrint.DocumentText = m_SelectedRecord.f_GetDocumentTextPatient(Application.StartupPath); Cl_EntityLog.f_CustomMessageLog(m_SelectedRecord, "Печать карточки для пациента" + (!m_SelectedRecord.p_IsPrintPatient ? " (первая печать)" : "")); } } }
private void ctrlBSave_Click(object sender, EventArgs e) { if (ctrlTBComment.Text == "" && MessageBox.Show("Поле \"Комментарий\" не заполенено.\nСохранить оценку без комментария?", "Сохранение оценки", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes) { return; } if (this.curRecord == null) { MessageBox.Show("Запись еще не сохранена!\nУстановка оценки невозможна.", "Оценка записи", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } Cl_Rating rating = new Cl_Rating(); rating.p_RecordID = this.curRecord.p_RecordID; rating.p_Time = DateTime.Now; rating.p_Comment = ctrlTBComment.Text; rating.p_UserID = Cl_SessionFacade.f_GetInstance().p_Doctor.p_UserID; rating.p_UserName = Cl_SessionFacade.f_GetInstance().p_Doctor.f_GetInitials(); if (ctrlRBValue_1.Checked) { rating.p_Value = 1; } if (ctrlRBValue_2.Checked) { rating.p_Value = 2; } if (ctrlRBValue_3.Checked) { rating.p_Value = 3; } if (ctrlRBValue_4.Checked) { rating.p_Value = 4; } if (ctrlRBValue_5.Checked) { rating.p_Value = 5; } Cl_App.m_DataContext.p_Ratings.Add(rating); Cl_App.m_DataContext.SaveChanges(); Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.Rating, string.Format("Выставлена оценка {0} для записи: {1}, дата записи: {2}, клиника: {3}", rating.p_Value, this.curRecord.p_Title, this.curRecord.p_DateCreate, this.curRecord.p_ClinicName), this.curRecord.p_RecordID); f_LoadRatingTable(rating.p_RecordID); selfRating = rating; if (firstRating == null) { firstRating = rating; } }
private void f_Edit(Cl_Record a_Record) { if (f_GetEdited(a_Record)) { Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.UIEvents, string.Format("Редактирование записи: {0}, дата записи: {1}, клиника: {2}", a_Record.p_Title, a_Record.p_DateCreate, a_Record.p_ClinicName), a_Record.p_RecordID); var dlgRecord = new Dlg_Record(); dlgRecord.e_Save += DlgRecord_e_Save; dlgRecord.p_Record = a_Record; dlgRecord.ShowDialog(this); Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.UIEvents, string.Format("Выход из редактирования записи: {0}, дата записи: {1}, клиника: {2}", a_Record.p_Title, a_Record.p_DateCreate, a_Record.p_ClinicName), a_Record.p_RecordID); } }
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; } } } }
/// <summary>Сохранение изменений БД с логированием изменений</summary> /// <param name="obj"></param> public void f_SaveChanges(Cl_EntityLog a_Log, I_ELog a_Obj) { using (var transaction = Database.BeginTransaction()) { try { SaveChanges(); a_Log.f_SaveEntity(a_Obj); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); MonitoringStub.Error("Error_Tree", "Не удалось сохранить изменения в базе данных", ex, null, null); } } }
private void ctrlDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("Удалить паттерн записей?", "Удаление паттерна записей", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction()) { try { if (ctrlTablePatterns.CurrentRow != null) { var pat = (Cl_RecordPattern)ctrlTablePatterns.CurrentRow.DataBoundItem; if (pat != null) { var pattern = m_Patterns.FirstOrDefault(p => p.p_ID == pat.p_ID); Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.RecordsPatterns, string.Format("Удален патерн \"{0}\" по шаблону \"{1}\"", pattern.p_Name, pattern.p_Template.p_Name), pattern.p_Template.p_TemplateID); foreach (Cl_RecordPatternValue val in pattern.p_Values) { Cl_App.m_DataContext.p_RecordsPatternsParams.RemoveRange(val.p_Params); } Cl_App.m_DataContext.p_RecordsPatternsValues.RemoveRange(pattern.p_Values); Cl_App.m_DataContext.p_RecordsPatterns.Remove(pattern); Cl_App.m_DataContext.SaveChanges(); transaction.Commit(); f_Refresh(); } } } catch { transaction.Rollback(); MonitoringStub.Error("Error_Tree", "Не удалось удалить паттерн записей", null, null, null); } } }
private void ctrlBReportAddRecordByFile_Click(object sender, EventArgs e) { Cl_Record record = new Cl_Record(); record.p_DateCreate = DateTime.Now; record.p_Type = E_RecordType.FinishedFile; record.p_DateLastChange = record.p_DateCreate; record.p_MedicalCard = Cl_SessionFacade.f_GetInstance().p_MedicalCard; record.p_MedicalCardID = record.p_MedicalCard.p_ID; record.p_ClinicName = Cl_SessionFacade.f_GetInstance().p_Doctor.p_ClinicName; record.p_Title = "Новая запись с готовым файлом"; //record.p_CategoryTotalID = category.p_ID; //record.p_CategoryTotal = category; record.f_SetDoctor(Cl_SessionFacade.f_GetInstance().p_Doctor); var dlgRecord = new Dlg_Record(); dlgRecord.e_Save += DlgRecord_e_Save; dlgRecord.p_Record = record; Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.UIEvents, "Создание новой записи с готовым файлом"); dlgRecord.ShowDialog(this); }
private void F_Main_FormClosing(object sender, FormClosingEventArgs e) { Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.AppEvents, "Завершение работы с ЭМК."); }
public Cl_Template f_UpSaveTemplate(Cl_Template curTemplate, I_Element[] elements, Cl_EntityLog m_Log) { Cl_Template newTemplate = curTemplate; if (this.f_IsActualElementsOnTemplate(curTemplate)) { return(f_SaveTemplate(curTemplate, elements, m_Log)); } using (var transaction = m_DataContextMegaTemplate.Database.BeginTransaction()) { try { newTemplate = f_UpdateTemplate(newTemplate); m_Log.f_SaveEntity(newTemplate); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); MonitoringStub.Error("Error_Editor", "При сохранении изменений произошла ошибка", ex, null, null); } } return(newTemplate); }
private void f_OnSelectRow(DataGridViewRow row) { m_SelectedRecord = null; m_SelectedRow = null; if (row != null && row is OutlookGridRow && !((OutlookGridRow)row).IsGroupRow && row.Tag != null) { try { var record = m_SelectedRecord = m_Records.FirstOrDefault(r => r.p_ID == ((Cl_Record)row.Tag).p_ID); if (record != null) { m_SelectedRow = row; Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.UIEvents, string.Format("Просмотр записи: {0}, дата записи: {1}, клиника: {2}", record.p_Title, record.p_DateCreate, record.p_ClinicName), record.p_RecordID); ctrlPRecordInfo.Visible = true; ctrlRecordInfo.Text = string.Format("{0} {1} [{2}, {3}]", record.p_DateCreate.ToShortDateString(), record.p_Title, record.p_DateLastChange, record.p_DoctorFIO); ctrlCMViewer.Enabled = true; ctrlBAddRecordFromRecord.Visible = ctrlBReportFormatPattern.Visible = !record.p_IsAutomatic && !Cl_SessionFacade.f_GetInstance().p_MedicalCard.p_IsDelete&& !Cl_SessionFacade.f_GetInstance().p_MedicalCard.p_IsArchive&& (m_Permission.p_IsEditAllRecords || m_Permission.p_IsEditSelfRecords); ctrlBReportEdit.Visible = ctrlMIEdit.Visible = f_GetEdited(record); ctrlBReportDelete.Visible = ctrlMIDelete.Visible = Cl_SessionFacade.f_GetInstance().p_Doctor.p_Permission.p_IsEditAllRecords || ((m_Permission.p_IsEditArchive || Cl_SessionFacade.f_GetInstance().p_Doctor.p_Permission.p_IsEditSelfRecords) && record.p_DoctorID == Cl_SessionFacade.f_GetInstance().p_Doctor.p_UserID); ctrlBReportRating.Visible = ctrlMIRating.Visible = m_Permission.p_IsEditAllRatings; ctrlBReportSyncBMK.Visible = ctrlMISyncBMK.Visible = !record.p_IsSyncBMK && record.p_IsPrintDoctor && m_Permission.p_IsEditArchive; ctrlBReportPrintDoctor.Visible = ctrlBReportPrintPatient.Visible = ctrlMIPrint.Visible = m_Permission.p_IsPrint; if (record.p_Type == E_RecordType.FinishedFile) { if (record.p_FileType == E_RecordFileType.HTML) { ctrlHTMLViewer.DocumentText = record.f_GetDocumentTextDoctor(Application.StartupPath); ctrlHTMLViewer.Visible = true; ctrlPDFViewer.Visible = false; } else if (record.p_FileType == E_RecordFileType.PDF) { var path = string.Format("{0}medicalChartTemp.pdf", Path.GetTempPath()); record.p_FileBytes = Cl_RecordsFacade.f_GetInstance().f_GetFileFromSql(record); File.WriteAllBytes(path, record.p_FileBytes); ctrlPDFViewer.src = path; ctrlPDFViewer.Show(); ctrlHTMLViewer.Visible = false; ctrlPDFViewer.Visible = true; } else if (record.p_FileType == E_RecordFileType.JFIF || record.p_FileType == E_RecordFileType.JIF || record.p_FileType == E_RecordFileType.JPE || record.p_FileType == E_RecordFileType.JPEG || record.p_FileType == E_RecordFileType.JPG || record.p_FileType == E_RecordFileType.PNG || record.p_FileType == E_RecordFileType.GIF) { ctrlHTMLViewer.DocumentText = record.f_GetDocumentTextDoctor(Application.StartupPath); ctrlHTMLViewer.Visible = true; ctrlPDFViewer.Visible = false; } } else { if (record.p_HTMLDoctor != null) { ctrlHTMLViewer.DocumentText = record.f_GetDocumentTextDoctor(Application.StartupPath); ctrlHTMLViewer.Visible = true; ctrlPDFViewer.Visible = false; } else { ctrlHTMLViewer.Visible = false; ctrlPDFViewer.Visible = false; } } } else { ctrlPRecordInfo.Visible = false; } } catch (Exception er) { MonitoringStub.Error("Error_Editor", "Не удалось отобразить запись", er, null, null); } } if (m_SelectedRecord == null) { ctrlCMViewer.Enabled = false; ctrlPRecordInfo.Visible = false; ctrlBReportFormatPattern.Visible = false; ctrlBReportEdit.Visible = false; ctrlBReportRating.Visible = false; ctrlBReportPrintDoctor.Visible = ctrlBReportPrintPatient.Visible = false; } }
private void ctrlBSave_Click(object sender, System.EventArgs e) { if (string.IsNullOrWhiteSpace(ctrlTitle.Text)) { MonitoringStub.Message("Заполните поле \"Заголовок\"!"); return; } if (ctrlDTPDateReception.Value == null) { MonitoringStub.Message("Заполните поле \"Дата приема\"!"); return; } if (ctrlDTPTimeReception.Value == null) { MonitoringStub.Message("Заполните поле \"Время приема\"!"); return; } if (m_Record != null) { Cl_Record record = null; if (m_Record.p_Type == E_RecordType.ByTemplate && m_ControlTemplate != null) { record = m_ControlTemplate.f_GetNewRecord(); } else if (m_Record.p_Type == E_RecordType.FinishedFile && m_ControlRecordByFile != null) { record = m_ControlRecordByFile.f_GetNewRecord(); if (record?.p_FileBytes == null) { MonitoringStub.Message("Заполните поле \"Файл записи\"!"); return; } } if (record != null) { using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction()) { try { if (m_Log.f_IsChanged(record) == false && record.p_Title == ctrlTitle.Text) { MonitoringStub.Message("Элемент не изменялся!"); transaction.Rollback(); return; } record.p_Title = ctrlTitle.Text; record.p_DateReception = new DateTime(ctrlDTPDateReception.Value.Year, ctrlDTPDateReception.Value.Month, ctrlDTPDateReception.Value.Day, ctrlDTPTimeReception.Value.Hour, ctrlDTPTimeReception.Value.Minute, 0); if (Cl_SessionFacade.f_GetInstance().p_Doctor.p_Permission.p_Role == Core.Permision.E_Roles.Assistant) { record.f_SetDoctor(Cl_SessionFacade.f_GetInstance().p_Doctor.p_ParentUser); } Cl_App.m_DataContext.p_Records.Add(record); Cl_App.m_DataContext.SaveChanges(); if (m_Record.p_Type == E_RecordType.FinishedFile) { record.p_FilePath = Cl_RecordsFacade.f_GetInstance().f_GetLocalResourcesRelativeFilePath(record); Cl_RecordsFacade.f_GetInstance().f_SaveFileFromSql(record); } else { record.p_HTMLDoctor = record.f_GetHTMLDoctor(); record.p_HTMLPatient = record.f_GetHTMLPatient(); } if (record.p_Version == 1) { record.p_RecordID = record.p_ID; } Cl_App.m_DataContext.SaveChanges(); Cl_EntityLog.f_CustomMessageLog(E_EntityTypes.UIEvents, string.Format("Сохранение записи: {0}, дата записи: {1}, клиника: {2}", record.p_Title, record.p_DateCreate, record.p_ClinicName), record.p_RecordID); m_Log.f_SaveEntity(record, record.p_ParentRecord != null ? $"Создана новая запись на основе {record.p_ParentRecord.p_Title}" : "Создана новая запись"); transaction.Commit(); f_SetRecord(record); e_Save?.Invoke(this, new Cl_Record.Cl_EventArgs() { p_Record = record }); this.Close(); } catch (Exception ex) { transaction.Rollback(); try { Cl_RecordsFacade.f_GetInstance().f_DeleteFileFromSql(record); } catch { }; MonitoringStub.Error("Error_Editor", "При сохранении изменений записи произошла ошибка", ex, null, null); } } } } }
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 ctrl_BEdit_Click(object sender, EventArgs e) { Cl_EntityLog.f_CustomMessageLog(p_EditableElement.p_Element, "Нажата кнопка \"Редактировать\""); p_IsReadOnly = false; }
private void ctrl_BCancel_Click(object sender, EventArgs e) { Cl_EntityLog.f_CustomMessageLog(p_EditableElement.p_Element, "Нажата кнопка \"Отмена\""); p_IsReadOnly = true; p_EditPanel.f_SetElement(p_EditableElement.p_Element); }
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; } } }
/// <summary> /// Сохранение шаблона /// </summary> /// <param name="curTemplate">Сохраняемый шаблон</param> /// <param name="items">Новый список элементов в сохраняемом шаблоне</param> /// <param name="m_Log">Объект логгера</param> /// <returns></returns> public Cl_Template f_SaveTemplate(Cl_Template curTemplate, I_Element[] elements, Cl_EntityLog m_Log = null) { using (var transaction = m_DataContextMegaTemplate.Database.BeginTransaction()) { try { Cl_Template newTemplate = null; if (curTemplate.p_Version == 0) { newTemplate = curTemplate; newTemplate.p_Version = 1; } else { newTemplate = new Cl_Template(); newTemplate.p_TemplateID = curTemplate.p_TemplateID; newTemplate.p_Title = curTemplate.p_Title; newTemplate.p_CategoryTotalID = curTemplate.p_CategoryTotalID; newTemplate.p_CategoryTotal = curTemplate.p_CategoryTotal; newTemplate.p_CategoryClinicID = curTemplate.p_CategoryClinicID; newTemplate.p_CategoryClinic = curTemplate.p_CategoryClinic; newTemplate.p_Type = curTemplate.p_Type; newTemplate.p_Name = curTemplate.p_Name; newTemplate.p_Version = curTemplate.p_Version + 1; newTemplate.p_ParentGroupID = curTemplate.p_ParentGroupID; newTemplate.p_ParentGroup = curTemplate.p_ParentGroup; newTemplate.p_Description = curTemplate.p_Description; m_DataContextMegaTemplate.p_Templates.Add(newTemplate); } m_DataContextMegaTemplate.SaveChanges(); foreach (I_Element item in elements) { Cl_TemplateElement tplEl = new Cl_TemplateElement(); tplEl.p_TemplateID = newTemplate.p_ID; tplEl.p_Template = newTemplate; if (item is Ctrl_Element) { Ctrl_Element block = (Ctrl_Element)item; tplEl.p_ChildElementID = block.p_ID; tplEl.p_ChildElement = block.p_Element; } else if (item is Ctrl_Template) { Ctrl_Template block = (Ctrl_Template)item; tplEl.p_ChildTemplateID = block.p_ID; tplEl.p_ChildTemplate = block.p_Template; } tplEl.p_Index = Array.IndexOf(elements, item) + 1; m_DataContextMegaTemplate.p_TemplatesElements.Add(tplEl); } m_DataContextMegaTemplate.SaveChanges(); if (m_Log != null && m_Log.f_IsChanged(newTemplate) == false) { if (newTemplate.Equals(curTemplate) && newTemplate.p_Version == 1) { newTemplate.p_Version = 0; } MonitoringStub.Message("Шаблон не изменялся!"); transaction.Rollback(); } else { m_Log.f_SaveEntity(newTemplate); transaction.Commit(); return(newTemplate); } } catch (Exception ex) { transaction.Rollback(); MonitoringStub.Error("Error_Editor", "При сохранении изменений произошла ошибка", ex, null, null); } return(curTemplate); } }