Exemple #1
0
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();

            // Отключение валидации объектов
            DevExpress.Persistent.Validation.RuleSet.CustomNeedToValidateRule += RuleSet_CustomNeedToValidateRule;

            // Получаем текущего пациента
            DetailView ownerView = ObjectSpace.Owner as DetailView;

            currentPacient = ObjectSpace.GetObject(ownerView.CurrentObject) as Pacient;
            // Текущий доктор
            currentDoctor = ObjectSpace.GetObject((Doctor)SecuritySystem.CurrentUser);

            // Контроллер создания услуги
            newObjController = Frame.GetController <DevExpress.ExpressApp.SystemModule.NewObjectViewController>();
            newObjController.ObjectCreating += newObjController_ObjectCreating;

            SplitContainerControl container = View.Control as SplitContainerControl;

            if (container == null)
            {
                return;
            }
            // Pacient_VisitCaseServices_ListView
            var gridControl = container.Controls[0].Controls[0] as GridControl;

            if (gridControl == null)
            {
                return;
            }

            gridView = gridControl.MainView as GridView;
            gridView.CustomDrawGroupRow += gridView_CustomDrawGroupRow;

            gridView.SelectionChanged += (o, e) =>
            {
                bool isGroupRow = gridView.IsGroupRow(gridView.FocusedRowHandle);
                // Oid посещения если isGroupRow = True
                if (isGroupRow)
                {
                    object selectedGroup = gridView.GetGroupRowValue(gridView.FocusedRowHandle);
                    currentVisitCase = selectedGroup != null && selectedGroup is Guid?
                                       ObjectSpace.FindObject <VisitCase>(VisitCase.Fields.Oid == (Guid)selectedGroup) : null;

                    currentMedService = null;
                }
                else
                {
                    currentVisitCase  = null;
                    currentMedService = View.CurrentObject as MedService;
                }
            };
        }
