private void label6_Click(object sender, EventArgs e) { auth DU = new auth(); DU.Show(); this.Hide(); }
private void regbutton_Click(object sender, EventArgs e) { string user_name = name.Text; string user_last_name = sname.Text; string user_login = login.Text; string user_password = password.Text; if (user_login.Length > 0 && user_last_name.Length > 0 && user_password.Length > 0 && user_name.Length > 0) { try { String insertQuery = " INSERT INTO users (user_login,user_password) VALUES(@user_login, @user_password)"; using (SqlConnection cn = getConnection()) { SqlCommand command = new SqlCommand(insertQuery, cn); command.Parameters.Add("@user_login", SqlDbType.VarChar); command.Parameters.Add("@user_password", SqlDbType.VarChar); command.Parameters["@user_login"].Value = user_login; command.Parameters["@user_password"].Value = user_password; cn.Open(); if (command.ExecuteNonQuery() == 1) { int tmp = auth_user(user_login, user_password); if (addUser(user_name, user_last_name, tmp) && Add_user_state(tmp)) { MessageBox.Show("Регистрация прошла успешно!!!"); auth DU = new auth(); DU.Show(); this.Hide(); } } } } catch (Exception err) {//"Заполните все поля!" MessageBox.Show(err.ToString()); MessageBox.Show("Проверьте данные!"); } } else { MessageBox.Show("Заполните все поля!"); } }