Esempio n. 1
0
    public bool AddProduct(category_product_detail pr)
    {
        LQDataContext ctxs = new LQDataContext();

        ctxs.category_product_details.InsertOnSubmit(pr);
        ctxs.SubmitChanges();
        return(true);
    }
Esempio n. 2
0
 public void UpdateProduct(category_product_detail pr)
 {
     try
     {
         LQDataContext ctxx = new LQDataContext();
         var           q    = ctxx.category_product_details.Where(d => d.id_pro == pr.id_pro).SingleOrDefault();
         q.id_cat    = pr.id_cat;
         q.pro_name  = pr.pro_name;
         q.pro_price = pr.pro_price;
         ctxx.SubmitChanges();
     }
     catch (Exception ex)
     {
     }
 }
    public void load_pro()
    {
        if (ck.checkQuantity(Request.QueryString["id"]))
        {
            id = Convert.ToInt32(Request.QueryString["id"]);
        }

        category_product_detail p = cl.getProduct(id);

        lblID.Text           = p.id_pro + "";
        lblName.Text         = p.pro_name;
        lblPrice.Text        = p.pro_price + "";
        Repeater3.DataSource = p.product_images;
        Repeater3.DataBind();
    }
 public void load_pro()
 {
     if (ck.checkQuantity(Request.QueryString["id"]))
     {
         id = Convert.ToInt32(Request.QueryString["id"]);
     }
     else
     {
         Response.Redirect("404.html");
     }
     p                    = cl.getProduct(id);
     lblID.Text           = p.id_pro + "";
     txtName.Text         = p.pro_name;
     txtPrice.Text        = p.pro_price + "";
     idCate               = p.id_cat;
     Repeater3.DataSource = p.product_images;
     Repeater3.DataBind();
 }
Esempio n. 5
0
 protected void btnAddPro_Click(object sender, EventArgs e)
 {
     if (FileU.HasFile)
     {
         foreach (var file in FileU.PostedFiles)
         {
             if (!ck.CheckFileType(file.FileName))
             {
                 tam = 1;
                 break;
             }
         }
         if (tam == 0)
         {
             int dem = 0;
             pr = new category_product_detail();
             if ((int)ViewState["bf"] == 1)
             {
                 pr.id_cat       = idCate;
                 ViewState["bf"] = 0;
             }
             else
             {
                 drCate.SelectedIndex = 0;
                 pr.id_cat            = Convert.ToInt32(drCate.SelectedItem.Value);
             }
             if (ck.checkstringnull(tbName1.Text))
             {
                 if (ck.checkstringnull(tbPrice1.Text))
                 {
                     if (ck.checknumber(tbPrice1.Text))
                     {
                         if (ck.checkstring(tbName1.Text, 50))
                         {
                             if (cl.checkalprod(tbName1.Text.Trim()))
                             {
                                 pr.pro_name  = tbName1.Text.Trim();
                                 pr.pro_price = float.Parse(tbPrice1.Text.Trim());
                                 cl.AddProduct(pr);
                                 foreach (var file in FileU.PostedFiles)
                                 {
                                     string fileName = "images/product-category/" + file.FileName;
                                     string filePath = MapPath(fileName);
                                     file.SaveAs(filePath);
                                     ip            = new product_image();
                                     ip.id_prod    = pr.id_pro;
                                     ip.img_url    = file.FileName;
                                     imgS.ImageUrl = ip.img_url;
                                     if (dem == 0)
                                     {
                                         ip.sub_img = 1;
                                     }
                                     else
                                     {
                                         ip.sub_img = 0;
                                     }
                                     dem++;
                                     cl.AddimgProd(ip);
                                 }
                             }
                             else
                             {
                                 ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Product Name Already Exist')", true);
                             }
                         }
                         else
                         {
                             ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Product Name Too Long')", true);
                         }
                     }
                     else
                     {
                         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Product Price Is Incorrect')", true);
                     }
                 }
                 else
                 {
                     ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please Type Product Price')", true);
                 }
             }
             else
             {
                 ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please Type Product Name')", true);
             }
         }
         else
         {
             ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Image File Too Large Or Not Format(.jpg|.png|.gif)')", true);
         }
     }
     else
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please Choose Image')", true);
     }
     load_Prod();
     loadCate();
     clearall();
 }