前台代码:
function bao(id)
{
var qs=id.split("_")[1];
var va=$("#docs").val();
var str=$("#V_"+qs).val();
$.ajax({
type: "POST",
url: "wo_print_yes1.aspx/editQTY",
data: "{values:"+str+",doc_no:"+va+",pn:"+qs+"}",
success: function(msg){
if(msg=="1")
alert("修改成功!");
else
alert("修改失败!");
}
});
}
public partial class erp_wo_print_yes1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// editQTY();
}
[WebMethod]
public static string editQTY(int values, string doc_no, string pn)
{
string StrSQL = "UPDATE order_detail SET qty = "+values+" WHERE (part_no = N'"+pn+"') AND (doc_no = N'"+doc_no+"')";
WebData1.ExecuteUpdate(StrSQL);
return "1";
}
}
$.ajax({
type: "POST",//用POST方式传输
dataType:"json",//数据格式:JSON
url:'handler.ashx',//目标地址
data:"p="+(pageindx+1)+"&orderby="+orderby,
beforeSend:function(){$("#divload").show();$("#Pagination").hide();},//发送数据之前
complete:function(){$("#divload").hide();$("#Pagination").show()},//接收数据完毕
success:function(json) {
$("#productTable tr:gt(0)").remove();
var productData = json.Products;
$.each(productData, function(i, n) {
var trs = "";
trs += "<tr><td>" + n.orderid + "</td><td>" + n.customerid + "</td><td>" + n.shipname + "</td><td>" + n.shipcity + "</td></tr>";
tbody += trs;
});
$("#productTable").append(tbody);
$("#productTable tr:gt(0):odd").attr("class", "odd");
$("#productTable tr:gt(0):even").attr("class", "enen");
$("#productTable tr:gt(0)").hover(function(){
$(this).addClass('mouseover');
},function(){
$(this).removeClass('mouseover');
});
}});
using System;
using System.Web;
using System.Data;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
//不让浏览器缓存
context.Response.Buffer = true;
context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
context.Response.AddHeader("pragma", "no-cache");
context.Response.AddHeader("cache-control", "");
context.Response.CacheControl = "no-cache";
context.Response.ContentType = "text/plain";
int pageindex;
int.TryParse(context.Request["p"], out pageindex);
string rder="orderid desc";
if (!string.IsNullOrEmpty(context.Request["orderby"]))
{
string[] strarr = context.Request["orderby"].ToString().Split('_');
if (strarr[1] == "0")
rder = strarr[0] + " asc";
else
rder = strarr[0] + " desc";
}
if (pageindex == 0)
pageindex = 1;
DataTable dt = Northwind.GetOrders(pageindex,order);
string jsonData = JsonHelper.DataTableToJSON(dt, "Products");
context.Response.Write(jsonData);
}
public bool IsReusable {
get {
return false;
}
}
}
这样用!
这样改下试试:
function bao(id)
{
var qs=id.split("_")[1];
var va=$("#docs").val();
var str=$("#V_"+qs).val();
$.ajax({
type: "POST",
url: "wo_print_yes1.aspx?Actiion=editQTY",
data: {values:"+str+",doc_no:"+va+",pn:"+qs+"},
success: function(msg){
if(msg=="1")
alert("修改成功!");
else
alert("修改失败!");
}
});
}
public partial class erp_wo_print_yes1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request["Action"] == "editQTY")
{
editQTY();
}
}
public void editQTY()
{
int values = Convert.ToInt32(Request.Params["values"]);
string doc_no = Request.Params["doc_no"].ToString();
string pn = Request.Params["pn"].ToString();
string StrSQL = "UPDATE order_detail SET qty = " + values + " WHERE (part_no = N'" + pn + "') AND (doc_no = N'" + doc_no + "')";
WebData1.ExecuteUpdate(StrSQL);
Response.Clear();
Response.Write("1");
Response.End();
}
}