protected void btnAddMedia_Click(object sender, EventArgs e) { ClearMediaControls(); hdnEditMediaId.Value = "0"; ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop1", "javascript:showMediaModal();", true); dvBrowseMedia.Visible = true; UpMediaModal.Update(); }
private void ClearMediaControls() { txtDescription.Text = string.Empty; // txtMediaID.Text = "1"; //txtMediaName.Text = string.Empty; txtMediaPath.Text = string.Empty; txtMediaPosition.Text = string.Empty; txtMediaURL.Text = string.Empty; txtValidFrom.Text = DateTime.Now.ToString("dd/MM/yyyy"); txtValidTo.Text = "31/12/2099"; ddlFileCategory.ClearSelection(); ddlFileCategory.SelectedIndex = 0; //ddlFileFormat.ClearSelection(); //ddlFileFormat.SelectedIndex = 0; ddlMediaType.ClearSelection(); ddlMediaType.SelectedIndex = 0; ddlRoomCategory.ClearSelection(); ddlRoomCategory.SelectedIndex = 0; ddlSubCategory.ClearSelection(); ddlSubCategory.SelectedIndex = 0; ddlFileMaster.ClearSelection(); ddlFileMaster.SelectedIndex = 0; btnSaveMedia.CommandName = "AddMedia"; btnSaveMedia.Text = "Add New Media"; gvMediaAttributes.SelectedIndex = 0; imgMedia.ImageUrl = string.Empty; imgMedia.Dispose(); //Delete save media if exist for the same DeleteMedia(); //fuMedia.Dispose(); ClearMediaAttributesControls(); gvMediaAttributes.DataSource = null; PageIndex = 0; gvMediaAttributes.DataBind(); divMediaAttributes.Visible = false; dvMsg.Style.Add("display", "none"); dvMsgMediaAttribute.Style.Add("display", "none"); UpMediaModal.Update(); }
protected void btnMediaReset_Click(object sender, EventArgs e) { ClearMediaControls(); dvBrowseMedia.Visible = true; UpMediaModal.Update(); }
protected void btnSaveMedia_Click(object sender, EventArgs e) { Accomodation_ID = new Guid(Request.QueryString["Hotel_Id"]); var resultAcco = AccSvc.GetHotelDetails(Accomodation_ID); MediaAbsPath = System.Configuration.ConfigurationManager.AppSettings["MediaAbsPath"] + resultAcco[0].ProductCategorySubType + "/" + resultAcco[0].CompanyHotelID.ToString() + "/"; MediaAbsUrl = System.Configuration.ConfigurationManager.AppSettings["MediaAbsURL"] + resultAcco[0].ProductCategorySubType + "/" + resultAcco[0].CompanyHotelID.ToString() + "/"; if (Page.IsValid) { if (btnSaveMedia.CommandName == "AddMedia") { MDMSVC.DC_Accommodation_Media newObj = new MDMSVC.DC_Accommodation_Media { Accommodation_Media_Id = Guid.NewGuid(), Category = (ddlFileCategory.SelectedIndex == 0 ? null : ddlFileCategory.SelectedItem.Text), Description = txtDescription.Text, //FileFormat = (ddlFileFormat.SelectedIndex == 0 ? null : ddlFileFormat.SelectedItem.Text), // MediaID = txtMediaID.Text, MediaType = (ddlMediaType.SelectedIndex == 0 ? null : ddlMediaType.SelectedItem.Text), Media_Position = Convert.ToInt32(txtMediaPosition.Text), RoomCategory = (ddlRoomCategory.SelectedIndex == 0 ? null : ddlRoomCategory.SelectedItem.Text), SubCategory = (ddlSubCategory.SelectedIndex == 0 ? null : ddlSubCategory.SelectedItem.Text), Accommodation_Id = Guid.Parse(Request.QueryString["Hotel_Id"]), ValidFrom = DateTime.ParseExact(txtValidFrom.Text.Trim(), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture), ValidTo = DateTime.ParseExact(txtValidTo.Text.Trim(), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture), IsActive = true, Create_Date = DateTime.Now, Create_User = System.Web.HttpContext.Current.User.Identity.Name, MediaFileMaster = (ddlFileMaster.SelectedIndex == 0 ? null : ddlFileMaster.SelectedItem.Text) }; if (!string.IsNullOrWhiteSpace(hdnMediaName.Value)) { //if(!string.IsNullOrWhiteSpace(txtMediaName.Text)) //{ // newObj.MediaName = System.IO.Path.GetFileNameWithoutExtension(txtMediaName.Text) + System.IO.Path.GetExtension(hdnMediaName.Value); // newObj.Media_Path = MediaAbsPath + resultAcco[0].CompanyHotelID.ToString() + "_" + System.IO.Path.GetFileNameWithoutExtension(txtMediaName.Text) + "_Ori" + System.IO.Path.GetExtension(hdnMediaName.Value); // newObj.Media_URL = MediaAbsUrl + resultAcco[0].CompanyHotelID.ToString() + "_" + System.IO.Path.GetFileNameWithoutExtension(txtMediaName.Text) + "_Ori" + System.IO.Path.GetExtension(hdnMediaName.Value); //} //else //{ newObj.MediaName = hdnMediaName.Value; newObj.Media_Path = MediaAbsPath + resultAcco[0].CompanyHotelID.ToString() + "_" + System.IO.Path.GetFileNameWithoutExtension(hdnMediaName.Value) + "_Ori" + System.IO.Path.GetExtension(hdnMediaName.Value); newObj.Media_URL = MediaAbsUrl + resultAcco[0].CompanyHotelID.ToString() + "_" + System.IO.Path.GetFileNameWithoutExtension(hdnMediaName.Value) + "_Ori" + System.IO.Path.GetExtension(hdnMediaName.Value); newObj.FileFormat = System.IO.Path.GetExtension(hdnMediaName.Value); //} } else { newObj.MediaName = string.Empty; newObj.Media_Path = string.Empty; newObj.Media_URL = string.Empty; newObj.FileFormat = string.Empty; } string sMediaPathToCheck = MediaAbsPath + hdnMediaName.Value; if (!string.IsNullOrWhiteSpace(hdnMediaName.Value)) { if (!System.IO.Directory.Exists(MapPath(MediaAbsPath))) { System.IO.Directory.CreateDirectory(MapPath(MediaAbsPath)); } if (System.IO.File.Exists(MapPath(newObj.Media_Path))) { System.IO.File.Delete(MapPath(newObj.Media_Path)); } FileInfo file = new FileInfo(MapPath(sMediaPathToCheck)); file.MoveTo(file.Directory.FullName + "\\" + System.IO.Path.GetFileName(MapPath(newObj.Media_Path))); //System.Drawing.Image _img = ThumbnailImage(System.Drawing.Image.FromFile(file.Directory.FullName + "\\" + System.IO.Path.GetFileName(MapPath(newObj.Media_Path))), 90, 60); //file.MoveTo(file.Directory.FullName + "\\" + System.IO.Path.GetFileName(MapPath(newObj.Media_Path))); } if (AccSvc.AddAccomodation_MediaDetails(newObj)) { //Auto insert file attributes try { //Shell32.Shell shell = new Shell32.Shell(); Type t = Type.GetTypeFromProgID("Shell.Application"); dynamic shell = Activator.CreateInstance(t); Shell32.Folder objFolder = shell.NameSpace(System.IO.Path.GetDirectoryName(MapPath(newObj.Media_Path))); Shell32.FolderItem folderItem = objFolder.ParseName(System.IO.Path.GetFileName(MapPath(newObj.Media_Path))); List <string> arrHeaders = new List <string>(); //Get file attribute list for consideratioins string strAttributeslist = Convert.ToString(ConfigurationManager.AppSettings["MediaAttributes"]); List <string> _lstAttributes = strAttributeslist.Split(',').ToList(); for (int i = 0; i < short.MaxValue; i++) { string header = objFolder.GetDetailsOf(null, i); if (String.IsNullOrEmpty(header)) { break; } arrHeaders.Add(header); } for (int i = 0; i < arrHeaders.Count; i++) { string AttrTypr = arrHeaders[i]; if (!_lstAttributes.Contains(AttrTypr)) { continue; } string AttrVal = objFolder.GetDetailsOf(folderItem, i); if (!string.IsNullOrWhiteSpace(AttrVal)) { MDMSVC.DC_Accomodation_Media_Attributes newObjAttr = new MDMSVC.DC_Accomodation_Media_Attributes { Accomodation_Media_Attributes_Id = Guid.NewGuid(), Accomodation_Media_Id = newObj.Accommodation_Media_Id, AttributeType = AttrTypr, AttributeValue = AttrVal, IsActive = true, Create_Date = DateTime.Now, IsSystemAttribute = true, Create_User = System.Web.HttpContext.Current.User.Identity.Name }; AccSvc.AddAccomodation_MediaAttributesDetails(newObjAttr); } } } catch { } BindMedia(); ClearMediaControls(); hdnFlag.Value = "true"; BootstrapAlert.BootstrapAlertMessage(dvMsg, "Media has been added successfully", BootstrapAlertType.Success); } else { BootstrapAlert.BootstrapAlertMessage(dvMsg, "Error Occurred", BootstrapAlertType.Warning); } } else if (btnSaveMedia.CommandName == "UpdateMedia") { Accomodation_ID = new Guid(Request.QueryString["Hotel_Id"]); Guid myRow_Id = Guid.Parse(gvMedia.SelectedDataKey.Value.ToString()); int intMediaPosition = 0; if (Int32.TryParse(txtMediaPosition.Text, out intMediaPosition)) { intMediaPosition = Convert.ToInt32(txtMediaPosition.Text); } MDMSVC.DC_Accommodation_Media newObj = new MDMSVC.DC_Accommodation_Media { Accommodation_Media_Id = myRow_Id, Category = (ddlFileCategory.SelectedIndex == 0 ? null : ddlFileCategory.SelectedItem.Text), MediaFileMaster = (ddlFileMaster.SelectedIndex == 0 ? null : ddlFileMaster.SelectedItem.Text), Description = txtDescription.Text, //FileFormat = (ddlFileFormat.SelectedIndex == 0 ? null : ddlFileFormat.SelectedItem.Text), MediaType = (ddlMediaType.SelectedIndex == 0 ? null : ddlMediaType.SelectedItem.Text), Media_Position = intMediaPosition, RoomCategory = (ddlRoomCategory.SelectedIndex == 0 ? null : ddlRoomCategory.SelectedItem.Text), SubCategory = (ddlSubCategory.SelectedIndex == 0 ? null : ddlSubCategory.SelectedItem.Text), ValidFrom = DateTime.ParseExact(txtValidFrom.Text.Trim(), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture), ValidTo = DateTime.ParseExact(txtValidTo.Text.Trim(), "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture), IsActive = true, Edit_Date = DateTime.Now, Edit_User = System.Web.HttpContext.Current.User.Identity.Name, }; if (AccSvc.UpdateAccomodation_MediaDetails(newObj)) { BindMedia(); ClearMediaControls(); hdnFlag.Value = "true"; BootstrapAlert.BootstrapAlertMessage(dvMsg, "Media has been updated successfully", BootstrapAlertType.Success); } else { BootstrapAlert.BootstrapAlertMessage(dvMsg, "Error Occurred", BootstrapAlertType.Warning); } } dvBrowseMedia.Visible = true; UpMediaModal.Update(); } //hdnFlag.Value = "true"; //ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop2" + DateTime.Today.Ticks.ToString(), "javascript:closeMediaModal();", true); // ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop2", "javascript:closeMediaModal();", true); }
protected void grdMedia_RowCommand(object sender, GridViewCommandEventArgs e) { dvMsg.Style.Add("display", "none"); dvMsgMediaAttribute.Style.Add("display", "none"); Guid myRow_Id = Guid.Parse(e.CommandArgument.ToString()); GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); int index = row.RowIndex; Accomodation_ID = Guid.Parse(Request.QueryString["Hotel_Id"]); if (e.CommandName.ToString() == "Select") { var record = AccSvc.GetAccomodation_MediaDetails(Accomodation_ID, myRow_Id); if (record != null) { if (record.Count > 0) { //UpMediaModal.Update(); ClearMediaControls(); txtDescription.Text = System.Web.HttpUtility.HtmlDecode(record[0].Description); // txtMediaID.Text = System.Web.HttpUtility.HtmlDecode(record[0].MediaID); //txtMediaName.Text = record[0].MediaName; txtMediaPath.Text = System.Web.HttpUtility.HtmlDecode(record[0].Media_Path); txtMediaPosition.Text = System.Web.HttpUtility.HtmlDecode(record[0].Media_Position.ToString()); txtMediaURL.Text = System.Web.HttpUtility.HtmlDecode(record[0].Media_URL); hdnEditMediaId.Value = Convert.ToString(record[0].Accommodation_Media_Id); imgMedia.ImageUrl = System.Web.HttpUtility.HtmlDecode(record[0].Media_URL); imgMedia.DescriptionUrl = System.Web.HttpUtility.HtmlDecode(record[0].Description); if (record[0].ValidFrom != null) { txtValidFrom.Text = (record[0].ValidFrom ?? DateTime.Now).ToString("dd/MM/yyyy"); } if (record[0].ValidTo != null) { txtValidTo.Text = (record[0].ValidTo ?? DateTime.Now).ToString("dd/MM/yyyy"); } ddlFileCategory.ClearSelection(); if (ddlFileCategory.Items.FindByText(System.Web.HttpUtility.HtmlDecode(record[0].Category)) != null) { ddlFileCategory.Items.FindByText(System.Web.HttpUtility.HtmlDecode(record[0].Category)).Selected = true; } //ddlFileFormat.ClearSelection(); //if (ddlFileFormat.Items.FindByText(System.Web.HttpUtility.HtmlDecode(record[0].FileFormat)) != null) //{ // ddlFileFormat.Items.FindByText(System.Web.HttpUtility.HtmlDecode(record[0].FileFormat)).Selected = true; //} ddlMediaType.ClearSelection(); if (ddlMediaType.Items.FindByText(System.Web.HttpUtility.HtmlDecode(record[0].MediaType)) != null) { ddlMediaType.Items.FindByText(System.Web.HttpUtility.HtmlDecode(record[0].MediaType)).Selected = true; } ddlRoomCategory.ClearSelection(); if (ddlRoomCategory.Items.FindByText(System.Web.HttpUtility.HtmlDecode(record[0].RoomCategory)) != null) { ddlRoomCategory.Items.FindByText(System.Web.HttpUtility.HtmlDecode(record[0].RoomCategory)).Selected = true; } ddlSubCategory.ClearSelection(); if (ddlSubCategory.Items.FindByText(System.Web.HttpUtility.HtmlDecode(record[0].SubCategory)) != null) { ddlSubCategory.Items.FindByText(System.Web.HttpUtility.HtmlDecode(record[0].SubCategory)).Selected = true; } ddlFileMaster.ClearSelection(); if (ddlFileMaster.Items.FindByText(System.Web.HttpUtility.HtmlDecode(record[0].MediaFileMaster)) != null) { ddlFileMaster.Items.FindByText(System.Web.HttpUtility.HtmlDecode(record[0].MediaFileMaster)).Selected = true; } btnSaveMedia.CommandName = "UpdateMedia"; btnSaveMedia.Text = "Update"; divMediaAttributes.Visible = true; BindMediaAttributes(record[0].Accommodation_Media_Id); //ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop1", "javascript:showMediaModal();", true); dvBrowseMedia.Visible = false; UpMediaModal.Update(); } } } else if (e.CommandName.ToString() == "SoftDelete") { TLGX_Consumer.MDMSVC.DC_Accommodation_Media newObj = new MDMSVC.DC_Accommodation_Media { Accommodation_Media_Id = myRow_Id, IsActive = false, Edit_Date = DateTime.Now, Edit_User = System.Web.HttpContext.Current.User.Identity.Name }; if (AccSvc.UpdateAccomodation_MediaDetails(newObj)) { BootstrapAlert.BootstrapAlertMessage(dvMsg, "Media details has been deleted successfully", BootstrapAlertType.Success); BindMedia(); } else { BootstrapAlert.BootstrapAlertMessage(dvMsg, "Error occured while deleteing media details. Please contact system Admin.", BootstrapAlertType.Danger); } } else if (e.CommandName.ToString() == "UnDelete") { TLGX_Consumer.MDMSVC.DC_Accommodation_Media newObj = new MDMSVC.DC_Accommodation_Media { Accommodation_Media_Id = myRow_Id, IsActive = true, Edit_Date = DateTime.Now, Edit_User = System.Web.HttpContext.Current.User.Identity.Name }; if (AccSvc.UpdateAccomodation_MediaDetails(newObj)) { BootstrapAlert.BootstrapAlertMessage(dvMsg, "Media details has been retrieved successfully", BootstrapAlertType.Success); BindMedia(); } else { BootstrapAlert.BootstrapAlertMessage(dvMsg, "Error occured while retrieved media details. Please contact system Admin.", BootstrapAlertType.Danger); } } }