void LoadAdDetails() { AdDetailsBll adbll = new AdDetailsBll(); DataTable dt = adbll.GetAdDetails(Convert.ToInt32(strAdId), Convert.ToInt32(strUserId)); if (dt.Rows.Count > 0) { lblCategory.Text = dt.Rows[0]["CategoryName"].ToString(); lbllAdtitle.Text = dt.Rows[0]["AdPostTitle"].ToString(); lblAddesc.Text = dt.Rows[0]["Description"].ToString(); lblPrice.Text = "Price : $" + dt.Rows[0]["Price"].ToString(); strImgpath = dt.Rows[0]["ImagePath"].ToString().Split(':'); strVideolink = dt.Rows[0]["VideoLink"].ToString(); string appPath = ConfigurationManager.AppSettings["ApplicationPath"].ToString().Trim(); string imageUrl = appPath + strImgpath[0]; adimage1.InnerHtml = string.Format( "<a align=center href='{0}'><br/><img align=center src='{0}' " + "width=350px height=450px alt='' border=2 bordorcolor='black'></a>", imageUrl); for (int intCnt = 1; strImgpath.Length > intCnt; intCnt++) { imageUrl = appPath + strImgpath[intCnt]; } if (strImgpath.Length >= 2) { imageUrl = appPath + strImgpath[1]; adimage2.InnerHtml = string.Format( "<a align=center href='{0}'><br/><img align=center src='{0}' " + "width=200px height=200px alt='' border=2 bordorcolor='black'></a>", imageUrl); } if (strImgpath.Length >= 3) { imageUrl = appPath + strImgpath[2]; adimage3.InnerHtml = string.Format( "<a align=center href='{0}'><br/><img align=center src='{0}' " + "width=200px height=200px alt='' border=2 bordorcolor='black'></a>", imageUrl); } if (strImgpath.Length >= 4) { imageUrl = appPath + strImgpath[3]; adimage4.InnerHtml = string.Format( "<a align=center href='{0}'><br/><img align=center src='{0}' " + "width=200px height=200px alt='' border=2 bordorcolor='black'></a>", imageUrl); } if (strImgpath.Length == 5) { imageUrl = appPath + strImgpath[4]; adimage5.InnerHtml = string.Format( "<a align=center href='{0}'><br/><img align=center src='{0}' " + "width=200px height=200px alt='' border=2 bordorcolor='black'></a>", imageUrl); } spnVideo.InnerHtml = BindUrl(strVideolink); } }
void LoadAdPost() { AdDetailsBll adbll = new AdDetailsBll(); dt = adbll.GetAdDetails(Convert.ToInt32(strAdpostId), Convert.ToInt32(strUserId)); if (dt.Rows.Count > 0) { txtTitle.Text = dt.Rows[0]["AdPostTitle"].ToString(); txtDesc.Text = dt.Rows[0]["Description"].ToString(); txtKeywords.Text = dt.Rows[0]["Keywords"].ToString(); txtPrice.Text = dt.Rows[0]["Price"].ToString(); txtVidolink.Text = dt.Rows[0]["VideoLink"].ToString(); //strImagePath = dt.Rows[0]["ImagePath"].ToString().Split(':'); strAllImgPath = dt.Rows[0]["ImagePath"].ToString(); strImageId = dt.Rows[0]["ImageId"].ToString(); for (int i = 0; i < ddlCategory.Items.Count; i++) { if (ddlCategory.Items[i].Text == dt.Rows[0]["CategoryName"].ToString()) { ddlCategory.SelectedIndex = i; } } DatePicker1.SelectedDate = Convert.ToDateTime(dt.Rows[0]["AdTillDate"].ToString()); //HtmlGenericControl spnHtml = (HtmlGenericControl)this.Page.FindControl("spnAdImag"); //if (spnHtml == null) // return; BindUrl(); //img1.Src = strImagePath[0]; //remove1.Attributes.Add("imgpath", strImagePath[0]); //fileuploadImg = strImagePath[0]; } }
void LoadAds() { objAd = new AdDetailsBll(); if (rdoSearch.SelectedItem.Value.ToString() == "0") { dt = objAd.SelectReportsByCity(txtSearch.Text.ToString().Trim()); } else { dt = objAd.SelectReportsByDate(Convert.ToDateTime(DatePicker1.SelectedDate.ToString()), Convert.ToDateTime(DatePicker2.SelectedDate.ToString())); } if (dt.Rows.Count > 0) { tblAdpost.Visible = true; lblError.Visible = false; } else { tblAdpost.Visible = false; lblError.Visible = true; lblError.Text = "No Reports"; } GridView1.DataSource = dt; GridView1.DataBind(); }
void LoadAds() { objAd = new AdDetailsBll(); if (rdoSearch.SelectedItem.Value.ToString() == "0") { dt = objAd.SearchAdsByAdtitle(txtSearch.Text.ToString().Trim()); //GetAllAdDetails(); } else { dt = objAd.SearchAdsByUsername(txtSearch.Text.ToString().Trim()); } if (dt.Rows.Count > 0) { tblAdpost.Visible = true; lblError.Visible = false; } else { tblAdpost.Visible = false; lblError.Visible = true; lblError.Text = "No Ads"; } GridView1.DataSource = dt; GridView1.DataBind(); }
//void LoadAdDetails() //{ // AdDetailsBll adbll = new AdDetailsBll(); // DataTable dt = adbll.GetAllAdDetails(); // string imageUrl = "", strPrice = "", strCategory = "", strTitle = "", strViewlink=""; // string strInnerhtmlContent = ""; // if (dt.Rows.Count > 0) // { // for (int intCnt = 0; intCnt < dt.Rows.Count; intCnt++) // { // strCategory = dt.Rows[intCnt]["CategoryName"].ToString(); // strTitle = dt.Rows[intCnt]["AdPostTitle"].ToString(); // strPrice = "Price : $" + dt.Rows[intCnt]["Price"].ToString(); // strImgpath = dt.Rows[intCnt]["ImagePath"].ToString().Split(':'); // string appPath = ConfigurationManager.AppSettings["ApplicationPath"].ToString().Trim(); // imageUrl = appPath + strImgpath[0]; // strViewlink = appPath + "/Account/ViewAds.aspx?aid=" + dt.Rows[intCnt]["AdPostId"].ToString() + "&uid=" + dt.Rows[intCnt]["UserId"].ToString(); // strInnerhtmlContent = strInnerhtmlContent + string.Format( // //sid.InnerHtml = sid.InnerHtml + string.Format( // "<div id='ps-albums'>" + // "<div class='ps-album' style='opacity:0;'> <img src='{0}' height />" + // "<div class='ps-desc'>" + // "<div class='ps-head'>" + // "<h3>{1}</h3>" + // "</div>" + // "<div class='ps-cont'> <span>Category on {2} <br><br> {3} <a href='{4}'>View</a></span> </div>" + // "</div>" + // "</div>" + // "</div>", imageUrl, strTitle, strCategory, strPrice, strViewlink); // } // } // //sid.InnerHtml = strInnerhtmlContent; //} void BindAlbumGrid() { int k = GridView1.PageCount; GridView1.Controls.Clear(); //gridpageIndex = 0; AdDetailsBll adbll = new AdDetailsBll(); if (txtSearch.Text.Trim() == "") { dt = adbll.GetAllAdDetails(); } else { dt = adbll.SearchAdsByKeyword(txtSearch.Text.Trim()); } if (dt.Rows.Count > 4) { decimal dPageSize = (dt.Rows.Count / 4M); //GridView1.PagerSettings.PageButtonCount = Convert.ToInt32(Math.Floor(dPageSize)); //GridView1.PageSize = Convert.ToInt32(Math.Ceiling(dPageSize)); } GridView1.DataSource = dt.DefaultView; GridView1.DataBind(); }
void DeleteRecord(string adpostId) { string path = string.Empty; AdDetailsBll adbll = new AdDetailsBll(); adbll.AdPostDeleteById(Convert.ToInt32(adpostId)); BindAlbumGrid(); }
protected void btnSaveAd_Click(object sender, EventArgs e) { //string str = fileuploadImg.PostedFile.FileName; HttpFileCollection fileCollection = Request.Files; for (int i = 0; i < fileCollection.Count; i++) { HttpPostedFile uploadfile = fileCollection[i]; string fileName = Path.GetFileName(uploadfile.FileName); } AdDetailsBll adbll = new AdDetailsBll(); UserInfoBll usrinfo = new UserInfoBll(); dt = usrinfo.SelectProfile(Convert.ToInt32(strUserId)); // userid try { #region .. CREATE AD POST .. int intAdpostId = adbll.CreateAdPost( Convert.ToInt32(strAdpostId), txtTitle.Text.ToString(), txtDesc.Text.ToString(), txtKeywords.Text.ToString(), Convert.ToInt32(strUserId), Convert.ToInt32(ddlCategory.SelectedItem.Value.ToString()), Convert.ToDecimal(txtPrice.Text.ToString()), Convert.ToInt32(dt.Rows[0]["StateId"].ToString()), Convert.ToInt32(dt.Rows[0]["CityId"].ToString()), Convert.ToInt32(dt.Rows[0]["CountryId"].ToString()), dt.Rows[0]["ZipCode"].ToString(), Convert.ToDateTime(DatePicker1.SelectedDate.ToString()), "NEW", 0 ); #endregion adbll.CreateAdImageDetails(Convert.ToInt32(strImageId), Convert.ToInt32(strAdpostId), strAllImgPath, txtVidolink.Text.ToString()); Response.Redirect("MyAdposts.aspx"); } catch (System.Threading.ThreadAbortException th) { } catch (Exception ex) { } }
protected void btnBlock_Click(object sender, EventArgs e) { foreach (GridViewRow r in GridView1.Rows) { int intBlockVal = 0; CheckBox chk = (CheckBox)r.Cells[0].FindControl("chkDeleteStatus"); if (chk.Checked) { intBlockVal = 1; } string sAdId = GridView1.DataKeys[r.RowIndex].Value.ToString(); objAd = new AdDetailsBll(); objAd.UpdateAdDeleteStatus(Convert.ToInt32(sAdId), intBlockVal); } //lblMessage.Visible = true; //lblMessage.Text = "Selected Ads are deleted"; }
protected void remove3_Click(object sender, EventArgs e) { string sourcepath = string.Empty; DirectoryInfo dirInfo = null; string Path1 = remove3.Attributes["imgpath"].ToString(); sourcepath = Server.MapPath("~" + Path1); FileInfo g = new FileInfo(sourcepath); if (g.Exists) { g.Delete(); } int index = strAllImgPath.IndexOf(Path1); int leng = Path1.Length; int newlength = 0; int newindex = 0; if (index + leng == strAllImgPath.Length && index == 0) { newindex = index; newlength = leng; } else if (index + leng == strAllImgPath.Length && index != 0) { newindex = index - 1; newlength = leng + 1; } else { newindex = index; newlength = leng + 1; } AdDetailsBll ad = new AdDetailsBll(); ad.UpdateAdImagePath(Convert.ToInt32(strImageId), strAllImgPath.Remove(newindex, newlength)); BindUrl(); }
void BindAlbumGrid() { int k = GridView1.PageCount; GridView1.Controls.Clear(); //gridpageIndex = 0; AdDetailsBll adbll = new AdDetailsBll(); dt = adbll.SelectUserAds(Convert.ToInt32(Session["UserId"].ToString())); if (dt.Rows.Count > 4) { decimal dPageSize = (dt.Rows.Count / 4M); //GridView1.PagerSettings.PageButtonCount = Convert.ToInt32(Math.Floor(dPageSize)); //GridView1.PageSize = Convert.ToInt32(Math.Ceiling(dPageSize)); } GridView1.DataSource = dt.DefaultView; GridView1.DataBind(); }
private void LoadImage() { try { AdDetailsBll adbll = new AdDetailsBll(); DataTable dt = adbll.GetAdDetails(Convert.ToInt32(strAdId), Convert.ToInt32(strUserId)); if (dt.Rows.Count > 0) { lblCategory.Text = dt.Rows[0]["CategoryName"].ToString(); lblTitle.Text = dt.Rows[0]["AdPostTitle"].ToString(); lblAddesc.Text = dt.Rows[0]["Description"].ToString(); lblPrice.Text = "Price : $" + dt.Rows[0]["Price"].ToString(); strImgpath = dt.Rows[0]["ImagePath"].ToString().Split(':'); strVideolink = dt.Rows[0]["VideoLink"].ToString(); } string appPath = ConfigurationManager.AppSettings["ApplicationPath"].ToString().Trim(); string divSlider = @"<ul class='slides'>"; string fileSlide = string.Empty; for (int i = 0; i < strImgpath.Length; i++) { fileSlide = @"<li><img src='"; fileSlide += strImgpath[i] + "' /></li>"; divSlider += fileSlide; } divImageSlider.InnerHtml = divSlider + "</ul>"; spnVideo.InnerHtml = BindUrl(strVideolink); } catch (Exception ex) { //ShowErrorMsg("error", ex.Message); } }
public void BindUrl() { VisibleNoImage(); string sImageHtml = ""; string appPath = ConfigurationManager.AppSettings["ApplicationPath"].ToString().Trim(); AdDetailsBll adbll = new AdDetailsBll(); dt = adbll.GetAdDetails(Convert.ToInt32(strAdpostId), Convert.ToInt32(strUserId)); if (dt.Rows.Count > 0) { strAllImgPath = dt.Rows[0]["ImagePath"].ToString(); if (strAllImgPath.Trim() != "") { strImagePath = dt.Rows[0]["ImagePath"].ToString().Split(':'); } } if (strImagePath.Length >= 1 && strImagePath[0] != null && strImagePath[0] != "") { img1.Src = strImagePath[0]; img1.Visible = true; remove1.Visible = true; remove1.Attributes.Add("imgpath", strImagePath[0]); } if (strImagePath.Length >= 2 && strImagePath[1] != null) { img2.Src = strImagePath[1]; img2.Visible = true; remove2.Visible = true; remove2.Attributes.Add("imgpath", strImagePath[1]); } if (strImagePath.Length >= 3 && strImagePath[2] != null) { img3.Src = strImagePath[2]; img3.Visible = true; remove3.Visible = true; remove3.Attributes.Add("imgpath", strImagePath[2]); } if (strImagePath.Length >= 4 && strImagePath[3] != null) { img4.Src = strImagePath[3]; img4.Visible = true; remove4.Visible = true; remove4.Attributes.Add("imgpath", strImagePath[3]); } if (strImagePath.Length >= 5 && strImagePath[4] != null) { img5.Src = strImagePath[4]; img5.Visible = true; remove5.Visible = true; remove5.Attributes.Add("imgpath", strImagePath[4]); } //sImageHtml = "<table height='100px' width='500px'><tr><td>"; //for (int i = 0; i < strImgPath.Length; i++) //{ // sImageHtml += "<img src='" + strImgPath[i] + "' height='60px' width='50px'><a id='remImg" + i.ToString() + "' href='#' onclick=''>Remove</a>"; //} //sImageHtml += "</td></tr><table>"; //return sImageHtml; }
protected void btnUpload_Click(object sender, EventArgs e) { int intError = 0; if (FileUpload1.HasFile) { string[] strTemp = new string[5]; strTemp = strAllImgPath.Split(':'); if (FileUpload1.PostedFile.ContentLength > 1048576) { errFile1.Visible = true; errFile1.Text = "Exceeds maximum limit 1 MB"; intError++; } else if (strTemp.Length == 5 && strTemp[4] != null && strTemp[4] != "") { errFile1.Visible = true; errFile1.Text = "Maximum 5 images are allowed. "; intError++; } else { errFile1.Visible = false; } } else { string[] strTemp = new string[5]; strTemp = strAllImgPath.Split(':'); if (strTemp.Length == 5 && strTemp[4] != null && strTemp[4] != "") { errFile1.Visible = true; errFile1.Text = "Maximum 5 images are allowed. "; intError++; } else { errFile1.Visible = true; errFile1.Text = "Select a image file. "; intError++; } } if (intError == 0) { string path = string.Empty; string finalPath = string.Empty; string filePath = string.Empty; int userId = Convert.ToInt32(Session["UserId"].ToString()); string sFilename = ""; if (FileUpload1.PostedFile != null) { HttpPostedFile myFile = FileUpload1.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { DirectoryInfo dirInfo = null; string fileSavePath = "/Data/TS_" + userId + "/Images/"; path = Server.MapPath("~" + fileSavePath); if (!Directory.Exists(path)) { dirInfo = Directory.CreateDirectory(path); } sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload1.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); } if (strAllImgPath.Trim() == "") { strAllImgPath = finalPath; } else { strAllImgPath = strAllImgPath + ":" + finalPath; } AdDetailsBll ad = new AdDetailsBll(); ad.UpdateAdImagePath(Convert.ToInt32(strImageId), strAllImgPath); BindUrl(); } } }
protected void btnAddPost_Click(object sender, EventArgs e) { if (Session["UserId"] == null) { Response.Redirect("Login.aspx"); } else { #region .. VALIDATION .. int intError = 0; if (DatePicker1.SelectedDate.ToString() == "1/1/0001 12:00:00 AM") { intError++; ErrDate.Visible = true; ErrDate.Text = "Select Date"; } if (ddlCategory.SelectedIndex == 0) { intError++; ErrCategory.Text = "Select Category"; ErrCategory.Visible = true; } if (FileUpload1.HasFile) { if (FileUpload1.PostedFile.ContentLength > 1048576) { errFile1.Visible = true; errFile1.Text = "Exceeds maximum limit 1 MB"; intError++; } else { errFile1.Visible = false; } } if (FileUpload2.HasFile) { if (FileUpload2.PostedFile.ContentLength > 1048576) { errFile2.Visible = true; errFile2.Text = "Exceeds maximum limit 1 MB"; intError++; } else { errFile2.Visible = false; } } if (FileUpload3.HasFile) { if (FileUpload3.PostedFile.ContentLength > 1048576) { errFile3.Visible = true; errFile3.Text = "Exceeds maximum limit 1 MB"; intError++; } else { errFile3.Visible = false; } } if (FileUpload4.HasFile) { if (FileUpload4.PostedFile.ContentLength > 1048576) { errFile4.Visible = true; errFile4.Text = "Exceeds maximum limit 1 MB"; intError++; } else { errFile4.Visible = false; } } if (FileUpload5.HasFile) { if (FileUpload5.PostedFile.ContentLength > 1048576) { errFile5.Visible = true; errFile5.Text = "Exceeds maximum limit 1 MB"; intError++; } else { errFile5.Visible = false; } } #endregion if (intError == 0) { AdDetailsBll adbll = new AdDetailsBll(); UserInfoBll usrinfo = new UserInfoBll(); DataTable dt = usrinfo.SelectProfile(Convert.ToInt32(Session["UserId"].ToString())); // userid try { #region .. CREATE AD POST .. int intAdpostId = adbll.CreateAdPost( 0, txtTitle.Text.ToString(), txtDesc.Text.ToString(), txtKeywords.Text.ToString(), Convert.ToInt32(Session["UserId"].ToString()), Convert.ToInt32(ddlCategory.SelectedItem.Value.ToString()), Convert.ToDecimal(txtPrice.Text.ToString()), Convert.ToInt32(dt.Rows[0]["StateId"].ToString()), Convert.ToInt32(dt.Rows[0]["CityId"].ToString()), Convert.ToInt32(dt.Rows[0]["CountryId"].ToString()), dt.Rows[0]["ZipCode"].ToString(), Convert.ToDateTime(DatePicker1.SelectedDate.ToString()), "NEW", 0 ); #endregion #region .. CREATE AD POST IMAGE .. string path = string.Empty; string strImgFinalPath = ""; string finalPath = string.Empty; string filePath = string.Empty; int userId = Convert.ToInt32(Session["UserId"].ToString()); string sFilename = ""; if (FileUpload1.PostedFile != null) { HttpPostedFile myFile = FileUpload1.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { DirectoryInfo dirInfo = null; fileSavePath = "/Data/TS_" + userId + "/Images/"; path = Server.MapPath("~" + fileSavePath); if (!Directory.Exists(path)) { dirInfo = Directory.CreateDirectory(path); } sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload1.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); } } strImgFinalPath = finalPath; if (FileUpload2.PostedFile != null) { HttpPostedFile myFile = FileUpload2.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload2.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } } if (FileUpload3.PostedFile != null) { HttpPostedFile myFile = FileUpload3.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload3.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } } if (FileUpload4.PostedFile != null) { HttpPostedFile myFile = FileUpload4.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload4.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } } if (FileUpload5.PostedFile != null) { HttpPostedFile myFile = FileUpload5.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen != 0) { path = Server.MapPath("~" + fileSavePath); sFilename = System.IO.Path.GetFileName(myFile.FileName); path = path + "/" + sFilename; FileUpload5.PostedFile.SaveAs(path); finalPath = Path.Combine(fileSavePath, sFilename); strImgFinalPath = strImgFinalPath + ":" + finalPath; } } adbll.CreateAdImageDetails(0, intAdpostId, strImgFinalPath, txtVidolink.Text.ToString()); #endregion Response.Redirect("ViewAds.aspx?aid=" + intAdpostId.ToString() + "&uid=" + Session["UserId"].ToString()); } catch (System.Threading.ThreadAbortException th) { } catch (Exception ex) { } } } }