Exemple #2
0
        private void gridView_CustomDrawGroupRow(object sender, RowObjectCustomDrawEventArgs e)
        {
            GridView  view      = sender as GridView;
            object    val       = view.GetGroupRowValue(e.RowHandle);
            VisitCase visitCase = val != null && val is Guid?
                                  ObjectSpace.FindObject <VisitCase>(VisitCase.Fields.Oid == (Guid)val) : null;

            GridGroupRowInfo info = e.Info as GridGroupRowInfo;

            if (info.Column.FieldName == "Case.Oid")
            {
                info.GroupText = string.Format("Посещение {0} ({1})", visitCase.Num, visitCase != null &&
                                               visitCase.MainDiagnose != null && visitCase.MainDiagnose.Diagnose != null ?
                                               visitCase.MainDiagnose.Diagnose.MKB : null);
            }
        }
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();

            ListView   listView   = View as ListView;
            DetailView detailView = View as DetailView;

            if (listView != null)
            {
                IObjectSpace os = Application.CreateObjectSpace();
                listView.CollectionSource.CriteriaApplied += (o, e) =>
                {
                    // Предварительная загрузка расписаний докторов
                    var collectionSB = (CollectionSourceBase)o;
                    if (collectionSB.Criteria != null)
                    {
                        var events = new List <DoctorEvent>(os.GetObjects <DoctorEvent>(collectionSB.Criteria[FILTERKEY]));
                        eventsDict = events.ToDictionary(de => de.Oid, de => de);
                    }
                };

                SchedulerListEditor listEditor = ((ListView)View).Editor as SchedulerListEditor;
                if (listEditor != null)
                {
                    SchedulerControl scheduler = listEditor.SchedulerControl;
                    if (scheduler != null)
                    {
                        // Кастомизация надписи в расписании доктора
                        scheduler.InitAppointmentDisplayText += (o, e) =>
                        {
                            Guid guid = (Guid)e.Appointment.Id;
                            if (eventsDict.ContainsKey(guid))
                            {
                                var doctorEvent = eventsDict[guid];
                                e.Text = doctorEvent != null && doctorEvent.Pacient != null ? doctorEvent.Pacient.FullName : string.Empty;
                            }
                        };

                        #region Кастомизация Тултипа расписания доктора

                        // https://documentation.devexpress.com/WindowsForms/118551/Controls-and-Libraries/Scheduler/Visual-Elements/Scheduler-Control/Appointment-Flyout
                        scheduler.OptionsView.ToolTipVisibility = ToolTipVisibility.Always;
                        scheduler.OptionsCustomization.AllowDisplayAppointmentFlyout = false;
                        scheduler.ToolTipController             = new ToolTipController();
                        scheduler.ToolTipController.ToolTipType = ToolTipType.SuperTip;
                        scheduler.ToolTipController.BeforeShow += (o, e) =>
                        {
                            var toolTipController           = (ToolTipController)o;
                            AppointmentViewInfo aptViewInfo = null;
                            try
                            {
                                aptViewInfo = (AppointmentViewInfo)toolTipController.ActiveObject;
                            }
                            catch
                            {
                                return;
                            }

                            if (aptViewInfo == null)
                            {
                                return;
                            }

                            Guid guid = (Guid)aptViewInfo.Appointment.Id;
                            if (!eventsDict.ContainsKey(guid))
                            {
                                // В словаре нет ключа т.к. расписание было только что создано
                                var events = new List <DoctorEvent>(ObjectSpace.GetObjects <DoctorEvent>(listView.CollectionSource.Criteria[FILTERKEY]));
                                eventsDict = events.ToDictionary(de => de.Oid, de => de);
                            }
                            DoctorEvent doctorEvent = eventsDict[guid];
                            // Вид талона (метка)
                            AppointmentLabel label = scheduler.Storage.Appointments.Labels.GetById(doctorEvent.Label);
                            StringBuilder    sb    = new StringBuilder();
                            sb.AppendLine(string.Format("Время: с {0:HH:mm} по {1:HH:mm}", doctorEvent.StartOn, doctorEvent.EndOn));
                            sb.AppendLine(string.Format("Пациент: {0}", doctorEvent.Pacient != null ? doctorEvent.Pacient.FullName : null));
                            sb.AppendLine(string.Format("Кем создано: {0}", doctorEvent.CreatedBy != null ? doctorEvent.CreatedBy.FullName : null));
                            sb.AppendLine(string.Format("Кто записал: {0}", doctorEvent.EditedBy != null ? doctorEvent.EditedBy.FullName : null));
                            sb.AppendLine(string.Format("Вид талона: {0}", label.DisplayName));
                            if (doctorEvent.Pacient != null)
                            {
                                sb.AppendLine(string.Format("Источник записи: {0}", CaptionHelper.GetDisplayText(doctorEvent.SourceType)));
                            }

                            SuperToolTip          SuperTip = new SuperToolTip();
                            SuperToolTipSetupArgs args     = new SuperToolTipSetupArgs();
                            args.Contents.Text = sb.ToString();
                            args.Contents.Font = new Font("Times New Roman", 11);
                            SuperTip.Setup(args);
                            e.SuperTip = SuperTip;
                        };

                        #endregion

                        // Кастомизация коллекции меток
                        var storage = scheduler.Storage;
                        IAppointmentLabelStorage labelStorage = storage.Appointments.Labels;
                        FillLabelStorage(labelStorage);

                        #region Кастомизация всплывающего меню на расписании врача
                        DoctorEvent recordedEvent = null;
                        VisitCase   visitCase     = null;

                        // Всплывающее меню на расписании врача
                        scheduler.PopupMenuShowing += (o, e) =>
                        {
                            Pacient pacient = listView.Tag as Pacient;
                            AppointmentBaseCollection appoinments = (o as SchedulerControl).SelectedAppointments;
                            Appointment appoinment = appoinments.Count == 1 ? appoinments[0] : null;
                            if (appoinment == null)
                            {
                                return;
                            }

                            Guid        key    = (Guid)appoinment.Id;
                            DoctorEvent dEvent = appoinment != null && eventsDict.ContainsKey(key) ? eventsDict[key] : null;

                            if (e.Menu.Id != DevExpress.XtraScheduler.SchedulerMenuItemId.AppointmentMenu)
                            {
                                return;
                            }
                            if (pacient != null && dEvent.Pacient == null & recordedEvent == null && dEvent.StartOn > DateTime.Now)
                            {
                                e.Menu.Items.Insert(0, new SchedulerMenuItem("Записать пациента", (o_, e_) =>
                                {
                                    IObjectSpace dEventObjectSpace = XPObjectSpace.FindObjectSpaceByObject(dEvent);
                                    dEvent.Pacient = dEventObjectSpace.GetObject(pacient);
                                    dEventObjectSpace.CommitChanges();
                                    // Обновление списочного представления
                                    listView.CollectionSource.Reload();
                                    // Расписание на которое записан пациент
                                    recordedEvent = dEvent;
                                    // Создание посещения для пациента
                                    visitCase = VisitCase.CreateVisitCase(dEventObjectSpace,
                                                                          dEventObjectSpace.GetObject(pacient),
                                                                          dEvent.AssignedTo, dEvent.StartOn);
                                    dEventObjectSpace.CommitChanges();
                                }));
                            }
                            else if (dEvent != null && dEvent.Pacient != null)
                            {
                                e.Menu.Items.Insert(0, new SchedulerMenuItem("Отменить запись", (o_, e_) =>
                                {
                                    IObjectSpace dEventObjectSpace = XPObjectSpace.FindObjectSpaceByObject(dEvent);
                                    dEvent.Pacient = null;
                                    dEventObjectSpace.CommitChanges();
                                    // Обновление списочного представления
                                    listView.CollectionSource.Reload();
                                    // Отмена записи пациента на выбранное расписание
                                    if (recordedEvent != null && recordedEvent.Oid == dEvent.Oid)
                                    {
                                        recordedEvent = null;
                                    }
                                    if (visitCase != null)
                                    {
                                        dEventObjectSpace.Delete(visitCase);
                                        dEventObjectSpace.CommitChanges();
                                    }
                                }));
                            }
                        };

                        #endregion

                        // Кастомизация цвета фона расписания:
                        // Если выбранный пациент уже записан, то цвет расписания окрашивается в светло-розовый.
                        // Если в расписании записан другой пациент, то цвет расписания окрашивается в морковный.
                        scheduler.AppointmentViewInfoCustomizing += (o_, e_) =>
                        {
                            Pacient pacient = listView.Tag as Pacient;
                            if (pacient != null)
                            {
                                Guid guid = (Guid)e_.ViewInfo.Appointment.Id;
                                if (eventsDict.ContainsKey(guid) && eventsDict[guid].Pacient != null)
                                {
                                    e_.ViewInfo.Appearance.BackColor = eventsDict[guid].Pacient.Oid == pacient.Oid ?
                                                                       Color.FromArgb(255, 192, 192) : Color.FromArgb(255, 128, 0);
                                }
                            }
                        };
                    }
                }
            }
            else if (detailView != null)
            {
                // Кастомизация коллекции меток
                foreach (SchedulerLabelPropertyEditor pe in ((DetailView)View).GetItems <SchedulerLabelPropertyEditor>())
                {
                    if (pe.Control != null)
                    {
                        ISchedulerStorage        storage      = ((AppointmentLabelEdit)pe.Control).Storage;
                        IAppointmentLabelStorage labelStorage = storage.Appointments.Labels;
                        FillLabelStorage(labelStorage);
                    }
                }
            }
        }
