Exemple #1
0
 public DefaultScheduleFakeRepository(IDIKernel diKernel) : base(diKernel)
 {
     Save(new DefaultSchedule
     {
         Day       = DaysInWeek.All,
         Week      = WeeksInMonth.All,
         Month     = MonthsInYear.All,
         Parameter = DIKernel.Get <IParameterRepository>().GetById(1),
         Period    = new Period
         {
             Years = 2
         },
         TimeStart = new TimeSpan(10, 0, 0),
         TimeEnd   = new TimeSpan(22, 0, 0)
     });
     Save(new DefaultSchedule
     {
         Day       = DaysInWeek.All,
         Week      = WeeksInMonth.Even,
         Month     = MonthsInYear.May,
         Parameter = DIKernel.Get <IParameterRepository>().GetById(2),
         Period    = new Period
         {
             Months = 6
         },
         TimeStart = new TimeSpan(10, 0, 0),
         TimeEnd   = new TimeSpan(22, 0, 0)
     });
 }
Exemple #2
0
        /// <summary>
        /// Создать запрос.
        /// </summary>
        /// <param name="query">Запрос.</param>
        /// <returns>Объект запроса к базе.</returns>
        protected SqlCommand CreateQuery(string query)
        {
            SqlCommand sqlCommand = DIKernel.Get <DB>().Connection.CreateCommand();

            sqlCommand.CommandText = query;
            return(sqlCommand);
        }
        public PersonalScheduleFakeRepository(IDIKernel diKernel)
            : base(diKernel)
        {
            Save(new PersonalSchedule
            {
                Parameter = DIKernel.Get <IParameterRepository>().GetById(1),
                Patient   = DIKernel.Get <IPatientRepository>().GetById(1),
                DateStart = DateTime.Now,
                DateEnd   = DateTime.Now.AddYears(1),
                Day       = DaysInWeek.All,
                Month     = MonthsInYear.All,
                Week      = WeeksInMonth.All,
                TimeStart = new TimeSpan(10, 0, 0),
                TimeEnd   = new TimeSpan(23, 0, 0)
            });

            Save(new PersonalSchedule
            {
                Parameter = DIKernel.Get <IParameterRepository>().GetById(2),
                Patient   = DIKernel.Get <IPatientRepository>().GetById(2),
                DateStart = DateTime.Now,
                DateEnd   = DateTime.Now.AddYears(2),
                Day       = DaysInWeek.Monday,
                Month     = MonthsInYear.All,
                Week      = WeeksInMonth.Even,
                TimeStart = new TimeSpan(8, 0, 0),
                TimeEnd   = new TimeSpan(12, 0, 0)
            });
        }
Exemple #4
0
        private void TsmiDiagnosisClick(object sender, EventArgs e)
        {
            var listForm = DIKernel.Get <ListForm <DiagnosisFullData> >();

            listForm.MdiParent = this;
            listForm.LoadData  = DIKernel.Get <DiagnosisRepository>().GetAll;
            listForm.InitializeOperations();
            listForm.Show();
            listForm.Activate();
        }
Exemple #5
0
        private void просмотрToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var listForm = new ListForm <ParameterDetail>(DIKernel);

            listForm.MdiParent = this;
            listForm.LoadData  = DIKernel.Get <ParameterRepository>().GetAll;
            listForm.InitializeOperations();
            listForm.Show();
            listForm.Activate();
        }
Exemple #6
0
        public IList <UserFullData> GetAll()
        {
            var                  db      = DIKernel.Get <DB.DB>();
            SqlCommand           command = CreateQuery(GetQueryText("GetAllUserShowData"));
            SqlDataReader        reader  = command.ExecuteReader();
            IList <UserFullData> doctors = Get <PropertyToColumnMapper <UserFullData> >().Map(reader);

            reader.Close();
            return(doctors);
        }
        public override bool Save(Patient entity)
        {
            var roleRepo = DIKernel.Get <IRoleRepository>();

            entity.Role = roleRepo.GetByName("Patient");
            var userRepo = DIKernel.Get <IUserRepository>();

            entity.Doctor = DIKernel.Get <IDoctorRepository>().GetById(entity.Doctor.Id);
            userRepo.Save(entity);
            return(base.Save(entity));
        }
