public bool Delete(SubCategory obj) { try { DAL DB = new DAL(ConnectionString); string sqlstring = "DELETE FROM SUBCATEGORY WHERE SUBCATEGORYID = " + obj.SubCategoryID.ToString(); int ROWCOUNT = DB.ExecuteCommandNoQuery(sqlstring); if (ROWCOUNT > 0) return true; else return false; } catch (Exception ex) { throw ex; } }
public bool Add(SubCategory objCat) { try { DAL DB = new DAL(ConnectionString); string sqlstring = "INSERT INTO SUBCATEGORY(CATEGORYID,SUBCATEGORYNAME) VALUES (" + objCat.CategoryID.ToString() + ",'" + objCat.SubCategoryName + "')"; int ROWCOUNT = DB.ExecuteCommandNoQuery(sqlstring); if (ROWCOUNT > 0) return true; else return false; } catch (Exception ex) { throw ex; } }
public Receipy() { SubCategory = new SubCategory(); }
public bool Edit(SubCategory obj) { try { DAL DB = new DAL(ConnectionString); string sqlstring = "UPDATE SUBCATEGORY SET SUBCATEGORYNAME = '" + obj.SubCategoryName + "',CATEGORYID = " + obj.CategoryID.ToString() + " WHERE SUBCATEGORYID = " + obj.SubCategoryID.ToString(); int ROWCOUNT = DB.ExecuteCommandNoQuery(sqlstring); if (ROWCOUNT > 0) return true; else return false; } catch (Exception ex) { throw ex; } }
public SubCategory GetObjectFromDR(DataRow DR) { try { SubCategory obj = new SubCategory(); obj.SubCategoryID = int.Parse(DR["SUBCATEGORYID"].ToString()); obj.SubCategoryName = DR["SUBCATEGORYNAME"].ToString(); obj.CategoryID = int.Parse(DR["CATEGORYID"].ToString()); obj.Category.CategoryID = obj.CategoryID; obj.Category.CategoryName = DR["CATEGORYNAME"].ToString(); return obj; } catch(Exception ex) { throw ex; } }