public bool Update(posBLL p) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstring); try { string sql = "UPDATE brand SET brand.brand=@brand WHERE brand.idbrand=@idbrand"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@brand", p.brand); cmd.Parameters.AddWithValue("@idbrand", p.idbrand); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { //Query success isSuccess = true; } else { //query failed isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(isSuccess); }
public bool Insert(posBLL p) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstring); try { String sql = "INSERT into brand (brand) VALUES(@brand)"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@brand", p.brand); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { //Queryable success isSuccess = true; } else { //Query failed isSuccess = false; } }catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(isSuccess); }