protected void lbtnModify_Click(object sender, EventArgs e)
    {

        Entity.Products pro=new  Entity.Products();
        pro.setCategoryID(int.Parse(ddlChaCategory.SelectedValue));
        pro.setPID(int.Parse(lbPID.Text));
        pro.setName(txtName.Text.Trim());
        pro.setDescription(txtDescription.Text.Trim()); 
        if (lbPID.Text == "" || txtName.Text.Trim() == "")
        {
            panelAttention.Visible = true;
            lbAttention.Text = "请选择修改的类别并填写修改后的类别名";
        }
        //else if (products.UpdateProducts(int.Parse(lbPID.Text), int.Parse(ddlChaCategory.SelectedValue), txtName.Text.Trim(), txtDescription.Text.Trim()))
        else if (products.UpdateProducts(pro))
        {
            panelSuccess.Visible = true; 
            lbSuccess.Text = "更新成功!";
            lbPID.Text = "";
            txtDescription.Text = txtName.Text = "";
            if (ddlCategory.SelectedItem.Value == "0")
                gvProductList.DataSource = products.GetProduct();
            else
                gvProductList.DataSource = products.GetProductByCID(int.Parse(ddlCategory.SelectedItem.Value));
            gvProductList.DataBind();
        }
        else {
            panelError.Visible = true;
            lbError.Text = "更新失败!";
        }
    }
Ejemplo n.º 2
0
 protected void lbtnModify_Click(object sender, EventArgs e)
 {
     Entity.Products pro = new  Entity.Products();
     pro.setCategoryID(int.Parse(ddlChaCategory.SelectedValue));
     pro.setPID(int.Parse(lbPID.Text));
     pro.setName(txtName.Text.Trim());
     pro.setDescription(txtDescription.Text.Trim());
     if (lbPID.Text == "" || txtName.Text.Trim() == "")
     {
         panelAttention.Visible = true;
         lbAttention.Text       = "请选择修改的类别并填写修改后的类别名";
     }
     //else if (products.UpdateProducts(int.Parse(lbPID.Text), int.Parse(ddlChaCategory.SelectedValue), txtName.Text.Trim(), txtDescription.Text.Trim()))
     else if (products.UpdateProducts(pro))
     {
         panelSuccess.Visible = true;
         lbSuccess.Text       = "更新成功!";
         lbPID.Text           = "";
         txtDescription.Text  = txtName.Text = "";
         if (ddlCategory.SelectedItem.Value == "0")
         {
             gvProductList.DataSource = products.GetProduct();
         }
         else
         {
             gvProductList.DataSource = products.GetProductByCID(int.Parse(ddlCategory.SelectedItem.Value));
         }
         gvProductList.DataBind();
     }
     else
     {
         panelError.Visible = true;
         lbError.Text       = "更新失败!";
     }
 }
Ejemplo n.º 3
0
 //更新
 //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);
     }
 }
Ejemplo n.º 4
0
 //新增
 //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);
     }
 }
 protected void lbtnAdd_Click(object sender, EventArgs e)
 {
     Entity.Products pro = new Entity.Products();
     pro.setCategoryID(int.Parse(ddlChaCategory.SelectedValue));
     pro.setDescription(txtDescription.Text.Trim());
     pro.setName( txtName.Text.Trim()); 
     if (products.AddProduct(pro))
     {
         panelSuccess.Visible = true;
         lbSuccess.Text = "新增成功!";
     }
     else 
     {
         panelError.Visible = true;
         lbError.Text = "新增失败!";
     }
 }
 protected void lbtnAdd_Click(object sender, EventArgs e)
 {
     Entity.Products pro = new Entity.Products();
     pro.setCategoryID(int.Parse(ddlChaCategory.SelectedValue));
     pro.setDescription(txtDescription.Text.Trim());
     pro.setName(txtName.Text.Trim());
     if (products.AddProduct(pro))
     {
         panelSuccess.Visible = true;
         lbSuccess.Text       = "新增成功!";
     }
     else
     {
         panelError.Visible = true;
         lbError.Text       = "新增失败!";
     }
 }
Ejemplo n.º 7
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;
     }
 }