main.aspx页面
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="MysqlHelpers" %>
<!DOCTYPE html>
<script runat="server">
public string RecId, userid, LOGIN, Token, ORG_ID;
public string JOSMATNAME, JOSMATCODE, JOSQUANTITY, JODWORKLINENAME,JOSMATID;
private dataManager dm = new dataManager(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
protected void Page_Load(object sender, EventArgs e)
{
if (Session["userid"] == null)
{
Response.Redirect("/CMMS/error/disconnect.html");
}
userid = Session["userid"].ToString();
ORG_ID = Session["ORGID"].ToString();
LoginManager lm = new LoginManager();
lm.getLM(userid, lm, dm);
LOGIN = lm.LOGIN;
Token = Session["token"].ToString();
</script>
<html>
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>批量更新节假日</title>
<script src="<%=ConfigurationManager.AppSettings["rooturl"].ToString()%>/js/jquery.min.js"></script>
<script charset="utf-8" src="<%=ConfigurationManager.AppSettings["rooturl"].ToString()%>/js/jquery.easyui.min.js"></script>
<script src="<%=ConfigurationManager.AppSettings["rooturl"].ToString()%>/js/easyui-lang-zh_CN.js"></script>
<link href="<%=ConfigurationManager.AppSettings["rooturl"].ToString()%>/themes/icon.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="<%=ConfigurationManager.AppSettings["rooturl"].ToString()%>/themes/<%=ConfigurationManager.AppSettings["theme"].ToString()%>/easyui.css" />
<link rel="stylesheet" type="text/css" href="<%=ConfigurationManager.AppSettings["rooturl"].ToString()%>/themes/demo.css" />
</head>
<body class="easyui-layout">
<div style="padding: 5px">
<div class="easyui-panel" title="批量更新节假日" style="width: 100%; height: 1200px" data-options="iconCls:'icon-save'">
<form id="fm1" name="fm1" method="post" enctype="multipart/form-data">
<div style="margin: 20px;">
<div style='margin-bottom: 15px'>
<input class='easyui-datebox' name='db' id='db' style='width: 320px' data-options='labelPosition: "left",label:"开始日期",value:"Today"' />
</div>
<div style='margin-bottom: 15px'>
<input class='easyui-datebox' name='db1' id='db1' style='width: 320px' data-options='labelPosition: "left",label:"结束日期",value:"Today"' />
</div>
<div style="margin-bottom:15px;">
<a href="#" class="easyui-linkbutton" οnclick='exec()' data-options="iconCls:'icon-add'">执行</a>
</div>
</div>
</form>
</div>
</div>
<script type="text/javascript">
var Token = '<%=Token%>';
var ORG_ID = "<%=ORG_ID%>";
var userid = '<%=userid %>';
function exec() {
var db = $("#db").datebox('getValue');
var db1 = $("#db1").datebox('getValue');
if (!db) {
alert("请填写完整信息!");
return;
}
$.ajax({
type: 'get',
url: 'getdata_tab.ashx?kssj=' + db + '&jssj=' + db1 + '&ORGID=<%=ORG_ID%>&r=' + Math.random(),//请求数据的地址
text: 'html',
success: function (data) {
if(data>0){
alert("更新成功!");
window.history.go(-1)
}
console.log('data=====',data)
},
error: function (event, XMLHttpRequest, ajaxOptions, thrownError) {
// alert(event);
}
})
}
</script>
</body>
</html>
getdata_tab.ashx页面
<%@ WebHandler Language="C#" Class="InitTable" %>
using System;
using MysqlHelpers;
using System.Data;
using System.Web;
using System.Text;
using System.Configuration;
using System.Collections.Generic;
using System.Web.SessionState;
using InitData;
public class InitTable : IHttpHandler, IRequiresSessionState
{
private dataManager dmBase = new dataManager(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/html";
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
string ORGID = Convert.ToString(context.Session["ORGID"]);
string result = string.Empty;
string kssj = Convert.ToString(context.Request["kssj"]);
string jssj = Convert.ToString(context.Request["jssj"]);
string QuerySqlMain = @"update fs_calendar set fs_calendar.DATETYPE=2 where CDATE >='"+kssj+"' and CDATE <='"+jssj+"' and ORGID='"+ORGID+"'";
int dt_all = dmBase.ExecuteNonQuery(QuerySqlMain);
context.Response.Write(dt_all);
context.Response.End();
}
public bool IsReusable
{
get
{
return false;
}
}
}
数据修改
int dt_all = dmBase.ExecuteNonQuery(QuerySqlMain);
context.Response.Write(dt_all);
数据查询
DataTable dt_all = dmBase.ExecuteDataTable(QuerySqlMain);
StringBuilder tab_sb = new StringBuilder();
context.Response.Write(tab_sb );