<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>login</title>
<link href="content/login/css/component.css" rel="stylesheet" type="text/css" />
<link href="content/login/css/demo.css" rel="stylesheet" type="text/css" />
<link href="content/login/css/normalize.css" rel="stylesheet" type="text/css" />
<script src="jquery-3.3.1.min.js"></script>
<script>
$(function () {
$('#btnOK').click(function () {
var usercode = $('#txtlogname').val();
var password = $('#txtlogpass').val();
$.ajax({
type: "post",
url: "Login.aspx?action=login",
data: { usercode: usercode, password: password },
//contentType: 'application/json',
dataType: 'json',
success: function (data) {
if (data.isSuccessed) {
location.href = "Main.aspx";
}
else
alert(data.Message);
},
error: function (xmlReq, err, c) {
alert("error:" + err);
}
});
})
})
</script>
</head>
<body>
<div class="container demo-1">
<div class="content">
<div id="large-header" class="large-header">
<canvas id="demo-canvas"></canvas>
<div class="logo_box">
<h3>校园招聘信息系统</h3>
<form action="#" name="f" method="post">
<div class="input_outer">
<span class="u_user"></span>
<input id="txtlogname" name="txtlogname" class="text" style="color: #FFFFFF !important" type="text" placeholder="请输入账户" />
</div>
<div class="input_outer">
<span class="us_uer"></span>
<input id="txtlogpass" name="txtlogpass" class="text" style="color: #FFFFFF !important; position: absolute; z-index: 100;" value="" type="password" placeholder="请输入密码" />
</div>
<%--<input id ="btnOK" value="登录" style="width:100%;" type="button" class="act-but submit"/>--%>
<div class="mb2">
<input id="btnOK" value="登录" style="width: 100%;" type="button" class="act-but submit" />-</div>
</form>
</div>
</div>
</div>
</div>
<!-- /container -->
<script src="content/login/js/TweenLite.min.js"></script>
<script src="content/login/js/EasePack.min.js"></script>
<script src="content/login/js/rAF.js"></script>
<script src="content/login/js/demo-1.js"></script>
<div style="text-align: center;">
</div>
</body>
</html>
public partial class Login : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
string action = Request.QueryString["action"] == null ? "" : Request.QueryString["action"];
switch (action)
{
case "login":
CheckLogin();
break;
}
}
private void CheckLogin()
{
string strusercode, strpassword;
strusercode = Request.Form["usercode"];
strpassword = Request.Form["password"];
SQLHelper db = new SQLHelper();
string strSql = "select * from sysuser where usercode='{0}' and pwd='{1}'";
strSql = string.Format(strSql, strusercode, strpassword);
DataTable dt = db.ExecuteQuery(strSql, CommandType.Text);
if (dt.Rows.Count == 1)
{
Session["usercode"] = dt.Rows[0]["usercode"].ToString();
Session["username"] = dt.Rows[0]["username"].ToString();
WriteMessage(true, "");
}
else
{
WriteMessage(false, "登录失败!");
}
}
}
///事件
<script>
$(function () {
loaddata();
$('#btnQuery').on('click', function () {
$('#dg').datagrid('options').queryParams = condition();
$("#dg").datagrid('reload');
})
//获取页大小变化事件
var pg = $("#dg").datagrid("getPager");
if (pg) {
$(pg).pagination({
onChangePageSize: function () {
$('#dg').datagrid('options').queryParams = condition();
$("#dg").datagrid('reload');
//alert('pagesize changed');
}
});
}
//新增事件 begin
$('#btnAdd').on('click', function () {
$('#w').dialog({
title: '新增数据',
width: 400,
height: 200,
closed: false,
cache: false,
href: 'useredit.aspx?action=add',
modal: true,
buttons: [{
text: '确定',
iconCls: 'icon-ok',
handler: function () {
//数据保存代码
$('#ff').form('submit', {
url: "useredit.aspx?action=addrecord", //表单提交地址 并带参数
onSubmit: function () {
return $(this).form('validate'); //验证表单是否通过验证规则
},
success: function (returndata) {
var obj = eval("(" + returndata + ")")
if (obj.isSuccessed) {
$('#dg').datagrid('reload'); //刷新数据表格datagrid
$('#w').dialog('close'); //关闭弹出新增窗口
$.messager.show({
title: '提示',
msg: obj.Message,
timeout: 2000,
showType: 'show'
});
}
else {
alert('保存失败!');
}
}
});
}
}, {
text: '关闭',
iconCls: 'icon-delete',
handler: function () {
$('#w').dialog('close'); //关闭弹出新增窗口
}
}]
});
});
// 新增事件 END
//update事件 begin
$('#btnEdit').on('click', function () {
var row = $('#dg').datagrid('getSelected');
if (row == null) {
$.messager.show({
title: '提示',
msg: '请选择您要编辑的数据.',
timeout: 2000,
showType: 'slide'
});
return;
}
$('#w').dialog({
title: '修改数据',
width: 400,
height: 200,
closed: false,
cache: false,
href: 'useredit.aspx?action=update&id=' + row.usercode,
modal: true,
buttons: [{
text: '确定',
iconCls: 'icon-ok',
handler: function () {
//数据保存代码
$('#ff').form('submit', {
url: "useredit.aspx?action=updaterecord&id=" + row.usercode, //表单提交地址 并带参数
onSubmit: function () {
return $(this).form('validate'); //验证表单是否通过验证规则
},
success: function (returndata) {
var obj = eval("(" + returndata + ")")
if (obj.isSuccessed) {
$('#dg').datagrid('reload'); //刷新数据表格datagrid
$('#w').dialog('close'); //关闭弹出新增窗口
$.messager.show({
title: '提示',
msg: obj.Message,
timeout: 2000,
showType: 'show'
});
}
else {
alert('保存失败!');
}
}
});
}
}, {
text: '关闭',
iconCls: 'icon-delete',
handler: function () {
$('#w').dialog('close'); //关闭弹出新增窗口
}
}]
});
});
// update事件 END
//删除事件 begin
$('#btnDel').on('click', function () {
var row = $('#dg').datagrid('getSelected');
if (row == null) {
$.messager.show({
title: '提示',
msg: '请选择您要删除的数据.',
timeout: 2000,
showType: 'slide'
});
return;
}
$.ajax({
url: 'useredit.aspx?action=delete&id=' + row.usercode,
success: function (data) {
if (data.isSuccessed) {
$('#dg').datagrid('reload'); //刷新数据表格datagrid
$.messager.show({
title: '提示',
msg: data.Message,
timeout: 2000,
showType: 'show'
});
}
else {
alert('删除失败!');
}
}
})
});
// 删除事件 END
//用户角色事件 begin
$('#btnrole').on('click', function () {
var row = $('#dg').datagrid('getSelected');
if (row == null) {
$.messager.show({
title: '提示',
msg: '请选择您要分配角色的用户.',
timeout: 2000,
showType: 'slide'
});
return;
}
$('#w').dialog({
title: '角色数据',
width: 400,
height: 200,
closed: false,
cache: false,
href: 'userrolelist.aspx?action=choose&id=' + row.usercode,
modal: true,
buttons: [{
text: '确定',
iconCls: 'icon-ok',
handler: function () {
var rolerow = $('#dgrole').datagrid('getSelected');
$.ajax({
type: "GET",
url: "userrolelist.aspx?action=save", //&usercode=" + usercode + "&pwd="+usercode,
data: { usercode: row.usercode, roleid: rolerow.roleid },
//dataType: "json",
success: function (returndata) {
var obj = eval("(" + returndata + ")");
if (obj.isSuccessed) {
$('#w').dialog('close');
}
else { }
}
});
}
}, {
text: '关闭',
iconCls: 'icon-delete',
handler: function () {
$('#w').dialog('close'); //关闭弹出新增窗口
}
}]
});
});
// update事件 END
})
function loaddata() {
$("#dg").datagrid({
url: "sysuser.aspx?action=select",//加载的URL
isField: "usercode",
pagination: true,//显示分页
pageSize: 5,//分页大小
pageList: [5, 10, 15, 20],//每页的个数
fit: true,//自动补全
fitColumns: true,
toolbar: '#tb',
sortName: 'usercode',
queryParams: {},//condition(),
singleSelect: true,
//iconCls: "icon-save",//图标
//title: "用户管理",
columns: [[ //每个列具体内容
{ field: 'usercode', title: '用户名', width: 100, sortable: true },
{ field: 'username', title: '姓名', width: 100, sortable: true },
{
field: 'pwd', title: '密码', width: 100,
formatter: function (value, row, index) {
return '******';
}
},
{ field: 'cmt', title: '备注' }
]]
})
}
function condition() {
var o = {};
o.value = $('#txtValue').val();
return o;
}
</script>
</head>
<body class="easyui-layout">
<div data-options="region:'center'">
<table id="dg">
</table>
</div>
<div id="tb">
<a href="#" id="btnAdd" class="easyui-linkbutton" data-options="iconCls:'icon-standard-add',plain:true">新增</a>
<a href="#" id="btnEdit" class="easyui-linkbutton" data-options="iconCls:'icon-standard-pencil',plain:true">修改</a>
<a href="#" id="btnDel" class="easyui-linkbutton" data-options="iconCls:'icon-standard-delete',plain:true">删除</a>
<input id="txtValue" class="easyui-textbox" data-options="prompt:'学号或者姓名'" style="width: 120px;" />
<a id="btnQuery" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-standard-zoom',plain:true">确定</a>
<a id="btnrole" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-standard-user',plain:true">用户角色</a>
</div>
<%--弹出窗口--%>
<div id="w">
</div>
</body>
</html>
public partial class sysuser : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
string action = "";
if (!IsPostBack)
{
action = Request["action"] == null ? "" : Request["action"].ToString();
switch (action)
{
case "select":
GetList();
break;
}
}
}
private void GetList()
{
int pageindex = int.Parse(Request.Form["page"]);
int pagesize = int.Parse(Request.Form["rows"]);
string sort = Request.Form["sort"];
string order = Request.Form["order"];
string value = Request.Form["value"];
STJB.BLL.sysuser bll = new STJB.BLL.sysuser();
DataTable dt = new DataTable();
ResultData data = new ResultData();
string strOrder = "";
if (!string.IsNullOrEmpty(sort))
{
strOrder = sort + " " + order;
}
string strWhere = "";
if (!string.IsNullOrEmpty(value))
{
strWhere = string.Format(" usercode like '%{0}%' or username like '%{0}%'", value);
}
data.total = bll.GetRecordCount(strWhere);
data.rows = bll.GetListByPage(strWhere, strOrder, (pageindex - 1) * pagesize + 1, pageindex * pagesize).Tables[0];
WriteData(Newtonsoft.Json.JsonConvert.SerializeObject(data));
}
}
///rolelist
</head>
<body class="easyui-layout">
<div data-options="region:'center'">
<table id="dg">
</table>
</div>
<div data-options="region:'east'" style="width: 280px">
<table id="tg">
</table>
</div>
<div id="tb">
<a href="#" id="btnAdd" class="easyui-linkbutton" data-options="iconCls:'icon-standard-add',plain:true">新增</a>
<a href="#" id="btnEdit" class="easyui-linkbutton" data-options="iconCls:'icon-standard-pencil',plain:true">修改</a>
<a href="#" id="btnDel" class="easyui-linkbutton" data-options="iconCls:'icon-standard-delete',plain:true">删除</a>
</div>
<div id="menutb">
<a href="#" id="btnSaveMenu" class="easyui-linkbutton" data-options="iconCls:'icon-standard-add',plain:true">保存</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-standard-pencil',plain:true">刷新</a>
</div>
<%--弹出窗口--%>
<div id="w">
</div>
<script>
$(function () {
loaddata();
loadtreedata();
$('#btnQuery').on('click', function () {
$('#dg').datagrid('options').queryParams = condition();
$("#dg").datagrid('reload');
})
//获取页大小变化事件
var pg = $("#dg").datagrid("getPager");
if (pg) {
$(pg).pagination({
onChangePageSize: function () {
$('#dg').datagrid('options').queryParams = condition();
$("#dg").datagrid('reload');
//alert('pagesize changed');
}
});
}
//新增事件 begin
$('#btnAdd').on('click', function () {
$('#w').dialog({
title: '新增数据',
width: 400,
height: 200,
closed: false,
cache: false,
href: 'roleedit.aspx?action=add',
modal: true,
buttons: [{
text: '确定',
iconCls: 'icon-ok',
handler: function () {
//数据保存代码
$('#ff').form('submit', {
url: "roleedit.aspx?action=addrecord", //表单提交地址 并带参数
onSubmit: function () {
return $(this).form('validate'); //验证表单是否通过验证规则
},
success: function (returndata) {
var obj = eval("(" + returndata + ")")
if (obj.isSuccessed) {
$('#dg').datagrid('reload'); //刷新数据表格datagrid
$('#w').dialog('close'); //关闭弹出新增窗口
$.messager.show({
title: '提示',
msg: obj.Message,
timeout: 2000,
showType: 'show'
});
}
else {
alert('保存失败!');
}
}
});
}
}, {
text: '关闭',
iconCls: 'icon-delete',
handler: function () {
$('#w').dialog('close'); //关闭弹出新增窗口
}
}]
});
});
// 新增事件 END
//update事件 begin
$('#btnEdit').on('click', function () {
var row = $('#dg').datagrid('getSelected');
if (row == null) {
$.messager.show({
title: '提示',
msg: '请选择您要编辑的数据.',
timeout: 2000,
showType: 'slide'
});
return;
}
$('#w').dialog({
title: '修改数据',
width: 400,
height: 200,
closed: false,
cache: false,
href: 'roleedit.aspx?action=update&id=' + row.roleid,
modal: true,
buttons: [{
text: '确定',
iconCls: 'icon-ok',
handler: function () {
//数据保存代码
$('#ff').form('submit', {
url: "roleedit.aspx?action=updaterecord&id=" + row.roleid, //表单提交地址 并带参数
onSubmit: function () {
return $(this).form('validate'); //验证表单是否通过验证规则
},
success: function (returndata) {
var obj = eval("(" + returndata + ")")
if (obj.isSuccessed) {
$('#dg').datagrid('reload'); //刷新数据表格datagrid
$('#w').dialog('close'); //关闭弹出新增窗口
$.messager.show({
title: '提示',
msg: obj.Message,
timeout: 2000,
showType: 'show'
});
}
else {
alert('保存失败!');
}
}
});
}
}, {
text: '关闭',
iconCls: 'icon-delete',
handler: function () {
$('#w').dialog('close'); //关闭弹出新增窗口
}
}]
});
});
// update事件 END
//删除事件 begin
$('#btnDel').on('click', function () {
var row = $('#dg').datagrid('getSelected');
if (row == null) {
$.messager.show({
title: '提示',
msg: '请选择您要删除的数据.',
timeout: 2000,
showType: 'slide'
});
return;
}
$.ajax({
url: 'roleedit.aspx?action=delete&id=' + row.roleid,
success: function (data) {
if (data.isSuccessed) {
$('#dg').datagrid('reload'); //刷新数据表格datagrid
$.messager.show({
title: '提示',
msg: data.Message,
timeout: 2000,
showType: 'show'
});
}
else {
alert('删除失败!');
}
}
})
});
// 删除事件 END
//btnSaveMenu begin
$('#btnSaveMenu').on('click', function () {
var row = $('#dg').datagrid('getSelected');
if (row == null) {
$.messager.show({
title: '提示',
msg: '请选择你要分配功能的角色.',
timeout: 2000,
showType: 'slide'
});
return;
}
var newfunids = [];
var rows = $('#tg').treegrid('getSelections');
for (i = 0 ; i < rows.length; i++) {
newfunids.push(rows[i].id);
}
$.ajax({
url: 'rolelist.aspx?action=savemenu&id=' + row.roleid,
type: 'post',
data: JSON.stringify(newfunids),
success: function (data) {
var obj = eval("(" + data + ")")
if (obj.isSuccessed) {
$('#tg').datagrid('reload'); //刷新数据表格datagrid
$.messager.show({
title: '提示',
msg: obj.Message,
timeout: 2000,
showType: 'show'
});
}
else {
alert('保存失败!');
}
}
})
});
// btnSaveMenu END
})
function loaddata() {
$("#dg").datagrid({
url: "rolelist.aspx?action=select",//加载的URL
isField: "roleid",
pagination: true,//显示分页
pageSize: 5,//分页大小
pageList: [5, 10, 15, 20],//每页的个数
fit: true,//自动补全
fitColumns: true,
toolbar: '#tb',
sortName: 'roleid',
queryParams: {},//condition(),
singleSelect: true,
//iconCls: "icon-save",//图标
//title: "用户管理",
columns: [[ //每个列具体内容
{ field: 'roleid', title: '', hidden: true },
{ field: 'rolename', title: '角色名称', width: 200, sortable: true },
{ field: 'cmt', title: '备注', width: 500 },
{
field: 'right', title: '权限',
formatter: function (value, row, index) {
return '<a href="#" onclick="ShowMenu(' + row.roleid + ')">查看</a>';
}
},
]]
})
}
function loadtreedata() {
$('#tg').treegrid({
title: '系统功能列表',
fit: true,
animate: true,//是否用动画效果
collapsible: false,//是否可折叠
//pagination: true,//分页控件
rownumbers: true,//行号
//fitColumns: true,
url: 'rolelist.aspx?action=menuselect',
method: 'get',
toolbar: '#menutb',
idField: 'id',//根据那个字段判断树节点关系
treeField: 'funname',//根据那个列展现树
showFooter: false,//是否使用页脚
sortName: 'funid',//默认排序字段,后台通过参数名“sort”获取
singleSelect: false,
//sortOrder: 'desc',//默认排序规则,后台通过参数名“order”获取
columns: [[
{ title: '', field: 'funid', hidden: true },
{ title: '功能', field: 'funname', width: 220, sortable: true },
{ title: '地址', field: 'url', width: 150, sortable: true },
{ title: '图标', field: 'icno', width: 80 },
{ title: '备注', field: 'cmt', width: 100, sortable: true }
]],
onBeforeExpand: function (node) {
},
onLoadSuccess: function () {
},
onClickRow: function (node) {
//点击行触发
},
onClickCell: function (rowIndex, field, value) {//点击表格触发
}
});
}
function condition() {
var o = {};
o.value = $('#txtValue').val();
return o;
}
function ShowMenu(roleid) {
$.ajax({
url: 'rolelist.aspx?action=showmenu&id=' + roleid,
success: function (data) {
$('#tg').treegrid('unselectAll');
//console.log(data);
var json = eval("(" + data + ")")
$.each(json, function (idx, obj) {
$('#tg').treegrid('select', obj.funid);
})
//if (obj.isSuccessed) {
// $('#dg').datagrid('reload'); //刷新数据表格datagrid
// $.messager.show({
// title: '提示',
// msg: obj.Message,
// timeout: 2000,
// showType: 'show'
// });
//}
//else {
// alert('删除失败!');
//}
}
})
}
</script>
</body>
public partial class right_rolelist : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
string action = "";
if (!IsPostBack)
{
action = Request["action"] == null ? "" : Request["action"].ToString();
switch (action)
{
case "select":
GetList();
break;
case "menuselect":
GetMenuList();
break;
case "savemenu":
SaveMenu();
break;
case "showmenu":
ShowMenu();
break;
}
}
}
private void GetList()
{
int pageindex = int.Parse(Request.Form["page"]);
int pagesize = int.Parse(Request.Form["rows"]);
string sort = Request.Form["sort"];
string order = Request.Form["order"];
string value = Request.Form["value"];
STJB.BLL.sysrole bll = new STJB.BLL.sysrole();
DataTable dt = new DataTable();
ResultData data = new ResultData();
string strOrder = "";
if (!string.IsNullOrEmpty(sort))
{
strOrder = sort + " " + order;
}
//string strWhere = "";
//if (!string.IsNullOrEmpty(value))
//{
// strWhere = string.Format(" usercode like '%{0}%' or username like '%{0}%'", value);
//}
data.total = bll.GetRecordCount("");
data.rows = bll.GetListByPage("", strOrder, (pageindex - 1) * pagesize + 1, pageindex * pagesize).Tables[0];
WriteData(Newtonsoft.Json.JsonConvert.SerializeObject(data));
}
/// <summary>
/// 获取菜单列表
/// </summary>
private void GetMenuList()
{
STJB.BLL.sysfunction bll = new STJB.BLL.sysfunction();
ResultData data = new ResultData();
data.total = bll.GetRecordCount("");
data.rows = bll.GetTreeList("").Tables[0];
WriteData(Newtonsoft.Json.JsonConvert.SerializeObject(data));
}
private void SaveMenu()
{
STJB.BLL.sysrolefun bll = new STJB.BLL.sysrolefun();
string id = Request["id"].ToString();
foreach (var m in bll.GetModelList(string.Format(" roleid = {0}", id)))
{
bll.Delete(m.id);
}
string[] strarr = HttpUtility.UrlDecode(Request.Form.ToString()).Replace("]", "").Replace("[", "").Split(',');
foreach (var funid in strarr)
{
var mm = new STJB.Model.sysrolefun();
mm.funid = decimal.Parse(funid);
mm.roleid = decimal.Parse(id);
bll.Add(mm);
}
WriteMessage(true, "OK!");
}
private void ShowMenu()
{
STJB.BLL.sysrolefun bll = new STJB.BLL.sysrolefun();
string id = Request["id"].ToString();
WriteData(Newtonsoft.Json.JsonConvert.SerializeObject(bll.GetModelList(string.Format(" roleid = {0}", id))));
}
}