private void dataGridViewBankAcc_CellValueChange(object sender, DataGridViewCellEventArgs e) { if (dataGridViewBankAcc.CurrentRow != null) { using (SqlConnection sql_conn = new SqlConnection(Server_connection.string_connction)) { sql_conn.Open(); DataGridViewRow dgvRow = dataGridViewBankAcc.CurrentRow; SqlCommand sql_command = new SqlCommand("AccountAddOrEdit", sql_conn); sql_command.CommandType = CommandType.StoredProcedure; sql_command.Parameters.AddWithValue("@AccNumber", Convert.ToInt32(dgvRow.Cells["AccNumber"].Value)); sql_command.Parameters.AddWithValue("@Firstname", dgvRow.Cells["Firstname"].Value == DBNull.Value ? "" : dgvRow.Cells["Firstname"].Value.ToString()); sql_command.Parameters.AddWithValue("@Lastname", dgvRow.Cells["Lastname"].Value == DBNull.Value ? "" : dgvRow.Cells["Lastname"].Value.ToString()); sql_command.Parameters.AddWithValue("@Summ", Convert.ToInt32(dgvRow.Cells["Summ"].Value == DBNull.Value ? "0" : dgvRow.Cells["Summ"].Value)); sql_command.Parameters.AddWithValue("@Last_year", Convert.ToInt32(dgvRow.Cells["Last_year"].Value == DBNull.Value ? "0" : dgvRow.Cells["Last_year"].Value)); sql_command.ExecuteNonQuery(); FormBankAccounts fba = new FormBankAccounts(this.user_id); fba.FormBankAccounts_Load(sender, e); } } }
private void btnLogin_Click(object sender, EventArgs e) { string mySQL = string.Empty; mySQL += "SELECT * FROM [AccountDB].[dbo].[User] "; mySQL += "WHERE Email = '" + txtEmail.Text.Trim() + "'"; DataTable userData = Server_connection.executeSQL(mySQL); if (userData.Rows.Count == 1) { string hashed_pass = userData.Rows[0][4].ToString(); if (Helpers.Verify(txtPassword.Text.Trim(), hashed_pass)) { txtEmail.Clear(); txtPassword.Clear(); PasswordCheckBox.Checked = false; if (userData.Rows[0][0].ToString() == "Client") { this.Hide(); FormAccountList fal = new FormAccountList(userData.Rows[0][0].ToString()); fal.ShowDialog(); } else { this.Hide(); FormBankAccounts fba = new FormBankAccounts(userData.Rows[0][0].ToString()); fba.ShowDialog(); } } else { MessageBox.Show("Wrong password"); } } else { MessageBox.Show("User with this email and password is not registreted"); } }