文件操作 - NewConveyances.js
返回文件管理
返回主菜单
删除本文件
文件: E:\HostingSpaces\kimblycr\howell.kimbly.in\wwwroot\js\NewConveyances.js
编辑文件内容
var CurrentImage; function AddNewConveyance() { $('#dvFrm').show(); $("#dvFrmEdit").hide(); $("#dvGrdReportConveyances").hide(); } function HideAddForm() { $('#dvFrm').hide(); } function SaveConveyance() { var year = document.getElementById("txtYear").value; var month = document.getElementById("SelMonth").value; var amount = document.getElementById("txtAmount").value; if (amount == '') { alert('Enter Amount'); return; } var remarks = document.getElementById("txtRemarks").value; remarks = remarks.replace(/'/g, ""); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "MyConveyances.aspx/AddConveyance", data: "{'Year':'" + year + "','Month':'" + month + "','Amount':'" + amount + "','Remarks':'" + remarks + "'}", dataType: "json", success: function (data) { if (data.d != null) { ViewNonSubmittedConveyance(data.d); $('#dvFrm').hide(); // GetNonSubmittedConveyances(); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); } function GetNonSubmittedConveyances() { var LoggedInEmpID = sessionStorage.getItem("LoggedInEmpID"); $("#dvFrmEdit").hide(); $('#dvFrm').hide(); var collection = "Conveyances"; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "MyConveyances.aspx/ViewNonSubmittedConveyance", 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>Amount</td><td>Month</td><td>Year</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 ViewNonSubmittedConveyance(id) { $("#dvFrmEdit").show(); $("#dvGrdReportConveyances").hide(); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "MyConveyances.aspx/ViewConveyanceByID", data: "{'id': '" + id + "'}", dataType: "json", success: function (data) { if (data.d != null) { console.log(data.d); var out = data.d.split(";"); document.getElementById('SelMonthEdit').value = out[0]; document.getElementById('txtYearEdit').value = out[1]; document.getElementById('txtAmountEdit').value = out[2]; document.getElementById('txtRemarksEdit').value = out[3]; } }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); GetConveyanceImages(id); document.getElementById('hdnID').value = id; } function UpdateConveyance() { console.log('UpdateConveyance'); var id = document.getElementById('hdnID').value; var year = document.getElementById("txtYearEdit").value; var month = document.getElementById("SelMonthEdit").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: "MyConveyances.aspx/UpdateConveyance", data: "{'Year':'" + year + "','Month':'" + month + "','Amount':'" + amount + "','Remarks':'" + remarks + "','ID':'" + id + "'}", dataType: "json", success: function (data) { if (data.d != null) { GetNonSubmittedConveyances(); } }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); } function HideEditForm() { $("#dvFrmEdit").hide(); $("#dvGrdReportConveyances").show(); } function GetConveyanceImages(id) { console.log('In GetConveyanceImages'); $("#ConveyanceImages").show(); $("#dvFrmEdit").show(); document.getElementById("placehere").innerHTML = ''; $("#placehere").empty(); $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "../WebMethods/Conveyances.aspx/GetConveyanceImages", 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 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 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 Zoom(src) { console.log(src); $("#ConvImage").attr("src", src); CurrentImage = src.substr(31); console.log(CurrentImage); } function DeleteImage() { var id = document.getElementById('hdnID').value; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "MyConveyances.aspx/DeleteConveyanceImage", data: "{'ID':'" + id + "','Image':'" + CurrentImage + "'}", dataType: "json", success: function (data) { if (data.d != null) { } }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); GetConveyanceImages(id); } function SubmitConveyance() { var id = document.getElementById('hdnID').value; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "MyConveyances.aspx/SubmitConveyance", data: "{'ID':'" + id + "'}", dataType: "json", success: function (data) { if (data.d != null) { } }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); GetNonSubmittedConveyances(); } function DeleteConveyance() { var id = document.getElementById('hdnID').value; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "MyConveyances.aspx/DeleteConveyance", data: "{'ID':'" + id + "'}", dataType: "json", success: function (data) { GetNonSubmittedConveyances(); }, error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.responseText); } }); }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件