Exemplo n.º 1
0
        public bool deleteAccount(string staffUsername)
        {
            bool result = false;

            using (SqlConnection conn = DB.GetConnection())
            {
                string     sql = "delete from account where username = @username";
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@username", staffUsername);
                try
                {
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                        result = cmd.ExecuteNonQuery() > 0;
                    }
                }
                finally
                {
                    conn.Close();
                }
            }
            return(result);
        }