使用ExtJS 实现Grid操作功能(删除,选择)
前台主页面:
图2:
doneForPrint.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="doneForPrint.aspx.cs" Inherits="oapro.Views.Com.OA.doneForPrint" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>已处理事项</title>
<link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~") %>js/extjs/2.2/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~") %>js/extjs/2.2/resources/css/xtheme-gray.css" />
<link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~") %>styles/extend.css" />
<script type="text/javascript" src="<%=ResolveUrl("~") %>js/extjs/2.2/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="<%=ResolveUrl("~") %>js/extjs/2.2/ext-all.js"></script>
<script type="text/javascript" src="<%=ResolveUrl("~") %>js/extjs/2.2/build/locale/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=ResolveUrl("~") %>js/oa/com.js"></script>
<script type="text/javascript" src="<%=ResolveUrl("~") %>views/com/oa/doneForPrint.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div id="content" style="layout: fit">
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>已处理事项</title>
<link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~") %>js/extjs/2.2/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~") %>js/extjs/2.2/resources/css/xtheme-gray.css" />
<link rel="stylesheet" type="text/css" href="<%=ResolveUrl("~") %>styles/extend.css" />
<script type="text/javascript" src="<%=ResolveUrl("~") %>js/extjs/2.2/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="<%=ResolveUrl("~") %>js/extjs/2.2/ext-all.js"></script>
<script type="text/javascript" src="<%=ResolveUrl("~") %>js/extjs/2.2/build/locale/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=ResolveUrl("~") %>js/oa/com.js"></script>
<script type="text/javascript" src="<%=ResolveUrl("~") %>views/com/oa/doneForPrint.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div id="content" style="layout: fit">
</div>
</form>
</body>
</html>
后台 引用
doneForPrint.js
var pdname = getvalue('pdname');
var tname = getvalue('tname');
var sparas = getvalue('sparas');
var titles = '';
var titlea, titleb;
if (titles != '没有这个[titles]值' && titles != '') {
titlea = titles.split(',')[0];
titleb = titles.split(',')[1];
} else {
titlea = '事由';
titleb = '文号';
}
var uid = getvalue('uid');
Ext.BLANK_IMAGE_URL = 'http://www.cnblogs.com/../Js/extjs/2.2/resources/images/default/s.gif';
var path = '/etoa/wf/';
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({ url: 'http://www.cnblogs.com/../controls/oa/action.ashx?action=GetDoneAllForPrint&pdname=' + pdname + '&tname=' + tname + '&sparas=' + sparas + '&uid=' + uid }),
reader: new Ext.data.JsonReader({
root: 'infos',
totalProperty: 'totalCount'
}, [
{ name: 'fid' },
{ name: 'fname' },
{ name: 'fnum' },
{ name: 'status' },
{ name: 'odept' },
{ name: 'stime' },
{ name: 'pdname' },
{ name: 'isdelete' }
]
)
});
Ext.onReady(function() {
Ext.QuickTips.init();
var sm = new Ext.grid.CheckboxSelectionModel();
var cm = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(), sm,
//{id:'id',header:'ID',width: 100,dataIndex:'id',align:'center'},
{header: titlea, width: 350, dataIndex: 'fname', align: 'center', renderer: renderProject },
// { header: titleb, width: 138, dataIndex: 'fnum', align: 'center' },
{header: '部门', width: 150, dataIndex: 'odept', align: 'center' },
{ header: '类型', width: 150, dataIndex: 'pdname', align: 'center' },
//{ header: '状态', width: 100, dataIndex: 'isdelete', align: 'center', renderer: renderStatus },
// { header: '历史记录', width: 100, dataIndex: 'fid', align: 'center', renderer: renderHistory },
//{header:'提交人',width: 150,dataIndex:'preoper',align:'center'},
//{header:'日期',width: 150,dataIndex:'',align:'center',renderer:renderTime}//,
//{header:'任务',width: 150,dataIndex:'ndef',align:'center'},
//{header:'打印状态',width: 150,dataIndex:'isdelete',align:'center',renderer:renderStatusForPrint},
//{id:'id',header:"查看",width: 115,dataIndex: 'fid', align:'center',renderer:renderProject,sortable: false}
{id: 'id', header: "打印状态", dataIndex: 'id', width: 60, align: 'center', renderer: renderProjectForPrintStatus, sortable: false },
{ id: 'id', header: "操作", dataIndex: 'id', width: 60, align: 'center', renderer: renderProjectForCommand, sortable: false }
]);
cm.defaultSortable = true;
function renderTime(value) {
return Ext.util.Format.substr(value, 0, 16);
}
function renderProject(value, p, record) {
return String.format(
'<a href="http://www.cnblogs.com/../controls/oa/action.ashx?action=GetForm&data={0}&id={1}&nid={2}&ndef={3}&pdname={4}&oper=view" target="_parent">{5}</a>',
record.data.fnum, record.data.fid, record.data.id, record.data.ndef, record.data.pdname, record.data.fname);
}
//For Command (del)
function renderProjectForCommand(value, p, record) {
return String.format(
'<a href="http://www.cnblogs.com/../controls/oa/action.ashx?action=DeleteRecordForPrint&data={0}&id={1}&nid={2}&ndef={3}&pdname={4}&oper=view" target="_parent"><img src="http://www.cnblogs.com/../Images/pic12.gif" style="cursor:hand" alt="删除" /></a>',
record.data.fnum, record.data.fid, record.data.id, record.data.ndef, record.data.pdname);
}
function renderProjectForPrintStatus(value, p, record) {
return String.format(
'<img src="http://www.cnblogs.com/../Images/ok.gif" style="cursor:hand" alt="已打印" />',
record.data.fnum, record.data.fid, record.data.id, record.data.ndef, record.data.pdname);
}
function renderHistory(value, p, record) {
return String.format(
'<a href="http://www.cnblogs.com/../views/dict/ShowHistory.aspx?formid={0}&pname={1}&fname={2}" target="_blank">历史记录</a>',
// '<image alt="进行中" src="http://www.cnblogs.com/../images/to.gif" onclick="window.open('+'http://www.cnblogs.com/../views/dict/ShowHistory.aspx?formid={0}&pname={1}&fname={2}'+')"/>',
value, record.data.pdname, record.data.fname);
}
Date.prototype.dateDiff = function(interval, objDate) {
//若參數不足或 objDate 不是日期物件則回傳 undefined
if (arguments.length < 2 || objDate.constructor != Date) return undefined;
switch (interval) {
//計算秒差
case "s": return parseInt((objDate - this) / 1000);
//計算分差
case "n": return parseInt((objDate - this) / 60000);
//計算時差
case "h": return parseInt((objDate - this) / 3600000);
//計算日差
case "d": return parseInt((objDate - this) / 86400000);
//計算週差
case "w": return parseInt((objDate - this) / (86400000 * 7));
//計算月差
case "m": return (objDate.getMonth() + 1) + ((objDate.getFullYear() - this.getFullYear()) * 12) - (this.getMonth() + 1);
//計算年差
case "y": return objDate.getFullYear() - this.getFullYear();
//輸入有誤
default: return undefined;
}
}
function renderStatus(value) {
var rstr = value;
if (value == '1') {
//printed document
//rstr = '<font color="red" size="4pt">→</font>';
rstr = "<image alt='进行中' src='http://www.cnblogs.com/../images/back.gif'/>";
} else if (value == '2') {
//rstr = '<font color="green" size="4pt">●</font>';
rstr = "<image alt='完成' src='http://www.cnblogs.com/../images/pic21.gif'/>";
} else if (value == '3') {
//rstr = '<font color="blue" size="4pt">▲</font>';
rstr = "<image alt='结束' src='http://www.cnblogs.com/../images/pic22.gif'/>";
} else if (value == '5') {
//rstr = '<font color="blue" size="4pt">▲</font>';
rstr = "<image alt='未实施' src='http://www.cnblogs.com/../images/pic212.gif'/>";
}
return rstr;
}
function AddInfo() {
window.location.href = path + 'nadd.jsp?id=' + pid;
}
//Initial GridPanel
var grid = new Ext.grid.GridPanel({
renderTo: 'content',
ds: ds,
cm: cm,
sm: sm,
//selModel: new Ext.grid.RowSelectionModel({ singleSelect: true }),
autoHeight: true,
bodyStyle: 'width:100%',
autoWidth: true,
title: '打印文档查询',
stripeRows: true,
//collapsible:true,
//tools:[{id:"save"},{id:"help"},{id:"up"},{id:"close",handler:function(){Ext.MessageBox.alert("工具栏按钮","工具栏上的关闭按钮时间被激发了")}}],
//titleCollapse:true ,
loadMask: { msg: '正在加载数据,请稍侯...' },
tbar: [
'<span style="font-weight:bold">列表</span> <i>关键字</i>: ',
{ xtype: 'textfield', width: 170, id: 'key', name: 'key' },
' 文档类型: ',
{ xtype: 'textfield', width: 170, id: 'keyType', name: 'keyType' },
{ text: ' 查询 ', iconCls: 'find', handler: SerachGrid, tooltip: '查询' },
{ xtype: 'tbseparator' },
{ text: '批量删除', tooltip: '删除', handler: doDel },
new Ext.Toolbar.Fill()//,
//'-',
//{text:' 新建 ',iconCls:'add',handler:AddInfo}
],
bbar: new Ext.PagingToolbar({
pageSize: 20,
store: ds,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录"
})
});
grid.on('rowcontextmenu', rightClickFn);
var rightClickMenu = new Ext.menu.Menu({
items: [{
//handler: rMenu2Fn,
text: '<span style="font-weight:bold;">欢迎使用!</span>'
}]
});
function rightClickFn(grid, rowindex, e) {
e.preventDefault();
rightClickMenu.showAt(e.getXY());
}
//delete all function
function SerachGrid() {
var message = Ext.get('key').dom.value;
var keyType = Ext.get('keyType').dom.value;
ds.reload({ params: { key: message, keyType: keyType, start: 0, limit: 20} });
}
function doDel() {
var row = grid.getSelectionModel().getSelections();
if (row.length == 0) {
Ext.MessageBox.alert("提示", "请您选择需要删除的记录!");
return;
}
Ext.MessageBox.confirm('提示', '确实要删除所选的记录吗?', showResult);
}
function showResult(btn) {
if (btn == 'yes') {
var row = grid.getSelections();
var jsonData = "";
for (var i = 0, len = row.length; i < len; i++) {
//var ss = row[i].get("id");
var ss = row[i].json.fid;
if (i == 0)
jsonData = jsonData + ss; //这样处理是为了删除的Lambda语句方便
else
jsonData = jsonData + "," + ss; //这样处理是为了删除的Lambda语句方便
}
//alert(jsonData);
var conn = new Ext.data.Connection();
conn.request({
url: "DeleteProject.asmx/DelProject", //请注意引用的路径
params: { fid: jsonData },
method: 'post',
scope: this,
callback: function(options, success, response) {
if (success) {
Ext.MessageBox.alert("提示", "所选记录成功删除!");
ds.load({ params: { start: 0, limit: 25} });
}
else
{ Ext.MessageBox.alert("提示", "所选记录删除失败!"); }
}
})
}
};
function rMenu1Fn() {
var selectedInfo = grid.getSelectionModel().getSelected();
if (selectedInfo) {
var id = selectedInfo.get("id");
window.location.href = 'update.jsp?id=' + id;
} else {
Ext.MessageBox.show({
msg: '<span style="font-weight:bold;font-size:14px">请选择一行数据!</span>',
multiline: false,
icon: Ext.Msg.WARNING
});
}
}
function rMenu2Fn() {
AddInfo();
}
grid.render();
var message = Ext.get('key').dom.value;
ds.load({ params: { key: message, start: 0, limit: 20} });
ds.on('beforeload', function() {
Ext.apply(
this.baseParams,
{
key: Ext.get('key').dom.value
});
});
});
**********************************************************
注意其中包含
var tname = getvalue('tname');
var sparas = getvalue('sparas');
var titles = '';
var titlea, titleb;
if (titles != '没有这个[titles]值' && titles != '') {
titlea = titles.split(',')[0];
titleb = titles.split(',')[1];
} else {
titlea = '事由';
titleb = '文号';
}
var uid = getvalue('uid');
Ext.BLANK_IMAGE_URL = 'http://www.cnblogs.com/../Js/extjs/2.2/resources/images/default/s.gif';
var path = '/etoa/wf/';
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({ url: 'http://www.cnblogs.com/../controls/oa/action.ashx?action=GetDoneAllForPrint&pdname=' + pdname + '&tname=' + tname + '&sparas=' + sparas + '&uid=' + uid }),
reader: new Ext.data.JsonReader({
root: 'infos',
totalProperty: 'totalCount'
}, [
{ name: 'fid' },
{ name: 'fname' },
{ name: 'fnum' },
{ name: 'status' },
{ name: 'odept' },
{ name: 'stime' },
{ name: 'pdname' },
{ name: 'isdelete' }
]
)
});
Ext.onReady(function() {
Ext.QuickTips.init();
var sm = new Ext.grid.CheckboxSelectionModel();
var cm = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(), sm,
//{id:'id',header:'ID',width: 100,dataIndex:'id',align:'center'},
{header: titlea, width: 350, dataIndex: 'fname', align: 'center', renderer: renderProject },
// { header: titleb, width: 138, dataIndex: 'fnum', align: 'center' },
{header: '部门', width: 150, dataIndex: 'odept', align: 'center' },
{ header: '类型', width: 150, dataIndex: 'pdname', align: 'center' },
//{ header: '状态', width: 100, dataIndex: 'isdelete', align: 'center', renderer: renderStatus },
// { header: '历史记录', width: 100, dataIndex: 'fid', align: 'center', renderer: renderHistory },
//{header:'提交人',width: 150,dataIndex:'preoper',align:'center'},
//{header:'日期',width: 150,dataIndex:'',align:'center',renderer:renderTime}//,
//{header:'任务',width: 150,dataIndex:'ndef',align:'center'},
//{header:'打印状态',width: 150,dataIndex:'isdelete',align:'center',renderer:renderStatusForPrint},
//{id:'id',header:"查看",width: 115,dataIndex: 'fid', align:'center',renderer:renderProject,sortable: false}
{id: 'id', header: "打印状态", dataIndex: 'id', width: 60, align: 'center', renderer: renderProjectForPrintStatus, sortable: false },
{ id: 'id', header: "操作", dataIndex: 'id', width: 60, align: 'center', renderer: renderProjectForCommand, sortable: false }
]);
cm.defaultSortable = true;
function renderTime(value) {
return Ext.util.Format.substr(value, 0, 16);
}
function renderProject(value, p, record) {
return String.format(
'<a href="http://www.cnblogs.com/../controls/oa/action.ashx?action=GetForm&data={0}&id={1}&nid={2}&ndef={3}&pdname={4}&oper=view" target="_parent">{5}</a>',
record.data.fnum, record.data.fid, record.data.id, record.data.ndef, record.data.pdname, record.data.fname);
}
//For Command (del)
function renderProjectForCommand(value, p, record) {
return String.format(
'<a href="http://www.cnblogs.com/../controls/oa/action.ashx?action=DeleteRecordForPrint&data={0}&id={1}&nid={2}&ndef={3}&pdname={4}&oper=view" target="_parent"><img src="http://www.cnblogs.com/../Images/pic12.gif" style="cursor:hand" alt="删除" /></a>',
record.data.fnum, record.data.fid, record.data.id, record.data.ndef, record.data.pdname);
}
function renderProjectForPrintStatus(value, p, record) {
return String.format(
'<img src="http://www.cnblogs.com/../Images/ok.gif" style="cursor:hand" alt="已打印" />',
record.data.fnum, record.data.fid, record.data.id, record.data.ndef, record.data.pdname);
}
function renderHistory(value, p, record) {
return String.format(
'<a href="http://www.cnblogs.com/../views/dict/ShowHistory.aspx?formid={0}&pname={1}&fname={2}" target="_blank">历史记录</a>',
// '<image alt="进行中" src="http://www.cnblogs.com/../images/to.gif" onclick="window.open('+'http://www.cnblogs.com/../views/dict/ShowHistory.aspx?formid={0}&pname={1}&fname={2}'+')"/>',
value, record.data.pdname, record.data.fname);
}
Date.prototype.dateDiff = function(interval, objDate) {
//若參數不足或 objDate 不是日期物件則回傳 undefined
if (arguments.length < 2 || objDate.constructor != Date) return undefined;
switch (interval) {
//計算秒差
case "s": return parseInt((objDate - this) / 1000);
//計算分差
case "n": return parseInt((objDate - this) / 60000);
//計算時差
case "h": return parseInt((objDate - this) / 3600000);
//計算日差
case "d": return parseInt((objDate - this) / 86400000);
//計算週差
case "w": return parseInt((objDate - this) / (86400000 * 7));
//計算月差
case "m": return (objDate.getMonth() + 1) + ((objDate.getFullYear() - this.getFullYear()) * 12) - (this.getMonth() + 1);
//計算年差
case "y": return objDate.getFullYear() - this.getFullYear();
//輸入有誤
default: return undefined;
}
}
function renderStatus(value) {
var rstr = value;
if (value == '1') {
//printed document
//rstr = '<font color="red" size="4pt">→</font>';
rstr = "<image alt='进行中' src='http://www.cnblogs.com/../images/back.gif'/>";
} else if (value == '2') {
//rstr = '<font color="green" size="4pt">●</font>';
rstr = "<image alt='完成' src='http://www.cnblogs.com/../images/pic21.gif'/>";
} else if (value == '3') {
//rstr = '<font color="blue" size="4pt">▲</font>';
rstr = "<image alt='结束' src='http://www.cnblogs.com/../images/pic22.gif'/>";
} else if (value == '5') {
//rstr = '<font color="blue" size="4pt">▲</font>';
rstr = "<image alt='未实施' src='http://www.cnblogs.com/../images/pic212.gif'/>";
}
return rstr;
}
function AddInfo() {
window.location.href = path + 'nadd.jsp?id=' + pid;
}
//Initial GridPanel
var grid = new Ext.grid.GridPanel({
renderTo: 'content',
ds: ds,
cm: cm,
sm: sm,
//selModel: new Ext.grid.RowSelectionModel({ singleSelect: true }),
autoHeight: true,
bodyStyle: 'width:100%',
autoWidth: true,
title: '打印文档查询',
stripeRows: true,
//collapsible:true,
//tools:[{id:"save"},{id:"help"},{id:"up"},{id:"close",handler:function(){Ext.MessageBox.alert("工具栏按钮","工具栏上的关闭按钮时间被激发了")}}],
//titleCollapse:true ,
loadMask: { msg: '正在加载数据,请稍侯...' },
tbar: [
'<span style="font-weight:bold">列表</span> <i>关键字</i>: ',
{ xtype: 'textfield', width: 170, id: 'key', name: 'key' },
' 文档类型: ',
{ xtype: 'textfield', width: 170, id: 'keyType', name: 'keyType' },
{ text: ' 查询 ', iconCls: 'find', handler: SerachGrid, tooltip: '查询' },
{ xtype: 'tbseparator' },
{ text: '批量删除', tooltip: '删除', handler: doDel },
new Ext.Toolbar.Fill()//,
//'-',
//{text:' 新建 ',iconCls:'add',handler:AddInfo}
],
bbar: new Ext.PagingToolbar({
pageSize: 20,
store: ds,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录"
})
});
grid.on('rowcontextmenu', rightClickFn);
var rightClickMenu = new Ext.menu.Menu({
items: [{
//handler: rMenu2Fn,
text: '<span style="font-weight:bold;">欢迎使用!</span>'
}]
});
function rightClickFn(grid, rowindex, e) {
e.preventDefault();
rightClickMenu.showAt(e.getXY());
}
//delete all function
function SerachGrid() {
var message = Ext.get('key').dom.value;
var keyType = Ext.get('keyType').dom.value;
ds.reload({ params: { key: message, keyType: keyType, start: 0, limit: 20} });
}
function doDel() {
var row = grid.getSelectionModel().getSelections();
if (row.length == 0) {
Ext.MessageBox.alert("提示", "请您选择需要删除的记录!");
return;
}
Ext.MessageBox.confirm('提示', '确实要删除所选的记录吗?', showResult);
}
function showResult(btn) {
if (btn == 'yes') {
var row = grid.getSelections();
var jsonData = "";
for (var i = 0, len = row.length; i < len; i++) {
//var ss = row[i].get("id");
var ss = row[i].json.fid;
if (i == 0)
jsonData = jsonData + ss; //这样处理是为了删除的Lambda语句方便
else
jsonData = jsonData + "," + ss; //这样处理是为了删除的Lambda语句方便
}
//alert(jsonData);
var conn = new Ext.data.Connection();
conn.request({
url: "DeleteProject.asmx/DelProject", //请注意引用的路径
params: { fid: jsonData },
method: 'post',
scope: this,
callback: function(options, success, response) {
if (success) {
Ext.MessageBox.alert("提示", "所选记录成功删除!");
ds.load({ params: { start: 0, limit: 25} });
}
else
{ Ext.MessageBox.alert("提示", "所选记录删除失败!"); }
}
})
}
};
function rMenu1Fn() {
var selectedInfo = grid.getSelectionModel().getSelected();
if (selectedInfo) {
var id = selectedInfo.get("id");
window.location.href = 'update.jsp?id=' + id;
} else {
Ext.MessageBox.show({
msg: '<span style="font-weight:bold;font-size:14px">请选择一行数据!</span>',
multiline: false,
icon: Ext.Msg.WARNING
});
}
}
function rMenu2Fn() {
AddInfo();
}
grid.render();
var message = Ext.get('key').dom.value;
ds.load({ params: { key: message, start: 0, limit: 20} });
ds.on('beforeload', function() {
Ext.apply(
this.baseParams,
{
key: Ext.get('key').dom.value
});
});
});
**********************************************************
注意其中包含
action.ashx
处理文件代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.SessionState;
using OA.Common;
namespace oapro.Controls.OA
{
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class wait : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
string returnStr = "";
Common common = new Common();
string userid = context.Session["userid"].ToString();
string action = context.Request["action"].ToString();
//主要真对多表单字段
if (action == "GetWaitAll")
{
string uid = userid;
string paras = context.Request["sparas"];
string[] para = paras.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
string key = Common.SplitNullD(context.Request["key"], "all");
if (key.Equals(""))
{
key = "all";
}
String name = "";
String tnum = "";
name = "all";
tnum = "select a.* from (";
for (int i = 0; i < para.Length; i++)
{
String[] parb = para[i].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
if (parb[0] != null && parb[1] != null)
{
if (i > 0)
{
tnum += " union ";
}
tnum += "select n.id as id, n.formid as fid, isnull(f." + parb[1] + ",'空值') as fname,isnull('" + parb[0] + "','空值') as fnum,n.pdname,n.preoper,n.stime,n.ndef from wf_node n inner join ";
tnum += parb[0];
tnum += " f on n.formid = f.id where n.operid = '" + uid + "' and n.status = '1'";
}
}
tnum += ") a where fname like '{0}' or 'all' = '{1}' ";
int start = int.Parse(Common.SplitNullD(context.Request["start"], "0"));
int limit = int.Parse(Common.SplitNullD(context.Request["limit"], "20"));
String tinfo = "select * from ( select *,ROW_NUMBER() Over(order by stime desc) as rowNum from (" + tnum + ") as b ) c where rowNum between '{2}' and '{3}' ";
String[] tjson = { "id", "fid", "fname", "fnum", "pdname", "preoper", "stime", "ndef" };
ListDaoImpl dao = new ListDaoImpl();
returnStr = dao.getInfoSe(tjson, tinfo, tnum, key, name, start, limit);
context.Response.ContentType = "text/plain";
context.Response.Write(returnStr.ToString());
}
if (action == "GetDoneAll")
{
//新加 类别查询
string pdname = context.Request["keyType"];
string uid = userid;
string paras = context.Request["sparas"];
string[] para = paras.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
string key = Common.SplitNullD(context.Request["key"], "all");
if (key.Equals(""))
{
key = "all";
}
String name = "";
String tnum = "";
name = "all";
tnum = "select a.* from (";
for (int i = 0; i < para.Length; i++)
{
String[] parb = para[i].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
if (parb[0] != null && parb[1] != null)
{
if (i > 0)
{
tnum += " union ";
}
tnum += "select distinct n.formid as fid, isnull(f." + parb[1] + ",'空值') as fname, '" + parb[0] + "' as fnum,n.pdname,p.status,p.stime,f.odept from wf_node n inner join ";
tnum += " wf_proc p on n.pid = p.id inner join ";
tnum += parb[0];
tnum += " f on n.formid = f.id where n.operid = '" + uid + "' and n.status = '2' ";
}
}
tnum += ") a where fname like '{0}' or 'all' = '{1}' ";
//文档查询类别 查询结果包括类别
if (!string.IsNullOrEmpty(pdname))
tnum += " and a.pdname like '%" + pdname + "%'";
int start = int.Parse(Common.SplitNullD(context.Request["start"], "0"));
int limit = int.Parse(Common.SplitNullD(context.Request["limit"], "20"));
String tinfo = "select * from ( select *,ROW_NUMBER() Over(order by stime desc) as rowNum from (" + tnum + ") as b ) c where rowNum between '{2}' and'{3}' ";
String[] tjson = { "fid", "fname", "fnum", "pdname", "status", "stime", "odept" };
ListDaoImpl dao = new ListDaoImpl();
returnStr = dao.getInfoSe(tjson, tinfo, tnum, key, name, start, limit);
context.Response.ContentType = "text/plain";
context.Response.Write(returnStr.ToString());
}
//获取已办 主要真对单表多字段
if (action == "GetDone")
{
String uid = context.Request["uid"];
String pname = context.Request["pname"];
String tname = context.Request["tname"];
String paras = context.Request["sparas"];
String[] para = paras.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
String key = Common.SplitNullD(context.Request["key"], "all");
if (key.Equals(""))
{
key = "all";
}
String name = "";
String tnum = "";
name = "all";
tnum = "select a.* from (select distinct n.formid as fid, isnull(f." + para[0] + ",'空值') as fname, isnull(f." + para[1] + ",'空值') as fnum,n.pdname,p.status,p.stime from wf_node n inner join ";
tnum += " wf_proc p on n.pid = p.id inner join ";
tnum += tname;
tnum += " f on n.formid = f.id where n.operid = '" + uid + "' and n.status = '2' and (f.";
tnum += para[0];
tnum += " like '{0}' or f.";
tnum += para[1];
tnum += " like '{1}' or 'all' = '{2}' or 'all' = '{3}' ) and 'all' = '{4}' ) a";
int start = int.Parse(Common.SplitNullD(context.Request["start"], "0"));
int limit = int.Parse(Common.SplitNullD(context.Request["limit"], "20"));
String tinfo = "select * from ( select *,ROW_NUMBER() Over(order by stime desc) as rowNum from (" + tnum + ") as b ) c where rowNum between '{5}' and '{6}' ";
String[] tjson = { "fid", "fname", "fnum", "pdname", "status", "stime" };
ListDaoImpl dao = new ListDaoImpl();
returnStr = dao.getInfo(tjson, tinfo, tnum, key, name, start, limit);
context.Response.ContentType = "text/plain";
context.Response.Write(returnStr.ToString());
}
//主要真对多表单字段
if (action == "GetForm")
{
String data = context.Request["data"];
String id = context.Request["id"];
String nid = context.Request["nid"];
String ndef = context.Request["ndef"];
String pdname = context.Request["pdname"];
String viewtype = context.Request["viewtype"];
String oper = context.Request["oper"];
String url = "http://www.cnblogs.com/views/forms/form/confirm.aspx";
url += "?data=";
url += data;
url += "&id=";
url += id;
url += "&formid=";
url += data;
url += "&nid=";
url += nid;
url += "&ndef=";
url += ndef;
url += "&pdname=";
url += pdname;
url += "&viewtype=";
url += viewtype;
url += "&action=";
url += oper;
//url = HttpUtility.UrlEncode(url);
context.Response.Redirect(url, true);
}
//获取所有被委托人委托过的事件
if (action == "GetDelegateAll")
{
}
if (action == "GetDoneAllForPrint")
{
#region For Print Document (Bind print data)
//Bind printed document
string pdname = context.Request["keyType"];
string uid = userid;
string paras = context.Request["sparas"];
string[] para = paras.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
string key = Common.SplitNullD(context.Request["key"], "all");
if (key.Equals(""))
{
key = "all";
}
String name = "";
String tnum = "";
name = "all";
tnum = "select a.* from (";
for (int i = 0; i < para.Length; i++)
{
String[] parb = para[i].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
if (parb[0] != null && parb[1] != null)
{
if (i > 0)
{
tnum += " union ";
}
tnum += "select distinct n.formid as fid, isnull(f." + parb[1] + ",'空值') as fname, '" + parb[0] + "' as fnum,n.pdname,p.status,p.stime,f.odept,f.isdelete from wf_node n inner join ";
tnum += " wf_proc p on n.pid = p.id inner join ";
tnum += parb[0];
tnum += " f on n.formid = f.id where n.operid = '" + uid + "' and n.status = '2' ";
}
}
tnum += ") a where fname like '{0}' or 'all' = '{1}' and a.isdelete=-1 ";
//文档查询类别 查询结果包括类别
if (!string.IsNullOrEmpty(pdname))
tnum += " and a.pdname like '%" + pdname + "%'";
int start = int.Parse(Common.SplitNullD(context.Request["start"], "0"));
int limit = int.Parse(Common.SplitNullD(context.Request["limit"], "20"));
String tinfo = "select * from ( select *,ROW_NUMBER() Over(order by stime desc) as rowNum from (" + tnum + ") as b ) c where rowNum between '{2}' and'{3}' ";
String[] tjson = { "fid", "fname", "fnum", "pdname", "status", "stime", "odept", "isdelete" };
ListDaoImpl dao = new ListDaoImpl();
returnStr = dao.getInfoSe(tjson, tinfo, tnum, key, name, start, limit);
context.Response.ContentType = "text/plain";
context.Response.Write(returnStr.ToString());
#endregion
}
//For Delete Print document record
if (action == "DeleteRecordForPrint")
{
String Fid = context.Request["id"];
//update isdelete=1
if (!string.IsNullOrEmpty(Fid))
{
#region Generate Model
EDay.OA.form_document_ii modelform_document_ii = new EDay.OA.form_document_ii();
EDay.OA.form_document_oi modelform_document_oi = new EDay.OA.form_document_oi();
EDay.OA.form_document_io modelform_document_io = new EDay.OA.form_document_io();
EDay.OA.form_notice modelform_notice = new EDay.OA.form_notice();
EDay.OA.form_leave modelform_leave = new EDay.OA.form_leave();
EDay.OA.form_auto modelform_auto = new EDay.OA.form_auto();
EDay.OA.form_supervise modelform_supervise = new EDay.OA.form_supervise();
EDay.OA.form_free modelform_free = new EDay.OA.form_free();
EDay.OA.form_travels_apply modelform_travels_apply = new EDay.OA.form_travels_apply();
EDay.OA.form_leavejobs modelform_leavejobs = new EDay.OA.form_leavejobs();
EDay.OA.form_meeting_useApply modelform_meeting_useApply = new EDay.OA.form_meeting_useApply();
EDay.OA.form_redHead modelform_redHead = new EDay.OA.form_redHead();
EDay.OA.form_orgdang modelform_orgdang = new EDay.OA.form_orgdang();
EDay.OA.form_orgtuan modelform_orgtuan = new EDay.OA.form_orgtuan();
EDay.OA.form_orggonghui modelform_orggonghui = new EDay.OA.form_orggonghui();
EDay.OA.form_redSend modelform_redSend = new EDay.OA.form_redSend();
EDay.OA.form_information_out modelform_information_out = new EDay.OA.form_information_out();
#endregion
#region
modelform_document_ii.UpdateByFid(Fid, 1);
modelform_document_oi.UpdateByFid(Fid, 1);
modelform_document_io.UpdateByFid(Fid, 1);
modelform_notice.UpdateByFid(Fid, 1);
modelform_leave.UpdateByFid(Fid, 1);
modelform_auto.UpdateByFid(Fid, 1);
modelform_supervise.UpdateByFid(Fid, 1);
modelform_free.UpdateByFid(Fid, 1);
modelform_travels_apply.UpdateByFid(Fid, 1);
modelform_leavejobs.UpdateByFid(Fid, 1);
modelform_meeting_useApply.UpdateByFid(Fid, 1);
modelform_redHead.UpdateByFid(Fid, 1);
modelform_orgdang.UpdateByFid(Fid, 1);
modelform_orgtuan.UpdateByFid(Fid, 1);
modelform_orggonghui.UpdateByFid(Fid, 1);
modelform_redSend.UpdateByFid(Fid, 1);
modelform_information_out.UpdateByFid(Fid, 1);
#endregion
string msg = "删除成功!";
string url = "http://www.cnblogs.com/main.html?url=views/com/oa/doneForPrint.aspx?tname=form_documents&sparas=form_document_ii,title;form_document_oi,title;form_document_io,title;form_notice,title;form_leave,title;form_auto,title;form_supervise,title;form_free,title;form_travels_apply,title;form_leavejobs,title;form_meeting_useApply,title;form_redHead,title;form_orgdang,title;form_orgtuan,title;form_orggonghui,title;form_redSend,title;form_information_out,title";
context.Response.Write("<script language='javascript' defer>alert('" + msg + "');window.location=\"" + url + "\"</script>");
}
}
}
public void TestFunction()
{
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.SessionState;
using OA.Common;
namespace oapro.Controls.OA
{
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class wait : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
string returnStr = "";
Common common = new Common();
string userid = context.Session["userid"].ToString();
string action = context.Request["action"].ToString();
//主要真对多表单字段
if (action == "GetWaitAll")
{
string uid = userid;
string paras = context.Request["sparas"];
string[] para = paras.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
string key = Common.SplitNullD(context.Request["key"], "all");
if (key.Equals(""))
{
key = "all";
}
String name = "";
String tnum = "";
name = "all";
tnum = "select a.* from (";
for (int i = 0; i < para.Length; i++)
{
String[] parb = para[i].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
if (parb[0] != null && parb[1] != null)
{
if (i > 0)
{
tnum += " union ";
}
tnum += "select n.id as id, n.formid as fid, isnull(f." + parb[1] + ",'空值') as fname,isnull('" + parb[0] + "','空值') as fnum,n.pdname,n.preoper,n.stime,n.ndef from wf_node n inner join ";
tnum += parb[0];
tnum += " f on n.formid = f.id where n.operid = '" + uid + "' and n.status = '1'";
}
}
tnum += ") a where fname like '{0}' or 'all' = '{1}' ";
int start = int.Parse(Common.SplitNullD(context.Request["start"], "0"));
int limit = int.Parse(Common.SplitNullD(context.Request["limit"], "20"));
String tinfo = "select * from ( select *,ROW_NUMBER() Over(order by stime desc) as rowNum from (" + tnum + ") as b ) c where rowNum between '{2}' and '{3}' ";
String[] tjson = { "id", "fid", "fname", "fnum", "pdname", "preoper", "stime", "ndef" };
ListDaoImpl dao = new ListDaoImpl();
returnStr = dao.getInfoSe(tjson, tinfo, tnum, key, name, start, limit);
context.Response.ContentType = "text/plain";
context.Response.Write(returnStr.ToString());
}
if (action == "GetDoneAll")
{
//新加 类别查询
string pdname = context.Request["keyType"];
string uid = userid;
string paras = context.Request["sparas"];
string[] para = paras.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
string key = Common.SplitNullD(context.Request["key"], "all");
if (key.Equals(""))
{
key = "all";
}
String name = "";
String tnum = "";
name = "all";
tnum = "select a.* from (";
for (int i = 0; i < para.Length; i++)
{
String[] parb = para[i].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
if (parb[0] != null && parb[1] != null)
{
if (i > 0)
{
tnum += " union ";
}
tnum += "select distinct n.formid as fid, isnull(f." + parb[1] + ",'空值') as fname, '" + parb[0] + "' as fnum,n.pdname,p.status,p.stime,f.odept from wf_node n inner join ";
tnum += " wf_proc p on n.pid = p.id inner join ";
tnum += parb[0];
tnum += " f on n.formid = f.id where n.operid = '" + uid + "' and n.status = '2' ";
}
}
tnum += ") a where fname like '{0}' or 'all' = '{1}' ";
//文档查询类别 查询结果包括类别
if (!string.IsNullOrEmpty(pdname))
tnum += " and a.pdname like '%" + pdname + "%'";
int start = int.Parse(Common.SplitNullD(context.Request["start"], "0"));
int limit = int.Parse(Common.SplitNullD(context.Request["limit"], "20"));
String tinfo = "select * from ( select *,ROW_NUMBER() Over(order by stime desc) as rowNum from (" + tnum + ") as b ) c where rowNum between '{2}' and'{3}' ";
String[] tjson = { "fid", "fname", "fnum", "pdname", "status", "stime", "odept" };
ListDaoImpl dao = new ListDaoImpl();
returnStr = dao.getInfoSe(tjson, tinfo, tnum, key, name, start, limit);
context.Response.ContentType = "text/plain";
context.Response.Write(returnStr.ToString());
}
//获取已办 主要真对单表多字段
if (action == "GetDone")
{
String uid = context.Request["uid"];
String pname = context.Request["pname"];
String tname = context.Request["tname"];
String paras = context.Request["sparas"];
String[] para = paras.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
String key = Common.SplitNullD(context.Request["key"], "all");
if (key.Equals(""))
{
key = "all";
}
String name = "";
String tnum = "";
name = "all";
tnum = "select a.* from (select distinct n.formid as fid, isnull(f." + para[0] + ",'空值') as fname, isnull(f." + para[1] + ",'空值') as fnum,n.pdname,p.status,p.stime from wf_node n inner join ";
tnum += " wf_proc p on n.pid = p.id inner join ";
tnum += tname;
tnum += " f on n.formid = f.id where n.operid = '" + uid + "' and n.status = '2' and (f.";
tnum += para[0];
tnum += " like '{0}' or f.";
tnum += para[1];
tnum += " like '{1}' or 'all' = '{2}' or 'all' = '{3}' ) and 'all' = '{4}' ) a";
int start = int.Parse(Common.SplitNullD(context.Request["start"], "0"));
int limit = int.Parse(Common.SplitNullD(context.Request["limit"], "20"));
String tinfo = "select * from ( select *,ROW_NUMBER() Over(order by stime desc) as rowNum from (" + tnum + ") as b ) c where rowNum between '{5}' and '{6}' ";
String[] tjson = { "fid", "fname", "fnum", "pdname", "status", "stime" };
ListDaoImpl dao = new ListDaoImpl();
returnStr = dao.getInfo(tjson, tinfo, tnum, key, name, start, limit);
context.Response.ContentType = "text/plain";
context.Response.Write(returnStr.ToString());
}
//主要真对多表单字段
if (action == "GetForm")
{
String data = context.Request["data"];
String id = context.Request["id"];
String nid = context.Request["nid"];
String ndef = context.Request["ndef"];
String pdname = context.Request["pdname"];
String viewtype = context.Request["viewtype"];
String oper = context.Request["oper"];
String url = "http://www.cnblogs.com/views/forms/form/confirm.aspx";
url += "?data=";
url += data;
url += "&id=";
url += id;
url += "&formid=";
url += data;
url += "&nid=";
url += nid;
url += "&ndef=";
url += ndef;
url += "&pdname=";
url += pdname;
url += "&viewtype=";
url += viewtype;
url += "&action=";
url += oper;
//url = HttpUtility.UrlEncode(url);
context.Response.Redirect(url, true);
}
//获取所有被委托人委托过的事件
if (action == "GetDelegateAll")
{
}
if (action == "GetDoneAllForPrint")
{
#region For Print Document (Bind print data)
//Bind printed document
string pdname = context.Request["keyType"];
string uid = userid;
string paras = context.Request["sparas"];
string[] para = paras.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
string key = Common.SplitNullD(context.Request["key"], "all");
if (key.Equals(""))
{
key = "all";
}
String name = "";
String tnum = "";
name = "all";
tnum = "select a.* from (";
for (int i = 0; i < para.Length; i++)
{
String[] parb = para[i].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
if (parb[0] != null && parb[1] != null)
{
if (i > 0)
{
tnum += " union ";
}
tnum += "select distinct n.formid as fid, isnull(f." + parb[1] + ",'空值') as fname, '" + parb[0] + "' as fnum,n.pdname,p.status,p.stime,f.odept,f.isdelete from wf_node n inner join ";
tnum += " wf_proc p on n.pid = p.id inner join ";
tnum += parb[0];
tnum += " f on n.formid = f.id where n.operid = '" + uid + "' and n.status = '2' ";
}
}
tnum += ") a where fname like '{0}' or 'all' = '{1}' and a.isdelete=-1 ";
//文档查询类别 查询结果包括类别
if (!string.IsNullOrEmpty(pdname))
tnum += " and a.pdname like '%" + pdname + "%'";
int start = int.Parse(Common.SplitNullD(context.Request["start"], "0"));
int limit = int.Parse(Common.SplitNullD(context.Request["limit"], "20"));
String tinfo = "select * from ( select *,ROW_NUMBER() Over(order by stime desc) as rowNum from (" + tnum + ") as b ) c where rowNum between '{2}' and'{3}' ";
String[] tjson = { "fid", "fname", "fnum", "pdname", "status", "stime", "odept", "isdelete" };
ListDaoImpl dao = new ListDaoImpl();
returnStr = dao.getInfoSe(tjson, tinfo, tnum, key, name, start, limit);
context.Response.ContentType = "text/plain";
context.Response.Write(returnStr.ToString());
#endregion
}
//For Delete Print document record
if (action == "DeleteRecordForPrint")
{
String Fid = context.Request["id"];
//update isdelete=1
if (!string.IsNullOrEmpty(Fid))
{
#region Generate Model
EDay.OA.form_document_ii modelform_document_ii = new EDay.OA.form_document_ii();
EDay.OA.form_document_oi modelform_document_oi = new EDay.OA.form_document_oi();
EDay.OA.form_document_io modelform_document_io = new EDay.OA.form_document_io();
EDay.OA.form_notice modelform_notice = new EDay.OA.form_notice();
EDay.OA.form_leave modelform_leave = new EDay.OA.form_leave();
EDay.OA.form_auto modelform_auto = new EDay.OA.form_auto();
EDay.OA.form_supervise modelform_supervise = new EDay.OA.form_supervise();
EDay.OA.form_free modelform_free = new EDay.OA.form_free();
EDay.OA.form_travels_apply modelform_travels_apply = new EDay.OA.form_travels_apply();
EDay.OA.form_leavejobs modelform_leavejobs = new EDay.OA.form_leavejobs();
EDay.OA.form_meeting_useApply modelform_meeting_useApply = new EDay.OA.form_meeting_useApply();
EDay.OA.form_redHead modelform_redHead = new EDay.OA.form_redHead();
EDay.OA.form_orgdang modelform_orgdang = new EDay.OA.form_orgdang();
EDay.OA.form_orgtuan modelform_orgtuan = new EDay.OA.form_orgtuan();
EDay.OA.form_orggonghui modelform_orggonghui = new EDay.OA.form_orggonghui();
EDay.OA.form_redSend modelform_redSend = new EDay.OA.form_redSend();
EDay.OA.form_information_out modelform_information_out = new EDay.OA.form_information_out();
#endregion
#region
modelform_document_ii.UpdateByFid(Fid, 1);
modelform_document_oi.UpdateByFid(Fid, 1);
modelform_document_io.UpdateByFid(Fid, 1);
modelform_notice.UpdateByFid(Fid, 1);
modelform_leave.UpdateByFid(Fid, 1);
modelform_auto.UpdateByFid(Fid, 1);
modelform_supervise.UpdateByFid(Fid, 1);
modelform_free.UpdateByFid(Fid, 1);
modelform_travels_apply.UpdateByFid(Fid, 1);
modelform_leavejobs.UpdateByFid(Fid, 1);
modelform_meeting_useApply.UpdateByFid(Fid, 1);
modelform_redHead.UpdateByFid(Fid, 1);
modelform_orgdang.UpdateByFid(Fid, 1);
modelform_orgtuan.UpdateByFid(Fid, 1);
modelform_orggonghui.UpdateByFid(Fid, 1);
modelform_redSend.UpdateByFid(Fid, 1);
modelform_information_out.UpdateByFid(Fid, 1);
#endregion
string msg = "删除成功!";
string url = "http://www.cnblogs.com/main.html?url=views/com/oa/doneForPrint.aspx?tname=form_documents&sparas=form_document_ii,title;form_document_oi,title;form_document_io,title;form_notice,title;form_leave,title;form_auto,title;form_supervise,title;form_free,title;form_travels_apply,title;form_leavejobs,title;form_meeting_useApply,title;form_redHead,title;form_orgdang,title;form_orgtuan,title;form_orggonghui,title;form_redSend,title;form_information_out,title";
context.Response.Write("<script language='javascript' defer>alert('" + msg + "');window.location=\"" + url + "\"</script>");
}
}
}
public void TestFunction()
{
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
贴图 实现效果
图1:
请大家多多指教!我的QQ418569732
MSN:litao6664@hotmail.com