//新增
 //public bool AddProduct(int CategoryID,string Name,string Description) {
 //    if (helper.ExcuteCommandInt("insert into Products(CategoryID,Name,Description) values("+CategoryID+",'"+Name+"','"+Description+"')") > 0)
 //        return true;
 //    else
 //        return false;
 //}
 public bool AddProduct(Entity.Products product)
 {
     //int CategoryID, string Name, string Description
     if (helper.ExcuteCommandInt("insert into Products(CategoryID,Name,Description) values("
                                 + product.getCategoryID() + ",'"
                                 + product.getName() + "','"
                                 + product.getDescription() + "')") > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
 //更新
 //public bool UpdateProducts(int PID,int CategoryID,string Name,string Description)
 //{
 //    if (helper.ExcuteCommandInt("update Products set CategoryID=" + CategoryID + ",Name='" + Name + "',Description='" + Description + "' where PID=" + PID + "") > 0)
 //        return true;
 //    else
 //        return false;
 //}
 public bool UpdateProducts(Entity.Products product)
 {
     if (helper.ExcuteCommandInt("update Products set CategoryID="
                                 + product.getCategoryID() + ",Name='"
                                 + product.getName() + "',Description='"
                                 + product.getDescription() + "' where PID="
                                 + product.getPID() + "") > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #3
0
 protected void gvProductList_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     paneInfo.Visible = panelSuccess.Visible = panelError.Visible = panelAttention.Visible = false;
     switch (e.CommandName)
     {
     case "Modify":
         try
         {
             Entity.Products pro = products.GetProductInfo(int.Parse(e.CommandArgument.ToString()));
             lbPID.Text                   = e.CommandArgument.ToString();
             txtName.Text                 = pro.getName();
             txtDescription.Text          = pro.getDescription();
             ddlChaCategory.SelectedValue = pro.getCategoryID().ToString();
         }
         catch { }
         break;
     }
 }