private void ctrlBAdd_Click(object sender, EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = "Image Files |*.bmp; *.gif; *.jpg; *.jpeg; *.png"; openFile.FilterIndex = 1; if (openFile.ShowDialog() != DialogResult.OK) { return; } Image result = null; try { result = Image.FromFile(openFile.FileName); } catch (Exception ex) { MonitoringStub.Problem("Problem_Editor", "Выбранный файл не является изображением", ex, null, null); return; } ctrlImage.Image = result; }
private void ctrlBAdd_Click(object sender, System.EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = "Файлы изображений (.bmp, .jpg, .png)|*.bmp;*.jpg;*.png|PDF файл (.pdf)|*.pdf|Веб страницы (.htm, .html)|*.htm;*.html"; if (openFile.ShowDialog() != DialogResult.OK) { return; } var recordFileType = Cl_RecordsFacade.f_GetInstance().f_GetFileType(openFile.FileName); if (recordFileType != null) { m_FileType = (E_RecordFileType)recordFileType; } else { MonitoringStub.Message("Неизвестный формат файла записи " + openFile.FileName); return; } m_FileBytes = File.ReadAllBytes(openFile.FileName); ctrlLFilePath.Text = openFile.FileName; }
/// <summary>Архивирование медкарты</summary> /// <param name="a_Number">Номер медкарта</param> /// <param name="a_PatientID">ID пациента</param> public bool f_ArchiveMedicalCard(string a_Number, int a_PatientID) { if (m_DataContextMegaTemplate != null) { var medicalCard = f_GetMedicalCard(a_Number, a_PatientID); if (medicalCard != null) { medicalCard.p_DateArchive = DateTime.Now; m_DataContextMegaTemplate.SaveChanges(); return(true); } else { MonitoringStub.Error("Error_MergeMedicalCards", "Не удалось найти медкарту для архивирования", null, null, null); return(false); } } else { MonitoringStub.Error("Error_MedicalCardsFacade", "Не инициализирован фасад", null, null, null); return(false); } }
private void f_UpdateControls() { try { m_ControlTemplate = null; m_ControlRecordByFile = null; ctrlPContent.Controls.Clear(); if (m_Record != null) { if (m_Record.p_Template != null) { if (m_Record.p_Template.p_TemplateElements == null) { var cTe = Cl_App.m_DataContext.Entry(m_Record.p_Template).Collection(g => g.p_TemplateElements).Query().Include(te => te.p_ChildElement).Include(te => te.p_ChildElement.p_Default).Include(te => te.p_ChildTemplate); cTe.Load(); } m_ControlTemplate = new Ctrl_Template(); m_ControlTemplate.Dock = DockStyle.Fill; m_ControlTemplate.p_Template = m_Record.p_Template; m_ControlTemplate.p_PaddingX = p_PaddingX; m_ControlTemplate.p_PaddingY = p_PaddingY; m_ControlTemplate.f_SetRecord(m_Record); ctrlPContent.Controls.Add(m_ControlTemplate); } else if (m_Record.p_Type == E_RecordType.FinishedFile) { m_ControlRecordByFile = new UС_RecordByFile(); m_ControlRecordByFile.f_SetRecord(m_Record); ctrlPContent.Controls.Add(m_ControlRecordByFile); } } } catch (Exception er) { MonitoringStub.Error("Error_Editor", "Не удалось обновить контролы в записи", er, null, null); } }
public object f_ConfirmChanges() { if (!f_ValidNumber(ctrl_NormValues.Lines)) { MonitoringStub.Message("Нормальные значения не являются числовыми или не соответствуют точности числа"); return(null); } if (!f_ValidNumber(ctrl_PatValues.Lines)) { MonitoringStub.Message("Патологические значения не являются числовыми или не соответствуют точности числа"); return(null); } if (!f_ValidNumber(new string[] { ctrl_Default.Text })) { MonitoringStub.Message("Значение по-умолчанию не является числовым или не соответствует точности числа"); return(null); } var templates = f_GetConflictTemplates(p_EditingElement); if (templates.Length > 0) { if (MessageBox.Show("Этот элемент уже используется в шаблонах. Сохранить новую версию элмента?", "", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return(null); } } using (var transaction = Cl_App.m_DataContext.Database.BeginTransaction()) { try { decimal dVal = 0; Cl_Element el = null; if (p_EditingElement.p_Version == 0) { el = p_EditingElement; el.p_Version = 1; } else { el = new Cl_Element(); el.p_Version = p_EditingElement.p_Version + 1; el.p_ParentGroupID = p_EditingElement.p_ParentGroupID; el.p_ParentGroup = p_EditingElement.p_ParentGroup; Cl_App.m_DataContext.p_Elements.Add(el); } el.p_ElementType = (E_ElementsTypes)ctrl_ControlType.f_GetSelectedItem(); el.p_ElementID = p_EditingElement.p_ElementID; el.p_Name = ctrl_Name.Text.Trim(); el.p_Tag = ctrlTag.Text.Trim(); el.p_Help = ctrl_Hint.Text; el.p_IsPartPre = ctrl_IsPartPre.Checked; if (el.p_IsPartPre) { el.p_PartPre = ctrl_PartPreValue.Text.Trim(); } el.p_IsPartPost = ctrl_IsPartPost.Checked; if (el.p_IsPartPost) { el.p_PartPost = ctrl_PartPostValue.Text.Trim(); } el.p_IsPartLocations = ctrl_IsPartLocations.Checked; if (el.p_IsPartLocations) { el.p_IsPartLocationsMulti = ctrl_IsPartLocationsMulti.Checked; } el.p_IsPartNorm = ctrl_IsPartNorm.Checked; if (el.p_IsPartNorm) { if (decimal.TryParse(ctrl_PartNormValue.Text, out dVal)) { if (f_ValidNumber(new string[] { dVal.ToString() })) { el.p_PartNorm = dVal; } else { MonitoringStub.Message("Значение поля \"Норма\" не соответствует точности!"); transaction.Rollback(); return(null); } } else { MonitoringStub.Message("Значение поля \"Норма\" не корректное!"); transaction.Rollback(); return(null); } } el.p_IsPartNormRange = ctrl_IsPartNormRange.Checked; el.p_IsChangeNotNormValues = ctrl_IsChangeNotNormValues.Checked; el.p_Visible = ctrl_IsVisible.Checked; el.p_VisiblePatient = ctrl_IsVisiblePatient.Checked; el.p_Required = ctrl_IsRequiredFIeld.Checked; el.p_Editing = ctrl_IsEditing.Checked; el.p_IsMultiSelect = ctrl_IsMultiSelect.Checked; el.p_Symmetrical = ctrl_IsSymmentry.Checked; el.p_SymmetryParamLeft = ctrl_Symmetry1.Text.Trim(); el.p_SymmetryParamRight = ctrl_Symmetry2.Text.Trim(); el.p_IsNumber = ctrl_IsNumber.Checked; el.p_NumberRound = Convert.ToByte(ctrl_NumberRound.Value); el.p_NumberFormula = ctrl_NumberFormula.Text; el.p_VisibilityFormula = ctrl_VisibilityFormula.Text; el.p_Comment = ctrl_Note.Text; Cl_App.m_DataContext.SaveChanges(); el.p_ParamsValues.Clear(); if (el.p_IsPartLocations) { el.f_AddValues(Cl_ElementParam.E_TypeParam.Location, ctrl_PartLocationsValue.Lines); } el.f_AddValues(Cl_ElementParam.E_TypeParam.NormValues, ctrl_NormValues.Lines); el.f_AddValues(Cl_ElementParam.E_TypeParam.PatValues, ctrl_PatValues.Lines); el.p_PartAgeNorms.Clear(); if (el.p_IsPartNormRange) { var norms = f_GetPartNormRanges(el.p_ID); if (norms != null) { el.p_PartAgeNorms.AddRange(norms); } else { transaction.Rollback(); return(null); } } Cl_App.m_DataContext.SaveChanges(); if (ctrl_Default.SelectedItem != null) { el.p_Default = el.p_NormValues.FirstOrDefault(v => v.p_Value == ctrl_Default.SelectedItem.ToString()); if (el.p_Default == null) { el.p_Default = el.p_PatValues.FirstOrDefault(v => v.p_Value == ctrl_Default.SelectedItem.ToString()); } if (el.p_Default != null) { el.p_DefaultID = el.p_Default.p_ID; } else { el.p_DefaultID = null; } } Cl_App.m_DataContext.SaveChanges(); if (templates.Length > 0) { foreach (var t in templates) { t.p_IsConflict = true; } } if (m_Log.f_IsChanged(el) == false) { if (el.Equals(p_EditingElement) && el.p_Version == 1) { el.p_Version = 0; } MonitoringStub.Message("Элемент не изменялся!"); transaction.Rollback(); return(null); } m_Log.f_SaveEntity(el); transaction.Commit(); f_SetElement(el); return(el); } catch (Exception ex) { transaction.Rollback(); MonitoringStub.Error("Error_Editor", "При сохранении изменений произошла ошибка", ex, null, null); return(null); } } }
private List <Cl_AgeNorm> f_GetPartNormRanges(int a_ElementID) { var norms = new List <Cl_AgeNorm>(); decimal?dVal = null; byte? bVal = null; foreach (DataGridViewRow row in ctrl_TPartNormRangeValues.Rows) { if (!row.IsNewRow) { Cl_AgeNorm norm = new Cl_AgeNorm(); bVal = f_GetAgeFrom(row); if (bVal != null) { norm.p_AgeFrom = (byte)bVal; } else { return(null); } bVal = f_GetAgeTo(row); if (bVal != null) { norm.p_AgeTo = (byte)bVal; } else { return(null); } if (norm.p_AgeFrom > norm.p_AgeTo) { MonitoringStub.Message("Значение поля \"Возраст от\" больше значения поля \"Возраст до\"!"); return(null); } dVal = f_GetMaleMin(row); if (dVal != null) { norm.p_MaleMin = (decimal)dVal; } else { return(null); } dVal = f_GetMaleMax(row); if (dVal != null) { norm.p_MaleMax = (decimal)dVal; } else { return(null); } dVal = f_GetFemaleMin(row); if (dVal != null) { norm.p_FemaleMin = (decimal)dVal; } else { return(null); } dVal = f_GetFemaleMax(row); if (dVal != null) { norm.p_FemaleMax = (decimal)dVal; } else { return(null); } norm.p_ElementID = a_ElementID; norms.Add(norm); } } return(norms); }
/// <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); } }
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); } } } } }
protected override void OnDragDrop(DragEventArgs drgevent) { string[] formats = drgevent.Data.GetFormats(); foreach (string format in formats) { var item = drgevent.Data.GetData(format); if (item is Ctrl_TreeNodeElement || item is Ctrl_TreeNodeTemplate) { if (item is Ctrl_TreeNodeElement) { Ctrl_TreeNodeElement nodeEl = (Ctrl_TreeNodeElement)item; if (f_HasElement(nodeEl.p_Element) || nodeEl.p_Element.p_Version == 0) { MonitoringStub.Warning("Элемент уже в шаблоне"); return; } } else if (item is Ctrl_TreeNodeTemplate) { Ctrl_TreeNodeTemplate nodeTemp = (Ctrl_TreeNodeTemplate)item; if (f_HasElement(nodeTemp.p_Template) || nodeTemp.p_Template.p_Version == 0) { MonitoringStub.Warning("Элемент уже в шаблоне"); return; } } } } if (this.IsDragging) { try { if (this.InsertionIndex != InvalidIndex) { int dragIndex; int dropIndex; dragIndex = (int)drgevent.Data.GetData(typeof(int)); dropIndex = this.InsertionIndex; if (dragIndex < dropIndex) { dropIndex--; } if (this.InsertionMode == I_InsertionMode.After && dragIndex < this.Items.Count - 1) { dropIndex++; } if (dropIndex != dragIndex) { //Point clientPoint = this.PointToClient(new Point(drgevent.X, drgevent.Y)); //args = new ListBoxItemDragEventArgs(dragIndex, dropIndex, this.InsertionMode, clientPoint.X, clientPoint.Y); //this.OnItemDrag(args); //if (!args.Cancel) { object dragItem; dragItem = this.Items[dragIndex]; this.Items.Remove(dragIndex); this.Items.Insert(dropIndex, dragItem); this.SelectedItem = dragItem; } } } } finally { this.Invalidate(this.InsertionIndex); this.InsertionIndex = InvalidIndex; this.InsertionMode = I_InsertionMode.None; this.IsDragging = false; } } else { if (drgevent.Data.GetData(drgevent.Data.GetFormats()[0]) is Ctrl_TreeNodeElement) { f_DragNewElement(drgevent.Data.GetData(drgevent.Data.GetFormats()[0]) as Ctrl_TreeNodeElement, drgevent.X, drgevent.Y); } else if (drgevent.Data.GetData(drgevent.Data.GetFormats()[0]) is Ctrl_TreeNodeTemplate) { f_DragNewTemplate(drgevent.Data.GetData(drgevent.Data.GetFormats()[0]) as Ctrl_TreeNodeTemplate, drgevent.X, drgevent.Y); } } base.OnDragDrop(drgevent); }
private void f_UpdateRecords(Cl_Record selectedRecord = null) { try { var patientID = Cl_SessionFacade.f_GetInstance().p_Patient.p_UserID; var patientUID = Cl_SessionFacade.f_GetInstance().p_Patient.p_UserUID; var records = Cl_App.m_DataContext.p_Records.Include(r => r.p_MedicalCard).AsQueryable(); if (Cl_SessionFacade.f_GetInstance().p_Doctor.p_Permission.p_IsReadSelectedRecords) { if (Cl_SessionFacade.f_GetInstance().p_DateStart != null && Cl_SessionFacade.f_GetInstance().p_DateEnd != null) { var dateStart = Cl_SessionFacade.f_GetInstance().p_DateStart; var dateEnd = Cl_SessionFacade.f_GetInstance().p_DateEnd; records = records.Where(r => r.p_DateLastChange >= dateStart && r.p_DateLastChange <= dateEnd); } else { MonitoringStub.Error("Error_Editor", "Для проверяющего С/К не указан период", null, null, null); } } records = records.Where(r => p_IsShowDeleted ? true : !r.p_IsDelete && r.p_MedicalCard != null && (r.p_MedicalCard.p_PatientUID == patientUID || r.p_MedicalCard.p_PatientID == patientID)); m_Records = records.GroupBy(e => e.p_RecordID).Select(grp => grp .OrderByDescending(v => v.p_Version).FirstOrDefault()) .Include(r => r.p_CategoryTotal).Include(r => r.p_CategoryClinic).Include(r => r.p_Values).Include(r => r.p_Template).Include(r => r.p_Values.Select(v => v.p_Params)).ToArray(); m_SelectedRecordBlock = true; ctrl_TRecords.BindData(null, null); ctrl_TRecords.Columns.AddRange(p_MedicalCardNumber, p_ClinikName, p_DateForming, p_CategoryTotal, p_Title, p_DoctorFIO); foreach (var record in m_Records) { OutlookGridRow row = new OutlookGridRow(); row.CreateCells(ctrl_TRecords, record.p_MedicalCardNumber, record.p_ClinicName, record.p_DateReception.ToString("dd.MM.yyyy HH:mm"), record.p_CategoryTotal != null ? record.p_CategoryTotal.p_Name : "", record.p_Title, record.p_DoctorFIO); row.Tag = record; ctrl_TRecords.Rows.Add(row); } ctrl_TRecords.Columns[0].Visible = false; ctrl_TRecords.GroupTemplate.Column = ctrl_TRecords.Columns[0]; ctrl_TRecords.Sort(ctrl_TRecords.Columns[2], System.ComponentModel.ListSortDirection.Descending); m_SelectedRecordBlock = false; if (selectedRecord != null) { foreach (OutlookGridRow row in ctrl_TRecords.Rows) { if (!row.IsGroupRow && ((Cl_Record)row.Tag).p_ID == selectedRecord.p_ID) { row.Selected = true; break; } } } } catch (Exception er) { MonitoringStub.Error("Error_Editor", "Не удалось обновить записи", er, null, null); } }
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 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; } } }