protected void GVLibrary_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("AddToFavorite")) { LinkButton lnkBtnFavorite = (LinkButton)e.CommandSource; Entity.UserInfo oUserInfo = new Entity.UserInfo(); oUserInfo.IntFavoriteTypeId = 0; oUserInfo.IntFavoriteId = 0; if (lnkBtnFavorite.Text == "Remove from Favorite") oUserInfo.IntFavoriteId = Convert.ToInt32(e.CommandArgument); oUserInfo.StrUserId = AppLib.GetLoggedInUserName(); oUserInfo.StrTitle = ""; oUserInfo.StrFavoriteType = "Library"; oUserInfo.DtCreatedOn = DateTime.Now; oUserInfo.IntFavoriteTypeId = Convert.ToInt32(e.CommandArgument); BLL.UserLib oUserLib = new BLL.UserLib(); oUserLib.LibraryAddToFavorite(oUserInfo); oUserInfo = null; oUserLib = null; BindLibrary(); } else if (e.CommandName.Equals("PathViewlabrariesFile")) { Entity.LibraryInfo oLibraryInfo = new Entity.LibraryInfo(); BLL.LibraryLib oLibraryLib = new BLL.LibraryLib(); oLibraryInfo = oLibraryLib.GetLibraryByLibraryId(Convert.ToInt32(e.CommandArgument)); if (oLibraryInfo.StrLocationType.ToLower().Equals("pdf") || oLibraryInfo.StrLocationType.ToLower().Equals("video")) { GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); LinkButton lnkNewslettes = (LinkButton)row.FindControl("lnkViewLabraries"); string path = AppConfig.GetBaseSiteUrl() + AppConfig.GetLibrariesFilePath() + oLibraryInfo.StrLocation; Response.Write("<script type='text/javascript'>detailedresults=window.open('" + path + "', 'popUpWindow', 'height=700,width=900,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes');</script>"); } else { } } }
private void AddUpdateLibraryDetails() { BLL.LibraryLib oLibraryLib = new BLL.LibraryLib(); Entity.LibraryInfo oLibraryInfo = new Entity.LibraryInfo(); oLibraryInfo.IntLibraryId = 0; oLibraryInfo.ChrIsDeleted = 'N'; oLibraryInfo.DtDeletedDate = DateTime.Now; oLibraryInfo.DtCreatedDate = DateTime.Now; oLibraryInfo.DtModifiedDate = oLibraryInfo.DtCreatedDate; oLibraryInfo.StrTitle = txttitle.Text.Trim(); oLibraryInfo.StrDescription = txtDescription.Text.Trim(); if (oLibraryInfo.StrDescription.Length > 500) oLibraryInfo.StrDescription = oLibraryInfo.StrDescription.Substring(0, 499); if (!txtDate.Text.Equals(string.Empty)) oLibraryInfo.DtLibraryDate = Convert.ToDateTime(txtDate.Text); else oLibraryInfo.DtLibraryDate = Convert.ToDateTime("01/01/1999"); oLibraryInfo.ChrIsActive = chkIsActive.Checked ? 'Y' : 'N'; oLibraryInfo.StrLocationType = ddlCategoryType.SelectedItem.Text; oLibraryInfo.StrCategory = ddlCategory.SelectedItem.Text; oLibraryInfo.StrLocation = string.Empty; if (ViewState["strOldFileName"] != null) oLibraryInfo.StrLocation = ViewState["strOldFileName"].ToString(); if (oLibraryInfo.StrLocationType.ToString().ToLower().Equals("pdf") || oLibraryInfo.StrLocationType.ToString().ToLower().Equals("video")) { string strpath = string.Empty; try { if (fupPDF.HasFile) { strpath = Request.PhysicalApplicationPath + AppConfig.GetLibrariesFilePath(); if (ViewState["strOldFileName"] != null) { if (System.IO.File.Exists(strpath + ViewState["strOldFileName"])) System.IO.File.Delete(strpath + ViewState["strOldFileName"]); } string strFileName = DateTime.Now.ToString("MMddyyyyHHmmss"); strFileName = AppLib.UploadCompanyExcelForUserRegRequest(ref fupPDF, strFileName, strpath); oLibraryInfo.StrLocation = strFileName; } } catch { } } else oLibraryInfo.StrLocation = txtLink.Text.Trim(); bool blnIsSuccessfullOperation = false; if (ViewState["intLibraryId"] != null) { oLibraryInfo.IntLibraryId = Convert.ToInt32(ViewState["intLibraryId"]); if (oLibraryLib.UpdateLibraryDetails(oLibraryInfo) > 0) { lblMsg.Text = "Library has been updated successfully."; ViewState["intLibraryId"] = null; ViewState["strOldFileName"] = null; blnIsSuccessfullOperation = true; } else lblMsg.Text = "Library already exists."; } else { if (oLibraryLib.SaveLibraryDetails(oLibraryInfo) > 0) { lblMsg.Text = "Library has been added successfully."; blnIsSuccessfullOperation = true; } else lblMsg.Text = "Library already exists."; } oLibraryInfo = null; oLibraryLib = null; if (blnIsSuccessfullOperation) { ClearControls(); BindLibrary(); } }
private void BindDetails() { if (Request.QueryString["type"] != null && Request.QueryString["id"] != null && Request.QueryString["fid"] != null) { BLL.NewsLib oNewsLib = new BLL.NewsLib(); Entity.NewsInfo oNewsInfo = new Entity.NewsInfo(); if (Request.QueryString["type"].ToString().ToLower().Equals("newsletter")) { trNewsletter.Visible = true; oNewsInfo = new Entity.NewsInfo(); oNewsLib = new BLL.NewsLib(); oNewsInfo = oNewsLib.GetNewsLettersById(Convert.ToInt32(Request.QueryString["id"])); if (oNewsInfo != null) { lblNewsletterDescription.Text = oNewsInfo.StrDescription; if (!oNewsInfo.StrNewsletterDate.ToString().Equals("1/1/1999 12:00:00 AM")) lblNewsletterDate.Text = oNewsInfo.StrNewsletterDate.ToShortDateString(); if (!oNewsInfo.StrPDFFilename.Equals("na.pdf")) { ancPrevious.Visible = true; ancPrevious.HRef = AppConfig.GetBaseSiteUrl() + AppConfig.GetNewsLettersPDFPath() + oNewsInfo.StrPDFFilename; } else { trNewsletterPDF.Visible = false; } } } else if (Request.QueryString["type"].ToString().ToLower().Equals("event")) { trEvent.Visible = true; if (Request.QueryString["id"] != null) { int _intEventId = 0; _intEventId = Convert.ToInt32(Request.QueryString["id"]); Entity.EventInfo oEventInfo = new Entity.EventInfo(); BLL.EventsLib oEventsLib = new BLL.EventsLib(); oEventInfo = oEventsLib.GetEventByEventId(_intEventId); if (oEventInfo != null) { lblEventActivity.Text = oEventInfo.StrActivity; lblEventComments.Text = oEventInfo.StrComments; lblEventDate.Text = oEventInfo.DtEventDate.ToShortDateString(); lblEventLocation.Text = oEventInfo.StrLocation; } oEventsLib = null; oEventInfo = null; } } else if (Request.QueryString["type"].ToString().ToLower().Equals("newsannouncements")) { trNewsAnnouncement.Visible = true; oNewsInfo = new Entity.NewsInfo(); oNewsLib = new BLL.NewsLib(); oNewsInfo = oNewsLib.GetNewsAnnouncementsById(Convert.ToInt32(Request.QueryString["id"])); if (oNewsInfo != null) { lblNewsAnnouncementDescription.Text = oNewsInfo.StrDescription; lblNewsAnnouncementDirectLink.Text = oNewsInfo.StrDirectLink; if (lblNewsAnnouncementDirectLink.Text.Trim().Equals(string.Empty)) { trNewsAnnouncementDirectLink.Visible = false; trNewsAnnouncementPDF.Visible = true; ancPreviousNewsAnnoucment.HRef = AppConfig.GetBaseSiteUrl() + AppConfig.GetNewsAnnouncementsPDFPath() + oNewsInfo.StrPDFFilename; } else { trNewsAnnouncementDirectLink.Visible = true; trNewsAnnouncementPDF.Visible = false; } oNewsInfo = null; oNewsLib = null; } } else if (Request.QueryString["type"].ToString().ToLower().Equals("library")) { trLibrary.Visible = true; Entity.LibraryInfo oLibraryInfo = new Entity.LibraryInfo(); BLL.LibraryLib oLibraryLib = new BLL.LibraryLib(); oLibraryInfo = oLibraryLib.GetLibraryByLibraryId(Convert.ToInt32(Request.QueryString["id"])); if (oLibraryInfo != null) { lblLibraryDescription.Text = oLibraryInfo.StrDescription; if (!oLibraryInfo.DtLibraryDate.ToString().Equals("1/1/1999 12:00:00 AM")) lblLibraryDate.Text = oLibraryInfo.DtLibraryDate.ToShortDateString(); if (oLibraryInfo.StrLocationType.ToLower().Equals("pdf") || oLibraryInfo.StrLocationType.ToLower().Equals("video")) { trLibraryLink.Visible = false; ancLibraryPDF.Visible = true; ancLibraryPDF.HRef = AppConfig.GetBaseSiteUrl() + AppConfig.GetLibrariesFilePath() + oLibraryInfo.StrLocation; } else { trLibraryPDF.Visible = false; lblLibraryWebsiteLink.Text = oLibraryInfo.StrLocation; } lblLibraryCategoryType.Text = oLibraryInfo.StrLocationType; lblLibraryCategory.Text = oLibraryInfo.StrCategory; oLibraryInfo = null; oLibraryLib = null; } } } }
protected void GVNews_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("EditNews")) { Entity.LibraryInfo oLibraryInfo = new Entity.LibraryInfo(); BLL.LibraryLib oLibraryLib = new BLL.LibraryLib(); oLibraryInfo = oLibraryLib.GetLibraryByLibraryId(Convert.ToInt32(e.CommandArgument)); if (oLibraryInfo != null) { // if (!odataReader.DtCancelOn.ToString().Equals("1/1/1999 12:00:00 AM")) txttitle.Text = oLibraryInfo.StrTitle; txtDescription.Text = oLibraryInfo.StrDescription; if (!oLibraryInfo.DtLibraryDate.ToString().Equals("1/1/1999 12:00:00 AM")) txtDate.Text = oLibraryInfo.DtLibraryDate.ToShortDateString(); chkIsActive.Checked = oLibraryInfo.ChrIsActive.Equals('Y') ? true : false; ViewState["strOldFileName"] = oLibraryInfo.StrLocation; if (oLibraryInfo.StrLocationType.ToLower().Equals("pdf") || oLibraryInfo.StrLocationType.ToLower().Equals("video")) { trLink.Style.Add("display", "none"); trFileUpload.Style.Add("display", "''"); ancPrevious.Visible = true; ancPrevious.HRef = AppConfig.GetBaseSiteUrl() + AppConfig.GetLibrariesFilePath() + oLibraryInfo.StrLocation; } else { txtLink.Text = oLibraryInfo.StrLocation; trLink.Style.Add("display", "''"); trFileUpload.Style.Add("display", "none"); } ddlCategoryType.SelectedIndex = ddlCategoryType.Items.IndexOf(ddlCategoryType.Items.FindByValue(oLibraryInfo.StrLocationType)); ddlCategory.SelectedIndex = ddlCategory.Items.IndexOf(ddlCategory.Items.FindByValue(oLibraryInfo.StrCategory)); lnkBtnSearch.Text = "Update"; ViewState["intLibraryId"] = e.CommandArgument.ToString(); oLibraryInfo = null; oLibraryLib = null; } } else if (e.CommandName.Equals("DeleteNews")) { BLL.LibraryLib oLibraryLib = new BLL.LibraryLib(); oLibraryLib.DeleteLibraryDetails(Convert.ToInt32(e.CommandArgument)); lblMsg.Text = "Library has been deleted successfully."; oLibraryLib = null; ClearControls(); BindLibrary(); } else if (e.CommandName.Equals("StatusChanged")) { BLL.LibraryLib oLibraryLib = new BLL.LibraryLib(); oLibraryLib.ActivateDeactivateLibrary(Convert.ToInt32(e.CommandArgument)); lblMsg.Text = "Library status has been changed successfully."; oLibraryLib = null; ClearControls(); BindLibrary(); } }