public static int UpdateCustomer(Customer c) { using (SqlConnection con = new SqlConnection(connString, credentials)) { try { Dictionary <string, object> p = new Dictionary <string, object> { { "@Id", c.Id }, { "@FirstName", c.FirstName }, { "@LastName", c.LastName }, { "@DateOfBirth", c.DateOfBirth }, { "@CompanyId", c.CompanyId } }; con.Open(); return(DBActions.ExecNonReaderSP(con, "updateCustomerByID", p)); } catch (Exception ex) { MessageBox.Show(ex.Message); return(-1); } finally { con.Close(); } } }
public static int DeleteCustomer(int id) { using (SqlConnection con = new SqlConnection(connString, credentials)) { try { Dictionary <string, object> p = new Dictionary <string, object> { { "@Id", id } }; con.Open(); return(DBActions.ExecNonReaderSP(con, "removeCustomerByID", p)); } catch (Exception ex) { MessageBox.Show(ex.Message); return(-1); } finally { con.Close(); } } }