public int Remove(Ecommers.Entity.Category catE) { if (catE.SupplierID == 0 && catE.CategoryID == 0) { return(0); } else { return(DAL.Rmove(catE)); } }
public int Edit(Ecommers.Entity.Category catE) { if (CheckData(catE) == 0) { return(0); } else { return(DAL.Edit(catE)); } }
public int Rmove(Ecommers.Entity.Category cat) { int result = 0; string sql = "delete from Category where CategoryID=@CategoryID and SupplierID=@SupplierID"; SqlCommand cmd = new SqlCommand(sql, DBC.conn); cmd.Parameters.AddWithValue("@CategoryID", cat.CategoryID); cmd.Parameters.AddWithValue("@SupplierID", cat.SupplierID); DBC.conn.Open(); result = cmd.ExecuteNonQuery(); DBC.conn.Close(); return(result); }
public int Add(Ecommers.Entity.Category cat) { int result = 0; string sql = "insert into Category (CategoryID , CategoryName , SupplierID ) values (@CategoryID , @CategoryName , @SupplierID )"; SqlCommand cmd = new SqlCommand(sql, DBC.conn); cmd.Parameters.AddWithValue("@CategoryID", cat.CategoryID); cmd.Parameters.AddWithValue("@CategoryName", cat.CategoryName); cmd.Parameters.AddWithValue("@SupplierID", cat.SupplierID); DBC.conn.Open(); result = cmd.ExecuteNonQuery(); DBC.conn.Close(); return(result); }
private int CheckData(Ecommers.Entity.Category cat) { if (cat.CategoryID == 0) { return(0); } else if (cat.CategoryName.Length == 0) { return(0); } else if (cat.SupplierID == 0) { return(0); } else { return(1); } }