Exemple #4
0
        private void newObjController_ObjectCreating(object sender, ObjectCreatingEventArgs e)
        {
            IObjectSpace objectSpace = e.ObjectSpace;

            // objectdisposedexception fix
            currentDoctor  = objectSpace.GetObject(currentDoctor);
            currentPacient = objectSpace.GetObject(currentPacient);

            MedService newMedService = objectSpace.CreateObject <MedService>();

            if (currentVisitCase != null || currentMedService != null)
            {
                var lookAndFeel = new UserLookAndFeel(this);
                var result      = XtraMessageBox.Show(lookAndFeel, "Создать новое посещение?", "Уточнение",
                                                      System.Windows.Forms.MessageBoxButtons.YesNo,
                                                      System.Windows.Forms.MessageBoxIcon.Question);

                if (result == System.Windows.Forms.DialogResult.No)
                {
                    result = XtraMessageBox.Show(lookAndFeel, "Услуга производится в ЛПУ?", "Уточнение",
                                                 System.Windows.Forms.MessageBoxButtons.YesNo,
                                                 System.Windows.Forms.MessageBoxIcon.Question);
                    // устанавливаем услугу по умолчанию
                    SetService(newMedService, result == System.Windows.Forms.DialogResult.Yes);
                    newMedService.Case = currentVisitCase != null ? currentVisitCase : currentMedService.VisitCase;
                    e.NewObject        = newMedService;
                    objectSpace.CommitChanges();
                    // Обновление представления пациента
                    ObjectSpace.CommitChanges();
                    ((DetailView)ObjectSpace.Owner).Refresh();
                    return;
                }
            }

            ShowViewParameters svp = new ShowViewParameters();
            IObjectSpace       os  = Application.CreateObjectSpace();
            DetailView         dv  = Application.CreateDetailView(os, new VisitCaseParameters());

            svp.CreatedView  = dv;
            svp.TargetWindow = TargetWindow.NewModalWindow;
            DialogController dc = new DialogController();

            dc.Accepting += (o, e_) =>
            {
                var       visitCaseParameters = e_.AcceptActionArgs.CurrentObject as VisitCaseParameters;
                VisitCase newVisitCase        = objectSpace.CreateObject <VisitCase>();
                newVisitCase.Pacient = objectSpace.GetObject(currentPacient);
                newVisitCase.Cel     = visitCaseParameters.CelPosesch;
                newVisitCase.Mesto   = visitCaseParameters.Mesto;
                newMedService.Case   = newVisitCase;

                // устанавливаем услугу по умолчанию
                SetService(newMedService, visitCaseParameters.Mesto == MestoObsluzhivaniya.LPU);
                objectSpace.CommitChanges();

                // Обновление представления пациента
                ObjectSpace.CommitChanges();
                ((DetailView)ObjectSpace.Owner).Refresh();
            };
            dc.CancelAction.Caption = "Отмена";
            svp.Controllers.Add(dc);
            Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null));

            e.NewObject = newMedService;
        }