文件操作 - NewHotel.js
返回文件管理
返回主菜单
删除本文件
文件: E:\HostingSpaces\kimblycr\howell.kimbly.in\wwwroot\js\NewHotel.js
编辑文件内容
var CurrentImage; function AddNewHotel() { $('#dvFrm').show(); $("#dvFrmEdit").hide(); $("#dvGrdReportHotel").hide(); $.ajax({ type: "POST", url: "MyHotel.aspx/GetSites", data: "", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { if (data.d != null) { var selectSite = document.getElementById('SelSite'); $("#SelSite").empty(); for (i = 0; i < data.d.length; i++) { selectSite.options[selectSite.options.length] = new Option(data.d[i].Name, data.d[i].ID); } } }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log('error'); } }); } function HideAddForm() { $('#dvFrm').hide(); } function SaveHotel() { var StartDate = document.getElementById("txtStartDate").value; var EndDate = document.getElementById("txtEndDate").value; var site = document.getElementById("SelSite").value; var amount = document.getElementById("txtAmount").value; if (amount == '') { alert('Please provide amount'); return; } var remarks = document.getElementById("txtRemarks").value; remarks = remarks.replace(/'/g, ""); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "MyHotel.aspx/AddHotel", data: "{'StartDate':'" + StartDate + "','EndDate':'" + EndDate + "','Amount':'" + amount + "','SiteID':'" + site + "','Remarks':'" + remarks + "'}", dataType: "json", success: function (data) { if (data.d != null) { HideAddForm(); //GetNonSubmittedHotel(); ViewNonSubmittedHotel(data.d); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); } function GetNonSubmittedHotel() { var LoggedInEmpID = sessionStorage.getItem("LoggedInEmpID"); $("#dvFrmEdit").hide(); $('#dvFrm').hide(); var collection = "Hotel"; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "MyHotel.aspx/ViewNonSubmittedHotel", data: "{'ID': '" + LoggedInEmpID + "'}", dataType: "json", success: function (data) { if (data.d != null) { console.log(data.d); $("#grd" + collection).empty(); var str = "<thead><tr><td>ID</td><td>Site</td><td>StartDate</td><td>EndDate</td><td>Amount</td><td>Remarks</td></tr></thead><tbody>"; for (i = 0; i < data.d.length; i++) { var hdr = data.d[i].RowData; str += hdr; } $("#grd" + collection).append(str); $("#grd" + collection).append("</tbody>"); $("#grd" + collection).show(); $("#dvGrdReport" + collection).show(); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); } function ViewNonSubmittedHotel(ID) { GetSites(ID); $("#dvFrmEdit").show(); $("#dvGrdReportHotel").hide(); GetHotelImages(ID); document.getElementById('hdnID').value = ID; } function GetSites(id) { $.ajax({ type: "POST", url: "MyHotel.aspx/GetSites", data: "", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { if (data.d != null) { var selectSite = document.getElementById('SelSiteEdit'); $("#SelSiteEdit").empty(); for (i = 0; i < data.d.length; i++) { selectSite.options[selectSite.options.length] = new Option(data.d[i].Name, data.d[i].ID); } GetValues(id); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log('error'); } }); } function GetValues(id) { $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "MyHotel.aspx/ViewHotelByID", data: "{'id': '" + id + "'}", dataType: "json", success: function (data) { if (data.d != null) { console.log(data.d); var out = data.d.split(";"); document.getElementById('SelSiteEdit').value = out[0]; document.getElementById('txtStartDateEdit').value = out[1]; document.getElementById('txtEndDateEdit').value = out[2]; document.getElementById('txtRemarksEdit').value = out[3]; document.getElementById('txtAmountEdit').value = out[4]; } }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); } function GetHotelImages(id) { console.log('In GetHotelImages'); //$("#HotelImages").show(); $("#dvFrmEdit").show(); document.getElementById("placehere").innerHTML = ''; $("#placehere").empty(); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "MyHotel.aspx/GetHotelImages", data: "{'ID': '" + id + "'}", dataType: "json", success: function (data) { if (data.d != null) { console.log('Length-' + data.d.length); for (i = 0; i < data.d.length; i++) { var hdr = data.d[i].RowData; console.log(hdr); if (i == 0) { $("#ConvImage").attr("src", hdr); } if ((hdr.toLowerCase().indexOf(".jpg") > -1) || (hdr.toLowerCase().indexOf(".png") > -1) || (hdr.toLowerCase().indexOf(".gif") > -1) || (hdr.toLowerCase().indexOf(".tif") > -1)) { addImage(hdr); } else { addHyperlink(hdr); } } } }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); } function addImage(src) { var elem = document.createElement("img"); elem.setAttribute("src", src); elem.setAttribute("height", "100"); elem.setAttribute("width", "100"); elem.setAttribute("alt", "No Image"); elem.setAttribute("onClick", "Zoom('" + src + "')"); elem.setAttribute("data-toggle", "modal"); elem.setAttribute("data-target", "#myModal") elem.setAttribute("style", "margin-right:10px"); document.getElementById("placehere").appendChild(elem); } function addHyperlink(src) { var a = document.createElement('a'); var filename = src.replace('http://myhowell.in/Images/', ''); var linkText = document.createTextNode(filename); a.appendChild(linkText); a.title = "File"; a.href = src; a.target = "_blank"; document.getElementById("placehere").appendChild(a); } function Zoom(src) { console.log('src-' + src); $("#ConvImage").attr("src", src); CurrentImage = src.substr(26); console.log(CurrentImage); } function DeleteImage() { console.log('In DeleteImage'); var id = document.getElementById('hdnID').value; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "MyHotel.aspx/DeleteHotelImage", data: "{'ID':'" + id + "','Image':'" + CurrentImage + "'}", dataType: "json", success: function (data) { if (data.d != null) { } }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); GetHotelImages(id); } function HideEditForm() { $("#dvFrmEdit").hide(); $("#dvGrdReportHotel").show(); } function SubmitHotel() { var id = document.getElementById('hdnID').value; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "MyHotel.aspx/SubmitHotel", data: "{'ID':'" + id + "'}", dataType: "json", success: function (data) { if (data.d != null) { } }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); GetNonSubmittedHotel(); } function UpdateHotel() { var id = document.getElementById('hdnID').value; var StartDate = document.getElementById("txtStartDateEdit").value; var EndDate = document.getElementById("txtEndDateEdit").value; var site = document.getElementById("SelSiteEdit").value; var amount = document.getElementById("txtAmountEdit").value; var remarks = document.getElementById("txtRemarksEdit").value; remarks = remarks.replace(/'/g, ""); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "MyHotel.aspx/UpdateHotel", data: "{'StartDate':'" + StartDate + "','EndDate':'" + EndDate + "','Amount':'" + amount + "','SiteID':'" + site + "','Remarks':'" + remarks + "','ID':'" + id + "'}", dataType: "json", success: function (data) { if (data.d != null) { } }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); GetNonSubmittedHotel(); } function DeleteHotel() { var id = document.getElementById('hdnID').value; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "MyHotel.aspx/DeleteHotel", data: "{'ID':'" + id + "'}", dataType: "json", success: function (data) { GetNonSubmittedHotel(); }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件