public void BindData() { if (Session["id"] != null) { long id = long.Parse(Session["id"].ToString()); DatalistPimage.DataSource = objpp.GetPicture(id); DatalistPimage.DataBind(); DatalistThumb.DataSource = objpp.GetPictures(id); DatalistThumb.DataBind(); } }
protected void btnsave_Click(object sender, EventArgs e) { Productpicture objpp = new Productpicture(); string newpath = ""; if (Session["id"] != null && Session["id"].ToString() != "") { long ID = long.Parse(Session["id"].ToString()); //String imgpath = File1.FileName; //string FullImage = File1.FileName; lblmsg.Text = ""; if (Session["up1"] != null && Session["up1"].ToString() != "") { if (Session["up1"] != null && Session["up1"].ToString() != "") { uploadpath = Session["up1"].ToString(); if (btnsave.Text == "Save") { //string filename = Path.GetFileName(AjaxFileUpload1.PostedFile.FileName); //AjaxFileUpload1.SaveAs(Server.MapPath(Session["path"].ToString())); objpp.ProductID = long.Parse(Session["id"].ToString()); long poid = objpp.ProductID; objpp.PicturePath = uploadpath; objpp.PictureThumbPath = uploadpath; List <Productpicture> lstppictur = objpp.GetPicture(poid); long ppictureid = 0; if (lstppictur.Count >= 1) { ppictureid = objpp.GetPPictures(poid); } else { ppictureid = objpp.SaveProductPicture(); } objpp.SaveProductPictureThumbnails(ppictureid); } else { // AjaxFileUpload1.SaveAs(Server.MapPath(Session["path"].ToString())); objpp.ProductID = long.Parse(Session["id"].ToString()); objpp.PicturePath = uploadpath; objpp.PictureThumbPath = uploadpath; string path = uploadpath; objpp.UpdateProductPictures(); long ppid = objpp.GetPictureID(objpp.ProductID); List <Productpicture> lstpic = objpp.GetPictureThumbnails(ppid); if (lstpic.Count > 0) { objpp.UpdateProductThumbnail(ppid, path); } else { objpp.SaveProductPictureThumbnails(ppid); } } } if (Session["up2"] != null && Session["up2"].ToString() != "") { uploadpath2 = Session["up2"].ToString(); if (btnsave.Text == "Save") { //string filename = Path.GetFileName(AjaxFileUpload1.PostedFile.FileName); //AjaxFileUpload1.SaveAs(Server.MapPath(Session["path"].ToString())); objpp.ProductID = long.Parse(Session["id"].ToString()); long poid = objpp.ProductID; objpp.PicturePath = uploadpath2; objpp.PictureThumbPath = uploadpath2; List <Productpicture> lstppictur = objpp.GetPicture(poid); long ppictureid = 0; if (lstppictur.Count >= 1) { ppictureid = objpp.GetPPictures(poid); } else { ppictureid = objpp.SaveProductPicture(); } objpp.SaveProductPictureThumbnails(ppictureid); } else { // AjaxFileUpload1.SaveAs(Server.MapPath(Session["path"].ToString())); objpp.ProductID = long.Parse(Session["id"].ToString()); objpp.PicturePath = uploadpath2; objpp.PictureThumbPath = uploadpath2; string path = uploadpath2; objpp.UpdateProductPictures(); long ppid = objpp.GetPictureID(objpp.ProductID); List <Productpicture> lstpic = objpp.GetPictureThumbnails(ppid); if (lstpic.Count > 0) { objpp.UpdateProductThumbnail(ppid, path); } else { objpp.SaveProductPictureThumbnails(ppid); } } } if (Session["up3"] != null && Session["up3"].ToString() != "") { uploadpath3 = Session["up3"].ToString(); if (btnsave.Text == "Save") { //string filename = Path.GetFileName(AjaxFileUpload1.PostedFile.FileName); //AjaxFileUpload1.SaveAs(Server.MapPath(Session["path"].ToString())); objpp.ProductID = long.Parse(Session["id"].ToString()); long poid = objpp.ProductID; objpp.PicturePath = uploadpath3; objpp.PictureThumbPath = uploadpath3; List <Productpicture> lstppictur = objpp.GetPicture(poid); long ppictureid = 0; if (lstppictur.Count >= 1) { ppictureid = objpp.GetPPictures(poid); } else { ppictureid = objpp.SaveProductPicture(); } objpp.SaveProductPictureThumbnails(ppictureid); } else { // AjaxFileUpload1.SaveAs(Server.MapPath(Session["path"].ToString())); objpp.ProductID = long.Parse(Session["id"].ToString()); objpp.PicturePath = uploadpath3; objpp.PictureThumbPath = uploadpath3; string path = uploadpath3; objpp.UpdateProductPictures(); long ppid = objpp.GetPictureID(objpp.ProductID); List <Productpicture> lstpic = objpp.GetPictureThumbnails(ppid); if (lstpic.Count > 0) { objpp.UpdateProductThumbnail(ppid, path); } else { objpp.SaveProductPictureThumbnails(ppid); } } } if (Session["up4"] != null && Session["up4"].ToString() != "") { uploadpath4 = Session["up4"].ToString(); if (btnsave.Text == "Save") { //string filename = Path.GetFileName(AjaxFileUpload1.PostedFile.FileName); //AjaxFileUpload1.SaveAs(Server.MapPath(Session["path"].ToString())); objpp.ProductID = long.Parse(Session["id"].ToString()); long poid = objpp.ProductID; objpp.PicturePath = uploadpath4; objpp.PictureThumbPath = uploadpath4; List <Productpicture> lstppictur = objpp.GetPicture(poid); long ppictureid = 0; if (lstppictur.Count >= 1) { ppictureid = objpp.GetPPictures(poid); } else { ppictureid = objpp.SaveProductPicture(); } objpp.SaveProductPictureThumbnails(ppictureid); } else { // AjaxFileUpload1.SaveAs(Server.MapPath(Session["path"].ToString())); objpp.ProductID = long.Parse(Session["id"].ToString()); objpp.PicturePath = uploadpath4; objpp.PictureThumbPath = uploadpath4; string path = uploadpath4; objpp.UpdateProductPictures(); long ppid = objpp.GetPictureID(objpp.ProductID); List <Productpicture> lstpic = objpp.GetPictureThumbnails(ppid); if (lstpic.Count > 0) { objpp.UpdateProductThumbnail(ppid, path); } else { objpp.SaveProductPictureThumbnails(ppid); } } } if (Session["up5"] != null && Session["up5"].ToString() != "") { uploadpath5 = Session["up5"].ToString(); if (btnsave.Text == "Save") { //string filename = Path.GetFileName(AjaxFileUpload1.PostedFile.FileName); //AjaxFileUpload1.SaveAs(Server.MapPath(Session["path"].ToString())); objpp.ProductID = long.Parse(Session["id"].ToString()); long poid = objpp.ProductID; objpp.PicturePath = uploadpath5; objpp.PictureThumbPath = uploadpath5; List <Productpicture> lstppictur = objpp.GetPicture(poid); long ppictureid = 0; if (lstppictur.Count >= 1) { ppictureid = objpp.GetPPictures(poid); } else { ppictureid = objpp.SaveProductPicture(); } objpp.SaveProductPictureThumbnails(ppictureid); } else { // AjaxFileUpload1.SaveAs(Server.MapPath(Session["path"].ToString())); objpp.ProductID = long.Parse(Session["id"].ToString()); objpp.PicturePath = uploadpath5; objpp.PictureThumbPath = uploadpath5; string path = uploadpath5; objpp.UpdateProductPictures(); long ppid = objpp.GetPictureID(objpp.ProductID); List <Productpicture> lstpic = objpp.GetPictureThumbnails(ppid); if (lstpic.Count > 0) { objpp.UpdateProductThumbnail(ppid, path); } else { objpp.SaveProductPictureThumbnails(ppid); } } } if (Session["up6"] != null && Session["up6"].ToString() != "") { uploadpath6 = Session["up6"].ToString(); if (btnsave.Text == "Save") { //string filename = Path.GetFileName(AjaxFileUpload1.PostedFile.FileName); //AjaxFileUpload1.SaveAs(Server.MapPath(Session["path"].ToString())); objpp.ProductID = long.Parse(Session["id"].ToString()); long poid = objpp.ProductID; objpp.PicturePath = uploadpath6; objpp.PictureThumbPath = uploadpath6; List <Productpicture> lstppictur = objpp.GetPicture(poid); long ppictureid = 0; if (lstppictur.Count >= 1) { ppictureid = objpp.GetPPictures(poid); } else { ppictureid = objpp.SaveProductPicture(); } objpp.SaveProductPictureThumbnails(ppictureid); } else { // AjaxFileUpload1.SaveAs(Server.MapPath(Session["path"].ToString())); objpp.ProductID = long.Parse(Session["id"].ToString()); objpp.PicturePath = uploadpath6; objpp.PictureThumbPath = uploadpath6; string path = uploadpath6; objpp.UpdateProductPictures(); long ppid = objpp.GetPictureID(objpp.ProductID); List <Productpicture> lstpic = objpp.GetPictureThumbnails(ppid); if (lstpic.Count > 0) { objpp.UpdateProductThumbnail(ppid, path); } else { objpp.SaveProductPictureThumbnails(ppid); } } } uploadpath = ""; uploadpath2 = ""; uploadpath3 = ""; uploadpath4 = ""; uploadpath5 = ""; uploadpath6 = ""; Session["up1"] = null; Session["up2"] = null; Session["up3"] = null; Session["up4"] = null; Session["up5"] = null; Session["up6"] = null; BindData(); Response.Redirect("Product.aspx"); } else { lblmsg.ForeColor = System.Drawing.Color.Red; lblmsg.Text = "Please select image before you save"; } } else { lblmsg.ForeColor = System.Drawing.Color.Red; lblmsg.Text = "Please select image before you savedasdsa"; } }