public bool AddimgProd(img_prod imp)
    {
        LQDataContext ctxs = new LQDataContext();

        ctxs.img_prods.InsertOnSubmit(imp);
        ctxs.SubmitChanges();
        return(true);
    }
 public void SetSttImage(img_prod imp, int mstt)
 {
     try
     {
         LQDataContext ctxx = new LQDataContext();
         var           q    = ctxx.img_prods.Where(d => d.id_img == imp.id_img).SingleOrDefault();
         q.stt_img = mstt;
         ctxx.SubmitChanges();
     }
     catch (Exception ex)
     {
     }
 }
 public void UpdateimgProd(img_prod imp)
 {
     try
     {
         LQDataContext ctxx = new LQDataContext();
         var           q    = ctxx.img_prods.Where(d => d.id_img == imp.id_img).SingleOrDefault();
         q.img_url = imp.img_url;
         ctxx.SubmitChanges();
     }
     catch (Exception ex)
     {
     }
 }
Beispiel #4
0
 protected void del_Command(object sender, CommandEventArgs e)
 {
     if (e.CommandName == "delcm")
     {
         foreach (RepeaterItem it in grid_product.Items)
         {
             Label n1 = (Label)it.FindControl("lblid");
             if (n1.Text == e.CommandArgument.ToString())
             {
                 int             n   = Convert.ToInt32(n1.Text);
                 List <img_prod> lim = rp.getProdImage(n);
                 foreach (img_prod imgpr in lim)
                 {
                     listim.Add(imgpr);
                     rp.DeleteImgProd(imgpr.id_img);
                 }
                 if (rp.DeleteProduct(n))
                 {
                     ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Delete Complete')", true);
                     break;
                 }
                 else
                 {
                     foreach (img_prod imgpr1 in listim)
                     {
                         img_prod imgtam = new img_prod();
                         imgtam.id_prod = imgpr1.id_prod;
                         imgtam.img_url = imgpr1.img_url;
                         imgtam.stt_img = imgpr1.stt_img;
                         rp.AddimgProd(imgtam);
                     }
                     ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Delete Fail')", true);
                 }
             }
         }
         load_Prod();
     }
 }
 partial void Insertimg_prod(img_prod instance);
Beispiel #6
0
 private void detach_img_prods(img_prod entity)
 {
     this.SendPropertyChanging();
     entity.prod = null;
 }
Beispiel #7
0
 private void attach_img_prods(img_prod entity)
 {
     this.SendPropertyChanging();
     entity.prod = this;
 }
Beispiel #8
0
 partial void Deleteimg_prod(img_prod instance);
Beispiel #9
0
 partial void Updateimg_prod(img_prod instance);
