日期:2014-05-16 浏览次数:22688 次
$(function() { $("#Btn_save").click(function() { $.ajax({ type: "post", url: "OnlineReport_Updown.aspx/save", data: "{}", beforeSend: function() { $("#ds").html("<img src='../../Images/ajax-loader.gif'/>"); $("#ds").show(); }, success: function(msg) { $("#txt").val = msg; } }); }); });
[WebMethod] public static string save() { string message = ""; int su = 0; int erorri = 0; for (int i = 0; i < GridView1.Rows.Count; i++) { try { Convert.ToDateTime(GridView1.Rows[i].Cells[2].Text.ToString()); } catch (Exception ex) { message = "第三列" + GridView1.HeaderRow.Cells[2].Text + "导入格式有误,请填写正确的时间格式:<yyyy-MM-dd><br>错误明细:" + ex.Message; return; } string InsertSQL = " insert into Is_Online_Report(CARRIER ,TRUCK ,PLAN_DATE,REMARK,CREATE_BY,CEATE_DATE) values('" + GridView1.Rows[i].Cells[0].Text.Replace(" ", "").Trim() + "','" + GridView1.Rows[i].Cells[1].Text.Replace(" ", "").Trim() + "',to_date('" + GridView1.Rows[i].Cells[2].Text.Replace(" ", "").Trim() + "','yyyy-MM-dd HH24:mi:ss'),'" + GridView1.Rows[i].Cells[3].Text.Replace(" ", "").Trim() + "','" + Session["UserName"].ToString() + "',to_date('" + DateTime.Now + "','yyyy-MM-dd HH24:mi:ss') )"; if (DAL.DBAccess.ExecuteNonQuery_VT(InsertSQL)) { su += 1; } else { erorri += 1; } } if (erorri > 0) { message = "保存出错!共" + erorri.ToString() + "行"; return; } message = "成功保存" + su + "条记录!"; GridView1.DataSource = null; GridView1.DataBind(); }