Exemple #8
0
        public IList <ParameterDetail> GetAll()
        {
            var           db      = DIKernel.Get <DB.DB>();
            SqlCommand    command = CreateQuery(GetQueryText("GetAllParameterShowData"));
            SqlDataReader reader  = command.ExecuteReader();

            IList <ParameterDetail> parameters = Get <PropertyToColumnMapper <ParameterDetail> >().Map(reader);

            reader.Close();
            return(parameters);
        }
Exemple #9
0
        private void TsmiDoctorsClick(object sender, EventArgs e)
        {
            var listForm = DIKernel.Get <ListForm <DoctorFullData> >();

            listForm.MdiParent = this;

            /*listForm.LoadData = DIKernel.Get<DoctorRepository>().GetAll;
             * listForm.DetailData = DIKernel.Get<DoctorRepository>().Detail;
             * listForm.DeleteData = DIKernel.Get<DoctorRepository>().Delete;*/
            listForm.InitializeOperations();
            listForm.Show();
            listForm.Activate();
        }
Exemple #10
0
 public override bool Update(DefaultSchedule entity)
 {
     foreach (DefaultSchedule defaultSchedule in _entities)
     {
         if (defaultSchedule.Id == entity.Id)
         {
             _entities.Remove(defaultSchedule);
             entity.Parameter = DIKernel.Get <IParameterRepository>().GetById(entity.Parameter.Id);
             _entities.Add(entity);
             return(true);
         }
     }
     throw new Exception("Переданное для обновления дефолтное расписание отсутствует в репозитории.");
 }
Exemple #11
0
 public ActionResult Edit(int?id, DoctorForm form)
 {
     if (!id.HasValue)
     {
         return(RedirectTo <DoctorController>(a => a.List()));
     }
     form.Doctor = form.Doctor ?? Get <IDoctorRepository>().GetById(id.Value);
     if (form.Doctor == null)
     {
         return(RedirectTo <DoctorController>(a => a.List()));
     }
     form.Specialties = DIKernel.Get <ISpecialtyRepository>().GetAll();
     return(View(form));
 }
 public override bool Delete(Patient entity)
 {
     entity.Doctor.Patients.ToList().Remove(entity);
     DIKernel.Get <IDoctorRepository>().Delete(entity.Doctor);
     for (int i = 0; i < _entities.Count; i++)
     {
         Patient patient = _entities[i];
         if (patient.Id == entity.Id)
         {
             _entities.RemoveAt(i);
         }
     }
     return(true);
 }
 public override bool Update(PersonalSchedule entity)
 {
     entity.Parameter = DIKernel.Get <IParameterRepository>().GetById(entity.Parameter.Id);
     entity.Patient   = DIKernel.Get <IPatientRepository>().GetById(entity.Patient.Id);
     for (int i = 0; i < _entities.Count; i++)
     {
         PersonalSchedule schedule = _entities[i];
         if (schedule.Id == entity.Id)
         {
             _entities[i] = entity;
             return(true);
         }
     }
     return(false);
 }
Exemple #14
0
 public ActionResult Delete(int?id, bool?confirm)
 {
     if (!id.HasValue)
     {
         return(RedirectTo <DoctorController>(a => a.List()));
     }
     if (!confirm.HasValue)
     {
         Doctor doctor = Get <IDoctorRepository>().GetById(id.Value);
         if (doctor == null)
         {
             return(RedirectTo <DoctorController>(a => a.List()));
         }
         var form = new DoctorForm {
             Doctor = doctor
         };
         return(View(form));
     }
     if (confirm.Value)
     {
         DIKernel.Get <IDoctorRepository>().DeleteById(id.Value);
     }
     return(RedirectTo <DoctorController>(a => a.List()));
 }
Exemple #15
0
 protected T Get <T>()
 {
     return(DIKernel.Get <T>());
 }
