private void Button_go_to_all_train(object sender, RoutedEventArgs e) { var win = new MainTrainWin(user); win.Show(); this.Close(); }
private void Window_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { using (UserContext db = new UserContext()) { var user_linq = db.Users.Where(p => p.Login == this.input_login.Text).ToList(); bool flag1 = false; bool flag2 = false; User Item = null; if (user_linq.Count != 0) { flag1 = true; this.Error_not_match.Visibility = Visibility.Hidden; } else { this.Error_not_log.Visibility = Visibility.Visible; this.Error_not_match.Visibility = Visibility.Hidden; } if (flag1) { var pass_linq = db.Users.Where(p => p.Password == this.input_password.Password).ToList(); if (pass_linq.Count != 0) { flag2 = true; foreach (var item in pass_linq) { Item = item; } } else { this.Error_not_match.Visibility = Visibility.Visible; this.Error_not_log.Visibility = Visibility.Hidden; } } if (flag1 && flag2) { var user = Item; var win_main = new MainTrainWin(user); win_main.Show(); db.Dispose(); this.Close(); flag1 = flag2 = false; } } } }
private void Create_Click(object sender, RoutedEventArgs e) { int id_train; if (Intensity_num != 0 && type_train != 0 && list_ex_id.Count != 0 && this.new_name.Text != "") { using (TrainingContext db = new TrainingContext()) { Training new_train = new Training { Name_training = this.new_name.Text, Description = this.new_Disc.Text, Groupe = type_train, ID_training = 1, ID_type = user.ID_user, Img = "/Training/user_training.png", Intensity = Intensity_num, Time = time_ex_all }; db.Trainings.Add(new_train); db.SaveChanges(); } using (TrainingContext db = new TrainingContext()) { db.Trainings.Load(); var list = db.Trainings.Local.ToBindingList(); id_train = list.Count; } using (ConnectionContext db = new ConnectionContext()) { foreach (var item in list_ex_id) { var new_con = new Connection { ID_note = 1, ID_ex = item, ID_training = id_train }; db.Connections.Add(new_con); } db.SaveChanges(); } var win_user_train = new MainTrainWin(user); win_user_train.Show(); win_c.Close(); } else { var win_er = new ERRORWin(); win_er.ChooseError("ERRORDataEntry"); win_er.Show(); } }
private void Button_Click_Next_Regist(object sender, RoutedEventArgs e) { if (!flag2) { using (UserContext db = new UserContext()) { var user_linq = db.Users.Where(p => p.Login == this.new_login.Text).ToList(); if (user_linq.Count != 0) { var win_c = new ERRORWin(); win_c.ChooseError("ERRORLoginClose"); win_c.Show(); } else { if (this.new_login.Text == "") { var win_a = new ERRORWin(); win_a.ChooseError("ERRORDataEntry"); win_a.Show(); } else { flag2 = true; } } } } if (flag2) { Regex reg = new Regex(@"^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])\S{1,8}$"); MatchCollection matches = reg.Matches(this.new_password.Text); if (matches.Count > 0) { flag3 = true; } else { var win_a = new ERRORWin(); win_a.ChooseError("ERRORDataEntry"); win_a.Show(); flag2 = false; } } if (flag2 && flag3) { if (flag) { progress_bar_step++; flag = false; } flag4 = false; switch (progress_bar_step) { case 1: this.Progress_bar_registr.Value = 25; this.Grid__regist_1.Visibility = Visibility.Visible; this.Grid_regist_2.Visibility = Visibility.Hidden; this.Grid_regist_3.Visibility = Visibility.Hidden; this.noti.Visibility = Visibility.Hidden; progress_bar_step++; break; case 2: this.Progress_bar_registr.Value = 50; this.Grid__regist_1.Visibility = Visibility.Hidden; this.Grid_regist_2.Visibility = Visibility.Visible; this.Grid_regist_3.Visibility = Visibility.Hidden; this.noti.Visibility = Visibility.Hidden; progress_bar_step++; break; case 3: if (this.new_name.Text == "") { this.Progress_bar_registr.Value = 50; var win_er = new ERRORWin(); win_er.ChooseError("ERRORDataEntry"); win_er.Show(); } else { this.Progress_bar_registr.Value = 75; this.Grid__regist_1.Visibility = Visibility.Hidden; this.Grid_regist_2.Visibility = Visibility.Hidden; this.Grid_regist_3.Visibility = Visibility.Visible; this.noti.Visibility = Visibility.Hidden; progress_bar_step++; } break; case 4: Regex reg = new Regex(@"^[0-9]*[,]?[0-9]+$"); MatchCollection matches1 = reg.Matches(this.new_w_s.Text); MatchCollection matches2 = reg.Matches(this.new_w_g.Text); if (matches1.Count == 0 || matches2.Count == 0) { this.Progress_bar_registr.Value = 75; var win_er = new ERRORWin(); win_er.ChooseError("ERRORDataEntry"); win_er.Show(); } else { this.Progress_bar_registr.Value = 100; this.Grid__regist_1.Visibility = Visibility.Hidden; this.Grid_regist_2.Visibility = Visibility.Hidden; this.Grid_regist_3.Visibility = Visibility.Hidden; this.noti.Visibility = Visibility.Visible; progress_bar_step++; } break; case 5: DateTime data = DateTime.Now; using (UserContext db = new UserContext()) { new_user = new User { ID_user = 1, Name = this.new_name.Text, Age = Convert.ToInt32(this.new_age.Text), Weight_start = this.new_w_s.Text, Weight_goal = this.new_w_g.Text, Data_start = data.ToString(), Login = this.new_login.Text, Password = this.new_password.Text }; db.Users.Add(new_user); db.SaveChanges(); MainTrainWin win = new MainTrainWin(new_user); win.Show(); this.Close(); } break; } } }