Beispiel #10
0
 partial void Insertimg_prod(img_prod instance);
    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 prod();
                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 (rp.checkalprod(tbName1.Text.Trim()))
                                {
                                    pr.pro_name = tbName1.Text.Trim();
                                    pr.pro_price = float.Parse(tbPrice1.Text.Trim());
                                    rp.AddProduct(pr);
                                    foreach (var file in FileU.PostedFiles)
                                    {
                                        string fileName = "images/home/" + file.FileName;
                                        string filePath = MapPath(fileName);
                                        file.SaveAs(filePath);
                                        ip = new img_prod();
                                        ip.id_prod = pr.id_pro;
                                        ip.img_url = file.FileName;
                                        if (dem == 0)
                                        {
                                            ip.stt_img = 1;
                                        }
                                        else
                                        {
                                            ip.stt_img = 0;
                                        }
                                        dem++;
                                        rp.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();
    }
	private void attach_img_prods(img_prod entity)
	{
		this.SendPropertyChanging();
		entity.prod = this;
	}
    public void UpdateimgProd(img_prod imp)
    {
        try
        {
            LQDataContext ctxx = new LQDataContext();
            var q = ctxx.img_prods.Where(d => d.id_img == imp.id_img).SingleOrDefault();
            q.img_url = imp.img_url;
            ctxx.SubmitChanges();
        }
        catch (Exception ex)
        {

        }
    }
Beispiel #14
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 prod();
             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 (rp.checkalprod(tbName1.Text.Trim()))
                             {
                                 pr.pro_name  = tbName1.Text.Trim();
                                 pr.pro_price = float.Parse(tbPrice1.Text.Trim());
                                 rp.AddProduct(pr);
                                 foreach (var file in FileU.PostedFiles)
                                 {
                                     string fileName = "images/home/" + file.FileName;
                                     string filePath = MapPath(fileName);
                                     file.SaveAs(filePath);
                                     ip         = new img_prod();
                                     ip.id_prod = pr.id_pro;
                                     ip.img_url = file.FileName;
                                     if (dem == 0)
                                     {
                                         ip.stt_img = 1;
                                     }
                                     else
                                     {
                                         ip.stt_img = 0;
                                     }
                                     dem++;
                                     rp.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();
 }
Beispiel #15
0
    public void ud()
    {
        foreach (RepeaterItem i in Repeater3.Items)
        {
            FileUpload fu  = (FileUpload)i.FindControl("FileUpload1");
            Label      lbl = (Label)i.FindControl("lblIDIMG");
            if (fu.HasFile)
            {
                if (!ck.CheckFileType(fu.FileName))
                {
                    tam = 1;
                    break;
                }
            }
        }
        if (FileUploadMore.HasFile)
        {
            foreach (var file1 in FileUploadMore.PostedFiles)
            {
                if (!ck.CheckFileType(file1.FileName))
                {
                    tam = 1;
                    break;
                }
            }
        }
        if (tam == 0)
        {
            foreach (RepeaterItem i in Repeater3.Items)
            {
                FileUpload fu  = (FileUpload)i.FindControl("FileUpload1");
                Label      lbl = (Label)i.FindControl("lblIDIMG");
                if (fu.HasFile)
                {
                    int    n111     = Convert.ToInt32(lbl.Text);
                    string fileName = "images/home/" + fu.FileName;
                    string filePath = MapPath(fileName);
                    fu.SaveAs(filePath);
                    img_prod ima = rp.getImage(n111);
                    ima.img_url = fu.FileName;
                    rp.UpdateimgProd(ima);
                }
            }
            if (FileUploadMore.HasFile)
            {
                foreach (var file1 in FileUploadMore.PostedFiles)
                {
                    string fileName = "images/home/" + file1.FileName;
                    string filePath = MapPath(fileName);
                    file1.SaveAs(filePath);
                    ip1         = new img_prod();
                    ip1.id_prod = p.id_pro;
                    ip1.img_url = file1.FileName;
                    rp.AddimgProd(ip1);
                }
            }

            if ((int)ViewState["bf"] == 1)
            {
                p.id_cat        = idCate;
                ViewState["bf"] = 0;
            }
            if (ck.checkstringnull(txtName.Text.Trim()))
            {
                if (ck.checkstringnull(txtPrice.Text.Trim()))
                {
                    if (ck.checknumber(txtPrice.Text.Trim()))
                    {
                        if (ck.checkstring(txtName.Text.Trim(), 50))
                        {
                            if (p.pro_name == txtName.Text.Trim())
                            {
                                p.pro_name  = txtName.Text.Trim();
                                p.pro_price = float.Parse(txtPrice.Text.Trim());
                                rp.UpdateProduct(p);
                                load_pro();
                            }
                            else
                            {
                                if (rp.checkalprod(txtName.Text.Trim()))
                                {
                                    p.pro_name  = txtName.Text.Trim();
                                    p.pro_price = float.Parse(txtPrice.Text.Trim());
                                    rp.UpdateProduct(p);
                                    load_pro();
                                }
                                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('Many Images Too Large Or Not Format(.jpg|.png|.gif)')", true);
            load_pro();
            loadCate();
        }
    }
    protected void del_Command(object sender, CommandEventArgs e)
    {
        if (e.CommandName == "delcm")
        {
            foreach (RepeaterItem it in grid_product.Items)
            {
                Label n1 = (Label)it.FindControl("lblid");
                if (n1.Text == e.CommandArgument.ToString())
                {
                    int n = Convert.ToInt32(n1.Text);
                    List<img_prod> lim = rp.getProdImage(n);
                    foreach (img_prod imgpr in lim)
                    {
                        listim.Add(imgpr);
                        rp.DeleteImgProd(imgpr.id_img);
                    }
                    if (rp.DeleteProduct(n))
                    {
                        
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Delete Complete')", true);
                        break;
                    }
                    else
                    {
                        foreach (img_prod imgpr1 in listim)
                        {
                            img_prod imgtam = new img_prod();
                            imgtam.id_prod = imgpr1.id_prod;
                            imgtam.img_url = imgpr1.img_url;
                            imgtam.stt_img = imgpr1.stt_img;
                            rp.AddimgProd(imgtam);
                        }
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Delete Fail')", true);
                       }
                }

            }
            load_Prod();
        }

    }
 partial void Updateimg_prod(img_prod instance);
    public void SetSttImage(img_prod imp, int mstt)
    {
        try
        {
            LQDataContext ctxx = new LQDataContext();
            var q = ctxx.img_prods.Where(d => d.id_img == imp.id_img).SingleOrDefault();
            q.stt_img = mstt;
            ctxx.SubmitChanges();
        }
        catch (Exception ex)
        {

        }
    }
 partial void Deleteimg_prod(img_prod instance);
    public void ud()
    {
        foreach (RepeaterItem i in Repeater3.Items)
        {
            FileUpload fu = (FileUpload)i.FindControl("FileUpload1");
            Label lbl = (Label)i.FindControl("lblIDIMG");
            if (fu.HasFile)
            {
                if (!ck.CheckFileType(fu.FileName))
                {
                    tam = 1;
                    break;
                }
            }
        }
        if (FileUploadMore.HasFile)
        {
            foreach (var file1 in FileUploadMore.PostedFiles)
            {
                if (!ck.CheckFileType(file1.FileName))
                {
                    tam = 1;
                    break;
                }
            }
         
        }
        if (tam == 0)
        {
            foreach (RepeaterItem i in Repeater3.Items)
            {
                FileUpload fu = (FileUpload)i.FindControl("FileUpload1");
                Label lbl = (Label)i.FindControl("lblIDIMG");
                if (fu.HasFile)
                {
                    
                        int n111 = Convert.ToInt32(lbl.Text);
                        string fileName = "images/home/" + fu.FileName;
                        string filePath = MapPath(fileName);
                        fu.SaveAs(filePath);
                        img_prod ima = rp.getImage(n111);
                        ima.img_url = fu.FileName;
                        rp.UpdateimgProd(ima);
                  
                }
            }
            if (FileUploadMore.HasFile)
            {
                foreach (var file1 in FileUploadMore.PostedFiles)
                {
                    string fileName = "images/home/" + file1.FileName;
                    string filePath = MapPath(fileName);
                    file1.SaveAs(filePath);
                    ip1 = new img_prod();
                    ip1.id_prod = p.id_pro;
                    ip1.img_url = file1.FileName;
                    rp.AddimgProd(ip1);
                }

            }

            if ((int)ViewState["bf"] == 1)
            {
                p.id_cat = idCate;
                ViewState["bf"] = 0;
            }
            if (ck.checkstringnull(txtName.Text.Trim()))
            {
                if (ck.checkstringnull(txtPrice.Text.Trim()))
                {
                    if (ck.checknumber(txtPrice.Text.Trim()))
                    {
                        if (ck.checkstring(txtName.Text.Trim(), 50))
                        {
                            if (p.pro_name == txtName.Text.Trim())
                            {
                                p.pro_name = txtName.Text.Trim();
                                p.pro_price = float.Parse(txtPrice.Text.Trim());
                                rp.UpdateProduct(p);
                                load_pro();
                            }
                            else
                            {
                                if (rp.checkalprod(txtName.Text.Trim()))
                                {
                                    p.pro_name = txtName.Text.Trim();
                                    p.pro_price = float.Parse(txtPrice.Text.Trim());
                                    rp.UpdateProduct(p);
                                    load_pro();
                                }
                                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('Many Images Too Large Or Not Format(.jpg|.png|.gif)')", true);
            load_pro();
            loadCate();
        }
       
      
    }
	private void detach_img_prods(img_prod entity)
	{
		this.SendPropertyChanging();
		entity.prod = null;
	}
 public bool AddimgProd(img_prod imp)
 {
     LQDataContext ctxs = new LQDataContext();
     ctxs.img_prods.InsertOnSubmit(imp);
     ctxs.SubmitChanges();
     return true;
 }