Exemple #16
0
        public void InitializeForm()
        {
            _dgvs = new List <YDataGridView>();
            _collectionsPropertiInfos = new List <PropertyInfo>();

            Type dataType = typeof(TData);

            PropertyInfo[] propertiesInfo = dataType.GetProperties();

            var operationsContext =
                DIKernel.Get <OperationsRepository>().Operations.Where(
                    o => o.GetType() == typeof(OperationsContext <TData>)).FirstOrDefault() as
                OperationsContext <TData>;

            if (operationsContext != null)
            {
                if (_Id == -1)
                {
                    SaveData    = operationsContext.Save;
                    _dataObject = new TData();
                }
                else
                {
                    UpdateData = operationsContext.Update;
                    DetailData = operationsContext.Detail;
                }
            }

            if (SaveData != null)
            {
                var saveC = new ToolStripButton {
                    DisplayStyle = ToolStripItemDisplayStyle.Text, Text = @"Сохранить"
                };
                saveC.Click += (sender, e) =>
                {
                    //Флаг, показывающий - нормально ли сохранились данные
                    var okFlag = true;
                    if (_dgvs.Count == _collectionsPropertiInfos.Count)
                    {
                        for (var i = 0; i < _dgvs.Count; i++)
                        {
                            if (_dgvs[i] != null)
                            {
                                var _att = _collectionsPropertiInfos[i].GetCustomAttributes(true).
                                           FirstOrDefault(a => a.GetType() == typeof(DinamicCollectionModelAttribute)) as DinamicCollectionModelAttribute;

                                var _tp = _att.TypeOfCollectionElement;

                                var _tpc = typeof(Collection <>);

                                var _cstrTpc = _tpc.MakeGenericType(_tp);

                                var _lclClln = Activator.CreateInstance(_cstrTpc);

                                var _pis = _cstrTpc.GetProperties();

                                var _linkForTable = _dgvs[i];

                                for (var _rowIndex = 0; _rowIndex < _dgvs[i].RowCount - 1; _rowIndex++)
                                //Последнюю строчку не учитываем, в связи с тем, что она
                                //автоматически подстанавливается
                                {
                                    try
                                    {
                                        var _localRow = Activator.CreateInstance(_tp);

                                        for (var _columnIndex = 0; _columnIndex < _dgvs[i].ColumnCount; _columnIndex++)
                                        {
                                            try
                                            {
                                                _tp.GetProperty(_dgvs[i].Columns[_columnIndex].Name)
                                                .SetValue(_localRow, _linkForTable[_columnIndex, _rowIndex].Value, null);
                                            }
                                            catch { }
                                        }
                                        _cstrTpc.GetMethod("Add").Invoke(_lclClln, new object[] { _localRow });
                                    }
                                    catch
                                    {
                                    }
                                }

                                _collectionsPropertiInfos[i].SetValue(_dataObject, _lclClln, null);
                            }
                            else
                            {
                                okFlag = false;
                                break;
                            }
                        }
                    }
                    else
                    {
                        okFlag = false;
                    }

                    QueryStatus status = SaveData(_dataObject);
                    YMessageBox.Information(status.StatusMessage);

                    if (status.Status == 1)
                    {
                        okFlag = false;
                    }
                    if (okFlag)
                    {
                        this.Close();
                    }
                };
                tsOperations.Items.Add(saveC);
            }

            if (UpdateData != null)
            {
                TData o = new TData {
                    Id = _Id
                };
                _dataObject = DetailData(o) as TData;
            }

            //служебная переменная
            PropertyInfo propertyInfoSpecial;

            foreach (PropertyInfo propertyInfo in propertiesInfo)
            {
                if (propertyInfo.GetCustomAttributes(true).FirstOrDefault(
                        a => a.GetType() == typeof(NotDisplayAttribute) || a.GetType() == typeof(HideAttribute)) == null)
                {
                    string textForLabel         = propertyInfo.Name;
                    var    displayNameAttribute =
                        propertyInfo.GetCustomAttributes(true).FirstOrDefault(
                            a => a.GetType() == typeof(DisplayNameAttribute)) as DisplayNameAttribute;
                    if (displayNameAttribute != null)
                    {
                        textForLabel = displayNameAttribute.DisplayName;
                    }
                    var labelText = new Label {
                        Text = textForLabel, Height = LHeight, Top = _cHeight, Left = 15
                    };
                    Control c             = null;
                    var     singSelectAtt =
                        propertyInfo.GetCustomAttributes(true).FirstOrDefault(
                            a => a.GetType() == typeof(SingleSelectEditModeAttribute)) as SingleSelectEditModeAttribute;

                    var dinCollectAtt = propertyInfo.GetCustomAttributes(true).FirstOrDefault(
                        a => a.GetType() == typeof(DinamicCollectionModelAttribute)) as DinamicCollectionModelAttribute;

                    if (singSelectAtt != null && singSelectAtt.OperationContext != null)
                    {
                        object operationContext = Get <OperationsRepository>().Operations.FirstOrDefault(
                            o => o.GetType() == singSelectAtt.OperationContext);
                        if (operationContext != null)
                        {
                            Type funcType =
                                typeof(Func <>).MakeGenericType(
                                    typeof(IList <>).MakeGenericType(
                                        singSelectAtt.OperationContext.GetGenericArguments()[0]));
                            if (operationContext.GetType().GetProperty("Load").PropertyType == funcType)
                            {
                                object loadProperty =
                                    operationContext.GetType().GetProperty("Load").GetValue(operationContext, null);
                                if (loadProperty != null)
                                {
                                    Type singleSelectorType =
                                        typeof(SingleSelector <>).MakeGenericType(
                                            singSelectAtt.OperationContext.GetGenericArguments()[0]);
                                    c = Activator.CreateInstance(singleSelectorType) as Control;
                                    singleSelectorType.GetProperty("Top").SetValue(c, _cHeight, null);
                                    singleSelectorType.GetProperty("Left").SetValue(c, labelText.Width + labelText.Left, null);
                                    object txbSv        = singleSelectorType.GetField("txbSelectedValue").GetValue(c);
                                    object databindings = txbSv.GetType().GetProperty("DataBindings").GetValue(txbSv, null);
                                    databindings.GetType().InvokeMember("Add", BindingFlags.InvokeMethod, null,
                                                                        databindings,
                                                                        new object[]
                                    {
                                        "Text", _dataObject,
                                        propertyInfo.Name,
                                        false,
                                        DataSourceUpdateMode.OnPropertyChanged
                                    });
                                    singleSelectorType.GetProperty("SourceProperty").SetValue(c, singSelectAtt.SourceProperty, null);
                                    singleSelectorType.GetProperty("LoadData").SetValue(c, loadProperty, null);
                                    singleSelectorType.GetMethod("InitializeData").Invoke(c, null);
                                }
                            }
                        }
                    }
                    else
                    {
                        if (dinCollectAtt != null)
                        {
                            //c = Activator.CreateInstance(typeof(DinamicCollection)) as Control;
                            var cc = new DinamicCollection();
                            cc.Width      = tscContent.ContentPanel.Width - 20;
                            cc.Left       = 10;
                            cc.tableWidth = tscContent.ContentPanel.Width - 50;

                            /*
                             * В случае создания нового элемента, необходимо создать коллекцию.
                             */
                            propertyInfoSpecial = propertyInfo;

                            Action addrow = () =>
                            {
                                try
                                {
                                    typeof(TData).GetMethod("AddRow").Invoke(_dataObject, null);
                                    //cc.dgvMetaData.DataSource = propertyInfoSpecial.GetValue(_dataObject, null);
                                }
                                catch (Exception exp)
                                {
                                    YMessageBox.Error(exp.Message);
                                }
                            };

                            if (SaveData != null)
                            {
                            }

                            _dgvs.Add((cc as DinamicCollection).dgvMetaData);
                            _collectionsPropertiInfos.Add(propertyInfo);

                            /*
                             * Далее необходимо создать столбыцы, которые описаны в сущности
                             */
                            PropertyInfo[] elementPropertiesInfo = dinCollectAtt.TypeOfCollectionElement.GetProperties();

                            if (elementPropertiesInfo != null)
                            {
                                var fieldNumeric = cc.dgvMetaData.ColumnCount;
                                foreach (PropertyInfo propertyInfoOfElem in elementPropertiesInfo)
                                {
                                    var elemAttr = propertyInfoOfElem.GetCustomAttributes(true).FirstOrDefault(a => a.GetType() == typeof(DisplayNameAttribute)) as DisplayNameAttribute;
                                    if (propertyInfoOfElem.GetCustomAttributes(true).FirstOrDefault(a => a.GetType() == typeof(HideAttribute)) == null)
                                    {
                                        var columnText = elemAttr.DisplayName != null && elemAttr.DisplayName != "" ? elemAttr.DisplayName : propertyInfoOfElem.Name;
                                        cc.dgvMetaData.Columns.Add(new DataGridViewTextBoxColumn()
                                        {
                                            Name = propertyInfoOfElem.Name, HeaderText = columnText, DataPropertyName = propertyInfoOfElem.Name
                                        });
                                        fieldNumeric++;
                                    }
                                    //else
                                    //{
                                    //    var columnText = elemAttr.DisplayName != null && elemAttr.DisplayName != "" ? elemAttr.DisplayName : propertyInfoOfElem.Name;
                                    //    cc.dgvMetaData.Columns.Add(new DataGridViewTextBoxColumn() { Name = propertyInfoOfElem.Name, HeaderText = columnText, DataPropertyName = propertyInfoOfElem.Name, Visible = false });
                                    //}
                                }

                                //cc.dgvMetaData.DataBindings.Add("DataSource", propertyInfo.GetValue(_dataObject, null), propertyInfo.Name, true, DataSourceUpdateMode.OnPropertyChanged);
                                //cc.dgvMetaData.DataSource = propertyInfo.GetValue(_dataObject, null);
                                var fieldWidth = 0;
                                if (fieldNumeric != 0)
                                {
                                    fieldWidth = cc.dgvMetaData.Width / fieldNumeric;
                                    fieldWidth = fieldWidth > 15 ? fieldWidth : 15;
                                }
                                //foreach (var column in cc.dgvMetaData.Columns)
                                //{
                                //    column.Width = fieldWidth;
                                //}

                                //for (var i = 0; i < cc.dgvMetaData.ColumnCount; i++)
                                //{
                                //    cc.dgvMetaData.Columns[i].Width = fieldWidth;
                                //}
                            }

                            cc.AddButtonClick = (sender, e) => {
                                cc.dgvMetaData.Rows.Add();

                                //addrow();
                                cc.dgvMetaData.Update();
                            };

                            cc.DeleteButtonClick = (sender, e) => {
                                var delRowIndex = 0;
                                for (var i = 0; i < cc.dgvMetaData.RowCount; i++)
                                {
                                    for (var j = 0; j < cc.dgvMetaData.ColumnCount; j++)
                                    {
                                        if (cc.dgvMetaData.Rows[i].Cells[j].Selected)
                                        {
                                            delRowIndex = i;
                                            i           = cc.dgvMetaData.RowCount;
                                            break;
                                        }
                                    }
                                }
                                if (cc.dgvMetaData.RowCount > 1 && delRowIndex != cc.dgvMetaData.RowCount - 1)
                                {
                                    cc.dgvMetaData.Rows.RemoveAt(delRowIndex);
                                }
                            };
                            c = cc as Control;
                            if (c != null)
                            {
                                if (propertyInfo.GetCustomAttributes(true).FirstOrDefault(a => a.GetType() == typeof(NotEditAttribute)) != null)
                                {
                                    c.Enabled = false;
                                }
                                _cHeight += c.Height + 5;
                                tscContent.ContentPanel.Controls.AddRange(new[] { c, labelText });
                            }
                        }
                        else
                        {
                            var editModeAtt =
                                propertyInfo.GetCustomAttributes(true).FirstOrDefault(
                                    a => a.GetType() == typeof(EditModeAttribute)) as EditModeAttribute;
                            if (propertyInfo.PropertyType == typeof(string))
                            {
                                c = new TextBox {
                                    Height = LHeight, Top = _cHeight, Left = labelText.Width + labelText.Left
                                };
                                c.DataBindings.Add("Text", _dataObject, propertyInfo.Name, false,
                                                   DataSourceUpdateMode.OnPropertyChanged);
                                if (editModeAtt != null && editModeAtt.Mode.HasFlag(EditModeEnum.Multiline))
                                {
                                    (c as TextBox).Multiline  = true;
                                    (c as TextBox).ScrollBars = ScrollBars.Both;
                                    c.Height = c.Height * 3;
                                    c.Width  = c.Width * 3;
                                }
                            }
                            if (propertyInfo.PropertyType == typeof(DateTime))
                            {
                                c = new DateTimePicker {
                                    Height = LHeight, Top = _cHeight, Left = labelText.Width + labelText.Left
                                };
                                c.DataBindings.Add("Value", _dataObject, propertyInfo.Name, false,
                                                   DataSourceUpdateMode.OnPropertyChanged);
                            }
                            if (propertyInfo.PropertyType == typeof(int))
                            {
                                c = new NumericUpDown {
                                    Height = LHeight, Top = _cHeight, Left = labelText.Width + labelText.Left
                                };
                                c.DataBindings.Add("Value", _dataObject, propertyInfo.Name, false,
                                                   DataSourceUpdateMode.OnPropertyChanged);
                            }
                            if (propertyInfo.PropertyType.Name == typeof(ICollection <>).Name)
                            {
                                c = new YDataGridView {
                                    Height = 200, Top = _cHeight, Left = labelText.Width + labelText.Left, Width = 400
                                };
                                (c as YDataGridView).DataSource        = propertyInfo.GetValue(_dataObject, null);
                                (c as YDataGridView).RowHeadersVisible = false;
                            }

                            if (c != null)
                            {
                                if (propertyInfo.GetCustomAttributes(true).FirstOrDefault(a => a.GetType() == typeof(NotEditAttribute)) != null)
                                {
                                    c.Enabled = false;
                                }
                                _cHeight += c.Height + 5;
                                tscContent.ContentPanel.Controls.AddRange(new[] { c, labelText });
                            }
                        }
                    }
                }
            }
        }
