private void ChangeUser_Click(object sender, RoutedEventArgs e) { LogInWindow liw = new LogInWindow(); DataBaseModel.CloseConnection(); Close(); liw.Show(); }
private void NewUser_Click(object sender, RoutedEventArgs e) { SignUpWindow suw = new SignUpWindow(); DataBaseModel.CloseConnection(); Close(); suw.Show(); }
public void IncorrectUser() { if (UserModel.state == false) { Mistake.Visibility = Visibility.Visible; return; } if (UserModel.state == true) { Mistake.Visibility = Visibility.Hidden; DataBaseModel.CloseConnection(); UserModel.LogInUser(UserModel.login, UserModel.password); TablesWindow tw = new TablesWindow(); Close(); tw.Show(); } }
private void button1_Click(object sender, EventArgs e) { string login = textBoxLogin.Text; string password = textBoxPassword.Text; string password2 = textBoxPassword2.Text; if (textBoxPassword.Text == string.Empty) { MessageBox.Show("Enter your password"); return; } if (textBoxLogin.Text == string.Empty) { MessageBox.Show("Enter your login"); return; } List <User> allUsers = User.GetUsersFromLocalFile(); bool flag = false; if (IsUserExist()) { return; } DataBaseModel dB = new DataBaseModel(); SqlCommand command = new SqlCommand("INSERT INTO users ( Login, Password,Userdata) VALUES (@login, @password,@UserData)", dB.getConnection()); // путь к файлу для загрузки string filename = @"C:\Users\andru\Desktop\Никита\Repos\kursach\kursach\bin\Debug\user.data"; byte[] imageData; using (System.IO.FileStream fs = new System.IO.FileStream(filename, FileMode.Open)) { imageData = new byte[fs.Length]; fs.Read(imageData, 0, imageData.Length); } command.Parameters.Add("@login", SqlDbType.VarChar).Value = textBoxLogin.Text; command.Parameters.Add("@password", SqlDbType.VarChar).Value = textBoxPassword.Text; command.Parameters.Add("@UserData", SqlDbType.VarBinary).Value = imageData; dB.OpenConnection(); if (command.ExecuteNonQuery() == 1) { MessageBox.Show("Account was create"); } else { MessageBox.Show("Some issue"); } dB.CloseConnection(); if (password == password2) { User user = new User(); user.login = login; user.password = password; User.SaveToLocalFile(user, login); MessageBox.Show("You was register"); this.Close(); } else { MessageBox.Show("Password dont match"); textBoxLogin.Text = ""; textBoxPassword.Text = ""; textBoxPassword2.Text = ""; } }
private void Exit_Click(object sender, RoutedEventArgs e) { DataBaseModel.CloseConnection(); Close(); }