Exemple #1
0
        // GET: Brigades/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Brigade brigade = db.Brigades.Find(id);

            if (brigade == null)
            {
                return(HttpNotFound());
            }
            return(View(brigade));
        }
Exemple #2
0
        // GET: Brigades/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Brigade brigade = db.Brigades.Find(id);

            if (brigade == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AreaId = new SelectList(db.Areas, "IdArea", "IdArea", brigade.AreaId);
            return(View(brigade));
        }
Exemple #3
0
        public Form7()
        {
            InitializeComponent();
            string       line;
            StreamReader fs = new StreamReader("brigade.txt");

            while ((line = fs.ReadLine()) != null)
            {
                Brigade  brig      = new Brigade();
                string[] splitLine = line.Split('|');
                brig.name = splitLine[0];
                listBox1.Items.Add(brig.name);
            }
            fs.Close();
        }
        public static void Update(Brigade model)
        {
            Brigade brigade = db.Brigades.FirstOrDefault(rec => rec.Id == model.Id);

            if (model.OrderId.HasValue)
            {
                brigade.OrderId = model.OrderId;
            }
            if (model.WorkTypeId.HasValue)
            {
                brigade.WorkTypeId = model.WorkTypeId;
            }

            db.SaveChanges();
        }
        public static void Create(Brigade model)
        {
            if (!model.WorkTypeId.HasValue)
            {
                throw new Exception("Column WorkTypeId could not be null");
            }

            db.Brigades.Add(
                new Brigade()
            {
                OrderId    = model.OrderId.HasValue ? model.OrderId : null,
                WorkTypeId = model.WorkTypeId
            });
            db.SaveChanges();
        }
        public async Task <IActionResult> OnGetAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Brigade = await _context.Brigade.FirstOrDefaultAsync(m => m.ID == id);

            if (Brigade == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemple #7
0
        public async Task <IActionResult> Create(CombatFormationViewModel combatForm)
        {
            Brigade brigade = new Brigade()
            {
                Name                  = combatForm.Name,
                Number                = combatForm.Number,
                TotalStrenght         = combatForm.TotalStrenght,
                AdditionalInformation = combatForm.AdditionalInformation,
                Commanders            = combatForm.Commanders,
                Regiments             = combatForm.Regiments,
                WeekId                = combatForm.WeekId,
                DivisionId            = combatForm.DivisionId,
                ArmyId                = combatForm.ArmyId,
                CorpsId               = combatForm.CorpsId,
                Image                 = combatForm.Image,
                Week                  = combatForm.Week,
                CoordinatesXY         = combatForm.Coordinates,
                CoordX                = combatForm.CoordX,
                CoordY                = combatForm.CoordY,
                Adress                = combatForm.Adress
            };

            if (ModelState.IsValid)
            {
                if (combatForm.Coordinates != null)
                {
                    string[] str = combatForm.Coordinates.Split(',', 2, StringSplitOptions.None);
                    brigade.CoordX = str[0];
                    brigade.CoordY = str[1];
                }
                if (combatForm.File != null)
                {
                    byte[] imageData = null;
                    // считываем переданный файл в массив байтов
                    using (var binaryReader = new BinaryReader(combatForm.File.OpenReadStream()))
                    {
                        imageData = binaryReader.ReadBytes((int)combatForm.File.Length);
                    }
                    // установка массива байтов
                    brigade.Image = imageData;
                }
                _context.Add(brigade);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Edit", new { id = brigade.BrigadeId }));
            }
            return(View(brigade));
        }
Exemple #8
0
        public async Task <IActionResult> PutBrigade(string id, Brigade update)
        {
            Brigade brigade;

            try
            {
                brigade = await _context.brigades.FindAsync(id);

                _context.Entry(brigade).State = EntityState.Detached;
            }
            catch (PostgresException e)
            {
                throw new NpgsqlException("Błąd serwera SQL - " + e.MessageText + " (kod " + e.SqlState + ")");
            }

            if (brigade != null)
            {
                foreach (PropertyInfo pi in typeof(Brigade).GetProperties())
                {
                    if ((pi.GetValue(update) != pi.GetValue(brigade)) && (pi.GetValue(update) != null))
                    {
                        _context.Entry(update).Property(pi.Name).IsModified = true;
                    }
                    else if (pi.Name.Equals("id"))
                    {
                        update.id = id;
                    }
                }
            }
            else
            {
                return(NotFound("Nie znaleziono"));
            }

            try
            {
                await _context.SaveChangesAsync();

                _context.Entry(update).State = EntityState.Detached;
                brigade = await _context.brigades.FindAsync(id);
            }
            catch (DbUpdateConcurrencyException e)
            {
                throw new DbUpdateConcurrencyException("Błąd podczas aktualizacji bazy danych - " + e.Message);
            }

            return(Ok(brigade));
        }
Exemple #9
0
        public async Task <JsonResult> Add([FromBody] Brigade input)
        {
            await CheckPermission();

            var sqlR = new BrigadeRepository(_logger);

            if (input.Id != 0)
            {
                await sqlR.Update(input);
            }
            else
            {
                await sqlR.Add(input);
            }
            return(Json(new { message = "addOrUpdate OK" }));
        }
        public async Task <IActionResult> OnPostAsync(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Brigade = await _context.Brigade.FindAsync(id);

            if (Brigade != null)
            {
                _context.Brigade.Remove(Brigade);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemple #11
0
 private void bSave_Click(object sender, EventArgs e)
 {
     if (Check())
     {
         Brigade brigade = new Brigade(this._Area.Id, Convert.ToByte(mtbCode.Text), tbTitle.Text);
         if (this._Brigade == null)
         {
             Databases.Tables.Brigades.Insert(brigade);
         }
         else
         {
             this._Brigade.Update(brigade);
         }
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
 }
        private void bBrigade_Click(object sender, EventArgs e)
        {
            frmStructure f = new frmStructure();

            f.CatalogMode = CatalogMode.Select;
            f.ShowDialog();
            if (f.ctrlStructure.SelectedBrigadeId != 0)
            {
                Brigade brigade = Databases.Tables.Brigades[f.ctrlStructure.SelectedBrigadeId];
                bBrigade.Text = String.Format("{0} / {1}", brigade.Area.Code.ToString("D2"), brigade.Code.ToString("D2"));
                bBrigade.Tag  = brigade;
            }
            if (this.bBrigade.Tag != null)
            {
                Calculate();
            }
        }
        public ActionResult SubmitRequest(Request request)
        {
            Brigade brigade = brigadeRepository.Get(request.Brigade?.BrigadeID);

            request.Brigade = brigade;
            requestRepository.Create(request);

            try
            {
                requestRepository.Save();
            }
            catch (DbEntityValidationException ex)
            {
                string msg = "Errors";
                foreach (DbEntityValidationResult validationError in ex.EntityValidationErrors)
                {
                    msg = validationError.Entry.Entity.ToString() + "\n";
                    foreach (DbValidationError err in validationError.ValidationErrors)
                    {
                        msg += err.ErrorMessage + "\n";
                    }
                }

                X.Msg.Notify(new NotificationConfig
                {
                    Icon  = Icon.Accept,
                    Title = "Errors",
                    Html  = msg
                }).Show();

                ViewBag.regime = 2;
                return(View("Index"));
            }


            X.Msg.Notify(new NotificationConfig
            {
                Icon  = Icon.Accept,
                Title = "Сохранение",
                Html  = request.RequestName + " добавлена"
            }).Show();

            return(RedirectToAction("Index"));
        }
Exemple #14
0
        public async Task Add(Brigade input)
        {
            var all = await GetAll();

            if (all.Any(x => x.Name.Equals(input.Name)))
            {
                throw new ValidationException(Error.AlreadyAddWithThisName);
            }
            using (var conn = new SqlConnection(AppSettings.ConnectionString))
            {
                await conn.ExecuteAsync(Sql.SqlQueryCach["Brigade.Add"],
                                        new
                {
                    name        = input.Name,
                    description = input.Description,
                    brigadeType = (int)input.BrigadeType
                });
            }
        }
Exemple #15
0
 public void SaveBrigade(Brigade brigade)
 {
     if (brigade.BrigadeId == 0)
     {
         context.Brigades.Add(brigade);
     }
     else
     {
         Brigade dbEntry = context.Brigades.Find(brigade.BrigadeId);
         if (dbEntry != null)
         {
             dbEntry.NavigatorTeamId  = brigade.NavigatorTeamId;
             dbEntry.OperatorTeamId   = brigade.OperatorTeamId;
             dbEntry.PilotTeamId      = brigade.PilotTeamId;
             dbEntry.StewardessTeamId = brigade.StewardessTeamId;
         }
     }
     context.SaveChanges();
 }
Exemple #16
0
        public async Task Update(Brigade input)
        {
            var current = await ById(input.Id);

            if (current.Name.Equals(input.Name))
            {
                throw new ValidationException(Error.AlreadyAddWithThisName);
            }

            using (var conn = new SqlConnection(AppSettings.ConnectionString))
            {
                await conn.ExecuteAsync(Sql.SqlQueryCach["Brigade.Update"],
                                        new
                {
                    name        = input.Name,
                    description = input.Description,
                    brigadeType = (int)input.BrigadeType,
                    id          = input.Id
                });
            }
        }
Exemple #17
0
        static int ScriptInsert1()
        {
            var order = OrderService.Read(new Order()
            {
                RegistrationDate = DateTime.Now.Date
            }, 1, 0).First();

            // Предполагается, что действия до создания модели - это моделирование выбора пользователя

            Brigade model = new Brigade()
            {
                WorkTypeId = 10, OrderId = order.Id
            };

            DateTime startTime = DateTime.Now;

            BrigadeService.Create(model);
            DateTime finishTime = DateTime.Now;

            return((int)(finishTime - startTime).TotalMilliseconds);
        }
Exemple #18
0
        private void DrawBrigade(DrawingContext dc, Brigade r)
        {
            int width     = r.GetWidthInPaces();
            int halfwidth = width / 2;
            int height    = r.GetDepthInPaces();

            int x     = r.MapX;
            int y     = r.MapY;
            int angle = r.FacingInDegrees;

            //r.ShortName = DateTime.Now.ToLongTimeString();

            dc.PushTransform(new RotateTransform(angle, x + halfwidth, y));

            // Create a rectangle and draw it in the DrawingContext.
            Rect rect = new Rect(new System.Windows.Point(x, y), new System.Windows.Size(width, height));

            dc.DrawRectangle(System.Windows.Media.Brushes.Blue, (System.Windows.Media.Pen)null, rect);

            //Rect rect2 = new Rect(new System.Windows.Point(x, y + height), new System.Windows.Size(width, 10));
            //dc.DrawRectangle(System.Windows.Media.Brushes.Black, (System.Windows.Media.Pen)null, rect2);

            /*
             * Rect rect3 = new Rect(new System.Windows.Point(x + (halfwidth - widgetsize) //150
             * , y - widgetsize), new System.Windows.Size(20, 10));
             * dc.DrawRectangle(System.Windows.Media.Brushes.Red, (System.Windows.Media.Pen)null, rect3);
             */

            dc.DrawText(


                new FormattedText(r.ShortName,
                                  CultureInfo.GetCultureInfo("en-us"),
                                  FlowDirection.LeftToRight,
                                  new Typeface("Verdana"),
                                  12, System.Windows.Media.Brushes.Black),
                new System.Windows.Point(x, y + height));

            dc.Pop();
        }
        public DirectResult EditRequest(int id, string newValue, object customer)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            Request request       = serializer.Deserialize <Request>((customer as string[])[0]);
            Brigade brigade       = brigadeRepository.Get(request.Brigade.BrigadeID);
            Request requestToSave = requestRepository.Get(id);

            requestToSave.Update(request);
            requestToSave.Brigade = brigade;
            requestRepository.Update(requestToSave);
            try
            {
                requestRepository.Save();
            }
            catch (DbEntityValidationException ex)
            {
                string msg = "Errors";
                foreach (DbEntityValidationResult validationError in ex.EntityValidationErrors)
                {
                    msg = validationError.Entry.Entity.ToString() + "\n";
                    foreach (DbValidationError err in validationError.ValidationErrors)
                    {
                        msg += err.ErrorMessage + "\n";
                    }
                }

                X.Msg.Notify(new NotificationConfig
                {
                    Icon  = Icon.Accept,
                    Title = "Ошибка!",
                    Html  = msg
                }).Show();

                return(this.Direct());
            }

            X.GetCmp <Store>("RequestStore").GetById(id).Commit();

            return(this.Direct());
        }
Exemple #20
0
        static int ScriptRead1()
        {
            Order order = OrderService.Read(new Order()
            {
                RegistrationDate = DateTime.Now.Date
            }, 1, 0).First();

            // Предполагается, что действия до создания модели - это моделирование выбора пользователя

            Brigade model = new Brigade()
            {
                OrderId = order.Id
            };

            DateTime startTime  = DateTime.Now;
            Brigade  brigade    = BrigadeService.Read(model, 1, 0).First();
            DateTime finishTime = DateTime.Now;

            Console.WriteLine("{0}: {1}", brigade.Id, brigade.Workers.Count);

            return((int)(finishTime - startTime).TotalMilliseconds);
        }
Exemple #21
0
        public override void New()
        {
            if (this.BrigadeId != 0)
            {
                Brigade    brigade = Databases.Tables.Brigades[BrigadeId];
                frmPersons form    = new frmPersons();

                form.ctrlPersons.Deletions = (from person in Databases.Tables.Persons.Active
                                              from brigadePerson in Databases.Tables.BrigadePersons.Active
                                              where person.Equals(brigadePerson.Person)
                                              select person).ToList();

                form.CatalogMode = CatalogMode.Select;
                form.ShowDialog();
                if (form.SelectedPersonId != 0)
                {
                    BrigadePerson brigadePerson = new BrigadePerson(this.BrigadeId, form.SelectedPersonId);
                    Databases.Tables.BrigadePersons.Insert(brigadePerson);
                }
                Init();
            }
        }
Exemple #22
0
        public ActionResult Delete(Guid id)
        {
            var brigade = new Brigade();

            try
            {
                using (SqlConnection oConn = new SqlConnection(_connString))
                {
                    string sqlString = "SELECT * FROM Brigades WHERE BrigadeId = @BrigadeId";
                    using (SqlCommand oCmd = new SqlCommand(sqlString, oConn))
                    {
                        if (ModelState.IsValid)
                        {
                            oCmd.Connection.Open();
                            oCmd.CommandType = CommandType.Text;
                            var oPrms = new SqlParameter[1];
                            oPrms[0]       = new SqlParameter(parameterName: "@BrigadeId", dbType: SqlDbType.UniqueIdentifier, size: 128);
                            oPrms[0].Value = id;
                            oCmd.Parameters.AddRange(oPrms);
                            using (SqlDataReader oRdr = oCmd.ExecuteReader())
                            {
                                while (oRdr.Read())
                                {
                                    brigade.Id   = new Guid(oRdr["BrigadeId"].ToString());
                                    brigade.Name = oRdr["Brigade"].ToString();
                                }
                            }
                        }
                        return(View(brigade));
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.Error = string.Format(format: "Error: {0}", arg0: ex.Message);
                return(View());
            }
        }
Exemple #23
0
        public async Task <ActionResult <Brigade> > PostBrigade(Brigade brigade)
        {
            try
            {
                _context.brigades.Any();
            }
            catch (PostgresException e)
            {
                throw new NpgsqlException("Błąd serwera SQL - " + e.MessageText + " (kod " + e.SqlState + ")");
            }

            _context.brigades.Add(brigade);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException e)
            {
                throw new DbUpdateConcurrencyException("Błąd podczas aktualizacji bazy danych - " + e.Message);
            }

            return(CreatedAtAction("GetBrigade", new { brigade.id }, brigade));
        }
        public ActionResult SubmitBrigade(Brigade brigade)
        {
            brigadeRepository.Create(brigade);
            try
            {
                brigadeRepository.Save();
            }
            catch (DbEntityValidationException ex)
            {
                string msg = "Errors";
                foreach (DbEntityValidationResult validationError in ex.EntityValidationErrors)
                {
                    msg = validationError.Entry.Entity.ToString() + "\n";
                    foreach (DbValidationError err in validationError.ValidationErrors)
                    {
                        msg += err.ErrorMessage + "\n";
                    }
                }

                X.Msg.Notify(new NotificationConfig
                {
                    Icon  = Icon.Accept,
                    Title = "Ошибка!",
                    Html  = msg
                }).Show();

                return(View("Index"));
            }
            //X.Msg.Notify(new NotificationConfig
            //{
            //    Icon = Icon.Accept,
            //    Title = "Сохранение",
            //    Html = brigade.BrigadeName + " добавлена"
            //}).Show();

            return(RedirectToAction("Index"));
        }
Exemple #25
0
 public ActionResult Create(Brigade brigade)
 {
     try
     {
         if (BrigadeExists(brigade))
         {
             ViewBag.Error = string.Format(format: "A record for Brigade '{0}' already exists!", arg0: brigade.Name);
             return(View());
         }
         else
         {
             using (SqlConnection oConn = new SqlConnection(_connString))
             {
                 string sqlString = "INSERT INTO Brigades (BrigadeId, Brigade) VALUES (@BrigadeId, @Brigade)";
                 using (SqlCommand oCmd = new SqlCommand(sqlString))
                 {
                     oCmd.Connection = oConn;
                     var oPrms = new SqlParameter[2];
                     oPrms[0]       = new SqlParameter(parameterName: "@BrigadeId", dbType: SqlDbType.UniqueIdentifier, size: 36);
                     oPrms[0].Value = Guid.NewGuid();
                     oPrms[1]       = new SqlParameter(parameterName: "@Brigade", dbType: SqlDbType.VarChar, size: 128);
                     oPrms[1].Value = brigade.Name;
                     oCmd.Parameters.AddRange(oPrms);
                     oConn.Open();
                     oCmd.ExecuteScalar();
                     oConn.Close();
                 }
             }
             return(RedirectToAction(actionName: "Index"));
         }
     }
     catch (Exception ex)
     {
         ViewBag.Error = string.Format(format: "Error: {0}", arg0: ex.Message);
         return(View());
     }
 }
Exemple #26
0
        public IEnumerable <Brigade> SelectBrigades()
        {
            List <Brigade> requests = new List <Brigade>();

            using (OracleConnection connection = new OracleConnection(OracleWcfService.CONNECTION_STRING))
            {
                connection.Open();  //исправить
                OracleCommand oraCommand = new OracleCommand("SELECT b.BRIGADE_ID, b.BRIGADE_NAME, e.FIO "
                                                             + "FROM BRIGADE b JOIN EMPLOYEE e on b.BRIGADE_LEAD_ID = e.EMPLOYEE_ID ", connection);
                OracleDataReader oraReader = oraCommand.ExecuteReader();
                if (oraReader.HasRows)
                {
                    while (oraReader.Read())
                    {
                        var temp = new Brigade();
                        temp.id          = oraReader.GetInt32(0);
                        temp.brigadeLead = oraReader.GetString(1);
                        temp.brigadeName = oraReader.GetString(2);
                        requests.Add(temp);
                    }
                }
            }
            return(requests);
        }
Exemple #27
0
        public void RedrawBrigade(Brigade b, bool removeOldVisuals)
        {
            if (b != null)
            {
                if (removeOldVisuals)
                {
                    // remove the old visual if it exists
                    DrawingVisual oldVisual = null;
                    brigadeVisualsById.TryGetValue(b.BrigadeId, out oldVisual);
                    if (oldVisual != null)
                    {
                        RemoveVisualChild(oldVisual);
                        m_Visuals.Remove(oldVisual);
                    }
                }

                // render a new visual
                DrawingVisual dv = CreateBrigadeDrawingVisual(b);
                brigadeVisuals[dv] = b;
                brigadeVisualsById[b.BrigadeId] = dv;
                m_Visuals.Add(dv);
                AddVisualChild(dv);
            }
        }
        public ActionResult NewBrigade()
        {
            Brigade brigade = new Brigade();

            return(PartialView("Brigade", brigade));
        }
Exemple #29
0
 private void UpdateBrigade(Brigade b)
 {
     Game.SelectedRegiment = null;
     Game.SelectedBrigade  = b;
 }
Exemple #30
0
        public ViewModelAddOperation(NavigationController controller) : base(controller)
        {
            Doctors         = new ObservableCollection <DoctorDataSource>();
            DoctorsSelected = new ObservableCollection <DoctorDataSource>();

            ShowDoctors = true;

            ShowMeds            = true;
            ShowMedsSelected    = true;
            ShowDoctorsSelected = true;
            TextBoxMinute       = Brushes.Gray;
            TextBoxHour         = Brushes.Gray;
            MinuteHour          = DateTime.Now;
            TimeCheckHour       = true;
            TimeCheckMinute     = true;
            ButtonSaveText      = "Назначить операцию";


            MessageBus.Default.Subscribe("AddOperationTypeForDialogBox", AddOperationTypeForDialogBox);
            MessageBus.Default.Subscribe("SetOperationResult", SetOperResult);
            MessageBus.Default.Subscribe("SetCurrentPatientForOperation", SetCurrentPatientID);
            MessageBus.Default.Subscribe("SetRightDiagnosisListForOperation", SetRightDiagnosisList);
            MessageBus.Default.Subscribe("SetLeftDiagnosisListForOperation", SetLeftDiagnosisList);
            MessageBus.Default.Subscribe("UpdateSelectedDoctors", UpdateSelectedDoctors);

            MessageBus.Default.Subscribe("SetRightOperationListForOperation", SetRightOpList);
            MessageBus.Default.Subscribe("SetLeftOperationListForOperation", SetLeftOpList);



            Controller    = controller;
            HasNavigation = false;
            Operation     = new Operation();
            // Operation.Date = DateTime.Now;
            LeftDiagnosisList  = new CollectionViewSource();
            RightDiagnosisList = new CollectionViewSource();
            LeftOperationList  = new CollectionViewSource();
            RightOperationList = new CollectionViewSource();



            var timeItem = Data.OperationDateTime.GetAll.Where(e => e.Operation_id == 0);

            foreach (var OpTImeWithNULL in timeItem)
            {
                if (Data.OperationDateTime.GetAll.Where(e => e.Operation_id != null && e.Operation_id != 0 && e.Datetime.Year == OpTImeWithNULL.Datetime.Year && e.Datetime.Month == OpTImeWithNULL.Datetime.Month && e.Datetime.Day == OpTImeWithNULL.Datetime.Day).FirstOrDefault() == null)
                {
                    foreach (var opDate in Data.OperationDateTime.GetAll.Where(e => e.Datetime.Year == OpTImeWithNULL.Datetime.Year && e.Datetime.Month == OpTImeWithNULL.Datetime.Month && e.Datetime.Day == OpTImeWithNULL.Datetime.Day))
                    {
                        Data.OperationDateTime.Remove(Data.OperationDateTime.Get(opDate.Id));
                    }
                }
                else
                {
                    var opDate1 = Data.OperationDateTime.Get(OpTImeWithNULL.Id);
                    opDate1.Doctor_id    = null;
                    opDate1.Note         = "Время свободно";
                    opDate1.Operation_id = null;
                    Data.Complete();
                }
            }
            Data.Complete();


            GetLeftFromLastObs = new DelegateCommand(
                () =>
            {
                var ExamsOfCurrPatient = Data.Examination.GetAll.ToList().Where(s => s.PatientId == CurrentPatient.Id).ToList();

                if (ExamsOfCurrPatient.Count > 0)
                {
                    DateTime MaxExam                       = ExamsOfCurrPatient.Max(s => s.Date);
                    var ExamsOfCurrPatientLatest           = ExamsOfCurrPatient.Where(s => s.Date == MaxExam).ToList();
                    List <DiagnosisObs> DiagOfCurrPatienLt = Data.DiagnosisObs.GetAll.ToList().Where(s => s.id_leg_examination == ExamsOfCurrPatientLatest[0].Id && s.isLeft == true).ToList();
                    //  List<DiagnosisObs> DiagOfCurrPatientRt = DiagObsRep.GetAll.ToList().Where(s => s.id_обследование_ноги == ExamsOfCurrPatientLatest[0].Id && s.isLeft == false).ToList();

                    //   MessageBus.Default.Call("SetDiagnosisListRight", null, DiagOfCurrPatientRt);
                    MessageBus.Default.Call("SetDiagnosisListLeft", null, DiagOfCurrPatienLt);


                    // ExaminationLeg leftLegExam = LegExamRep.Get(ExamsOfCurrPatientLatest[0].idLeftLegExamination.Value);
                    // ExaminationLeg rightLegExam = LegExamRep.Get(ExamsOfCurrPatientLatest[0].idRightLegExamination.Value);

                    // Letters bufLetter = new Letters();
                    Controller.NavigateTo <ViewModelAddOperation>();
                }
                else
                {
                    MessageBox.Show("Нет диагноза слева последнего обследования");
                }
            }
                );
            GetRightFromLastObs = new DelegateCommand(
                () =>
            {
                var ExamsOfCurrPatient = Data.Examination.GetAll.ToList().Where(s => s.PatientId == CurrentPatient.Id).ToList();

                if (ExamsOfCurrPatient.Count > 0)
                {
                    DateTime MaxExam             = ExamsOfCurrPatient.Max(s => s.Date);
                    var ExamsOfCurrPatientLatest = ExamsOfCurrPatient.Where(s => s.Date == MaxExam).ToList();
                    //  List<DiagnosisObs> DiagOfCurrPatienLt = DiagObsRep.GetAll.ToList().Where(s => s.id_обследование_ноги == ExamsOfCurrPatientLatest[0].Id && s.isLeft == true).ToList();
                    List <DiagnosisObs> DiagOfCurrPatientRt = Data.DiagnosisObs.GetAll.ToList().Where(s => s.id_leg_examination == ExamsOfCurrPatientLatest[0].Id && s.isLeft == false).ToList();

                    MessageBus.Default.Call("SetDiagnosisListRight", null, DiagOfCurrPatientRt);
                    // MessageBus.Default.Call("SetDiagnosisListLeft", null, DiagOfCurrPatienLt);


                    // ExaminationLeg leftLegExam = LegExamRep.Get(ExamsOfCurrPatientLatest[0].idLeftLegExamination.Value);
                    // ExaminationLeg rightLegExam = LegExamRep.Get(ExamsOfCurrPatientLatest[0].idRightLegExamination.Value);

                    // Letters bufLetter = new Letters();
                    Controller.NavigateTo <ViewModelAddOperation>();
                }
                else
                {
                    MessageBox.Show("Нет диагноза справа последнего обследования");
                }
            }
                );

            ToCurrentPatientCommand = new DelegateCommand(
                () =>
            {
                if (Operation.Datetime_id != null && Operation.Datetime_id != 0)
                {
                    var OpDate          = Data.OperationDateTime.Get(Operation.Datetime_id.Value);
                    OpDate.Doctor_id    = null;
                    OpDate.Note         = "Время свободно";
                    OpDate.Operation_id = null;
                    Data.Complete();

                    var timeItem1 = Data.OperationDateTime.Where(e => e.Operation_id != null && e.Datetime.Year == OpDate.Datetime.Year && e.Datetime.Month == OpDate.Datetime.Month && e.Datetime.Day == OpDate.Datetime.Day).FirstOrDefault();
                    if (timeItem1 == null)
                    {
                        foreach (var opDate in Data.OperationDateTime.Where(e => e.Datetime.Year == OpDate.Datetime.Year && e.Datetime.Month == OpDate.Datetime.Month && e.Datetime.Day == OpDate.Datetime.Day))
                        {
                            Data.OperationDateTime.Remove(Data.OperationDateTime.Get(opDate.Id));
                        }
                    }
                    Data.Complete();

                    CurrentPanelSelectTime.SelectedOpTimeView     = null;
                    CurrentPanelSelectTime.SelectedOpTimeViewCopy = null;
                    CurrentPanelSelectTime.BuffSelectedOpTimeView = null;
                }
                Controller.NavigateTo <ViewModelCurrentPatient>();
            }
                );

            ToOperationOverviewCommand = new DelegateCommand(
                () =>
            {
                bool test = false;
                if (SelectedLegId == 0)
                {
                    //  ObservableCollection<OperationTypesDataSource> aray = (ObservableCollection<OperationTypesDataSource>)LeftOperationList.Source;
                    if (LeftOperationList.Source == null ||
                        ((ObservableCollection <OperationTypesDataSource>)LeftOperationList.Source).Count == 0 ||
                        ((ObservableCollection <DiagnosisDataSource>)LeftDiagnosisList.Source).Count == 0 ||
                        LeftDiagnosisList.Source == null || RightDiagnosisList.Source == null ||
                        ((ObservableCollection <DiagnosisDataSource>)RightDiagnosisList.Source).Count == 0 ||
                        ((ObservableCollection <DiagnosisDataSource>)LeftDiagnosisList.Source).Count == 0 ||
                        DoctorsSelected.Count == 0 || TimeCheckHour == false || TimeCheckMinute == false || Operation.Datetime_id == null)
                    {
                        MessageBox.Show("Не всё заполнено!");
                        if (Operation.Datetime_id == null)
                        {
                            Button_time_B = Brushes.Red;
                        }
                        else
                        {
                            Button_time_B = Brushes.Gray;
                        }
                    }
                    else
                    {
                        test = true;
                    }
                }
                else if (SelectedLegId == 1)
                {
                    if (RightOperationList.Source == null || ((ObservableCollection <OperationTypesDataSource>)RightOperationList.Source).Count == 0 || RightDiagnosisList.Source == null || ((ObservableCollection <DiagnosisDataSource>)RightDiagnosisList.Source).Count == 0 || ((ObservableCollection <DiagnosisDataSource>)LeftDiagnosisList.Source).Count == 0 || DoctorsSelected.Count == 0 || TimeCheckHour == false || TimeCheckMinute == false || Operation.Datetime_id == null)
                    {
                        MessageBox.Show("Не всё заполнено!");
                    }
                    else
                    {
                        test = true;
                    }
                }
                else if (RightOperationList.Source == null || ((ObservableCollection <OperationTypesDataSource>)RightOperationList.Source).Count == 0 || LeftOperationList.Source == null || ((ObservableCollection <OperationTypesDataSource>)LeftOperationList.Source).Count == 0 || LeftDiagnosisList.Source == null || RightDiagnosisList.Source == null || ((ObservableCollection <DiagnosisDataSource>)LeftDiagnosisList.Source).Count == 0 || ((ObservableCollection <DiagnosisDataSource>)RightDiagnosisList.Source).Count == 0 || DoctorsSelected.Count == 0 || TimeCheckHour == false || TimeCheckMinute == false || Operation.Datetime_id == null)
                {
                    MessageBox.Show("Не всё заполнено!");
                }
                else
                {
                    test = true;
                }
                if (test)
                {
                    // Operation.Date = new DateTime(Operation.Date.Year,// Operation.Date.Month,// Operation.Date.Day, MinuteHour.Hour, MinuteHour.Minute, 0);
                    // Operation.Time = MinuteHour.Hour + ":" + MinuteHour.Minute + ":" + 0;
                    var opDate = Data.OperationDateTime.Get(Operation.Datetime_id.Value);

                    Operation.PatientId    = CurrentPatient.Id;
                    Operation.AnestheticId = AnestethicTypesID[AnesteticSelected];
                    Operation.OnWhatLegOp  = SelectedLegId.ToString();
                    Data.Operation.Add(Operation);
                    Data.Complete();
                    opDate.Operation_id = Operation.Id;

                    //    var opDataToRemove = new OperationDateTime();
                    //    var test = true;
                    //    var OperationRep = new OperationRepository(context);
                    var SelectedOpDate = Data.OperationDateTime.Get(Operation.Datetime_id.Value);
                    opDate.Doctor_id   = SelectedOpDate.Doctor_id;
                    opDate.Note        = SelectedOpDate.Note;

                    foreach (var Doctor in DoctorsSelected)
                    {
                        if (Doctor.isDoctor)
                        {
                            Brigade buf      = new Brigade();
                            buf.id_doctor    = Doctor.id;
                            buf.id_operation = Operation.Id;
                            Data.Brigade.Add(buf);
                            Data.Complete();
                        }
                        else
                        {
                            BrigadeMedPersonal buf = new BrigadeMedPersonal();
                            buf.id_med_staff       = Doctor.id;
                            buf.id_operation       = Operation.Id;
                            Data.BrigadeMedPersonal.Add(buf);
                            Data.Complete();
                        }
                    }


                    if (LeftOperationList.Source != null)
                    {
                        foreach (var OpL in (ObservableCollection <OperationTypesDataSource>)LeftOperationList.Source)
                        {
                            OperationTypeOperations buf = new OperationTypeOperations();
                            buf.id_operation_type       = OpL.Data.Id;
                            buf.id_operation            = Operation.Id;
                            buf.isLeft = true;

                            Data.OperationTypeOperations.Add(buf);
                            Data.Complete();
                        }
                    }
                    if (RightOperationList.Source != null)
                    {
                        foreach (var OpR in (ObservableCollection <OperationTypesDataSource>)RightOperationList.Source)
                        {
                            OperationTypeOperations buf = new OperationTypeOperations();
                            buf.id_operation_type       = OpR.Data.Id;
                            buf.id_operation            = Operation.Id;
                            buf.isLeft = false;

                            Data.OperationTypeOperations.Add(buf);
                            Data.Complete();
                        }
                    }

                    if (LeftDiagnosisList.Source != null)
                    {
                        foreach (var diagnozL in (ObservableCollection <DiagnosisDataSource>)LeftDiagnosisList.Source)
                        {
                            Diagnosis buf    = new Diagnosis();
                            buf.id_diagnosis = diagnozL.Data.Id;
                            buf.id_operation = Operation.Id;
                            buf.isLeft       = true;

                            Data.Diagnosis.Add(buf);
                            Data.Complete();
                        }
                    }



                    if (RightDiagnosisList.Source != null)
                    {
                        foreach (var diagnozR in (ObservableCollection <DiagnosisDataSource>)RightDiagnosisList.Source)
                        {
                            Diagnosis buf    = new Diagnosis();
                            buf.id_diagnosis = diagnozR.Data.Id;
                            buf.id_operation = Operation.Id;
                            buf.isLeft       = false;

                            Data.Diagnosis.Add(buf);
                            Data.Complete();
                        }
                    }

                    //       Data.Complete();
                    if (isSetOperResult == true)
                    {
                        OperationResult.IdNextOperation = Operation.Id;
                        Data.Complete();
                        isSetOperResult = false;
                    }

                    CurrentPanelSelectTime.SelectedOpTimeView     = null;
                    CurrentPanelSelectTime.SelectedOpTimeViewCopy = null;
                    CurrentPanelSelectTime.BuffSelectedOpTimeView = null;

                    MessageBus.Default.Call("SetCurrentACCOp", this, null);
                    MessageBus.Default.Call("GetOperationForOverwiev", this, Operation.Id);

                    Controller.NavigateTo <ViewModelOperationOverview>();
                    //    Data.Complete();
                    Operation       = new Operation();
                    OperationResult = new OperationResult();
                }
            }
                );
            IsLeftLegInOperation  = Visibility.Visible;
            IsRightLegInOperation = Visibility.Visible;
            ToLeftOprCommand      = new DelegateCommand(
                () =>
            {
                MessageBus.Default.Call("SetleftOrRightOpForOp", this, "Left");
                Controller.NavigateTo <ViewModelOperationListForOperation>();
            }
                );
            ToRightOprCommand = new DelegateCommand(
                () =>
            {
                MessageBus.Default.Call("SetleftOrRightOpForOp", this, "Right");
                Controller.NavigateTo <ViewModelOperationListForOperation>();
            }
                );
            ToLeftDiagCommand = new DelegateCommand(
                () =>
            {
                MessageBus.Default.Call("SetleftOrRight", this, "Left");
                Controller.NavigateTo <ViewModelDiagnosisListForOperation>();
            }
                );
            ToRightDiagCommand = new DelegateCommand(
                () =>
            {
                MessageBus.Default.Call("SetleftOrRight", this, "Right");
                Controller.NavigateTo <ViewModelDiagnosisListForOperation>();
            }
                );
            //for right panel
            CurrentPanelViewModel = new OperationTypePanelViewModel(this);

            OpenPanelCommand = new DelegateCommand(() =>
            {
                CurrentPanelViewModel.ClearPanel();
                CurrentPanelViewModel.PanelOpened = true;
            });
            #region Select time comands
            CurrentPanelSelectTime = new SelectTimePanelViewModel(this);
            OpenPanelSelectTime    = new DelegateCommand(() =>
            {
                CurrentPanelSelectTime.ClearPanel();
                CurrentPanelSelectTime.PanelOpened = true;
            });
            RevertSelectTimeCommand = new DelegateCommand(() =>
            {
                CurrentPanelSelectTime.PanelOpened = false;
                Handled = false;
                //if (Operation.Datetime_id == null || Operation.Datetime_id == 0)
                //{
                CurrentPanelSelectTime.SelectedOpTimeView     = null;
                CurrentPanelSelectTime.SelectedOpTimeViewCopy = null;
                CurrentPanelSelectTime.BuffSelectedOpTimeView = null;
                //}
            });
            TextForDate           = "Время не выбрано";
            SaveSelectTimeCommand = new DelegateCommand(() =>
            {
                if (CurrentPanelSelectTime.SelectedOpTimeView != null)
                {
                    Button_time_B         = Brushes.Gray;
                    Operation.Datetime_id = CurrentPanelSelectTime.SelectedOpTimeView.Id;

                    TextForDate = CurrentPanelSelectTime.SelectedOpTimeView.Datetime.ToString("HH:mm\ndd MMMM yyyy\n", CultureInfo.GetCultureInfo("ru-ru"));
                    string buff = FirstCharToUpper(CurrentPanelSelectTime.SelectedOpTimeView.Datetime.ToString("dddd", CultureInfo.GetCultureInfo("ru-ru")));
                    //buff = buff.First().ToString().ToUpper() + buff.Substring(1);
                    TextForDate += buff;
                }
                else
                {
                    Operation.Datetime_id = null;
                    TextForDate           = "Время не выбрано";
                }
                CurrentPanelSelectTime.PanelOpened = false;
            });
            #endregion
            #region Anestetic New type comands
            CurrentPanelAnestViewModel = new AnetheticTypePanelViewModel(this);
            OpenPanelAnesteticCommand  = new DelegateCommand(() =>
            {
                CurrentPanelAnestViewModel.ClearPanel();
                CurrentPanelAnestViewModel.PanelOpened = true;
            });
            SaveAnesteticCommand = new DelegateCommand(() =>
            {
                var newType = CurrentPanelAnestViewModel.GetPanelType();
                if (!string.IsNullOrWhiteSpace(newType.Str))
                {
                    CurrentPanelAnestViewModel.PanelOpened = false;
                    Handled = false;
                    Data.Anestethic.Add((newType));
                    Data.Complete();
                    AnestethicTypes = new ObservableCollection <string>();
                    foreach (var OprType in Data.Anestethic.GetAll)
                    {
                        AnestethicTypes.Add(OprType.Str);
                        AnestethicTypesID.Add(OprType.Id);
                    }
                    AnesteticSelected = AnestethicTypes.Count - 1;
                }
                else
                {
                    MessageBox.Show("Не все поля заполнены");
                }
            });
            RevertAnesteticCommand = new DelegateCommand(() =>
            {
                CurrentPanelAnestViewModel.PanelOpened = false;
                Handled = false;
            });
            #endregion
            SaveCommand = new DelegateCommand(() =>
            {
                if (SelectedLegId == 0)
                {
                    IsLeftLegInOperation  = Visibility.Visible;
                    IsRightLegInOperation = Visibility.Collapsed;
                }
                else if (SelectedLegId == 1)
                {
                    IsLeftLegInOperation  = Visibility.Collapsed;
                    IsRightLegInOperation = Visibility.Visible;
                }
                else
                {
                    IsLeftLegInOperation  = Visibility.Visible;
                    IsRightLegInOperation = Visibility.Visible;
                }
                CurrentPanelViewModel.ClearPanel();
                CurrentPanelViewModel.PanelOpened = false;
            });

            RevertCommand = new DelegateCommand(() =>
            {
                Controller.NavigateTo <ViewModelCurrentPatient>();
            });
        }