Exemple #17
0
        private void InitializeProperties(object obj)
        {
            Type objType = obj.GetType();

            PropertyInfo[] propertiesInfo =
                objType.GetProperties().Where(
                    p =>
                    p.GetCustomAttributes(true).Where(
                        a => a.GetType() == typeof(NotDisplayAttribute) || a.GetType() == typeof(HideAttribute)).Count
                        () == 0).ToArray();
            foreach (PropertyInfo propertyInfo in propertiesInfo)
            {
                var propertyValue = propertyInfo.GetValue(obj, null);
                var att           =
                    propertyInfo.GetCustomAttributes(true).Where(a => a is DisplayNameAttribute).FirstOrDefault() as
                    DisplayNameAttribute;
                string labelText = att == null ? propertyInfo.Name : att.DisplayName;
                var    textLabel = new Label
                {
                    Text   = labelText,
                    Height = RHeight,
                    Top    = _cHeight,
                    Left   = 0
                };
                if (propertyValue is ICollection)
                {
                    var dataGridView = new YDataGridView
                    {
                        DataSource          = propertyValue,
                        BackgroundColor     = Color.White,
                        AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill,
                        Top = textLabel.Top + textLabel.Height
                    };
                    Controls.AddRange(new Control[] { textLabel, dataGridView });
                    _cHeight = dataGridView.Height + dataGridView.Top;
                    Type operationContextType = typeof(OperationsContext <>);
                    Type dObjType             = propertyValue.GetType().GetGenericArguments()[0];
                    Type objOperContxType     = operationContextType.MakeGenericType(dObjType);
                    var  operationsContext    =
                        DIKernel.Get <OperationsRepository>().Operations.Where(o => o.GetType() == objOperContxType).
                        FirstOrDefault();
                    if (operationsContext != null)
                    {
                        PropertyInfo pi         = operationsContext.GetType().GetProperty(@"Detail");
                        Type         methodType = typeof(Func <,>).MakeGenericType(dObjType, typeof(object));
                        var          mv         = pi.GetValue(operationsContext, null);
                        var          pv         = propertyValue as ICollection;
                        var          arr        = new object[pv.Count];
                        pv.CopyTo(arr, 0);
                        if (mv != null)
                        {
                            dataGridView.Detail =
                                clickedRow =>
                            {
                                object ob = methodType.InvokeMember("DynamicInvoke", BindingFlags.InvokeMethod,
                                                                    null, mv,
                                                                    new[] { arr[clickedRow] });
                                var form = new DetailForm(DIKernel, ob)
                                {
                                    MdiParent = MdiParent
                                };
                                form.Show();
                            };
                        }
                        dataGridView.InitializeOperations();
                    }
                }
                else
                {
                    string labelValue = propertyValue.ToString();
                    var    valueLabel = new Label
                    {
                        Text     = labelValue,
                        Top      = _cHeight,
                        Left     = textLabel.Width + 10,
                        AutoSize = true
                    };
                    _cHeight += RHeight > valueLabel.Height ? RHeight : valueLabel.Height;
                    Controls.AddRange(new[] { textLabel, valueLabel });
                }
            }
        }
