Beispiel #1
0
 public void Execute(object parameter)
 {
     this.execute(parameter);
     using (BD_KURSACH_Entities db = new BD_KURSACH_Entities())
     {
         try
         {
             Client  client  = new Client();
             var     clients = db.Client.ToList();
             TextBox text    = (TextBox)parameter;
             foreach (var c in clients)
             {
                 if (c.id.ToString() == text.Text)
                 {
                     client = c;
                 }
             }
             Trainer trainer = WorkTrainerWindowViewModel.trainer;
             client.Number_Group    = trainer.Number_Group;
             db.Entry(client).State = EntityState.Modified;
             db.SaveChanges();
             MessageBox.Show($"клиент добавлен в группу под номером {client.Number_Group}");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
 public void Execute(object parameter)
 {
     using (BD_KURSACH_Entities db = new BD_KURSACH_Entities())
     {
         try
         {
             WorkUserWindowViewModel.client.FirstName                  = WindowOfViews.EditDataUser.FirstName.Text;
             WorkUserWindowViewModel.client.SecondName                 = WindowOfViews.EditDataUser.SecondName.Text;
             WorkUserWindowViewModel.client.Login                      = WindowOfViews.EditDataUser.Login.Text;
             WorkUserWindowViewModel.client.Password                   = WindowOfViews.EditDataUser.Password.Text;
             WorkUserWindowViewModel.client.DataClient.Weight          = int.Parse(WindowOfViews.EditDataUser.Weight.Text);
             WorkUserWindowViewModel.client.DataClient.Height          = int.Parse(WindowOfViews.EditDataUser.Height.Text);
             WorkUserWindowViewModel.client.DataClient.Bodytype        = WindowOfViews.EditDataUser.BodyType.Text;
             db.Entry(WorkUserWindowViewModel.client).State            = EntityState.Modified;
             db.Entry(WorkUserWindowViewModel.client.DataClient).State = EntityState.Modified;
             db.SaveChanges();
             MessageBox.Show("изменения прошли успешно");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Beispiel #3
0
        private static double GetProgress()
        {
            double progress11 = 1;
            double progress12 = 1;
            double progress13 = 1;
            double progress21 = 1;
            double progress22 = 1;
            double progress23 = 1;
            int    crossexer  = 0;
            double progress   = 0;

            using (BD_KURSACH_Entities db = new BD_KURSACH_Entities())
            {
                using (var transaction = db.Database.BeginTransaction())
                {
                    var exer = db.ResultExercises.Where(i => i.Id_Client == WorkUserWindowViewModel.client.id).ToList();
                    if (exer.Count() != 0)
                    {
                        try
                        {
                            var sortedexer = from u in exer
                                             orderby u.Date descending
                                             select u;
                            if (sortedexer.FirstOrDefault().First_Day_Quantity != "" && sortedexer.FirstOrDefault().Second_Day_Quantity != "" && sortedexer.FirstOrDefault().Third_Day_Quantity != "")
                            {
                                crossexer = 6;
                            }
                            if (sortedexer.FirstOrDefault().First_Day_Quantity == "" || sortedexer.FirstOrDefault().Second_Day_Quantity == "" || sortedexer.FirstOrDefault().Third_Day_Quantity == "")
                            {
                                crossexer = 12;
                            }

                            if (sortedexer.FirstOrDefault().First_Day_Quantity != "" && sortedexer.FirstOrDefault().Second_Day_Quantity == "" && sortedexer.FirstOrDefault().Third_Day_Quantity == "")
                            {
                                crossexer += 6;
                            }
                            if (sortedexer.FirstOrDefault().First_Day_Quantity == "" && sortedexer.FirstOrDefault().Second_Day_Quantity != "" && sortedexer.FirstOrDefault().Third_Day_Quantity == "")
                            {
                                crossexer += 6;
                            }
                            if (sortedexer.FirstOrDefault().First_Day_Quantity == "" && sortedexer.FirstOrDefault().Second_Day_Quantity == "" && sortedexer.FirstOrDefault().Third_Day_Quantity != "")
                            {
                                crossexer += 6;
                            }

                            for (int i = 0; i < crossexer; i++)
                            {
                                if (sortedexer.ElementAt(i).First_Day_Quantity != "")
                                {
                                    if (sortedexer.ElementAt(i).First_Day_Weight != "" && sortedexer.ElementAt(i).First_Day_Quantity != "")
                                    {
                                        progress11 = int.Parse(sortedexer.ElementAt(i).First_Day_Weight);
                                        progress11 = progress11 * int.Parse(sortedexer.ElementAt(i).First_Day_Quantity) * 0.8;
                                    }
                                    if (sortedexer.ElementAt(i).First_Day_Weight == "" && sortedexer.ElementAt(i).First_Day_Quantity != "")
                                    {
                                        progress11 = int.Parse(sortedexer.ElementAt(i).First_Day_Quantity) * 10;
                                    }
                                }
                                if (sortedexer.ElementAt(i).Second_Day_Quantity != "")
                                {
                                    if (sortedexer.ElementAt(i).Second_Day_Weight != "" && sortedexer.ElementAt(i).Second_Day_Quantity != "")
                                    {
                                        progress12 = int.Parse(sortedexer.ElementAt(i).Second_Day_Weight);
                                        progress12 = progress12 * int.Parse(sortedexer.ElementAt(i).Second_Day_Quantity) * 0.8;
                                    }
                                    if (sortedexer.ElementAt(i).Second_Day_Weight == "" && sortedexer.ElementAt(i).Second_Day_Quantity != "")
                                    {
                                        progress12 = int.Parse(sortedexer.ElementAt(i).Second_Day_Quantity) * 10;
                                    }
                                }
                                if (sortedexer.ElementAt(i).Third_Day_Quantity != "")
                                {
                                    if (sortedexer.ElementAt(i).Third_Day_Weight != "" && sortedexer.ElementAt(i).Third_Day_Quantity != "")
                                    {
                                        progress13 = int.Parse(sortedexer.ElementAt(i).Third_Day_Weight);
                                        progress13 = progress13 * int.Parse(sortedexer.ElementAt(i).Third_Day_Quantity) * 0.8;
                                    }
                                    if (sortedexer.ElementAt(i).Third_Day_Weight == "" && sortedexer.ElementAt(i).Third_Day_Quantity != "")
                                    {
                                        progress13 = int.Parse(sortedexer.ElementAt(i).Third_Day_Quantity) * 10;
                                    }
                                }
                            }
                            //--------------------------------------------------------------------------------------------------------------------
                            for (int k = sortedexer.Count() - crossexer; k < sortedexer.Count(); k++)
                            {
                                if (sortedexer.ElementAt(k).First_Day_Quantity != "")
                                {
                                    if (sortedexer.ElementAt(k).First_Day_Weight != "" && sortedexer.ElementAt(k).First_Day_Quantity != "")
                                    {
                                        progress21 = int.Parse(sortedexer.ElementAt(k).First_Day_Weight);
                                        progress21 = progress21 * int.Parse(sortedexer.ElementAt(k).First_Day_Quantity) * 0.8;
                                    }
                                    if (sortedexer.ElementAt(k).First_Day_Weight == "" && sortedexer.ElementAt(k).First_Day_Quantity != "")
                                    {
                                        progress21 = int.Parse(sortedexer.ElementAt(k).First_Day_Quantity) * 10;
                                    }
                                }
                                if (sortedexer.ElementAt(k).Second_Day_Quantity != "")
                                {
                                    if (sortedexer.ElementAt(k).Second_Day_Weight != "" && sortedexer.ElementAt(k).Second_Day_Quantity != "")
                                    {
                                        progress22 = int.Parse(sortedexer.ElementAt(k).Second_Day_Weight);
                                        progress22 = progress22 * int.Parse(sortedexer.ElementAt(k).Second_Day_Quantity) * 0.8;
                                    }
                                    if (sortedexer.ElementAt(k).Second_Day_Weight == "" && sortedexer.ElementAt(k).Second_Day_Quantity != "")
                                    {
                                        progress22 = int.Parse(sortedexer.ElementAt(k).Second_Day_Quantity) * 10;
                                    }
                                }
                                if (sortedexer.ElementAt(k).Third_Day_Quantity != "")
                                {
                                    if (sortedexer.ElementAt(k).Third_Day_Weight != "" && sortedexer.ElementAt(k).Third_Day_Quantity != "")
                                    {
                                        progress23 = int.Parse(sortedexer.ElementAt(k).Third_Day_Weight);
                                        progress23 = progress23 * int.Parse(sortedexer.ElementAt(k).Third_Day_Quantity) * 0.8;
                                    }
                                    if (sortedexer.ElementAt(k).Third_Day_Weight == "" && sortedexer.ElementAt(k).Third_Day_Quantity != "")
                                    {
                                        progress23 = int.Parse(sortedexer.ElementAt(k).Third_Day_Quantity) * 10;
                                    }
                                }
                            }

                            if (progress21 != 1 && progress22 != 1 && progress23 != 1)
                            {
                                progress = (progress21 + progress22 + progress23) / (progress11 + progress12 + progress13);
                            }
                            if (progress21 == 1)
                            {
                                progress = (double)client.DataClient.Progress * (progress21 / progress11);
                            }
                            if (progress22 == 1)
                            {
                                progress = (double)client.DataClient.Progress * (progress22 / progress12);
                            }
                            if (progress23 == 1)
                            {
                                progress = (double)client.DataClient.Progress * (progress23 / progress13);
                            }
                            client.DataClient.Progress        = Math.Round(progress, 2);
                            db.Entry(client.DataClient).State = EntityState.Modified;
                            db.SaveChanges();
                            transaction.Commit();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                            transaction.Rollback();
                        }
                    }
                }
            }
            return(Math.Round(progress, 2));
        }