private void ButtonSaveUser_OnClick(object sender, RoutedEventArgs e) { CheckPassAndLogin check = new CheckPassAndLogin(); CaffeDataContext db = new CaffeDataContext(); HashClass hash = new HashClass(); if (check.ChceckPassEqals(Pass1TB.Text, Pass2TB.Text) && check.ChceckPassNumeric(Pass1TB.Text) && check.CheckPassLength(Pass1TB.Text)) { int IdMax = db.Users.Max(s => s.Id_user); User u = new User() { Name = UserNameTB.Text, Id_user = IdMax + 1, Password = hash.GetHashString(Pass1TB.Text) }; db.Users.InsertOnSubmit(u); db.SubmitChanges(); MessageBox.Show("Zapisoano zmiany !!!"); Pass1TB.Text = ""; Pass2TB.Text = ""; UserNameTB.Text = ""; } else { MessageBox.Show("Nieprawidłowe dane !"); } }
private void ButtonSavePassChange_OnClick(object sender, RoutedEventArgs e) { CheckPassAndLogin check = new CheckPassAndLogin(); if (check.ChceckPassEqals(Pass11TB.Text, Pass22TB.Text) && check.ChceckPassNumeric(Pass11TB.Text) && check.CheckPassLength(Pass11TB.Text)) { CaffeDataContext db = new CaffeDataContext(); HashClass hash = new HashClass(); User u = db.Users.FirstOrDefault(s => s.Id_user == userID); u.Password = hash.GetHashString(Pass11TB.Text); db.SubmitChanges(); MessageBox.Show("Zapisano zmieny !!!"); Pass11TB.Text = ""; Pass22TB.Text = ""; } else { MessageBox.Show("Nieprawidłowe dane !"); } }