Exemple #18
0
 private void button1_Click(object sender, EventArgs e)
 {
     multiSelector1.SetData(DIKernel.Get <SpecialtyRepository>().GetAll(), new List <Specialty.Specialty>());
 }
 public override bool Update(Patient entity)
 {
     entity.Doctor = DIKernel.Get <IDoctorRepository>().GetById(entity.Doctor.Id);
     return(base.Update(entity));
 }
Exemple #20
0
 public override sealed bool Save(DefaultSchedule entity)
 {
     entity.Parameter = DIKernel.Get <IParameterRepository>().GetById(entity.Parameter.Id);
     return(base.Save(entity));
 }
Exemple #21
0
        public void InitializeOperations()
        {
            var operationsContext =
                DIKernel.Get <OperationsRepository>().Operations.Where(
                    o => o.GetType() == typeof(OperationsContext <TData>)).FirstOrDefault() as
                OperationsContext <TData>;

            if (operationsContext != null)
            {
                LoadData   = operationsContext.Load;
                DeleteData = operationsContext.Delete;
                DetailData = operationsContext.Detail ?? DefaulDetailData;
            }
            else
            {
                DetailData = DefaulDetailData;
            }
            if (LoadData != null)
            {
                var el = new ToolStripButton
                {
                    DisplayStyle = ToolStripItemDisplayStyle.Text,
                    Text         = @"Обновить"
                };
                el.Click += (sender, e) => RefreshData();
                ydgvwc.tsOperations.Items.Add(el);
            }
            if (DeleteData != null)
            {
                var el = new ToolStripButton
                {
                    DisplayStyle = ToolStripItemDisplayStyle.Text,
                    Text         = @"Удалить"
                };
                Action <int> deleteAction = clickedRow =>
                {
                    QueryStatus status = DeleteData(_data[clickedRow]);
                    if (status.Status == 0)
                    {
                        YMessageBox.Information(status.StatusMessage);
                    }
                };
                el.Click += (sender, e) =>
                {
                    if (ydgvwc.ydgvData.SelectedCells.Count == 0)
                    {
                        YMessageBox.Information(@"Выберите строку для удаления");
                    }
                    else
                    {
                        int selectedIndex = ydgvwc.ydgvData.SelectedCells[0].RowIndex;
                        deleteAction(selectedIndex);
                    }
                };
                ydgvwc.ydgvData.Delete = deleteAction;
                ydgvwc.tsOperations.Items.Add(el);
            }
            if (DetailData != null)
            {
                var el = new ToolStripButton
                {
                    DisplayStyle = ToolStripItemDisplayStyle.Text,
                    Text         = @"Подробнее"
                };
                Action <int> detail = clickedRow =>
                {
                    var form = new DetailForm(DIKernel, DetailData(_data[clickedRow]))
                    {
                        MdiParent = MdiParent
                    };
                    form.Show();
                };
                el.Click += (sender, e) =>
                {
                    if (ydgvwc.ydgvData.SelectedCells.Count == 0)
                    {
                        YMessageBox.Information(@"Выберите строку для просмотра подробных данных.");
                    }
                    else
                    {
                        int selectedIndex = ydgvwc.ydgvData.SelectedCells[0].RowIndex;
                        detail(selectedIndex);
                    }
                };
                ydgvwc.tsOperations.Items.Add(el);
                ydgvwc.ydgvData.Detail = detail;
            }
            ydgvwc.ydgvData.InitializeOperations();
        }
 public override sealed bool Save(PersonalSchedule entity)
 {
     entity.Patient   = DIKernel.Get <IPatientRepository>().GetById(entity.Patient.Id);
     entity.Parameter = DIKernel.Get <IParameterRepository>().GetById(entity.Parameter.Id);
     return(base.Save(entity));
 }