public void Save(ProductNewsModel model)
 {
     if (!Exists(model.ProdutID))
     {
         Add(model);
     }
     else
     {
         Update(model);
     }
 }
 public ProductNewsModel GetModel(int ProductID)
 {
     string sql = "select * from [pdproductnews] where [productid]={0}";
     sql = String.Format(sql, ProductID);
     ProductNewsModel model = null;
     DataTable dt = dbr.ExecuteDataSet(CommandType.Text, sql).Tables[0];
     if (dt.Rows.Count > 0)
     {
         model = new ProductNewsModel() { ProdutID = Convert.ToInt32(dt.Rows[0]["productid"]), NewsID = Convert.ToInt32(dt.Rows[0]["newsid"]) };
     }
     return model;
 }
 public void Update(ProductNewsModel model)
 {
     dal.Update(model);
 }
 public void Delete(ProductNewsModel model)
 {
     dal.Delete(model);
 }
 public void Add(ProductNewsModel model)
 {
     dal.Add(model);
 }
 public void Update(ProductNewsModel model)
 {
     string sql = "update [pdproductnews] set [newsid]={0} where [productid]={1}";
     sql = String.Format(sql, model.ProdutID, model.NewsID);
     dbw.ExecuteNonQuery(CommandType.Text, sql);
 }
 public void Delete(ProductNewsModel model)
 {
     string sql = "delete from [pdproductnews] where [productid]={0} and [newsid]={1}";
     sql = String.Format(sql, model.ProdutID, model.NewsID);
     dbw.ExecuteNonQuery(CommandType.Text, sql);
 }
 public void Add(ProductNewsModel model)
 {
     string sql = "insert into [pdproductnews] ([productid],[newsid]) values ({0},{1})";
     sql = String.Format(sql, model.ProdutID, model.NewsID);
     dbw.ExecuteNonQuery(CommandType.Text, sql);
 }