日期:2014-05-17 浏览次数:20394 次
function SaveClick() { var Price1 = 0; for (var i = 1; i <= 10; i++) { var SumPrice = $("#txtSumPrice" + i).val(); if (SumPrice != "") { Price1 = Price1 + parseFloat(SumPrice); } } var SupplierId1 = parseInt($("#ddSupplierList").val()); var Performance1 = "1"; var Time2 = $("#Calendar").val().replace(/-/g, "/"); $.ajax({ //利用Ajax调用Web服务中的数据,实现与后台交互 type: "POST", contentType: "application/json;utf-8", url: "WebService.asmx/addPurchaseOrders", data: "{ 'SupplierId' :'" + SupplierId1 + "', 'Price' :'" + Price1 + "', 'Performance' :'" + Performance1.toString() + "', 'Time1':'" + Time2 + "'}", //data: "{ 'SupplierId' :" + SupplierId1 + ", 'Price' :" + Price1 + ", 'Performance' :" + Performance1.toString() + ", Time1:'" + Time2 + "'}", //data: "{ 'SupplierId' :" + SupplierId1 + ", 'Price' :" + Price1 + ", 'Performance' :" + Performance1 + "}", dataType: 'json', anysc: false, success: function (data) { alert("ok"); // alert(data.d); //SaveClickContent(data.d); }, error: function (XMLResponse) { alert(XMLResponse.responseText); alert("false"); } }) }
[WebMethod] public string addPurchaseOrders(int SupplierId, decimal Price, string Performance, string Time1 ) { string str=""; BLL.PurchaseOrder bll = new BLL.PurchaseOrder(); Model.PurchaseOrder model = new Model.PurchaseOrder(); model.SupplierId = SupplierId; model.Price = Price; if (Performance == "1") { model.Performance = "保存"; } model.RecTime = DateTime.Parse(Time1); if (bll.Add(model)) { str = bll.SearchLastId().ToString(); return str; } return str; }