add
|
@ -0,0 +1,164 @@
|
|||
10
|
||||
|
||||
dir
|
||||
8
|
||||
file:///D:/Repositories/ZhangPu/trunk/view/App_Code
|
||||
file:///D:/Repositories/ZhangPu
|
||||
|
||||
|
||||
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
69712cd5-45d9-e244-acd6-b3e9c1159652
|
||||
|
||||
PagePublic.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:10.289868Z
|
||||
88adefccb355a757a198d9d5710b8905
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
637
|
||||
|
||||
ExcelExp.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:10.305493Z
|
||||
622cd19125108d2405c68fbaa5dd594a
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1888
|
||||
|
||||
SessionEndModule.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:10.305493Z
|
||||
afc00bfe8b5a4c00a5defa6a1221b0fb
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
5243
|
||||
|
||||
PageBase.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:10.321118Z
|
||||
ada92b7d54cfb24aba200636f6b94af8
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2850
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
|
||||
namespace view.App_Code
|
||||
{
|
||||
/// <summary>
|
||||
/// utils 的摘要说明
|
||||
/// </summary>
|
||||
public class ExcelExp
|
||||
{
|
||||
public ExcelExp()
|
||||
{
|
||||
//
|
||||
// TODO: 在此处添加构造函数逻辑
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
public static void Export(GridView GridView1, DataView dv ,ScriptManager sm,Control Button1,string fileName, Page page )
|
||||
{
|
||||
sm.RegisterPostBackControl(Button1);
|
||||
GridView1.AllowPaging = false;
|
||||
GridView1.Columns[GridView1.Columns.Count-1].Visible = false;
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
|
||||
|
||||
HttpContext.Current.Response.Charset = "GB2312";
|
||||
HttpContext.Current.Response.ContentEncoding = Encoding.UTF7;
|
||||
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName + ".xls", Encoding.UTF8).ToString());
|
||||
HttpContext.Current.Response.ContentType = "application/ms-excel";
|
||||
page.EnableViewState = false;
|
||||
StringWriter tw = new StringWriter();
|
||||
HtmlTextWriter hw = new HtmlTextWriter(tw);
|
||||
GridView1.RenderControl(hw);
|
||||
HttpContext.Current.Response.Write(tw.ToString());
|
||||
HttpContext.Current.Response.End();
|
||||
|
||||
GridView1.AllowPaging = false;
|
||||
GridView1.Columns[GridView1.Columns.Count - 1].Visible = true;
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using ZhangPu.Gov.Logical;
|
||||
|
||||
/// <summary>
|
||||
/// utils 的摘要说明
|
||||
/// </summary>
|
||||
public class PageBase : PagePublic
|
||||
{
|
||||
public PageBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// protected LEmployee lem;
|
||||
// const string DefaultPage = "~/index.aspx";
|
||||
// const string HomePage = "~/Desktop.aspx";
|
||||
|
||||
public void CheckAuthority()
|
||||
{
|
||||
if (checkCloseIE()) return;
|
||||
|
||||
string requestPage = Request.AppRelativeCurrentExecutionFilePath + Request.Url.Query;
|
||||
requestPage = requestPage.ToUpper();
|
||||
// if (DefaultPage.Equals(requestPage)) return; //起始页不做判断
|
||||
if (DefaultPage.ToUpper() == requestPage) return; //起始页不做判断
|
||||
|
||||
if (lem == null)
|
||||
{
|
||||
logobj.LoginLog(string.Empty,"lem is null");
|
||||
Response.Redirect(DefaultPage);
|
||||
}
|
||||
if (HomePage.ToUpper() == requestPage) return;
|
||||
if (lem.GetEmployee.em_account == "Root") //内建管理员
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (lem.AuthList.Contains(requestPage)) return;
|
||||
if (!new LRoleAuthority().GetPublicAuthorityList().Contains(requestPage))
|
||||
{
|
||||
logobj.RequestPageLog();
|
||||
|
||||
logobj.LoginLog(lem.GetEmployee.em_account ,"NoAccess!");
|
||||
|
||||
Response.Redirect(DefaultPage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override void OnPreInit(EventArgs e)
|
||||
{
|
||||
|
||||
base.OnPreInit(e);
|
||||
|
||||
CheckAuthority();
|
||||
|
||||
}
|
||||
bool checkCloseIE()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Request.QueryString["___command"]))
|
||||
{
|
||||
string cmd = Request.QueryString["___command"];
|
||||
if (cmd == "ClearSession")
|
||||
{
|
||||
if ((Session["CurrentUser"] != null))
|
||||
{
|
||||
|
||||
if (System.Configuration.ConfigurationManager.AppSettings["sessionstate"] != "InProc")
|
||||
if (Session["CurrentUserId"] != null)
|
||||
{
|
||||
// ((ArrayList)Application["userlst"]).Remove(Session["CurrentUserAccount"].ToString());
|
||||
myLog.RequestLog logobj = new myLog.RequestLog();
|
||||
logobj.LogoutLog(int.Parse(Session["CurrentUserId"].ToString()));
|
||||
}
|
||||
}
|
||||
Session.Abandon(); //清空Session, all sessions will be clear ? no kiding, it will obsolete the current session.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Web.UI;
|
||||
using ZhangPu.Gov.Logical;
|
||||
|
||||
/// <summary>
|
||||
/// PagePublic 的摘要说明
|
||||
/// </summary>
|
||||
public class PagePublic : Page
|
||||
{
|
||||
protected LEmployee lem;
|
||||
protected const string DefaultPage = "~/index.aspx";
|
||||
protected const string HomePage = "~/Desktop.aspx";
|
||||
protected myLog.RequestLog logobj;
|
||||
public PagePublic()
|
||||
{
|
||||
|
||||
}
|
||||
protected override void OnPreInit(EventArgs e)
|
||||
{
|
||||
lem = (LEmployee)Session["CurrentUser"];
|
||||
|
||||
base.OnPreInit(e);
|
||||
logobj = new myLog.RequestLog();
|
||||
logobj.RequestPageLog();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
using System.Web;
|
||||
using System.Web.Caching;
|
||||
using System.Web.SessionState;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace view.App_Code
|
||||
{
|
||||
/// <summary>
|
||||
/// When an ASP.NET State Server other than InProc, the Session_End event
|
||||
/// does not get fired. This is an HttpModule which uses some workarounds
|
||||
/// and fires a static event when a session ends, with the value of a single
|
||||
/// configurable session variable in the event arguments.
|
||||
/// </summary>
|
||||
public class SessionEndModule : IHttpModule
|
||||
{
|
||||
#region Private Variables
|
||||
|
||||
private HttpApplication m_HttpApplication;
|
||||
private static string m_SessionObjectKey;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// This is the key of the item in the session which should be returned
|
||||
/// in the SessionEnd event (as the SessionObject).
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// If you're storing the user ID in the session, under a key called 'UserId'
|
||||
/// and need to do something with it in the SessionEnd event, you would set
|
||||
/// this to 'UserId', which would cause the value of the session key called
|
||||
/// 'UserId' to be returned.
|
||||
/// </example>
|
||||
public static string SessionObjectKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SessionObjectKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SessionObjectKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IHttpModule Implementation
|
||||
|
||||
public void Init(HttpApplication context)
|
||||
{
|
||||
m_HttpApplication = context;
|
||||
m_HttpApplication.PreRequestHandlerExecute += new EventHandler(OnPreRequestHandlerExecute);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Do Nothing
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Event raised when the session ends
|
||||
/// </summary>
|
||||
public static event SessionEndEventHandler SessionEnd;
|
||||
|
||||
#endregion
|
||||
|
||||
private void OnPreRequestHandlerExecute(object sender, EventArgs e)
|
||||
{
|
||||
// We only want to update the session when an ASPX page is being viewed
|
||||
// We're also doing this in the PreRequestHandler, as doing it elsewhere
|
||||
// (like the PostRequestHandler) can cause some strange behaviour.
|
||||
|
||||
if (Path.GetExtension(m_HttpApplication.Context.Request.Path).ToLower() == ".aspx")
|
||||
{
|
||||
// Ensure we have a HttpContext
|
||||
if (HttpContext.Current == null)
|
||||
{
|
||||
Debug.WriteLine("No current http context");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the current session
|
||||
HttpSessionState currentSession = HttpContext.Current.Session;
|
||||
|
||||
// Ensure we have a current session
|
||||
if (currentSession == null)
|
||||
{
|
||||
Debug.WriteLine("No current session");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the session timeout
|
||||
TimeSpan sessionTimeout = new TimeSpan(0, 0, currentSession.Timeout, 0, 0);
|
||||
|
||||
// Get the object in the session we want to retrieve when the session times out
|
||||
object sessionObject = currentSession[SessionObjectKey];
|
||||
|
||||
// Add the object to the cache with the current session id, and set a cache removal callback method
|
||||
HttpContext.Current.Cache.Insert(currentSession.SessionID, sessionObject, null, DateTime.MaxValue, sessionTimeout, CacheItemPriority.NotRemovable, CacheItemRemovedCallbackMethod);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is fired when an item is removed from the cache. It is used to detect when a cache item
|
||||
/// expires, indicating that the session has expired, and fires the SessionEnd event.
|
||||
/// </summary>
|
||||
private void CacheItemRemovedCallbackMethod(string key, object value, CacheItemRemovedReason reason)
|
||||
{
|
||||
if (reason == CacheItemRemovedReason.Expired)
|
||||
{
|
||||
if (SessionEnd != null)
|
||||
{
|
||||
SessionEndedEventArgs e = new SessionEndedEventArgs(key, value);
|
||||
SessionEnd(this, e);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for handling the SessionEnd event
|
||||
/// </summary>
|
||||
public delegate void SessionEndEventHandler(object sender, SessionEndedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// SessionEndedEventArgs for use in the SessionEnd event
|
||||
/// </summary>
|
||||
public class SessionEndedEventArgs : EventArgs
|
||||
{
|
||||
public readonly string SessionId;
|
||||
public readonly object SessionObject;
|
||||
|
||||
public SessionEndedEventArgs(string sessionId, object sessionObject)
|
||||
{
|
||||
SessionId = sessionId;
|
||||
SessionObject = sessionObject;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
|
||||
namespace view.App_Code
|
||||
{
|
||||
/// <summary>
|
||||
/// utils 的摘要说明
|
||||
/// </summary>
|
||||
public class ExcelExp
|
||||
{
|
||||
public ExcelExp()
|
||||
{
|
||||
//
|
||||
// TODO: 在此处添加构造函数逻辑
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
public static void Export(GridView GridView1, DataView dv ,ScriptManager sm,Control Button1,string fileName, Page page )
|
||||
{
|
||||
sm.RegisterPostBackControl(Button1);
|
||||
GridView1.AllowPaging = false;
|
||||
GridView1.Columns[GridView1.Columns.Count-1].Visible = false;
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
|
||||
|
||||
HttpContext.Current.Response.Charset = "GB2312";
|
||||
HttpContext.Current.Response.ContentEncoding = Encoding.UTF7;
|
||||
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName + ".xls", Encoding.UTF8).ToString());
|
||||
HttpContext.Current.Response.ContentType = "application/ms-excel";
|
||||
page.EnableViewState = false;
|
||||
StringWriter tw = new StringWriter();
|
||||
HtmlTextWriter hw = new HtmlTextWriter(tw);
|
||||
GridView1.RenderControl(hw);
|
||||
HttpContext.Current.Response.Write(tw.ToString());
|
||||
HttpContext.Current.Response.End();
|
||||
|
||||
GridView1.AllowPaging = false;
|
||||
GridView1.Columns[GridView1.Columns.Count - 1].Visible = true;
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using DeiNiu.wms.Logical;
|
||||
|
||||
/// <summary>
|
||||
/// utils 的摘要说明
|
||||
/// </summary>
|
||||
public class PageBase : PagePublic
|
||||
{
|
||||
public PageBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// protected LEmployee lem;
|
||||
// const string DefaultPage = "~/index.aspx";
|
||||
// const string HomePage = "~/Desktop.aspx";
|
||||
|
||||
public void CheckAuthority()
|
||||
{
|
||||
if (checkCloseIE()) return;
|
||||
|
||||
string requestPage = Request.AppRelativeCurrentExecutionFilePath + Request.Url.Query;
|
||||
requestPage = requestPage.ToUpper();
|
||||
// if (DefaultPage.Equals(requestPage)) return; //起始页不做判断
|
||||
if (DefaultPage.ToUpper() == requestPage) return; //起始页不做判断
|
||||
|
||||
if (lem == null)
|
||||
{
|
||||
//logobj.LoginLog(string.Empty,"lem is null");
|
||||
Response.Redirect(DefaultPage);
|
||||
}
|
||||
if (HomePage.ToUpper() == requestPage) return;
|
||||
if (lem.GetEmployee.em_account == "Root") //内建管理员
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (lem.AuthList.Contains(requestPage)) return;
|
||||
if (!new LRoleAuthority().GetPublicAuthorityList().Contains(requestPage))
|
||||
{
|
||||
// logobj.RequestPageLog();
|
||||
|
||||
// logobj.LoginLog(lem.GetEmployee.em_account ,"NoAccess!");
|
||||
|
||||
Response.Redirect(DefaultPage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override void OnPreInit(EventArgs e)
|
||||
{
|
||||
|
||||
base.OnPreInit(e);
|
||||
|
||||
CheckAuthority();
|
||||
|
||||
}
|
||||
bool checkCloseIE()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Request.QueryString["___command"]))
|
||||
{
|
||||
string cmd = Request.QueryString["___command"];
|
||||
if (cmd == "ClearSession")
|
||||
{
|
||||
if ((Session["CurrentUser"] != null))
|
||||
{
|
||||
|
||||
if (System.Configuration.ConfigurationManager.AppSettings["sessionstate"] != "InProc")
|
||||
if (Session["CurrentUserId"] != null)
|
||||
{
|
||||
// ((ArrayList)Application["userlst"]).Remove(Session["CurrentUserAccount"].ToString());
|
||||
DeiNiu.RequestLog logobj = new DeiNiu.RequestLog();
|
||||
// logobj.LogoutLog(int.Parse(Session["CurrentUserId"].ToString()));
|
||||
}
|
||||
}
|
||||
Session.Abandon(); //清空Session, all sessions will be clear ? no kiding, it will obsolete the current session.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Web.UI;
|
||||
using DeiNiu.wms.Logical;
|
||||
|
||||
/// <summary>
|
||||
/// PagePublic 的摘要说明
|
||||
/// </summary>
|
||||
public class PagePublic : Page
|
||||
{
|
||||
protected LEmployee lem;
|
||||
protected const string DefaultPage = "~/index.aspx";
|
||||
protected const string HomePage = "~/Desktop.aspx";
|
||||
protected DeiNiu.RequestLog logobj;
|
||||
public PagePublic()
|
||||
{
|
||||
|
||||
}
|
||||
protected override void OnPreInit(EventArgs e)
|
||||
{
|
||||
lem = (LEmployee)Session["CurrentUser"];
|
||||
|
||||
base.OnPreInit(e);
|
||||
logobj = new DeiNiu.RequestLog();
|
||||
logobj.RequestPageLog();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
using System.Web;
|
||||
using System.Web.Caching;
|
||||
using System.Web.SessionState;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace view.App_Code
|
||||
{
|
||||
/// <summary>
|
||||
/// When an ASP.NET State Server other than InProc, the Session_End event
|
||||
/// does not get fired. This is an HttpModule which uses some workarounds
|
||||
/// and fires a static event when a session ends, with the value of a single
|
||||
/// configurable session variable in the event arguments.
|
||||
/// </summary>
|
||||
public class SessionEndModule : IHttpModule
|
||||
{
|
||||
#region Private Variables
|
||||
|
||||
private HttpApplication m_HttpApplication;
|
||||
private static string m_SessionObjectKey;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// This is the key of the item in the session which should be returned
|
||||
/// in the SessionEnd event (as the SessionObject).
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// If you're storing the user ID in the session, under a key called 'UserId'
|
||||
/// and need to do something with it in the SessionEnd event, you would set
|
||||
/// this to 'UserId', which would cause the value of the session key called
|
||||
/// 'UserId' to be returned.
|
||||
/// </example>
|
||||
public static string SessionObjectKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SessionObjectKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SessionObjectKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IHttpModule Implementation
|
||||
|
||||
public void Init(HttpApplication context)
|
||||
{
|
||||
m_HttpApplication = context;
|
||||
m_HttpApplication.PreRequestHandlerExecute += new EventHandler(OnPreRequestHandlerExecute);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Do Nothing
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Event raised when the session ends
|
||||
/// </summary>
|
||||
public static event SessionEndEventHandler SessionEnd;
|
||||
|
||||
#endregion
|
||||
|
||||
private void OnPreRequestHandlerExecute(object sender, EventArgs e)
|
||||
{
|
||||
// We only want to update the session when an ASPX page is being viewed
|
||||
// We're also doing this in the PreRequestHandler, as doing it elsewhere
|
||||
// (like the PostRequestHandler) can cause some strange behaviour.
|
||||
|
||||
if (Path.GetExtension(m_HttpApplication.Context.Request.Path).ToLower() == ".aspx")
|
||||
{
|
||||
// Ensure we have a HttpContext
|
||||
if (HttpContext.Current == null)
|
||||
{
|
||||
Debug.WriteLine("No current http context");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the current session
|
||||
HttpSessionState currentSession = HttpContext.Current.Session;
|
||||
|
||||
// Ensure we have a current session
|
||||
if (currentSession == null)
|
||||
{
|
||||
Debug.WriteLine("No current session");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the session timeout
|
||||
TimeSpan sessionTimeout = new TimeSpan(0, 0, currentSession.Timeout, 0, 0);
|
||||
|
||||
// Get the object in the session we want to retrieve when the session times out
|
||||
object sessionObject = currentSession[SessionObjectKey];
|
||||
|
||||
// Add the object to the cache with the current session id, and set a cache removal callback method
|
||||
HttpContext.Current.Cache.Insert(currentSession.SessionID, sessionObject, null, DateTime.MaxValue, sessionTimeout, CacheItemPriority.NotRemovable, CacheItemRemovedCallbackMethod);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is fired when an item is removed from the cache. It is used to detect when a cache item
|
||||
/// expires, indicating that the session has expired, and fires the SessionEnd event.
|
||||
/// </summary>
|
||||
private void CacheItemRemovedCallbackMethod(string key, object value, CacheItemRemovedReason reason)
|
||||
{
|
||||
if (reason == CacheItemRemovedReason.Expired)
|
||||
{
|
||||
if (SessionEnd != null)
|
||||
{
|
||||
SessionEndedEventArgs e = new SessionEndedEventArgs(key, value);
|
||||
SessionEnd(this, e);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for handling the SessionEnd event
|
||||
/// </summary>
|
||||
public delegate void SessionEndEventHandler(object sender, SessionEndedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// SessionEndedEventArgs for use in the SessionEnd event
|
||||
/// </summary>
|
||||
public class SessionEndedEventArgs : EventArgs
|
||||
{
|
||||
public readonly string SessionId;
|
||||
public readonly object SessionObject;
|
||||
|
||||
public SessionEndedEventArgs(string sessionId, object sessionObject)
|
||||
{
|
||||
SessionId = sessionId;
|
||||
SessionObject = sessionObject;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
10
|
||||
|
||||
dir
|
||||
8
|
||||
file:///D:/Repositories/ZhangPu/trunk/view/App_Code
|
||||
file:///D:/Repositories/ZhangPu
|
||||
|
||||
|
||||
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
69712cd5-45d9-e244-acd6-b3e9c1159652
|
||||
|
||||
PagePublic.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:10.289868Z
|
||||
88adefccb355a757a198d9d5710b8905
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
637
|
||||
|
||||
ExcelExp.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:10.305493Z
|
||||
622cd19125108d2405c68fbaa5dd594a
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1888
|
||||
|
||||
SessionEndModule.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:10.305493Z
|
||||
afc00bfe8b5a4c00a5defa6a1221b0fb
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
5243
|
||||
|
||||
PageBase.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:10.321118Z
|
||||
ada92b7d54cfb24aba200636f6b94af8
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2850
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
|
||||
namespace view.App_Code
|
||||
{
|
||||
/// <summary>
|
||||
/// utils 的摘要说明
|
||||
/// </summary>
|
||||
public class ExcelExp
|
||||
{
|
||||
public ExcelExp()
|
||||
{
|
||||
//
|
||||
// TODO: 在此处添加构造函数逻辑
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
public static void Export(GridView GridView1, DataView dv ,ScriptManager sm,Control Button1,string fileName, Page page )
|
||||
{
|
||||
sm.RegisterPostBackControl(Button1);
|
||||
GridView1.AllowPaging = false;
|
||||
GridView1.Columns[GridView1.Columns.Count-1].Visible = false;
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
|
||||
|
||||
HttpContext.Current.Response.Charset = "GB2312";
|
||||
HttpContext.Current.Response.ContentEncoding = Encoding.UTF7;
|
||||
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName + ".xls", Encoding.UTF8).ToString());
|
||||
HttpContext.Current.Response.ContentType = "application/ms-excel";
|
||||
page.EnableViewState = false;
|
||||
StringWriter tw = new StringWriter();
|
||||
HtmlTextWriter hw = new HtmlTextWriter(tw);
|
||||
GridView1.RenderControl(hw);
|
||||
HttpContext.Current.Response.Write(tw.ToString());
|
||||
HttpContext.Current.Response.End();
|
||||
|
||||
GridView1.AllowPaging = false;
|
||||
GridView1.Columns[GridView1.Columns.Count - 1].Visible = true;
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using ZhangPu.Gov.Logical;
|
||||
|
||||
/// <summary>
|
||||
/// utils 的摘要说明
|
||||
/// </summary>
|
||||
public class PageBase : PagePublic
|
||||
{
|
||||
public PageBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// protected LEmployee lem;
|
||||
// const string DefaultPage = "~/index.aspx";
|
||||
// const string HomePage = "~/Desktop.aspx";
|
||||
|
||||
public void CheckAuthority()
|
||||
{
|
||||
if (checkCloseIE()) return;
|
||||
|
||||
string requestPage = Request.AppRelativeCurrentExecutionFilePath + Request.Url.Query;
|
||||
requestPage = requestPage.ToUpper();
|
||||
// if (DefaultPage.Equals(requestPage)) return; //起始页不做判断
|
||||
if (DefaultPage.ToUpper() == requestPage) return; //起始页不做判断
|
||||
|
||||
if (lem == null)
|
||||
{
|
||||
logobj.LoginLog(string.Empty,"lem is null");
|
||||
Response.Redirect(DefaultPage);
|
||||
}
|
||||
if (HomePage.ToUpper() == requestPage) return;
|
||||
if (lem.GetEmployee.em_account == "Root") //内建管理员
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (lem.AuthList.Contains(requestPage)) return;
|
||||
if (!new LRoleAuthority().GetPublicAuthorityList().Contains(requestPage))
|
||||
{
|
||||
logobj.RequestPageLog();
|
||||
|
||||
logobj.LoginLog(lem.GetEmployee.em_account ,"NoAccess!");
|
||||
|
||||
Response.Redirect(DefaultPage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override void OnPreInit(EventArgs e)
|
||||
{
|
||||
|
||||
base.OnPreInit(e);
|
||||
|
||||
CheckAuthority();
|
||||
|
||||
}
|
||||
bool checkCloseIE()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Request.QueryString["___command"]))
|
||||
{
|
||||
string cmd = Request.QueryString["___command"];
|
||||
if (cmd == "ClearSession")
|
||||
{
|
||||
if ((Session["CurrentUser"] != null))
|
||||
{
|
||||
|
||||
if (System.Configuration.ConfigurationManager.AppSettings["sessionstate"] != "InProc")
|
||||
if (Session["CurrentUserId"] != null)
|
||||
{
|
||||
// ((ArrayList)Application["userlst"]).Remove(Session["CurrentUserAccount"].ToString());
|
||||
myLog.RequestLog logobj = new myLog.RequestLog();
|
||||
logobj.LogoutLog(int.Parse(Session["CurrentUserId"].ToString()));
|
||||
}
|
||||
}
|
||||
Session.Abandon(); //清空Session, all sessions will be clear ? no kiding, it will obsolete the current session.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Web.UI;
|
||||
using ZhangPu.Gov.Logical;
|
||||
|
||||
/// <summary>
|
||||
/// PagePublic 的摘要说明
|
||||
/// </summary>
|
||||
public class PagePublic : Page
|
||||
{
|
||||
protected LEmployee lem;
|
||||
protected const string DefaultPage = "~/index.aspx";
|
||||
protected const string HomePage = "~/Desktop.aspx";
|
||||
protected myLog.RequestLog logobj;
|
||||
public PagePublic()
|
||||
{
|
||||
|
||||
}
|
||||
protected override void OnPreInit(EventArgs e)
|
||||
{
|
||||
lem = (LEmployee)Session["CurrentUser"];
|
||||
|
||||
base.OnPreInit(e);
|
||||
logobj = new myLog.RequestLog();
|
||||
logobj.RequestPageLog();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
using System.Web;
|
||||
using System.Web.Caching;
|
||||
using System.Web.SessionState;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace view.App_Code
|
||||
{
|
||||
/// <summary>
|
||||
/// When an ASP.NET State Server other than InProc, the Session_End event
|
||||
/// does not get fired. This is an HttpModule which uses some workarounds
|
||||
/// and fires a static event when a session ends, with the value of a single
|
||||
/// configurable session variable in the event arguments.
|
||||
/// </summary>
|
||||
public class SessionEndModule : IHttpModule
|
||||
{
|
||||
#region Private Variables
|
||||
|
||||
private HttpApplication m_HttpApplication;
|
||||
private static string m_SessionObjectKey;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// This is the key of the item in the session which should be returned
|
||||
/// in the SessionEnd event (as the SessionObject).
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// If you're storing the user ID in the session, under a key called 'UserId'
|
||||
/// and need to do something with it in the SessionEnd event, you would set
|
||||
/// this to 'UserId', which would cause the value of the session key called
|
||||
/// 'UserId' to be returned.
|
||||
/// </example>
|
||||
public static string SessionObjectKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SessionObjectKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SessionObjectKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IHttpModule Implementation
|
||||
|
||||
public void Init(HttpApplication context)
|
||||
{
|
||||
m_HttpApplication = context;
|
||||
m_HttpApplication.PreRequestHandlerExecute += new EventHandler(OnPreRequestHandlerExecute);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Do Nothing
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Event raised when the session ends
|
||||
/// </summary>
|
||||
public static event SessionEndEventHandler SessionEnd;
|
||||
|
||||
#endregion
|
||||
|
||||
private void OnPreRequestHandlerExecute(object sender, EventArgs e)
|
||||
{
|
||||
// We only want to update the session when an ASPX page is being viewed
|
||||
// We're also doing this in the PreRequestHandler, as doing it elsewhere
|
||||
// (like the PostRequestHandler) can cause some strange behaviour.
|
||||
|
||||
if (Path.GetExtension(m_HttpApplication.Context.Request.Path).ToLower() == ".aspx")
|
||||
{
|
||||
// Ensure we have a HttpContext
|
||||
if (HttpContext.Current == null)
|
||||
{
|
||||
Debug.WriteLine("No current http context");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the current session
|
||||
HttpSessionState currentSession = HttpContext.Current.Session;
|
||||
|
||||
// Ensure we have a current session
|
||||
if (currentSession == null)
|
||||
{
|
||||
Debug.WriteLine("No current session");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the session timeout
|
||||
TimeSpan sessionTimeout = new TimeSpan(0, 0, currentSession.Timeout, 0, 0);
|
||||
|
||||
// Get the object in the session we want to retrieve when the session times out
|
||||
object sessionObject = currentSession[SessionObjectKey];
|
||||
|
||||
// Add the object to the cache with the current session id, and set a cache removal callback method
|
||||
HttpContext.Current.Cache.Insert(currentSession.SessionID, sessionObject, null, DateTime.MaxValue, sessionTimeout, CacheItemPriority.NotRemovable, CacheItemRemovedCallbackMethod);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is fired when an item is removed from the cache. It is used to detect when a cache item
|
||||
/// expires, indicating that the session has expired, and fires the SessionEnd event.
|
||||
/// </summary>
|
||||
private void CacheItemRemovedCallbackMethod(string key, object value, CacheItemRemovedReason reason)
|
||||
{
|
||||
if (reason == CacheItemRemovedReason.Expired)
|
||||
{
|
||||
if (SessionEnd != null)
|
||||
{
|
||||
SessionEndedEventArgs e = new SessionEndedEventArgs(key, value);
|
||||
SessionEnd(this, e);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for handling the SessionEnd event
|
||||
/// </summary>
|
||||
public delegate void SessionEndEventHandler(object sender, SessionEndedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// SessionEndedEventArgs for use in the SessionEnd event
|
||||
/// </summary>
|
||||
public class SessionEndedEventArgs : EventArgs
|
||||
{
|
||||
public readonly string SessionId;
|
||||
public readonly object SessionObject;
|
||||
|
||||
public SessionEndedEventArgs(string sessionId, object sessionObject)
|
||||
{
|
||||
SessionId = sessionId;
|
||||
SessionObject = sessionObject;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
|
||||
namespace view.App_Code
|
||||
{
|
||||
/// <summary>
|
||||
/// utils 的摘要说明
|
||||
/// </summary>
|
||||
public class ExcelExp
|
||||
{
|
||||
public ExcelExp()
|
||||
{
|
||||
//
|
||||
// TODO: 在此处添加构造函数逻辑
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
public static void Export(GridView GridView1, DataView dv ,ScriptManager sm,Control Button1,string fileName, Page page )
|
||||
{
|
||||
sm.RegisterPostBackControl(Button1);
|
||||
GridView1.AllowPaging = false;
|
||||
GridView1.Columns[GridView1.Columns.Count-1].Visible = false;
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
|
||||
|
||||
HttpContext.Current.Response.Charset = "GB2312";
|
||||
HttpContext.Current.Response.ContentEncoding = Encoding.UTF7;
|
||||
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName + ".xls", Encoding.UTF8).ToString());
|
||||
HttpContext.Current.Response.ContentType = "application/ms-excel";
|
||||
page.EnableViewState = false;
|
||||
StringWriter tw = new StringWriter();
|
||||
HtmlTextWriter hw = new HtmlTextWriter(tw);
|
||||
GridView1.RenderControl(hw);
|
||||
HttpContext.Current.Response.Write(tw.ToString());
|
||||
HttpContext.Current.Response.End();
|
||||
|
||||
GridView1.AllowPaging = false;
|
||||
GridView1.Columns[GridView1.Columns.Count - 1].Visible = true;
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using DeiNiu.wms.Logical;
|
||||
|
||||
/// <summary>
|
||||
/// utils 的摘要说明
|
||||
/// </summary>
|
||||
public class PageBase : PagePublic
|
||||
{
|
||||
public PageBase()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// protected LEmployee lem;
|
||||
// const string DefaultPage = "~/index.aspx";
|
||||
// const string HomePage = "~/Desktop.aspx";
|
||||
|
||||
public void CheckAuthority()
|
||||
{
|
||||
if (checkCloseIE()) return;
|
||||
|
||||
string requestPage = Request.AppRelativeCurrentExecutionFilePath + Request.Url.Query;
|
||||
requestPage = requestPage.ToUpper();
|
||||
// if (DefaultPage.Equals(requestPage)) return; //起始页不做判断
|
||||
if (DefaultPage.ToUpper() == requestPage) return; //起始页不做判断
|
||||
|
||||
if (lem == null)
|
||||
{
|
||||
logobj.LoginLog(string.Empty,"lem is null");
|
||||
Response.Redirect(DefaultPage);
|
||||
}
|
||||
if (HomePage.ToUpper() == requestPage) return;
|
||||
if (lem.GetEmployee.em_account == "Root") //内建管理员
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (lem.AuthList.Contains(requestPage)) return;
|
||||
if (!new LRoleAuthority().GetPublicAuthorityList().Contains(requestPage))
|
||||
{
|
||||
logobj.RequestPageLog();
|
||||
|
||||
logobj.LoginLog(lem.GetEmployee.em_account ,"NoAccess!");
|
||||
|
||||
Response.Redirect(DefaultPage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override void OnPreInit(EventArgs e)
|
||||
{
|
||||
|
||||
base.OnPreInit(e);
|
||||
|
||||
CheckAuthority();
|
||||
|
||||
}
|
||||
bool checkCloseIE()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Request.QueryString["___command"]))
|
||||
{
|
||||
string cmd = Request.QueryString["___command"];
|
||||
if (cmd == "ClearSession")
|
||||
{
|
||||
if ((Session["CurrentUser"] != null))
|
||||
{
|
||||
|
||||
if (System.Configuration.ConfigurationManager.AppSettings["sessionstate"] != "InProc")
|
||||
if (Session["CurrentUserId"] != null)
|
||||
{
|
||||
// ((ArrayList)Application["userlst"]).Remove(Session["CurrentUserAccount"].ToString());
|
||||
DeiNiu.RequestLog logobj = new DeiNiu.RequestLog();
|
||||
logobj.LogoutLog(int.Parse(Session["CurrentUserId"].ToString()));
|
||||
}
|
||||
}
|
||||
Session.Abandon(); //清空Session, all sessions will be clear ? no kiding, it will obsolete the current session.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Web.UI;
|
||||
using DeiNiu.wms.Logical;
|
||||
|
||||
/// <summary>
|
||||
/// PagePublic 的摘要说明
|
||||
/// </summary>
|
||||
public class PagePublic : Page
|
||||
{
|
||||
protected LEmployee lem;
|
||||
protected const string DefaultPage = "~/index.aspx";
|
||||
protected const string HomePage = "~/Desktop.aspx";
|
||||
protected DeiNiu.RequestLog logobj;
|
||||
public PagePublic()
|
||||
{
|
||||
|
||||
}
|
||||
protected override void OnPreInit(EventArgs e)
|
||||
{
|
||||
lem = (LEmployee)Session["CurrentUser"];
|
||||
|
||||
base.OnPreInit(e);
|
||||
logobj = new DeiNiu.RequestLog();
|
||||
logobj.RequestPageLog();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
using System.Web;
|
||||
using System.Web.Caching;
|
||||
using System.Web.SessionState;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace view.App_Code
|
||||
{
|
||||
/// <summary>
|
||||
/// When an ASP.NET State Server other than InProc, the Session_End event
|
||||
/// does not get fired. This is an HttpModule which uses some workarounds
|
||||
/// and fires a static event when a session ends, with the value of a single
|
||||
/// configurable session variable in the event arguments.
|
||||
/// </summary>
|
||||
public class SessionEndModule : IHttpModule
|
||||
{
|
||||
#region Private Variables
|
||||
|
||||
private HttpApplication m_HttpApplication;
|
||||
private static string m_SessionObjectKey;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Accessors
|
||||
|
||||
/// <summary>
|
||||
/// This is the key of the item in the session which should be returned
|
||||
/// in the SessionEnd event (as the SessionObject).
|
||||
/// </summary>
|
||||
/// <example>
|
||||
/// If you're storing the user ID in the session, under a key called 'UserId'
|
||||
/// and need to do something with it in the SessionEnd event, you would set
|
||||
/// this to 'UserId', which would cause the value of the session key called
|
||||
/// 'UserId' to be returned.
|
||||
/// </example>
|
||||
public static string SessionObjectKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_SessionObjectKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_SessionObjectKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IHttpModule Implementation
|
||||
|
||||
public void Init(HttpApplication context)
|
||||
{
|
||||
m_HttpApplication = context;
|
||||
m_HttpApplication.PreRequestHandlerExecute += new EventHandler(OnPreRequestHandlerExecute);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Do Nothing
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
/// <summary>
|
||||
/// Event raised when the session ends
|
||||
/// </summary>
|
||||
public static event SessionEndEventHandler SessionEnd;
|
||||
|
||||
#endregion
|
||||
|
||||
private void OnPreRequestHandlerExecute(object sender, EventArgs e)
|
||||
{
|
||||
// We only want to update the session when an ASPX page is being viewed
|
||||
// We're also doing this in the PreRequestHandler, as doing it elsewhere
|
||||
// (like the PostRequestHandler) can cause some strange behaviour.
|
||||
|
||||
if (Path.GetExtension(m_HttpApplication.Context.Request.Path).ToLower() == ".aspx")
|
||||
{
|
||||
// Ensure we have a HttpContext
|
||||
if (HttpContext.Current == null)
|
||||
{
|
||||
Debug.WriteLine("No current http context");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the current session
|
||||
HttpSessionState currentSession = HttpContext.Current.Session;
|
||||
|
||||
// Ensure we have a current session
|
||||
if (currentSession == null)
|
||||
{
|
||||
Debug.WriteLine("No current session");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the session timeout
|
||||
TimeSpan sessionTimeout = new TimeSpan(0, 0, currentSession.Timeout, 0, 0);
|
||||
|
||||
// Get the object in the session we want to retrieve when the session times out
|
||||
object sessionObject = currentSession[SessionObjectKey];
|
||||
|
||||
// Add the object to the cache with the current session id, and set a cache removal callback method
|
||||
HttpContext.Current.Cache.Insert(currentSession.SessionID, sessionObject, null, DateTime.MaxValue, sessionTimeout, CacheItemPriority.NotRemovable, CacheItemRemovedCallbackMethod);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is fired when an item is removed from the cache. It is used to detect when a cache item
|
||||
/// expires, indicating that the session has expired, and fires the SessionEnd event.
|
||||
/// </summary>
|
||||
private void CacheItemRemovedCallbackMethod(string key, object value, CacheItemRemovedReason reason)
|
||||
{
|
||||
if (reason == CacheItemRemovedReason.Expired)
|
||||
{
|
||||
if (SessionEnd != null)
|
||||
{
|
||||
SessionEndedEventArgs e = new SessionEndedEventArgs(key, value);
|
||||
SessionEnd(this, e);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for handling the SessionEnd event
|
||||
/// </summary>
|
||||
public delegate void SessionEndEventHandler(object sender, SessionEndedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// SessionEndedEventArgs for use in the SessionEnd event
|
||||
/// </summary>
|
||||
public class SessionEndedEventArgs : EventArgs
|
||||
{
|
||||
public readonly string SessionId;
|
||||
public readonly object SessionObject;
|
||||
|
||||
public SessionEndedEventArgs(string sessionId, object sessionObject)
|
||||
{
|
||||
SessionId = sessionId;
|
||||
SessionObject = sessionObject;
|
||||
}
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 525 KiB |
After Width: | Height: | Size: 525 KiB |
After Width: | Height: | Size: 1.8 MiB |
After Width: | Height: | Size: 525 KiB |
After Width: | Height: | Size: 525 KiB |
After Width: | Height: | Size: 3.7 MiB |
After Width: | Height: | Size: 525 KiB |
After Width: | Height: | Size: 1.0 MiB |
After Width: | Height: | Size: 2.3 MiB |
|
@ -0,0 +1,14 @@
|
|||
<%@ Page Language="C#" MasterPageFile="~/masterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>
|
||||
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<asp:TextBox id="TextBox11" runat="server" Visible ="false">
|
||||
</asp:TextBox>
|
||||
<asp:TextBox id="TextBox12" runat="server" Visible ="false">
|
||||
</asp:TextBox>
|
||||
<asp:Button id="Button1" runat="server" OnClick="Button1_Click" Text="Button" Visible ="false" />
|
||||
<cc1:calendarextender id="CalendarExtender11" runat="server" targetcontrolid="TextBox11"></cc1:calendarextender>
|
||||
<cc1:calendarextender id="CalendarExtender12" runat="server" cssclass="MyCalendar"
|
||||
firstdayofweek="Monday" targetcontrolid="TextBox12"></cc1:calendarextender>
|
||||
</asp:Content>
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
|
||||
public partial class _Default : System.Web.UI.Page
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect("index.aspx",true);
|
||||
}
|
||||
protected void Button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
if ((Session["CurrentUser"] != null))
|
||||
{
|
||||
|
||||
if (System.Configuration.ConfigurationManager.AppSettings["sessionstate"] != "InProc")
|
||||
if (Session["CurrentUserId"] != null)
|
||||
{
|
||||
// ((ArrayList)Application["userlst"]).Remove(Session["CurrentUserAccount"].ToString());abc
|
||||
DeiNiu.RequestLog logobj = new DeiNiu.RequestLog();
|
||||
logobj.LogoutLog(int.Parse(Session["CurrentUserId"].ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,194 @@
|
|||
<%@ Page Language="C#" MasterPageFile="~/masterPage.master" AutoEventWireup="true" ClassName="Desktop"
|
||||
CodeFile="Desktop.aspx.cs" Inherits="Desktop" %>
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<table class="Table_NoBorder" width="100%">
|
||||
|
||||
<tr>
|
||||
<td colspan="2" align="left">
|
||||
<asp:Label ID="Label5" runat="server" CssClass="Label" Text='系统提示板'></asp:Label></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2" align="left" style="height: 12px">
|
||||
<asp:Label ID="Label4" runat="server" CssClass="Label" Text='工作计划'></asp:Label></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<table class="Table_Border" width="100%" border="0">
|
||||
<tr class="HeaderStyle">
|
||||
<td>
|
||||
<asp:Label ID="lbToday" runat="server" CssClass="Label" Text="今天"></asp:Label></td>
|
||||
<td>
|
||||
<asp:Label ID="lbTomorrow" runat="server" CssClass="Label" Text="明天"></asp:Label></td>
|
||||
<td>
|
||||
<asp:Label ID="lbafterTomorrow" runat="server" CssClass="Label" Text="后天"></asp:Label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="33%" valign="top">
|
||||
<asp:GridView ID="gvWorkplan1" runat="server" AutoGenerateColumns="False" CssClass="DataGrid"
|
||||
DataKeyNames="ID" EmptyDataText="没有数据。" PagerStyle-HorizontalAlign="Right"
|
||||
ShowFooter="True" Width="100%">
|
||||
<Columns>
|
||||
<asp:BoundField Visible="false" DataField="ID" SortExpression="ID"
|
||||
HeaderText="workplanid"></asp:BoundField>
|
||||
<asp:BoundField Visible="false" DataField="wpd_workplan" SortExpression="wpd_workplan"
|
||||
HeaderText="wpd_workplanid"></asp:BoundField>
|
||||
<asp:BoundField DataField="wpd_number" SortExpression="wpd_number" HeaderText="序号">
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="wpd_content" SortExpression="wpd_content" HeaderText="计划内容">
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="wpd_mem" SortExpression="wpd_mem" HeaderText="计划说明">
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
</Columns>
|
||||
<RowStyle CssClass="ItemStyle" HorizontalAlign="Center" />
|
||||
<EmptyDataTemplate>
|
||||
没有可显示的工作计划
|
||||
</EmptyDataTemplate>
|
||||
<SelectedRowStyle CssClass="SelectedItemStyle" />
|
||||
<PagerStyle HorizontalAlign="Right" />
|
||||
<HeaderStyle CssClass="HeaderStyle" HorizontalAlign="Center" />
|
||||
<AlternatingRowStyle CssClass="AlternatingItemStyle" />
|
||||
</asp:GridView>
|
||||
</td>
|
||||
<td width="33%" valign="top">
|
||||
<asp:GridView ID="gvWorkplan2" runat="server" AutoGenerateColumns="False" CssClass="DataGrid"
|
||||
DataKeyNames="ID" EmptyDataText="没有数据。" PagerStyle-HorizontalAlign="Right"
|
||||
ShowFooter="True" Width="100%">
|
||||
<Columns>
|
||||
<asp:BoundField Visible="false" DataField="ID" SortExpression="ID"
|
||||
HeaderText="workplanid"></asp:BoundField>
|
||||
<asp:BoundField Visible="false" DataField="wpd_workplan" SortExpression="wpd_workplan"
|
||||
HeaderText="wpd_workplanid">
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="wpd_number" SortExpression="wpd_number" HeaderText="序号">
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="wpd_content" SortExpression="wpd_content" HeaderText="计划内容">
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="wpd_mem" SortExpression="wpd_mem" HeaderText="计划说明">
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
</Columns>
|
||||
<RowStyle CssClass="ItemStyle" HorizontalAlign="Center" />
|
||||
<EmptyDataTemplate>
|
||||
没有可显示的工作计划
|
||||
</EmptyDataTemplate>
|
||||
<SelectedRowStyle CssClass="SelectedItemStyle" />
|
||||
<PagerStyle HorizontalAlign="Right" />
|
||||
<HeaderStyle CssClass="HeaderStyle" HorizontalAlign="Center" />
|
||||
<AlternatingRowStyle CssClass="AlternatingItemStyle" />
|
||||
</asp:GridView>
|
||||
</td>
|
||||
<td width="33%" valign="top">
|
||||
<asp:GridView ID="gvWorkplan3" runat="server" AutoGenerateColumns="False" CssClass="DataGrid"
|
||||
DataKeyNames="ID" EmptyDataText="没有数据。" PagerStyle-HorizontalAlign="Right"
|
||||
ShowFooter="True" Width="100%">
|
||||
<Columns>
|
||||
<asp:BoundField Visible="false" DataField="ID" SortExpression="ID"
|
||||
HeaderText="workplanid"></asp:BoundField>
|
||||
<asp:BoundField Visible="false" DataField="wpd_workplan" SortExpression="wpd_workplan"
|
||||
HeaderText="wpd_workplanid">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="wpd_number" SortExpression="wpd_number" HeaderText="序号">
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="wpd_content" SortExpression="wpd_content" HeaderText="计划内容">
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="wpd_mem" SortExpression="wpd_mem" HeaderText="计划说明">
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
</Columns>
|
||||
<RowStyle CssClass="ItemStyle" HorizontalAlign="Center" />
|
||||
<EmptyDataTemplate>
|
||||
没有可显示的工作计划
|
||||
</EmptyDataTemplate>
|
||||
<SelectedRowStyle CssClass="SelectedItemStyle" />
|
||||
<PagerStyle HorizontalAlign="Right" />
|
||||
<HeaderStyle CssClass="HeaderStyle" HorizontalAlign="Center" />
|
||||
<AlternatingRowStyle CssClass="AlternatingItemStyle" />
|
||||
</asp:GridView>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="ALine">
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="HeaderStyle">
|
||||
<td align="left" width="50%">
|
||||
<asp:Label ID="Label8" runat="server" CssClass="Label" Text='个人信息'></asp:Label></td>
|
||||
<!---td align="left">
|
||||
<asp:Label ID="Label9" runat="server" CssClass="Label" Text='系统信息'></asp:Label></td ---->
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top"><asp:LinkButton ID="lkChgPswd" runat="server" OnClick="lkChgPswd_Click" >修改密码</asp:LinkButton>
|
||||
<div runat="server" id="divPasswdChg" visible="false">
|
||||
<table class="Table_Border" width="50%">
|
||||
<tr>
|
||||
<td nowrap >
|
||||
<asp:Label ID="Label10" runat="server" CssClass="Label" Text="原密码"></asp:Label></td>
|
||||
<td >
|
||||
<asp:TextBox ID="txtOldPasswd" CssClass="TextBox" runat="server" MaxLength="25" TextMode="Password"></asp:TextBox>
|
||||
</td>
|
||||
<td ><asp:Button ID="btn_save" runat="server" Text="修改" CssClass="Button" OnClick="btn_save_Click" />
|
||||
</td>
|
||||
<td > <asp:Label ID="lbPasswdNotice" runat="server" CssClass="Label" Text=""></asp:Label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap > <asp:Label ID="Label11" runat="server" CssClass="Label" Text="新密码"></asp:Label>
|
||||
</td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtNewPasswd" CssClass="TextBox" runat="server" MaxLength="25" TextMode="Password"></asp:TextBox>
|
||||
</td>
|
||||
<td>
|
||||
<asp:Button ID="btn_cancel" runat="server" Text="取消" CssClass="Button" OnClick="btn_cancel_Click" /></td>
|
||||
<td >
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
<td valign="top">
|
||||
|
||||
<asp:LinkButton ID="lkbtnusers" runat="server" OnClick="lkbtnusers_Click">在线用户</asp:LinkButton>
|
||||
<div runat="server" id="divOnlineUsers" visible="false">
|
||||
<table class="Table_Border" width="50%" border="0">
|
||||
<tr>
|
||||
|
||||
<td >
|
||||
<asp:Label ID="lbOnLineUserCnt" runat="server" CssClass="Label" Text=""> </asp:Label>
|
||||
</td>
|
||||
|
||||
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Content>
|
||||
|
|
@ -0,0 +1,298 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using ajax;
|
||||
using DeiNiu.Utils;
|
||||
using DeiNiu.wms.Logical;
|
||||
|
||||
public partial class Desktop : PageBase
|
||||
{
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
bindWorkplan();
|
||||
//bindProjectInfo();
|
||||
//bindTrainingInfo();
|
||||
showOnlineUsers();
|
||||
}
|
||||
|
||||
void bindWorkplan()
|
||||
{
|
||||
LWorkplan wp = new LWorkplan();
|
||||
lbToday.Text = DateTime.Today.ToShortDateString();
|
||||
lbTomorrow.Text = DateTime.Today.AddDays(1).ToShortDateString();
|
||||
lbafterTomorrow.Text = DateTime.Today.AddDays(2).ToShortDateString();
|
||||
gvWorkplan1.DataSource = wp.GetLWorkplan.getWorkplanDetails(lem.GetEmployee.ID, lbToday.Text);
|
||||
gvWorkplan2.DataSource = wp.GetLWorkplan.getWorkplanDetails(lem.GetEmployee.ID, lbTomorrow.Text);
|
||||
gvWorkplan3.DataSource = wp.GetLWorkplan.getWorkplanDetails(lem.GetEmployee.ID, lbafterTomorrow.Text);
|
||||
gvWorkplan3.DataBind();
|
||||
gvWorkplan2.DataBind();
|
||||
gvWorkplan1.DataBind();
|
||||
}
|
||||
/*
|
||||
void bindProjectInfo()
|
||||
{
|
||||
LProject lpj = new LProject();
|
||||
|
||||
//上个月
|
||||
|
||||
|
||||
DataTable lmDt = lpj.GetProject.GetProjects(lem.GetEmployee.ID,DateTime.Now.AddMonths(-1).Year.ToString(),
|
||||
DateTime.Now.AddMonths(-1).Month.ToString()) ;
|
||||
DataView dv = lmDt.DefaultView;
|
||||
//上个月通过数量
|
||||
dv.RowFilter = " pj_status in('" +
|
||||
ProjectStatus.新增审核通过 + "','" + ProjectStatus.项目完成 + "','" + ProjectStatus.删减审核通过 + "')" +
|
||||
" or pd_status in('" + ProjectDetailStatus.审核通过 + "','" + ProjectDetailStatus.考核通过 + "') ";
|
||||
lbLMPassed.Text = dv.Count.ToString();
|
||||
|
||||
//上个月未通过数量
|
||||
dv.RowFilter = " pj_status like '%未通过%' or pd_status like '%未通过%'";
|
||||
lblmFailed.Text = dv.Count.ToString();
|
||||
//上个月待提交数量
|
||||
dv.RowFilter = " pj_status in('" +
|
||||
ProjectStatus.项目已分配 + "','" + ProjectStatus.新增未提交 + "')" +
|
||||
" and pd_status in('" + ProjectDetailStatus.月度未提交 + "') ";
|
||||
lblm4submit.Text = dv.Count.ToString();
|
||||
|
||||
|
||||
|
||||
//上个月得分
|
||||
dv.RowFilter = string.Empty;
|
||||
Double lmscore = 0;
|
||||
for(int i =0;i<lmDt.Rows.Count;i++)
|
||||
{
|
||||
lmscore += Convert.ToDouble(lmDt.Rows[i]["pj_score"]);
|
||||
}
|
||||
|
||||
lblmScore.Text = lmscore.ToString();
|
||||
|
||||
|
||||
//上月待审核
|
||||
lb4preapprove.Text = "0";
|
||||
if (lem.CanShenHe || lem.CanYuShen)
|
||||
{
|
||||
lmDt = lpj.Get4ApproveList(lem.GetCanApproveDeptList(), DateTime.Now.AddMonths(-1).Year.ToString(),
|
||||
DateTime.Now.AddMonths(-1).Month.ToString());
|
||||
dv = lmDt.DefaultView;
|
||||
lb4preapprove.Text = dv.Count.ToString();
|
||||
}
|
||||
if (lem.CanKaoHe)
|
||||
{
|
||||
dv = lpj.GetProjectsByYearMonth(DateTime.Now.AddMonths(-1).Year.ToString(),DateTime.Now.AddMonths(-1).Month.ToString()).DefaultView;
|
||||
dv.RowFilter = "pj_status in('" + ProjectStatus.新增审核通过 + "','" + ProjectStatus.项目完成 + "','" + ProjectStatus.删减审核通过 + "') and pd_status <>'"
|
||||
+ ProjectDetailStatus.考核通过 +
|
||||
"' or pd_status in('" + ProjectDetailStatus.审核通过 + "')";
|
||||
|
||||
lb4preapprove.Text = (Convert.ToInt32( lb4preapprove.Text)+ dv.Count).ToString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//本月
|
||||
|
||||
|
||||
lmDt = lpj.GetProject.GetProjects(lem.GetEmployee.ID, DateTime.Now.Year.ToString(),
|
||||
DateTime.Now.Month.ToString());
|
||||
dv = lmDt.DefaultView;
|
||||
//本月通过数量
|
||||
dv.RowFilter = " pj_status in('" +
|
||||
ProjectStatus.新增审核通过 + "','" + ProjectStatus.项目完成 + "','" + ProjectStatus.删减审核通过 + "')" +
|
||||
" or pd_status in('" + ProjectDetailStatus.审核通过 + "','" + ProjectDetailStatus.考核通过 + "') ";
|
||||
lbpassed.Text = dv.Count.ToString();
|
||||
|
||||
//本月未通过数量
|
||||
dv.RowFilter = " pj_status like '%未通过%' or pd_status like '%未通过%'";
|
||||
lbfailed.Text = dv.Count.ToString();
|
||||
|
||||
|
||||
//本月得分
|
||||
dv.RowFilter = string.Empty;
|
||||
lmscore = 0;
|
||||
for (int i = 0; i < lmDt.Rows.Count; i++)
|
||||
{
|
||||
lmscore += Convert.ToDouble(lmDt.Rows[i]["pj_score"]);
|
||||
}
|
||||
|
||||
lbscore.Text = lmscore.ToString();
|
||||
|
||||
//本月待提交数量
|
||||
dv.RowFilter = " pj_status in('" +
|
||||
ProjectStatus.项目已分配 + "','" + ProjectStatus.新增未提交 + "')" +
|
||||
" and pd_status in('" + ProjectDetailStatus.月度未提交 + "') ";
|
||||
lb4submit.Text = dv.Count.ToString();
|
||||
|
||||
|
||||
//本月待审核
|
||||
lb4approve.Text = "0";
|
||||
if (lem.CanShenHe || lem.CanYuShen)
|
||||
{
|
||||
lmDt = lpj.Get4ApproveList(lem.GetCanApproveDeptList(), DateTime.Now .Year.ToString(),
|
||||
DateTime.Now .Month.ToString());
|
||||
dv = lmDt.DefaultView;
|
||||
lb4approve.Text = dv.Count.ToString();
|
||||
}
|
||||
if (lem.CanKaoHe)
|
||||
{
|
||||
dv = lpj.GetProjectsByYearMonth(DateTime.Now .Year.ToString(), DateTime.Now .Month.ToString()).DefaultView;
|
||||
dv.RowFilter = "pj_status in('" + ProjectStatus.新增审核通过 + "','" + ProjectStatus.项目完成 + "','" + ProjectStatus.删减审核通过 + "') and pd_status <>'"
|
||||
+ ProjectDetailStatus.考核通过 +
|
||||
"' or pd_status in('" + ProjectDetailStatus.审核通过 + "')";
|
||||
|
||||
lb4approve.Text = (Convert.ToInt32(lb4preapprove.Text) + dv.Count).ToString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//全年项目
|
||||
|
||||
|
||||
lmDt = lpj.GetProject.GetProjects(lem.GetEmployee.ID, DateTime.Now.Year.ToString() );
|
||||
dv = lmDt.DefaultView;
|
||||
//全年通过数量
|
||||
dv.RowFilter = " pj_status in('" +
|
||||
ProjectStatus.新增审核通过 + "','" + ProjectStatus.项目完成 + "','" + ProjectStatus.删减审核通过 + "')" +
|
||||
" or pd_status in('" + ProjectDetailStatus.审核通过 + "','" + ProjectDetailStatus.考核通过 + "') ";
|
||||
lbYearPassed .Text = dv.Count.ToString();
|
||||
|
||||
//全年未通过数量
|
||||
dv.RowFilter = " pj_status like '%未通过%' or pd_status like '%未通过%'";
|
||||
lbYearFailed.Text = dv.Count.ToString();
|
||||
|
||||
|
||||
//全年得分
|
||||
dv.RowFilter = string.Empty;
|
||||
lmscore = 0;
|
||||
for (int i = 0; i < lmDt.Rows.Count; i++)
|
||||
{
|
||||
lmscore += Convert.ToDouble(lmDt.Rows[i]["pj_score"]);
|
||||
}
|
||||
|
||||
lbYearscore1.Text = lmscore.ToString();
|
||||
|
||||
//全年待提交数量
|
||||
dv.RowFilter = " pj_status in('" +
|
||||
ProjectStatus.项目已分配 + "','" + ProjectStatus.新增未提交 + "')" +
|
||||
" and pd_status in('" + ProjectDetailStatus.月度未提交 + "') ";
|
||||
lbyear4submit.Text = dv.Count.ToString();
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
/*
|
||||
void bindTrainingInfo()
|
||||
{
|
||||
|
||||
DataTable dt = lem.GetLessons(lem.GetEmployee.ID);
|
||||
DataView dv = dt.DefaultView;
|
||||
dv.RowFilter = "train_passed=1";
|
||||
lbtpassed.Text = dv.Count.ToString();
|
||||
dv.RowFilter = "train_passed=0 and le_enddate< '" + DateTime.Now.ToShortDateString() +"'";
|
||||
lbtfailed.Text = dv.Count.ToString();
|
||||
|
||||
//总学分
|
||||
decimal allScore = 0;
|
||||
|
||||
for(int i=0;i<dt.Rows.Count;i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dt.Rows[i]["le_xuefen"].ToString() != null)
|
||||
allScore += Convert.ToDecimal(dt.Rows[0]["le_xuefen"].ToString());
|
||||
}
|
||||
catch (Exception er)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
lbtxuefen.Text = allScore.ToString();
|
||||
|
||||
//取得学分
|
||||
dv.RowFilter = "train_passed=1";
|
||||
decimal passedScore = 0;
|
||||
for (int i = 0; i < dv.Count; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dv.Table.Rows[i]["le_xuefen"].ToString() != null)
|
||||
passedScore += Convert.ToDecimal(dv.Table.Rows[0]["le_xuefen"].ToString());
|
||||
}
|
||||
catch (Exception er)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
lbtxuefenPassed.Text = passedScore.ToString();
|
||||
|
||||
|
||||
//在修课程
|
||||
|
||||
dv.RowFilter = "train_passed=0 and le_enddate > '" + DateTime.Now.ToShortDateString() +"'";
|
||||
lbt4learn.Text = dv.Count.ToString();
|
||||
}
|
||||
*/
|
||||
void showOnlineUsers()
|
||||
{
|
||||
lbOnLineUserCnt.Text = "";
|
||||
ArrayList al = lem.OnLineUsers;
|
||||
foreach (string s in al)
|
||||
{
|
||||
lbOnLineUserCnt.Text = lbOnLineUserCnt.Text + s + " <br> ";
|
||||
}
|
||||
}
|
||||
|
||||
protected void btn_save_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if(lem.GetEmployee.ValidUser(lem.GetEmployee.em_account, txtOldPasswd.Text)>0)
|
||||
{
|
||||
lem.GetEmployee.em_passwd = Util.Encrypt(txtNewPasswd.Text);
|
||||
lem.GetEmployee.Update();
|
||||
}
|
||||
|
||||
|
||||
this.divPasswdChg.Visible = false;
|
||||
}
|
||||
protected void btn_cancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
this.divPasswdChg.Visible = false;
|
||||
}
|
||||
protected void lkChgPswd_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
this.divPasswdChg.Visible = !divPasswdChg.Visible;
|
||||
}
|
||||
/*
|
||||
protected void LinkButton1_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect("~/training/Lessonview.aspx");
|
||||
}
|
||||
protected void LinkButton4_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect("~/training/Lessonview.aspx");
|
||||
}
|
||||
protected void LinkButton2_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect("~/training/Lessonview.aspx");
|
||||
}
|
||||
protected void LinkButton3_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.Redirect("~/training/Lessonview.aspx");
|
||||
}
|
||||
*/
|
||||
protected void lkbtnusers_Click(object sender, EventArgs e)
|
||||
{
|
||||
divOnlineUsers.Visible = !divOnlineUsers.Visible;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,572 @@
|
|||
10
|
||||
|
||||
dir
|
||||
8
|
||||
file:///D:/Repositories/ZhangPu/trunk/view/Dict
|
||||
file:///D:/Repositories/ZhangPu
|
||||
|
||||
|
||||
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
69712cd5-45d9-e244-acd6-b3e9c1159652
|
||||
|
||||
DeptMain.aspx.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.289823Z
|
||||
16712142e760c3e3ca05f45b4c57db33
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
11293
|
||||
|
||||
RoleMain.aspx
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.289823Z
|
||||
e86a662f72124fe2cc27f337d8ddcdcc
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
6333
|
||||
|
||||
RoleEmp.aspx.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.305448Z
|
||||
29348ca6500b98725ee06c066a4239aa
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
7294
|
||||
|
||||
RoleMain.aspx.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.321073Z
|
||||
3c85c792f5bd33b889e2b19cb3f3c7eb
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
6742
|
||||
|
||||
PublicNewsMain.aspx
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.321073Z
|
||||
7eca18f28e1e3addf4103a5718da3b2f
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
5727
|
||||
|
||||
RoleAuth.aspx
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.336698Z
|
||||
923c19644561f8abd2223b27bc39ea5d
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
4914
|
||||
|
||||
PublicNewsMain.aspx.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.367949Z
|
||||
da6058e5b414376016fd3ff1f92a1d55
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
7327
|
||||
|
||||
EmployeeMain.aspx
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.352323Z
|
||||
b1e9c22e4ad270cf8d85e9e9231bfd66
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
21972
|
||||
|
||||
RoleAuth.aspx.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.383574Z
|
||||
8e3ca1ea83b574b2fa6f2fb11f07e496
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
7171
|
||||
|
||||
EmployeeMain.aspx.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.383574Z
|
||||
6eff2b885c77e15164d857702de2ca53
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
16631
|
||||
|
||||
AuthorityMain.aspx
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.399199Z
|
||||
ce3967044bd3a42f90be997ca92794fe
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
6956
|
||||
|
||||
DeptEmp.aspx
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.414824Z
|
||||
1f9769b3547376f0636c60df6d538452
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
3986
|
||||
|
||||
DeptMain.aspx
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.430449Z
|
||||
615dea6c12eabab33e8b27fccf9398c6
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
6799
|
||||
|
||||
AuthorityMain.aspx.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.430449Z
|
||||
d273d8709e68a9505712a8cfb4feb8c6
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
10578
|
||||
|
||||
DeptEmp.aspx.cs
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.446074Z
|
||||
59457379588f33f15f70f8c8c5d61564
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
8261
|
||||
|
||||
RoleEmp.aspx
|
||||
file
|
||||
|
||||
|
||||
|
||||
|
||||
2011-04-01T02:51:03.461699Z
|
||||
3e2ed1f1a7b9334d307e2b47e7aa6a7e
|
||||
2011-03-31T02:53:16.230701Z
|
||||
2
|
||||
mwang
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
5646
|
||||
|
|
@ -0,0 +1,319 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using ZhangPu.Gov.Logical;
|
||||
using Tracen.Utils;
|
||||
|
||||
namespace ajax.Dict
|
||||
{
|
||||
public partial class AuthorityMain :PageBase
|
||||
{
|
||||
private LAuthority _logic;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
_logic = new LAuthority();
|
||||
Databound();
|
||||
}
|
||||
SessionSeting();
|
||||
}
|
||||
|
||||
/***************************************** private methods ******************************************/
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
|
||||
|
||||
//装载选定部门节点的部门数据
|
||||
DataView dv = new DataView(_logic.GetAllActiveData().Tables[0]);
|
||||
|
||||
if (TreeAuth.SelectedNode != null)
|
||||
{
|
||||
TreeAuth.SelectedNode.ChildNodes.Clear();
|
||||
BindTree(TreeAuth.SelectedNode.Value, TreeAuth.SelectedNode, dv);
|
||||
|
||||
//绑定树列表里选中的部门下的所有部门数据
|
||||
dv.RowFilter = "auth_uplevel = '" + TreeAuth.SelectedValue + "'";
|
||||
}
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
UpdateSession();
|
||||
ClearDetail();
|
||||
}
|
||||
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LAuthority)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set data from shift object to page
|
||||
/// </summary>
|
||||
private void DetailDataBind()
|
||||
{
|
||||
//公共信息不可以有url,必须为public
|
||||
LAuthority ltmp = new LAuthority();
|
||||
ltmp.Initialize(Convert.ToInt32(TreeAuth.SelectedValue));
|
||||
chkPublic.Enabled = !ltmp.GetAuthority.auth_publicInfomation;
|
||||
chkPublicInfo.Enabled = !ltmp.GetAuthority.auth_publicInfomation;
|
||||
chkAlert.Enabled =!chkPublicInfo.Enabled; //跑马灯的上级必须是公共信息
|
||||
if (chkPublicInfo.Checked) txtLink.Enabled = false;
|
||||
|
||||
DataDetail.Visible = true;
|
||||
txtName.Text = _logic.GetAuthority.auth_name;
|
||||
txtDesc.Text = _logic.GetAuthority.auth_desc;
|
||||
txtLink.Text = _logic.GetAuthority.auth_link;
|
||||
chkPublic.Checked = _logic.GetAuthority.auth_public;
|
||||
chkPublicInfo.Checked = _logic.GetAuthority.auth_publicInfomation;
|
||||
//上级为公共信息,则下级也必须是
|
||||
if(ltmp.GetAuthority.auth_publicInfomation)
|
||||
chkPublicInfo.Checked = ltmp.GetAuthority.auth_publicInfomation;
|
||||
if (ltmp.GetAuthority.auth_public)
|
||||
chkPublic.Checked = ltmp.GetAuthority.auth_public;
|
||||
chkAlert.Checked = _logic.GetAuthority.auth_marqueen;
|
||||
chkPublic.Checked = _logic.GetAuthority.auth_public;
|
||||
ltmp = null;
|
||||
|
||||
// chkStatus.Checked = _logic.GetRole.dr;
|
||||
}
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
protected void btnAddnew_Click(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(true);
|
||||
_logic.Initialize();
|
||||
GridView1.SelectedIndex = -1;
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetDataBack();
|
||||
//shifts id eq 0 means this is new one,to add; else an old one, to update
|
||||
|
||||
int oper = 0;
|
||||
oper = _logic.GetAuthority.ID > 0 ? _logic.GetAuthority.Update() : _logic.GetAuthority.Add();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
lbEdit.Text = "";
|
||||
}
|
||||
|
||||
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
||||
{
|
||||
|
||||
if (GridView1 != null)
|
||||
{
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
}
|
||||
/*
|
||||
_logic.GetRole.dr = false;
|
||||
_logic.GetRole.Update();
|
||||
|
||||
*/
|
||||
_logic.GetAuthority.Delete();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
||||
{
|
||||
GridView1.PageIndex = e.NewPageIndex;
|
||||
Databound();
|
||||
|
||||
//GridView1.DataSource = shiftLgc.getAllShifts().Tables[0];
|
||||
// GridView1.DataBind();
|
||||
}
|
||||
|
||||
protected void GridView1_DataBinding(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
// _logic.GetRole.operater = Session["CurrentUserID"].ToString(); todo: write a public method to handle operater,createtime,lastmodfied ... log info.
|
||||
|
||||
if (!(_logic.GetAuthority.ID > 0))
|
||||
{
|
||||
_logic.GetAuthority.lastmodified = DateTime.Now.ToString();
|
||||
_logic.GetAuthority.auth_uplevel = Convert.ToInt32(TreeAuth.SelectedValue);
|
||||
}
|
||||
|
||||
_logic.GetAuthority.auth_name = txtName.Text;
|
||||
_logic.GetAuthority.auth_desc = txtDesc.Text;
|
||||
_logic.GetAuthority.auth_link = txtLink.Text;
|
||||
_logic.GetAuthority.auth_public = chkPublic.Checked;
|
||||
_logic.GetAuthority.auth_publicInfomation =chkPublicInfo.Checked ;
|
||||
_logic.GetAuthority.auth_marqueen = chkAlert.Checked;
|
||||
|
||||
}
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
DataDetail.Visible = true;
|
||||
lbEdit.Text = addNew ? "增加新记录" : "修改现有记录";
|
||||
btnSubmit.Enabled = true;
|
||||
}
|
||||
|
||||
private void ClearDetail()
|
||||
{
|
||||
txtName.Text = "";
|
||||
txtDesc.Text = "";
|
||||
txtLink.Text ="";
|
||||
chkPublic.Checked = false;
|
||||
chkPublicInfo.Checked = false;
|
||||
DataDetail.Visible = false;
|
||||
}
|
||||
|
||||
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void BindTree(string id, TreeNode pNode, DataView dv)
|
||||
{
|
||||
|
||||
dv.RowFilter = "auth_uplevel = '" + id + "'";
|
||||
foreach (DataRowView row in dv)
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = row["auth_name"].ToString();
|
||||
node.Value = row["pk_authority"].ToString();
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
|
||||
TreeAuth.Nodes.Add(node);
|
||||
node.Expanded = false;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pNode.ChildNodes.Add(node);
|
||||
node.Expanded = false;
|
||||
|
||||
}
|
||||
BindTree(node.Value, node, new DataView(dv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void TreeAuth_SelectedNodeChanged1(object sender, EventArgs e)
|
||||
{
|
||||
GridView1.SelectedIndex = -1;
|
||||
DataView dv = new DataView(_logic.GetAllActiveData().Tables[0]);
|
||||
dv.RowFilter = "auth_uplevel = '" + TreeAuth.SelectedValue + "'";
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
ClearDetail();
|
||||
if(TreeAuth.SelectedNode.ChildNodes.Count>0)TreeAuth.SelectedNode.Expand();
|
||||
}
|
||||
|
||||
protected void chkPublicInfo_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
switch (chkPublicInfo.Checked)
|
||||
{
|
||||
case true:
|
||||
txtLink.Text = string.Empty;
|
||||
txtLink.Enabled = false;
|
||||
chkPublic.Checked = true;
|
||||
chkPublic.Enabled = false;
|
||||
break;
|
||||
|
||||
case false:
|
||||
txtLink.Text = _logic.GetAuthority.auth_link;
|
||||
txtLink.Enabled = false;
|
||||
chkPublic.Checked = false;
|
||||
chkPublic.Enabled = true;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
|
||||
CheckBox chk;
|
||||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
chk = new CheckBox();
|
||||
chk.Text = "";
|
||||
chk.Enabled = false;
|
||||
chk.Checked = e.Row.Cells[4].Text.Trim().Equals("True");
|
||||
e.Row.Cells[4].Controls.Add(chk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master" AutoEventWireup="true" CodeFile="AuthorityMain.aspx.cs" Inherits="ajax.Dict.AuthorityMain" %>
|
||||
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
|
||||
Namespace="System.Web.UI" TagPrefix="asp" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<table width="100%" class="Table_NoBorder">
|
||||
|
||||
<tr><td>
|
||||
<table width="100%" class="Table_Border">
|
||||
<tr><td width="50" height="200" align="left" valign="top">
|
||||
<asp:TreeView ID="TreeAuth" runat="server" ShowLines="True" ImageSet="Arrows" OnSelectedNodeChanged="TreeAuth_SelectedNodeChanged1">
|
||||
<SelectedNodeStyle BackColor="Azure" BorderColor="Transparent" />
|
||||
<Nodes>
|
||||
<asp:TreeNode Text="所有权限" Selected="True" Value="0" Expanded="True"></asp:TreeNode>
|
||||
</Nodes>
|
||||
</asp:TreeView>
|
||||
</td>
|
||||
<td width="1" class="VLine" ></td>
|
||||
<td width="100%" align="left" valign="top"> <!------ THE DATA GRID AREA ------>
|
||||
|
||||
<asp:Label ID="lbDataGridTitle" visible="false" runat="server" CssClass="Label" Text="权限维护" />
|
||||
<asp:Label ID="lbEdit" runat="server" CssClass="Label" visible="false" Text="" />
|
||||
<asp:GridView id="GridView1" CssClass="DataGrid"
|
||||
PageSize="10" PagerStyle-HorizontalAlign="Right"
|
||||
runat="server"
|
||||
AutoGenerateColumns="False"
|
||||
DataKeyNames="PK_AUTHORITY"
|
||||
OnRowDeleting="GridView1_RowDeleting"
|
||||
AllowPaging="True"
|
||||
OnPageIndexChanging="GridView1_PageIndexChanging"
|
||||
|
||||
OnSorting="GridView1_Sorting" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="100%" ShowFooter="True" EmptyDataText='没有数据。' OnRowDataBound="GridView1_RowDataBound1">
|
||||
|
||||
<SelectedRowStyle CssClass="SelectedItemStyle"></SelectedRowStyle>
|
||||
<HeaderStyle CssClass="HeaderStyle" HorizontalAlign="Center"></HeaderStyle>
|
||||
<RowStyle CssClass="ItemStyle" HorizontalAlign="Center"></RowStyle>
|
||||
<AlternatingRowStyle CssClass="AlternatingItemStyle"></AlternatingRowStyle>
|
||||
|
||||
|
||||
<Columns>
|
||||
<asp:BoundField ReadOnly="True" DataField="PK_AUTHORITY" visible="false" HeaderText="权限id" SortExpression="PK_DEPARTMENT" ></asp:BoundField>
|
||||
<asp:BoundField DataField="AUTH_NAME" HeaderText="权限名称" SortExpression="DEP_NAME" >
|
||||
|
||||
|
||||
</asp:BoundField>
|
||||
|
||||
<asp:BoundField DataField="AUTH_DESC" HeaderText="权限描述" SortExpression="DEP_CODE" ><ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" /></asp:BoundField>
|
||||
<asp:BoundField DataField="AUTH_LINK" HeaderText="权限连接" SortExpression="AUTH_LINK" ><ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" /></asp:BoundField>
|
||||
<asp:BoundField DataField="AUTH_PUBLIC" HeaderText="公共权限" SortExpression="AUTH_PUBLIC" ><ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" /></asp:BoundField>
|
||||
<asp:BoundField DataField="dr" HeaderText="可用" SortExpression="dr" Visible="False" ></asp:BoundField>
|
||||
|
||||
<asp:CommandField HeaderText="编 辑" ShowDeleteButton="True" DeleteText="<img src=../Images/Delete.gif border=0 title=删除 onclick='return delete_click()'>" ShowHeader="True" ShowSelectButton="True" SelectText="<img src=../Images/edit.gif border=0 title=修改 >">
|
||||
<HeaderStyle HorizontalAlign="Center" Wrap="False" />
|
||||
<ItemStyle HorizontalAlign="Center" Wrap="False" />
|
||||
</asp:CommandField>
|
||||
</Columns>
|
||||
<PagerStyle HorizontalAlign="Right" />
|
||||
<emptydatatemplate> 没有数据</emptydatatemplate>
|
||||
</asp:gridview>
|
||||
<asp:Button ID="btn_addNew" runat="server" Text="新增记录" CssClass="Button" OnClick="btnAddnew_Click" />
|
||||
<asp:Panel ID ="DataDetail" runat="server" Width="100%" Visible="false">
|
||||
|
||||
<!------ THE ADD /DELETE AREA ------>
|
||||
<table class="Table_NoBorder" width="90%">
|
||||
<tr>
|
||||
<td colspan="4" class="ALine">
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td nowrap>
|
||||
<asp:Label ID="Label2" runat="server" CssClass="Label" Text="权限名称"></asp:Label></td>
|
||||
<td >
|
||||
|
||||
<asp:TextBox ID="txtName" runat="server" CssClass="TextBox" MaxLength="25"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName"
|
||||
ErrorMessage="*">*</asp:RequiredFieldValidator></td>
|
||||
<td nowrap>
|
||||
<asp:Label ID="Label5" runat="server" CssClass="Label" Text="权限连接"></asp:Label></td><td colspan="2" >
|
||||
<asp:TextBox ID="txtLink" CssClass="TextBox" runat="server" MaxLength="400" Width="400px"></asp:TextBox>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<td>
|
||||
<asp:Label ID="Label3" runat="server" CssClass="Label" Text="权限描述"></asp:Label></td><td colspan="4">
|
||||
<asp:TextBox ID="txtDesc" CssClass="Long_TextBox" runat="server" MaxLength="50" Width="650px"></asp:TextBox></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<td>
|
||||
<asp:Label ID="lbpublic" runat="server" CssClass="Label" Text="公共权限"></asp:Label></td>
|
||||
<td >
|
||||
<asp:CheckBox id="chkPublic" runat="server">
|
||||
</asp:CheckBox></td>
|
||||
|
||||
<td><asp:Label ID="Label1" runat="server" CssClass="Label" Text="公共信息"></asp:Label></td>
|
||||
<td ><asp:CheckBox id="chkPublicInfo" runat="server" OnCheckedChanged="chkPublicInfo_CheckedChanged" autopostback="true">
|
||||
</asp:CheckBox> <asp:CheckBox id="chkAlert" runat="server" Text="跑马灯">
|
||||
</asp:CheckBox></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="4" class="ALine">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" colspan="4"> <asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存数据" OnClick="btnSubmit_Click" />
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Panel>
|
||||
</td></tr>
|
||||
|
||||
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
</asp:Content>
|
||||
|
|
@ -0,0 +1,309 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using System.Transactions;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using ZhangPu.Gov.Logical;
|
||||
using Tracen.Utils;
|
||||
|
||||
public partial class DeptEmp : PageBase
|
||||
{
|
||||
private LEmployee _logic;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
_logic = new LEmployee();
|
||||
|
||||
Databound();
|
||||
|
||||
//分配角色时初始化部门人员树
|
||||
|
||||
}
|
||||
SessionSeting();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
bindGV();
|
||||
UpdateSession();
|
||||
bindDept();
|
||||
bindDeptEmp();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定部门
|
||||
/// </summary>
|
||||
private void bindDept()
|
||||
{
|
||||
TreeDept.Nodes.Clear();
|
||||
BindTree(TreeDept, "0", TreeDept.SelectedNode, _logic.GetDepartments().DefaultView);
|
||||
SetTreeDeptChecked();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 绑定部门及用户
|
||||
/// </summary>
|
||||
private void bindDeptEmp()
|
||||
{
|
||||
TreeDeptEmp.Nodes.Clear();
|
||||
BindEmpTree(TreeDeptEmp, "0", TreeDeptEmp.SelectedNode, _logic.GetDepartments().DefaultView, _logic.GetActivedEmpDept().DefaultView);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void BindEmpTree(TreeView tree, string id, TreeNode pNode, DataView deptdv,DataView empdv)
|
||||
{
|
||||
|
||||
deptdv.RowFilter = "dep_mastdept = '" + id + "'";
|
||||
foreach (DataRowView row in deptdv)
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = "<em>" + row["dep_name"] + "</em>" ;
|
||||
node.Value = row["pk_department"].ToString();
|
||||
node.SelectAction = TreeNodeSelectAction.None;
|
||||
node.ShowCheckBox = false;
|
||||
node.Expanded = true;
|
||||
empdv.RowFilter = "de_dept=" + node.Value;
|
||||
foreach (DataRowView emrow in empdv)
|
||||
{
|
||||
TreeNode tnEmp = new TreeNode("<Strong>" + emrow["em_name"] + "</Strong>" , emrow["pk_employee"].ToString());
|
||||
node.ChildNodes.Add(tnEmp);
|
||||
}
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
|
||||
tree.Nodes.Add(node);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
pNode.ChildNodes.Add(node);
|
||||
|
||||
}
|
||||
BindEmpTree(tree,node.Value, node, new DataView(deptdv.Table), new DataView(empdv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void BindTree(TreeView tree, string id, TreeNode pNode, DataView deptdv )
|
||||
{
|
||||
|
||||
deptdv.RowFilter = "dep_mastdept = '" + id + "'";
|
||||
foreach (DataRowView row in deptdv)
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = "<Strong>" + row["dep_name"].ToString() + "</Strong>";
|
||||
node.Value = row["pk_department"].ToString();
|
||||
node.SelectAction = TreeNodeSelectAction.None;
|
||||
node.ShowCheckBox = true;
|
||||
node.Expanded = true;
|
||||
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
|
||||
tree.Nodes.Add(node);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
pNode.ChildNodes.Add(node);
|
||||
|
||||
}
|
||||
BindTree(tree, node.Value, node, new DataView(deptdv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LEmployee)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (TreeDeptEmp.SelectedNode== null) return;
|
||||
ArrayList al = new ArrayList();
|
||||
|
||||
GetCheckedNode(TreeDept.Nodes, al);
|
||||
_logic.Initialize();
|
||||
// using (TransactionScope trans = new TransactionScope())
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.GetDeptEmp.Delete(Convert.ToInt32(TreeDeptEmp.SelectedValue));
|
||||
|
||||
foreach (string id in al)
|
||||
{
|
||||
_logic.GetDeptEmp.de_dept = Convert.ToInt32(id);
|
||||
_logic.GetDeptEmp.de_employee = Convert.ToInt32(TreeDeptEmp.SelectedValue);
|
||||
_logic.GetDeptEmp.Add();
|
||||
}
|
||||
|
||||
// trans.Complete();
|
||||
}
|
||||
catch (MyException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception("出现异常,保存失败。");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Databound();
|
||||
}
|
||||
|
||||
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GetCheckedNode(TreeNodeCollection tnc, ArrayList checkedvalues )
|
||||
{
|
||||
foreach(TreeNode node in tnc)
|
||||
{
|
||||
if(node.Checked)
|
||||
{
|
||||
checkedvalues.Add(node.Value);
|
||||
|
||||
}
|
||||
GetCheckedNode(node.ChildNodes, checkedvalues);
|
||||
}
|
||||
}
|
||||
|
||||
void SetCheckedNode(TreeNodeCollection tnc, ArrayList setcheckedvalues)
|
||||
{
|
||||
foreach (TreeNode node in tnc)
|
||||
{
|
||||
node.Checked = setcheckedvalues.Contains(Convert.ToInt32(node.Value));
|
||||
|
||||
SetCheckedNode(node.ChildNodes, setcheckedvalues);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
|
||||
btnSubmit.Enabled = true;
|
||||
|
||||
}
|
||||
void SetTreeDeptChecked()
|
||||
{
|
||||
if( TreeDeptEmp.SelectedNode ==null) return;
|
||||
ArrayList deptList = new ArrayList();
|
||||
DataTable dt = _logic.GetDepartments(Convert.ToInt32(TreeDeptEmp.SelectedValue));
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
deptList.Add(dr["pk_department"]);
|
||||
}
|
||||
SetCheckedNode(TreeDept.Nodes, deptList);
|
||||
}
|
||||
|
||||
protected void TreeDeptEmp_SelectedNodeChanged(object sender, EventArgs e)
|
||||
{
|
||||
GvDept.SelectedIndex = -1;
|
||||
SetTreeDeptChecked();
|
||||
bindGV();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void bindGV( )
|
||||
{
|
||||
//人员部门清单
|
||||
string nodevalue = TreeDeptEmp.SelectedValue;
|
||||
if (nodevalue.Length >0 && nodevalue != "0") //selected node is an employee
|
||||
{
|
||||
|
||||
lbEmDept.Text = TreeDeptEmp.SelectedNode.Text + " 人员部门清单";
|
||||
GvDept.DataSource = _logic.GetDepartments(Convert.ToInt32(nodevalue));
|
||||
|
||||
|
||||
}
|
||||
GvDept.DataBind();
|
||||
|
||||
}
|
||||
|
||||
protected void GvDept_RowUpdating(object sender, GridViewUpdateEventArgs e)
|
||||
{
|
||||
if (GvDept.DataKeys != null)
|
||||
{
|
||||
string id = GvDept.DataKeys[e.RowIndex].Value.ToString();
|
||||
|
||||
_logic.GetDeptEmp.ID = Convert.ToInt32(id);
|
||||
_logic.GetDeptEmp.getModel();
|
||||
|
||||
_logic.GetDeptEmp.de_title = ((TextBox)GvDept.Rows[e.RowIndex].Cells[3].Controls[1]).Text;
|
||||
|
||||
//_logic.GetTrainingDetail.operater =
|
||||
_logic.GetDeptEmp.Update();
|
||||
}
|
||||
GvDept.EditIndex = -1;
|
||||
GvDept.SelectedIndex = e.RowIndex;
|
||||
bindGV();
|
||||
}
|
||||
protected void GvDept_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
|
||||
{
|
||||
GvDept.EditIndex = -1;
|
||||
GvDept.SelectedIndex = e.RowIndex;
|
||||
bindGV();
|
||||
}
|
||||
protected void GvDept_RowEditing(object sender, GridViewEditEventArgs e)
|
||||
{
|
||||
GvDept.EditIndex = e.NewEditIndex;
|
||||
GvDept.SelectedIndex = e.NewEditIndex;
|
||||
bindGV();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master" AutoEventWireup="true" CodeFile="DeptEmp.aspx.cs" Inherits="DeptEmp" %>
|
||||
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<table class="Table_NoBorder" width="100%">
|
||||
|
||||
<tr><td>
|
||||
<table width="100%" class="Table_NoBorder" border="1">
|
||||
<tr>
|
||||
<td style="width: 300px" ><asp:Label ID="lbrole" runat="server" Font-Bold="True" Text="人员列表" /> </td>
|
||||
<td style="width: 300px"> <asp:Label ID="lbemp" runat="server" Font-Bold="True" Text="部门列表" /></td>
|
||||
<td style="width: 300px" nowrap>
|
||||
<asp:Label ID="lbEmDept" runat="server" Font-Bold="True" Text="人员部门清单" /></td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign ="top"><asp:TreeView id="TreeDeptEmp" runat="server" ShowLines="True" ImageSet="Arrows" OnSelectedNodeChanged="TreeDeptEmp_SelectedNodeChanged" >
|
||||
<SelectedNodeStyle BackColor="Azure" BorderColor="Transparent" />
|
||||
<nodes>
|
||||
<asp:TreeNode Text="张浦镇" Selected="True" Value="0" Expanded="True" SelectAction="None"></asp:TreeNode>
|
||||
</nodes>
|
||||
</asp:TreeView></td>
|
||||
<td valign ="top">
|
||||
|
||||
|
||||
<asp:TreeView id="TreeDept" runat="server" ShowLines="True" ImageSet="Arrows"
|
||||
ShowCheckBoxes="All" OnSelectedNodeChanged="TreeDeptEmp_SelectedNodeChanged" ><SelectedNodeStyle BackColor="Azure" BorderColor="Transparent" />
|
||||
<nodes>
|
||||
<asp:TreeNode Text="张浦镇" Selected="True" Value="0" Expanded="True" SelectAction="None"></asp:TreeNode>
|
||||
</nodes>
|
||||
</asp:TreeView>
|
||||
|
||||
</td>
|
||||
<td valign ="top">
|
||||
<asp:gridview id="GvDept" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="DataGrid" emptydatatext="没有数据。"
|
||||
ShowFooter="True"
|
||||
DataKeyNames="pk_deptemp"
|
||||
Width="100%" TabIndex="1" OnRowCancelingEdit="GvDept_RowCancelingEdit" OnRowUpdating="GvDept_RowUpdating" OnRowEditing="GvDept_RowEditing">
|
||||
<columns>
|
||||
<asp:BoundField ReadOnly="True" DataField="pk_deptemp" Visible="False" SortExpression="pk_deptemp" HeaderText="id"></asp:BoundField>
|
||||
<asp:BoundField ReadOnly="True" DataField="DEP_NAME" SortExpression="DEP_NAME" HeaderText="部门名称"></asp:BoundField>
|
||||
<asp:BoundField ReadOnly="True" DataField="DEP_DESC" SortExpression="DEP_DESC" HeaderText="部门描述"></asp:BoundField>
|
||||
<asp:TemplateField SortExpression="DE_TITLE" HeaderText="职务"><EditItemTemplate>
|
||||
<asp:TextBox runat="server" Text='<%# Bind("DE_TITLE") %>' id="TextBox1"></asp:TextBox>
|
||||
|
||||
</EditItemTemplate>
|
||||
<ItemTemplate>
|
||||
<asp:Label runat="server" Text='<%# Bind("DE_TITLE") %>' id="Label1"></asp:Label>
|
||||
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
<asp:CommandField InsertVisible="False" CancelImageUrl="~/Images/undo.gif" EditImageUrl="~/Images/edit.gif" ShowHeader="True" UpdateImageUrl="~/Images/save.gif" ButtonType="Image" ShowEditButton="True"></asp:CommandField>
|
||||
</columns>
|
||||
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center" />
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center" />
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle" />
|
||||
<SelectedRowStyle CssClass="SelectedItemStyle"></SelectedRowStyle>
|
||||
</asp:gridview>
|
||||
|
||||
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
</td></tr>
|
||||
<tr><td class="ALine" >
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<td align="center" > <asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存数据" OnClick="btnSubmit_Click" />
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td style="width: 532px">
|
||||
|
||||
<br/></td></tr>
|
||||
</table>
|
||||
|
||||
</asp:Content>
|
||||
|
|
@ -0,0 +1,361 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using ZhangPu.Gov.Logical;
|
||||
using Tracen.Utils;
|
||||
|
||||
public partial class DeptMain : PageBase
|
||||
{
|
||||
private LDepartment _logic;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
_logic = new LDepartment();
|
||||
Databound();
|
||||
}
|
||||
SessionSeting();
|
||||
}
|
||||
|
||||
/***************************************** private methods ******************************************/
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
//绑定部门列表
|
||||
drplstDept.DataSource = _logic.GetAllActiveData();
|
||||
drplstDept.DataTextField = "dep_name";
|
||||
drplstDept.DataValueField = "pk_department";
|
||||
drplstDept.DataBind();
|
||||
|
||||
|
||||
|
||||
|
||||
drplstDept.Items.Insert(0, (new ListItem("张浦镇", "0")));
|
||||
drplstDept.SelectedItem.Selected = false;
|
||||
drplstDept.Items.FindByText("张浦镇").Selected = true;
|
||||
|
||||
|
||||
|
||||
//绑定部门人员列表
|
||||
DropDownList1.DataSource = _logic.GetEmployees();
|
||||
DropDownList1.DataTextField = "em_name";
|
||||
DropDownList1.DataValueField = "pk_employee";
|
||||
DropDownList1.DataBind();
|
||||
DropDownList1.Items.Insert(0,(new ListItem("请选择...","0")));
|
||||
DropDownList1.SelectedItem.Selected = false;
|
||||
DropDownList1.Items.FindByText("请选择...").Selected = true;
|
||||
//装载选定部门节点的部门数据
|
||||
DataView dv = new DataView(_logic.GetAllActiveData());
|
||||
string selectedValue = TreeDept.SelectedValue;
|
||||
TreeDept.Nodes.Clear();
|
||||
TreeDept.Nodes.Add(new TreeNode("张浦镇","0"));
|
||||
TreeDept.Nodes[0].Expanded = true;
|
||||
BindTree("0", TreeDept.Nodes[0], dv);
|
||||
// TreeDept.SelectedNode.ChildNodes.Clear();
|
||||
// BindTree(TreeDept.SelectedValue, TreeDept.SelectedNode, dv);
|
||||
// TreeDept.Nodes.AddAt(0, new TreeNode("张浦镇", "0"));
|
||||
if (selectedValue =="0") TreeDept.Nodes[0].Selected = true;
|
||||
else
|
||||
{
|
||||
setTreeDeptSelected(selectedValue, TreeDept.Nodes[0]);
|
||||
}
|
||||
|
||||
//绑定树列表里选中的部门下的所有部门数据
|
||||
dv.RowFilter = "dep_mastdept = '" + selectedValue + "'";
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
UpdateSession();
|
||||
// btnSubmit.Enabled = false;
|
||||
// ClearDetail();
|
||||
|
||||
|
||||
drplstDept.Items.Clear();
|
||||
initializeDrlstDept(TreeDept.Nodes, drplstDept ,"");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void initializeDrlstDept(TreeNodeCollection nds, DropDownList drplist, string emptyString)
|
||||
{
|
||||
|
||||
|
||||
foreach (TreeNode nd in nds)
|
||||
{
|
||||
|
||||
ListItem li = new ListItem(emptyString + nd.Text,nd.Value);
|
||||
drplist.Items.Add(li);
|
||||
string NextemptyString = emptyString+ "----";
|
||||
foreach (TreeNode nd1 in nd.ChildNodes)
|
||||
{
|
||||
li = new ListItem(NextemptyString + nd1.Text, nd1.Value);
|
||||
drplist.Items.Add(li);
|
||||
|
||||
if (nd1.ChildNodes.Count > 0)
|
||||
{
|
||||
NextemptyString +="----";
|
||||
initializeDrlstDept(nd1.ChildNodes, drplist, NextemptyString);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setTreeDeptSelected(string toFind,TreeNode nd)
|
||||
{
|
||||
foreach (TreeNode cnd in nd.ChildNodes)
|
||||
{
|
||||
if (cnd.Value == toFind)
|
||||
{
|
||||
cnd.Selected = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
setTreeDeptSelected(toFind,cnd);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LDepartment)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set data from shift object to page
|
||||
/// </summary>
|
||||
private void DetailDataBind()
|
||||
{
|
||||
DataDetail.Visible = true;
|
||||
txtDepName.Text = _logic.GetDepartment.dep_name ;
|
||||
txtDepcode.Text = _logic.GetDepartment.dep_code;
|
||||
txtDepDesc.Text = _logic.GetDepartment.dep_desc;
|
||||
txtDepType.Text = _logic.GetDepartment.dep_type;
|
||||
DropDownList1.SelectedItem.Selected = false;
|
||||
if(DropDownList1.Items.FindByValue(_logic.GetDepartment.dep_manager.ToString())!=null)
|
||||
{
|
||||
DropDownList1.Items.FindByValue(_logic.GetDepartment.dep_manager.ToString()).Selected = true;
|
||||
}
|
||||
drplstDept.SelectedItem.Selected = false;
|
||||
if (drplstDept.Items.FindByValue(_logic.GetDepartment.dep_mastdept.ToString()) != null)
|
||||
{
|
||||
drplstDept.Items.FindByValue(_logic.GetDepartment.dep_mastdept.ToString()).Selected = true;
|
||||
}
|
||||
|
||||
// chkStatus.Checked = _logic.GetRole.dr;
|
||||
}
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
protected void btnAddnew_Click(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(true);
|
||||
_logic.Initialize();
|
||||
DetailDataBind();
|
||||
GridView1.SelectedIndex = -1;
|
||||
Databound();
|
||||
drplstDept.SelectedItem.Selected = false;
|
||||
if (drplstDept.Items.FindByValue(TreeDept.SelectedNode.Value) != null)
|
||||
{
|
||||
drplstDept.Items.FindByValue(TreeDept.SelectedNode.Value).Selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetDataBack();
|
||||
//shifts id eq 0 means this is new one,to add; else an old one, to update
|
||||
|
||||
int oper = 0;
|
||||
oper = _logic.GetDepartment.ID > 0 ? _logic.GetDepartment.Update() : _logic.GetDepartment.Add();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
}
|
||||
|
||||
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
||||
{
|
||||
|
||||
if (GridView1 != null)
|
||||
{
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
}
|
||||
/*
|
||||
_logic.GetRole.dr = false;
|
||||
_logic.GetRole.Update();
|
||||
|
||||
*/
|
||||
_logic.GetDepartment.Delete();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
||||
{
|
||||
GridView1.PageIndex = e.NewPageIndex;
|
||||
Databound();
|
||||
|
||||
//GridView1.DataSource = shiftLgc.getAllShifts().Tables[0];
|
||||
// GridView1.DataBind();
|
||||
}
|
||||
|
||||
protected void GridView1_DataBinding(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
/*
|
||||
CheckBox chk;
|
||||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
chk = new CheckBox();
|
||||
chk.Text = "激活";
|
||||
chk.Enabled = false;
|
||||
chk.Checked = e.Row.Cells[3].Text.Trim().Equals("1");
|
||||
e.Row.Cells[3].Controls.Add(chk);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
// _logic.GetRole.operater = Session["CurrentUserID"].ToString(); todo: write a public method to handle operater,createtime,lastmodfied ... log info.
|
||||
|
||||
if (!(_logic.GetDepartment.ID > 0 ))
|
||||
{
|
||||
_logic.GetDepartment.lastmodified = DateTime.Now.ToString();
|
||||
_logic.GetDepartment.dep_mastdept = Convert.ToInt32(TreeDept.SelectedValue);
|
||||
}
|
||||
|
||||
_logic.GetDepartment.dr = true;
|
||||
_logic.GetDepartment.dep_name = txtDepName.Text;
|
||||
_logic.GetDepartment.dep_desc = txtDepDesc.Text;
|
||||
_logic.GetDepartment.dep_code = txtDepcode.Text;
|
||||
_logic.GetDepartment.dep_type = txtDepType.Text;
|
||||
if (DropDownList1.SelectedItem != null ) _logic.GetDepartment.dep_manager = Convert.ToInt32(DropDownList1.SelectedValue);
|
||||
if (drplstDept.SelectedItem != null) _logic.GetDepartment.dep_mastdept = Convert.ToInt32(drplstDept.SelectedValue);
|
||||
}
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
DataDetail.Visible = true;
|
||||
lbEdit.Text = addNew ? "增加新记录" : "修改现有记录";
|
||||
btnSubmit.Enabled = true;
|
||||
}
|
||||
|
||||
private void ClearDetail()
|
||||
{
|
||||
txtDepName.Text = "";
|
||||
txtDepcode.Text = "";
|
||||
txtDepDesc.Text = "";
|
||||
txtDepType.Text ="";
|
||||
DataDetail.Visible = false;
|
||||
}
|
||||
|
||||
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void BindTree(string id, TreeNode pNode, DataView dv)
|
||||
{
|
||||
|
||||
dv.RowFilter = "dep_mastdept = '" + id + "'";
|
||||
foreach (DataRowView row in dv)
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = row["dep_name"].ToString();
|
||||
node.Value = row["pk_department"].ToString();
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
|
||||
TreeDept.Nodes.Add(node);
|
||||
node.Expanded = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pNode.ChildNodes.Add(node);
|
||||
node.Expanded = true;
|
||||
|
||||
}
|
||||
BindTree(node.Value, node, new DataView(dv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
protected void TreeDept_SelectedNodeChanged(object sender, EventArgs e)
|
||||
{
|
||||
GridView1.SelectedIndex = -1;
|
||||
DataView dv = new DataView(_logic.GetAllActiveData());
|
||||
dv.RowFilter = "dep_mastdept = '" + TreeDept.SelectedValue + "'";
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
ClearDetail();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master" AutoEventWireup="true" CodeFile="DeptMain.aspx.cs" Inherits="DeptMain" %>
|
||||
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
|
||||
Namespace="System.Web.UI" TagPrefix="asp" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<table width="100%" class="Table_NoBorder">
|
||||
|
||||
<tr><td>
|
||||
<table width="100%" class="Table_Border">
|
||||
<tr><td width="50" height="200" align="left" valign="top">
|
||||
<asp:TreeView ID="TreeDept" runat="server" ShowLines="True" OnSelectedNodeChanged="TreeDept_SelectedNodeChanged" ImageSet="Arrows">
|
||||
<Nodes>
|
||||
<asp:TreeNode Text="张浦镇" Value="0" Expanded="True" Selected="True"></asp:TreeNode>
|
||||
</Nodes>
|
||||
<SelectedNodeStyle BackColor="Azure" BorderColor="Transparent" />
|
||||
</asp:TreeView>
|
||||
</td>
|
||||
<td width="1" class="VLine" ></td>
|
||||
<td align="left" valign="top"> <!------ THE DATA GRID AREA ------>
|
||||
|
||||
<asp:Label ID="lbDataGridTitle" Visible="false" runat="server" CssClass="Label" Text="部门维护" />
|
||||
<asp:Label ID="lbEdit" Visible="false" runat="server" CssClass="Label" Text=""></asp:Label>
|
||||
<asp:gridview id="GridView1" CssClass="DataGrid"
|
||||
PageSize="10" PagerStyle-HorizontalAlign="Right"
|
||||
runat="server"
|
||||
AutoGenerateColumns="False"
|
||||
DataKeyNames="pk_department"
|
||||
OnRowDeleting="GridView1_RowDeleting"
|
||||
AllowPaging="True"
|
||||
OnPageIndexChanging="GridView1_PageIndexChanging"
|
||||
OnRowDataBound="GridView1_RowDataBound"
|
||||
OnSorting="GridView1_Sorting" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="95% " ShowFooter="True" EmptyDataText='没有数据。'>
|
||||
|
||||
<Columns>
|
||||
<asp:BoundField ReadOnly="True" DataField="PK_DEPARTMENT" Visible="true" SortExpression="PK_DEPARTMENT" HeaderText="部门编号"></asp:BoundField>
|
||||
<asp:BoundField DataField="DEP_NAME" SortExpression="DEP_NAME" HeaderText="部门名称"></asp:BoundField>
|
||||
<asp:BoundField DataField="DEP_CODE" SortExpression="DEP_CODE" HeaderText="部门代码"></asp:BoundField>
|
||||
<asp:BoundField DataField="EM_NAME" SortExpression="DEP_CODE" HeaderText="负责人"></asp:BoundField>
|
||||
<asp:BoundField DataField="DEP_TYPE" SortExpression="DEP_TYPE" HeaderText="部门类型"></asp:BoundField>
|
||||
<asp:BoundField DataField="DEP_DESC" SortExpression="DEP_DESC" HeaderText="部门描述"></asp:BoundField>
|
||||
<asp:BoundField DataField="dr" Visible="False" SortExpression="dr" HeaderText="可用"></asp:BoundField>
|
||||
<asp:CommandField SelectText="<img src=../Images/edit.gif border=0 title=修改 >" ShowDeleteButton="True" ShowHeader="True" DeleteText="<img src=../Images/Delete.gif border=0 title=删除 onclick='return delete_click()'>" ShowSelectButton="True" HeaderText="编 辑">
|
||||
<HeaderStyle Width="15%" HorizontalAlign="Center"></HeaderStyle>
|
||||
|
||||
<ItemStyle Width="15%" HorizontalAlign="Center"></ItemStyle>
|
||||
</asp:CommandField>
|
||||
</Columns>
|
||||
<RowStyle CssClass="ItemStyle" HorizontalAlign="Center"></RowStyle>
|
||||
|
||||
<SelectedRowStyle CssClass="SelectedItemStyle"></SelectedRowStyle>
|
||||
<PagerStyle HorizontalAlign="Right" />
|
||||
<HeaderStyle CssClass="HeaderStyle" HorizontalAlign="Center"></HeaderStyle>
|
||||
<AlternatingRowStyle CssClass="AlternatingItemStyle"></AlternatingRowStyle>
|
||||
<emptydatatemplate> 没有数据</emptydatatemplate>
|
||||
</asp:gridview>
|
||||
<asp:Button ID="btn_addNew" runat="server" Text="新增记录" CssClass="Button" OnClick="btnAddnew_Click" />
|
||||
|
||||
<asp:Panel ID ="DataDetail" runat="server" Width="100%" Visible="false">
|
||||
|
||||
<!------ THE ADD /DELETE AREA ------>
|
||||
<table class="Table_NoBorder" width="90%">
|
||||
<tr>
|
||||
<td colspan ="4" class="ALine" >
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td>
|
||||
<asp:Label ID="Label2" runat="server" CssClass="Label" Text="部门名称"></asp:Label></td><td >
|
||||
|
||||
<asp:TextBox ID="txtDepName" runat="server" CssClass="TextBox" MaxLength="25"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtDepName"
|
||||
ErrorMessage="*" ValidationGroup="1">*</asp:RequiredFieldValidator></td>
|
||||
<td>
|
||||
<asp:Label ID="Label4" runat="server" CssClass="Label" Text="部门代码"></asp:Label></td><td >
|
||||
<asp:TextBox ID="txtDepcode" runat="server" CssClass="TextBox" MaxLength="25"></asp:TextBox>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<asp:Label ID="Label15" runat="server" CssClass="Label" Text="部门类别"></asp:Label></td><td >
|
||||
<asp:TextBox ID="txtDepType" CssClass="TextBox" runat="server" MaxLength="25"></asp:TextBox>
|
||||
</td>
|
||||
<td>
|
||||
<asp:Label ID="Label3" runat="server" CssClass="Label" Text="部门描述"></asp:Label></td><td >
|
||||
<asp:TextBox ID="txtDepDesc" CssClass="Long_TextBox" runat="server" MaxLength="50"></asp:TextBox></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td >
|
||||
<asp:Label ID="Label1" runat="server" CssClass="Label" Text="部门负责人"></asp:Label></td>
|
||||
<td >
|
||||
|
||||
<asp:DropDownList ID="DropDownList1" runat="server" CssClass="DropDownList">
|
||||
</asp:DropDownList></td>
|
||||
|
||||
<td >
|
||||
<asp:Label ID="Label5" runat="server" CssClass="Label" Text="上级部门"></asp:Label></td>
|
||||
<td >
|
||||
|
||||
<asp:DropDownList ID="drplstDept" runat="server" CssClass="DropDownList">
|
||||
</asp:DropDownList></td>
|
||||
<td />
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan ="4" class="ALine" >
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" colspan ="4" > <asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存数据" OnClick="btnSubmit_Click" ValidationGroup="1" />
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Panel>
|
||||
</td></tr>
|
||||
|
||||
|
||||
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
</asp:Content>
|
||||
|
|
@ -0,0 +1,533 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using view.App_Code;
|
||||
using ZhangPu.Gov.Logical;
|
||||
using Tracen.Utils;
|
||||
|
||||
public partial class EmployeeMain : PageBase
|
||||
{
|
||||
private LEmployee _logic;
|
||||
protected void Page_Init()
|
||||
{
|
||||
|
||||
PostBackTrigger trigger = new PostBackTrigger();
|
||||
trigger.ControlID = Button1.UniqueID;
|
||||
|
||||
// (Button)pnGridViewProcess.FindControl("btnExcel")).UniqueID.ToString();
|
||||
|
||||
// (UpdatePanel)(Page.Controls[0].FindControl("UpdatePanel1")).Triggers.Add(trigger);
|
||||
|
||||
((UpdatePanel)Master.FindControl("UpdatePanel1")).Triggers.Add(trigger);
|
||||
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
|
||||
_logic = new LEmployee();
|
||||
bindDeptTree();
|
||||
Databound();
|
||||
}
|
||||
SessionSeting();
|
||||
}
|
||||
|
||||
/***************************************** private methods ******************************************/
|
||||
|
||||
void bindDeptTree()
|
||||
{
|
||||
|
||||
DataView dvDept = new DataView(_logic.GetDepartments());
|
||||
|
||||
//装载选定部门节点的部门数据
|
||||
|
||||
TreeDept.SelectedNode.ChildNodes.Clear();
|
||||
BindTree(TreeDept.SelectedNode.Value, TreeDept.SelectedNode, dvDept);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
|
||||
//绑定部门树选中的部门下的所有员工数据
|
||||
bindGrid();
|
||||
|
||||
|
||||
|
||||
UpdateSession();
|
||||
// btnSubmit.Enabled = false;
|
||||
ClearDetail();
|
||||
}
|
||||
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LEmployee)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set data from shift object to page
|
||||
/// </summary>
|
||||
private void DetailDataBind()
|
||||
{
|
||||
DataDetail.Visible = true;
|
||||
txtAccount.ReadOnly = true;
|
||||
txtName.Text = _logic.GetEmployee.em_name;
|
||||
txtBirthday.Text = _logic.GetEmployee.em_birthday.ToString();
|
||||
txtCell.Text = _logic.GetEmployee.em_cellnum;
|
||||
txtDateParty.Text = _logic.GetEmployee.em_date_in_party.ToString();
|
||||
txtID.Text = _logic.GetEmployee.em_idnum;
|
||||
txtMail.Text = _logic.GetEmployee.em_email;
|
||||
//txtPasswd.Text = _logic.GetEmployee.em_passwd;
|
||||
txtAccount.Text = _logic.GetEmployee.em_account;
|
||||
lbSelectedDept.Text = TreeDept.SelectedNode.Text;
|
||||
drplstSex.Items.FindByValue("1").Selected = true;
|
||||
|
||||
if (_logic.GetEmployee.em_sex)
|
||||
{
|
||||
drplstSex.Items.FindByValue("0").Selected = false;
|
||||
drplstSex.Items.FindByValue("1").Selected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
drplstSex.Items.FindByValue("1").Selected = false;
|
||||
drplstSex.Items.FindByValue("0").Selected = true;
|
||||
}
|
||||
if (drplstEducation.Items.FindByValue(_logic.GetEmployee.em_education) != null)
|
||||
// drplstEducation.Items.FindByValue(_logic.GetEmployee.em_education).Selected=true; //ListItemColleciton can only select one item, if another has been selected, this will case error.
|
||||
SetDropDownlistSelection(drplstEducation, _logic.GetEmployee.em_education);
|
||||
|
||||
bindGV();
|
||||
|
||||
if (drlstPlitics.Items.FindByValue(_logic.GetEmployee.em_politic) != null)
|
||||
//drlstPlitics.Items.FindByValue(_logic.GetEmployee.em_politic).Selected = true;
|
||||
SetDropDownlistSelection(drlstPlitics, _logic.GetEmployee.em_politic);
|
||||
|
||||
// chkStatus.Checked = _logic.GetRole.dr;
|
||||
}
|
||||
|
||||
|
||||
void bindGV()
|
||||
{
|
||||
GvDept.DataSource = _logic.GetDepartments(_logic.GetEmployee.ID);
|
||||
GvDept.DataBind();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
protected void btnAddnew_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(TreeDept.SelectedValue == "0" )
|
||||
{
|
||||
ScriptManager.RegisterStartupScript(btnSubmit, typeof(UpdatePanel), "alert",
|
||||
"alert('请选择用户所属部门。');", true);
|
||||
return;
|
||||
}
|
||||
txtAccount.ReadOnly = false;
|
||||
chgOperTxt(true);
|
||||
_logic.Initialize();
|
||||
ClearDetail();
|
||||
GridView1.SelectedIndex = -1;
|
||||
Databound();
|
||||
txtTitle.Enabled = true;
|
||||
lbTitle.Visible = true;
|
||||
txtTitle.Visible = true;
|
||||
lbSelectedDept.Text = TreeDept.SelectedNode.Text;
|
||||
// DetailDataBind();
|
||||
DataDetail.Visible = true;
|
||||
bindGV();
|
||||
}
|
||||
|
||||
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
bool userNotExist = true;
|
||||
SetDataBack();
|
||||
if (txtName.Text.Trim().Length == 0)
|
||||
{
|
||||
txtName.Focus();
|
||||
bindGrid();
|
||||
// ScriptManager.RegisterStartupScript(btnSubmit, typeof(UpdatePanel), "alert",
|
||||
// "alert('请输入用户姓名。');", true);
|
||||
return;
|
||||
|
||||
}
|
||||
if (txtAccount.Text.Trim().Length == 0)
|
||||
{
|
||||
txtAccount.Focus();
|
||||
bindGrid();
|
||||
// ScriptManager.RegisterStartupScript(btnSubmit, typeof (UpdatePanel), "alert",
|
||||
// "alert('请输入用户账号。');", true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if(lem.GetEmployee.em_account !="mysec" )
|
||||
if (_logic != null)
|
||||
if (_logic.GetEmployee != null)
|
||||
if(_logic.GetEmployee.QueryActived().Tables[0].Rows.Count>20)
|
||||
return;
|
||||
*/
|
||||
|
||||
if (_logic != null)
|
||||
if (_logic.GetEmployee != null)
|
||||
if (_logic.GetEmployee.ID > 0)
|
||||
_logic.GetEmployee.Update();
|
||||
else
|
||||
{
|
||||
userNotExist = _logic.AddEmployee();
|
||||
|
||||
|
||||
}
|
||||
if (!userNotExist)
|
||||
{
|
||||
ScriptManager.RegisterStartupScript(btnSubmit, typeof (UpdatePanel), "alert",
|
||||
"alert('用户名 " + txtAccount.Text
|
||||
+ " 已经存在,请重新输入,操作失败。');", true);
|
||||
|
||||
bindGrid();
|
||||
|
||||
txtAccount.Text ="";
|
||||
txtAccount.Focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearDetail();
|
||||
Databound();
|
||||
DataDetail.Visible = false;
|
||||
}
|
||||
|
||||
}
|
||||
void bindGrid()
|
||||
{
|
||||
_logic.GetEmployee.em_dept = TreeDept.SelectedValue;
|
||||
DataView dv = TreeDept.SelectedValue != "0" ? new DataView(_logic.GetActiveEmpByDept(Convert.ToInt32(TreeDept.SelectedValue))) : new DataView(_logic.GetActivedEmpDept());
|
||||
dv.RowFilter = "em_name <>'Root'";
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
|
||||
}
|
||||
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
||||
{
|
||||
|
||||
if (GridView1 != null)
|
||||
{
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
}
|
||||
|
||||
_logic.GetEmployee.Delete();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
||||
{
|
||||
GridView1.PageIndex = e.NewPageIndex;
|
||||
Databound();
|
||||
|
||||
//GridView1.DataSource = shiftLgc.getAllShifts().Tables[0];
|
||||
// GridView1.DataBind();
|
||||
}
|
||||
|
||||
protected void GridView1_DataBinding(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
Label lb;
|
||||
switch (e.Row.RowType)
|
||||
{
|
||||
case DataControlRowType.DataRow:
|
||||
lb = new Label();
|
||||
lb.Text = e.Row.Cells[3].Text.Trim().Equals("True") ? "男" : "女";
|
||||
e.Row.Cells[3].Controls.Add(lb);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
// _logic.GetRole.operater = Session["CurrentUserID"].ToString(); todo: write a public method to handle operater,createtime,lastmodfied ... log info.
|
||||
|
||||
if ( _logic.GetEmployee.ID >0 )
|
||||
{
|
||||
_logic.GetEmployee.lastmodified = DateTime.Now.ToString();
|
||||
|
||||
if(txtPasswd.Text.Trim().Length>0)
|
||||
_logic.GetEmployee.em_passwd = PublicUtils.Encrypt(txtPasswd.Text.Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
_logic.GetEmployee.em_passwd = PublicUtils.Encrypt(txtPasswd.Text.Trim());
|
||||
}
|
||||
|
||||
|
||||
|
||||
_logic.GetEmployee.dr = true;
|
||||
_logic.GetEmployee.em_name = txtName.Text;
|
||||
_logic.GetEmployee.em_account = txtAccount.Text;
|
||||
_logic.GetEmployee.em_birthday = txtBirthday.Text;
|
||||
_logic.GetEmployee.em_cellnum = txtCell.Text;
|
||||
_logic.GetEmployee.em_date_in_party = txtDateParty.Text;
|
||||
_logic.GetEmployee.em_date_work = txtworkdate.Text;
|
||||
_logic.GetEmployee.em_education = drplstEducation.SelectedValue;
|
||||
_logic.GetEmployee.em_email = txtMail.Text;
|
||||
_logic.GetEmployee.em_idnum = txtID.Text;
|
||||
|
||||
_logic.GetEmployee.em_politic = drlstPlitics.SelectedValue;
|
||||
_logic.GetEmployee.em_sex = drplstSex.SelectedIndex == 0;
|
||||
|
||||
|
||||
_logic.GetEmployee.em_dept = TreeDept.SelectedValue;
|
||||
_logic.GetEmployee.em_jobcode = txtTitle.Text;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
DataDetail.Visible = true;
|
||||
lbEdit.Text = addNew ? "增加新记录" : "修改现有记录";
|
||||
btnSubmit.Enabled = true;
|
||||
}
|
||||
|
||||
private void ClearDetail()
|
||||
{
|
||||
lbEdit.Text = "";
|
||||
txtworkdate.Text = "";
|
||||
txtName.Text = "" ;
|
||||
txtBirthday.Text = "";
|
||||
txtCell.Text = "";
|
||||
txtDateParty.Text = "";
|
||||
txtID.Text = "";
|
||||
txtMail.Text ="";
|
||||
txtPasswd.Text ="";
|
||||
txtAccount.Text ="";
|
||||
txtTitle.Text = "";
|
||||
lbSelectedDept.Text = TreeDept.SelectedNode.Text;
|
||||
txtPasswd.Text = "";
|
||||
InitDropdownlist();
|
||||
//装载选定部门节点的部门数据
|
||||
// drlstPlitics.SelectedIndex = -1;
|
||||
DataDetail.Visible = false;
|
||||
}
|
||||
|
||||
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
lbTitle.Visible = false;
|
||||
txtTitle.Visible = false;
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
txtTitle.Enabled = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void BindTree(string id, TreeNode pNode, DataView dv)
|
||||
{
|
||||
|
||||
dv.RowFilter = "dep_mastdept = '" + id + "'";
|
||||
foreach (DataRowView row in dv)
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = row["dep_name"].ToString();
|
||||
node.Value = row["pk_department"].ToString();
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
|
||||
TreeDept.Nodes.Add(node);
|
||||
node.Expanded = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pNode.ChildNodes.Add(node);
|
||||
node.Expanded = true;
|
||||
|
||||
}
|
||||
BindTree(node.Value, node, new DataView(dv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
protected void TreeDept_SelectedNodeChanged(object sender, EventArgs e)
|
||||
{
|
||||
/*
|
||||
DataView dv = new DataView(_logic.GetAllActiveData().Tables[0]);
|
||||
if(TreeDept.SelectedValue !="0")
|
||||
dv.RowFilter = "em_dept = '" + TreeDept.SelectedValue + "'";
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
ClearDetail();
|
||||
*/
|
||||
if (_logic != null) _logic.Initialize();
|
||||
GridView1.SelectedIndex = -1;
|
||||
Databound();
|
||||
|
||||
|
||||
}
|
||||
protected void drplstSex_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
ListItem selectedItem = drplstSex.Items[1];
|
||||
selectedItem.Selected = true;
|
||||
}
|
||||
|
||||
protected void InitDropdownlist()
|
||||
{
|
||||
|
||||
drplstSex.Items[ drplstSex.SelectedIndex].Selected = false;
|
||||
drplstSex.Items.FindByValue("1").Selected = true;
|
||||
|
||||
drlstPlitics.Items[drlstPlitics.SelectedIndex].Selected = false;
|
||||
drlstPlitics.Items[0].Selected = true;
|
||||
|
||||
}
|
||||
|
||||
protected void SetDropDownlistSelection(DropDownList drdlst,string value)
|
||||
{
|
||||
drdlst.Items[drdlst.SelectedIndex].Selected = false;
|
||||
if (drdlst.Items.FindByValue(value)!=null)
|
||||
drdlst.Items.FindByValue(value).Selected = true;
|
||||
}
|
||||
|
||||
//如果没有下面方法会报错类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内
|
||||
public override void VerifyRenderingInServerForm(Control control)
|
||||
{
|
||||
}
|
||||
protected void Excel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Master.ScriptMgr.RegisterPostBackControl(this.Button1);
|
||||
GridView1.AllowPaging = false;
|
||||
GridView1.Columns[11].Visible = false;
|
||||
Databound();
|
||||
Export("application/ms-excel", "张浦镇系统用户列表.xls");
|
||||
GridView1.AllowPaging = false;
|
||||
GridView1.Columns[11].Visible = true;
|
||||
Databound();
|
||||
|
||||
}
|
||||
|
||||
private void Export(string FileType, string FileName)
|
||||
{
|
||||
|
||||
Response.Charset = "GB2312";
|
||||
Response.ContentEncoding = Encoding.UTF7;
|
||||
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
|
||||
Response.ContentType = FileType;
|
||||
EnableViewState = false;
|
||||
StringWriter tw = new StringWriter();
|
||||
HtmlTextWriter hw = new HtmlTextWriter(tw);
|
||||
GridView1.RenderControl(hw);
|
||||
Response.Write(tw.ToString());
|
||||
Response.End();
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void GvDept_RowUpdating(object sender, GridViewUpdateEventArgs e)
|
||||
{
|
||||
if (GvDept.DataKeys != null)
|
||||
{
|
||||
string id = GvDept.DataKeys[e.RowIndex].Value.ToString();
|
||||
|
||||
_logic.GetDeptEmp.ID = Convert.ToInt32(id);
|
||||
_logic.GetDeptEmp.getModel();
|
||||
|
||||
_logic.GetDeptEmp.de_title = ((TextBox)GvDept.Rows[e.RowIndex].Cells[3].Controls[1]).Text;
|
||||
|
||||
//_logic.GetTrainingDetail.operater =
|
||||
_logic.GetDeptEmp.Update();
|
||||
}
|
||||
GvDept.EditIndex = -1;
|
||||
GvDept.SelectedIndex = e.RowIndex;
|
||||
bindGV();
|
||||
}
|
||||
protected void GvDept_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
|
||||
{
|
||||
GvDept.EditIndex = -1;
|
||||
GvDept.SelectedIndex = e.RowIndex;
|
||||
bindGV();
|
||||
}
|
||||
protected void GvDept_RowEditing(object sender, GridViewEditEventArgs e)
|
||||
{
|
||||
GvDept.EditIndex = e.NewEditIndex;
|
||||
GvDept.SelectedIndex = e.NewEditIndex;
|
||||
bindGV();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,297 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master"
|
||||
AutoEventWireup="true" CodeFile="EmployeeMain.aspx.cs" Inherits="EmployeeMain" %>
|
||||
|
||||
<%@ MasterType VirtualPath="~/masterPage.master" %>
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<table width="100%" class="Table_NoBorder">
|
||||
<tr>
|
||||
<td>
|
||||
<table width="100%" class="Table_Border">
|
||||
<tr>
|
||||
<td width="50" height="200" align="left" valign="top">
|
||||
<asp:TreeView ID="TreeDept" runat="server" ShowLines="True" OnSelectedNodeChanged="TreeDept_SelectedNodeChanged"
|
||||
ImageSet="Arrows">
|
||||
<nodes>
|
||||
<asp:TreeNode Text="张浦镇" Value="0" Expanded="True" Selected="True"></asp:TreeNode>
|
||||
</nodes>
|
||||
<selectednodestyle backcolor="Azure" bordercolor="Transparent" />
|
||||
</asp:TreeView>
|
||||
<asp:TextBox id="TextBox11" runat="server" visible=false>
|
||||
</asp:TextBox>
|
||||
|
||||
<cc1:calendarextender id="CalendarExtender11" runat="server" targetcontrolid="TextBox11"></cc1:calendarextender>
|
||||
|
||||
</td>
|
||||
<td width="1" class="VLine">
|
||||
</td>
|
||||
<td align="left" valign="top" width="90%">
|
||||
<!------ THE DATA GRID AREA ------>
|
||||
<asp:Label ID="lbDataGridTitle" Visible="false" runat="server" CssClass="Label" Text="人员维护" />
|
||||
<asp:Label ID="lbEdit" Visible="false" runat="server" CssClass="Label" Text=""></asp:Label>
|
||||
<asp:gridview id="GridView1" CssClass="DataGrid" PageSize="10" PagerStyle-HorizontalAlign="Right"
|
||||
runat="server" AutoGenerateColumns="False" OnRowEditing="GridView1_RowEditing"
|
||||
DataKeyNames="pk_employee" OnRowDeleting="GridView1_RowDeleting" AllowPaging="True"
|
||||
OnPageIndexChanging="GridView1_PageIndexChanging" OnRowDataBound="GridView1_RowDataBound"
|
||||
OnSorting="GridView1_Sorting" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
|
||||
Width="99%" ShowFooter="True" EmptyDataText='没有数据。'>
|
||||
<selectedrowstyle cssclass="SelectedItemStyle"></selectedrowstyle>
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center"></headerstyle>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center"></rowstyle>
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle"></alternatingrowstyle>
|
||||
<columns>
|
||||
<asp:BoundField Visible="TRUE" ReadOnly="True" DataField="PK_EMPLOYEE" HeaderText="人员编号" SortExpression="PK_EMPLOYEE" ></asp:BoundField>
|
||||
<asp:BoundField DataField="EM_NAME" HeaderText="姓名" SortExpression="EM_NAME">
|
||||
<ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="DEP_NAME" HeaderText="部门" SortExpression="DEP_NAME" >
|
||||
<ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="EM_SEX" HeaderText="性别" SortExpression="EM_SEX" HtmlEncode="False" DataFormatString="{0:True:男;False:女}">
|
||||
<ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="EM_BIRTHDAY" HeaderText="出生日期" SortExpression="EM_BIRTHDAY" DataFormatString="{0:yyyy-MM-dd}" HtmlEncode="False">
|
||||
<ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="de_title" HeaderText="职务" SortExpression="de_title">
|
||||
<ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="em_education" HeaderText="学历" SortExpression="em_education">
|
||||
<ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="em_politic" HeaderText="人员性质" SortExpression="em_politic">
|
||||
<ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="em_date_in_party" HeaderText="入党时间" SortExpression="em_date_in_party" DataFormatString="{0:yyyy-MM-dd}" HtmlEncode="False" >
|
||||
<ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="em_date_work" HeaderText="参加工作时间" SortExpression="em_date_work" DataFormatString="{0:yyyy-MM-dd}" HtmlEncode="False">
|
||||
<ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="dr" HeaderText="可用" SortExpression="dr" Visible="False" ></asp:BoundField>
|
||||
|
||||
<asp:CommandField HeaderText="编 辑" ShowDeleteButton="True" DeleteText="<img src=../Images/Delete.gif border=0 title=删除 onclick='return delete_click()'>" ShowHeader="True" ShowSelectButton="True" SelectText="<img src=../Images/edit.gif border=0 title=修改 >">
|
||||
<HeaderStyle HorizontalAlign="Center" Width="10%" />
|
||||
<ItemStyle HorizontalAlign="Center" Width="10%" />
|
||||
</asp:CommandField>
|
||||
</columns>
|
||||
<pagerstyle horizontalalign="Right" />
|
||||
<emptydatatemplate> 没有数据</emptydatatemplate>
|
||||
</asp:gridview>
|
||||
<asp:Button ID="btn_addNew" runat="server" Text="新增记录" CssClass="Button" OnClick="btnAddnew_Click" />
|
||||
<asp:Button ID="Button1" runat="server" Text="导出Excel" CssClass="Button" OnClick="Excel_Click" />
|
||||
|
||||
<asp:Panel ID="DataDetail" runat="server" Width="100%" Visible="false">
|
||||
<!------ THE ADD /DELETE AREA ------>
|
||||
<table class="Table_NoBorder" border="0" width="95%">
|
||||
<tr>
|
||||
<td colspan="6" class="ALine">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<asp:Label ID="Label2" runat="server" CssClass="Label" Text='姓名'></asp:Label></td>
|
||||
<td nowrap>
|
||||
<asp:TextBox ID="txtName" runat="server" CssClass="TextBox" MaxLength="25">
|
||||
</asp:TextBox>
|
||||
<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ControlToValidate="txtName"
|
||||
ErrorMessage="请输入用户名。" SetFocusOnError="True" ValidationGroup="1">*</asp:RequiredFieldValidator></td>
|
||||
<td>
|
||||
<asp:Label ID="Label4" runat="server" CssClass="Label" Text='性别'></asp:Label></td>
|
||||
<td>
|
||||
<asp:DropDownList ID="drplstSex" runat="server" CssClass="DropDownList">
|
||||
<asp:ListItem Value="1">男</asp:ListItem>
|
||||
<asp:ListItem Value="0">女</asp:ListItem>
|
||||
</asp:DropDownList></td>
|
||||
<td nowrap>
|
||||
出生日期</td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtBirthday" CssClass="TextBox" runat="server" MaxLength="25">
|
||||
</asp:TextBox>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<asp:Label ID="Label6" runat="server" CssClass="Label" Text="身份证号"></asp:Label></td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtID" CssClass="TextBox" runat="server" MaxLength="25">
|
||||
</asp:TextBox>
|
||||
</td>
|
||||
<td nowrap>
|
||||
<asp:Label ID="Label3" runat="server" CssClass="Label" Text="人员性质"></asp:Label></td>
|
||||
<td>
|
||||
<asp:DropDownList ID="drlstPlitics" runat="server" CssClass="DropDownList">
|
||||
<asp:ListItem>无党派</asp:ListItem>
|
||||
<asp:ListItem>中共党员</asp:ListItem>
|
||||
<asp:ListItem>共青团员</asp:ListItem>
|
||||
<asp:ListItem>其他党派</asp:ListItem>
|
||||
</asp:DropDownList></td>
|
||||
<td nowrap>
|
||||
<asp:Label ID="lbPartytime" runat="server" CssClass="Label" Text="入党时间" /></td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtDateParty" CssClass="TextBox" runat="server" MaxLength="25">
|
||||
</asp:TextBox></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<asp:Label ID="Label10" runat="server" CssClass="Label" Text="电子信箱"></asp:Label></td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtMail" CssClass="TextBox" runat="server" MaxLength="25" CausesValidation="True"></asp:TextBox>
|
||||
<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ControlToValidate="txtMail"
|
||||
ErrorMessage="电子信箱格式不正确,正确格式如zhangsan@163.net。" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
|
||||
ValidationGroup="1">*
|
||||
</asp:RegularExpressionValidator>
|
||||
</td>
|
||||
<td>
|
||||
<asp:Label ID="Label5" runat="server" CssClass="Label" Text="参加工作时间"></asp:Label></td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtworkdate" CssClass="TextBox" runat="server" MaxLength="25">
|
||||
</asp:TextBox></td>
|
||||
<td>
|
||||
学历</td>
|
||||
<td>
|
||||
<asp:DropDownList ID="drplstEducation" CssClass="DropDownList" runat="server">
|
||||
<asp:ListItem>博士</asp:ListItem>
|
||||
<asp:ListItem>硕士研究生</asp:ListItem>
|
||||
<asp:ListItem>本科</asp:ListItem>
|
||||
<asp:ListItem>专科</asp:ListItem>
|
||||
<asp:ListItem>中专</asp:ListItem>
|
||||
<asp:ListItem>高中</asp:ListItem>
|
||||
<asp:ListItem>初中</asp:ListItem>
|
||||
<asp:ListItem>小学</asp:ListItem>
|
||||
<asp:ListItem>其他</asp:ListItem>
|
||||
</asp:DropDownList></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap>
|
||||
<asp:Label ID="Label7" runat="server" CssClass="Label" Text="账号"></asp:Label></td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtAccount" CssClass="TextBox" runat="server" MaxLength="25">
|
||||
</asp:TextBox>
|
||||
<asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ControlToValidate="txtAccount"
|
||||
ErrorMessage="请输入账号。" ValidationGroup="1">*</asp:RequiredFieldValidator></td>
|
||||
<td nowrap>
|
||||
<asp:Label ID="Label8" runat="server" CssClass="Label" Text="密码"></asp:Label></td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtPasswd" CssClass="TextBox" runat="server" MaxLength="25" TextMode="Password">
|
||||
</asp:TextBox></td>
|
||||
<td>
|
||||
<asp:Label ID="Label9" runat="server" CssClass="Label" Text="手机"></asp:Label></td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtCell" CssClass="TextBox" runat="server" MaxLength="25" CausesValidation="True"></asp:TextBox>
|
||||
<asp:RegularExpressionValidator id="RegularExpressionValidator2" runat="server" ControlToValidate="txtCell"
|
||||
Display="Dynamic" ErrorMessage="手机号码格式不正确,应为11位数字。" ValidationExpression="^\d{11}$" ValidationGroup="1">*
|
||||
</asp:RegularExpressionValidator></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap>
|
||||
<asp:Label ID="lableDept" runat="server" CssClass="Label" Text="当前部门"></asp:Label></td>
|
||||
<td>
|
||||
<asp:Label ID="lbSelectedDept" runat="server" CssClass="Label" Text="" /></td>
|
||||
<td nowrap>
|
||||
<asp:Label ID="lbTitle" runat="server" CssClass="Label" Text="职务"></asp:Label></td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtTitle" CssClass="TextBox" runat="server" MaxLength="25">
|
||||
</asp:TextBox></td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<asp:Label ID="lbempdept" runat="server" CssClass="Label" Text="部门分配"></asp:Label></td>
|
||||
<td colspan="4" align="center">
|
||||
<asp:gridview id="GvDept" runat="server" AutoGenerateColumns="False" CssClass="DataGrid"
|
||||
DataKeyNames="pk_deptemp" emptydatatext="没有数据。" ShowFooter="True" tabIndex="1"
|
||||
Width="100%" OnRowCancelingEdit="GvDept_RowCancelingEdit" OnRowUpdating="GvDept_RowUpdating"
|
||||
OnRowEditing="GvDept_RowEditing">
|
||||
<columns>
|
||||
<asp:BoundField ReadOnly="True" DataField="pk_deptemp" Visible="False" SortExpression="pk_deptemp" HeaderText="id"></asp:BoundField>
|
||||
<asp:BoundField ReadOnly="True" DataField="DEP_NAME" SortExpression="DEP_NAME" HeaderText="部门名称"></asp:BoundField>
|
||||
<asp:BoundField ReadOnly="True" DataField="DEP_DESC" SortExpression="DEP_DESC" HeaderText="部门描述"></asp:BoundField>
|
||||
<asp:TemplateField SortExpression="DE_TITLE" HeaderText="职务"><EditItemTemplate>
|
||||
<asp:TextBox runat="server" Text='<%# Bind("DE_TITLE") %>' id="TextBox1"></asp:TextBox>
|
||||
|
||||
</EditItemTemplate>
|
||||
<ItemTemplate>
|
||||
<asp:Label runat="server" Text='<%# Bind("DE_TITLE") %>' id="Label1"></asp:Label>
|
||||
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
<asp:CommandField InsertVisible="False" CancelImageUrl="~/Images/undo.gif" EditImageUrl="~/Images/edit.gif" ShowHeader="True" UpdateImageUrl="~/Images/save.gif" ButtonType="Image" ShowEditButton="True"></asp:CommandField>
|
||||
</columns>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center" />
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center" />
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle" />
|
||||
<selectedrowstyle cssclass="SelectedItemStyle" />
|
||||
</asp:gridview>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtBirthday"
|
||||
FirstDayOfWeek="Monday" CssClass="MyCalendar">
|
||||
</cc1:CalendarExtender>
|
||||
</td>
|
||||
<td>
|
||||
<cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtworkdate"
|
||||
FirstDayOfWeek="Monday" CssClass="MyCalendar">
|
||||
</cc1:CalendarExtender>
|
||||
</td>
|
||||
<td>
|
||||
<cc1:CalendarExtender ID="CalendarExtender3" runat="server" TargetControlID="txtDateParty"
|
||||
FirstDayOfWeek="Monday" CssClass="MyCalendar">
|
||||
</cc1:CalendarExtender>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6" >
|
||||
<asp:ValidationSummary id="ValidationSummary1" runat="server" ValidationGroup="1" HeaderText="错误提示"></asp:ValidationSummary>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6" class="ALine">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6" align="center">
|
||||
<asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存" OnClick="btnSubmit_Click" ValidationGroup="1" />
|
||||
<!--input type="button" id="ButtonCancel" onClick="reset()" class="Button" value="取消修改" name="ButtonCancel"/-->
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Panel>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="ALine">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align="center" style="height: 309px" valign="top">
|
||||
<!------ THE ADD /DELETE AREA ------>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Content>
|
|
@ -0,0 +1,266 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Tracen.Utils;
|
||||
using ZhangPu.Gov.Logical;
|
||||
|
||||
public partial class PublicNewsMain : PageBase
|
||||
{
|
||||
private LPublicNews _logic;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
_logic = new LPublicNews();
|
||||
Databound();
|
||||
}
|
||||
SessionSeting();
|
||||
}
|
||||
|
||||
/***************************************** private methods ******************************************/
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
|
||||
|
||||
//装载选定节点的数据
|
||||
DataView dv = new DataView(_logic.QueryPublicInfomation());
|
||||
|
||||
TreeAuth.SelectedNode.ChildNodes.Clear();
|
||||
BindTree(TreeAuth.SelectedNode.Value, TreeAuth.SelectedNode, dv);
|
||||
//绑定树列表里选中的所有数据
|
||||
|
||||
GridView1.DataSource = _logic.QueryNews(Convert.ToInt32(TreeAuth.SelectedValue));
|
||||
GridView1.DataBind();
|
||||
|
||||
// GVFiles.DataSource = null;
|
||||
// GVFiles.DataBind();
|
||||
UpdateSession();
|
||||
ClearDetail();
|
||||
}
|
||||
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LPublicNews)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set data from shift object to page
|
||||
/// </summary>
|
||||
private void DetailDataBind()
|
||||
{
|
||||
|
||||
DataDetail.Visible = true;
|
||||
txtTitle.Text = _logic.GetPublicNews.news_title;
|
||||
txtDesc.Text = _logic.GetPublicNews.news_content;
|
||||
}
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
protected void btnAddnew_Click(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(true);
|
||||
_logic.Initialize();
|
||||
|
||||
GridView1.SelectedIndex = -1;
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
//todo bind attached files infomationsss\\
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetDataBack();
|
||||
//shifts id eq 0 means this is new one,to add; else an old one, to update
|
||||
|
||||
int oper = 0;
|
||||
oper = _logic.GetPublicNews.ID > 0 ? _logic.GetPublicNews.Update() : _logic.GetPublicNews.Add();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
lbEdit.Text = "";
|
||||
}
|
||||
|
||||
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
||||
{
|
||||
|
||||
if (GridView1 != null)
|
||||
{
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
}
|
||||
/*
|
||||
_logic.GetRole.dr = false;
|
||||
_logic.GetRole.Update();
|
||||
|
||||
*/
|
||||
_logic.GetPublicNews.Delete();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
||||
{
|
||||
GridView1.PageIndex = e.NewPageIndex;
|
||||
Databound();
|
||||
|
||||
//GridView1.DataSource = shiftLgc.getAllShifts().Tables[0];
|
||||
// GridView1.DataBind();
|
||||
}
|
||||
|
||||
protected void GridView1_DataBinding(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
// _logic.GetRole.operater = Session["CurrentUserID"].ToString(); todo: write a public method to handle operater,createtime,lastmodfied ... log info.
|
||||
|
||||
if (!(_logic.GetPublicNews.ID > 0))
|
||||
{
|
||||
_logic.GetPublicNews.last_modified = DateTime.Now.ToString();
|
||||
_logic.GetPublicNews.news_authority = Convert.ToInt32(TreeAuth.SelectedValue);
|
||||
}
|
||||
|
||||
_logic.GetPublicNews.news_title = txtTitle.Text;
|
||||
_logic.GetPublicNews.news_content = txtDesc.Text;
|
||||
|
||||
//todo bind files
|
||||
}
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
DataDetail.Visible = true;
|
||||
lbEdit.Text = addNew ? "增加新记录" : "修改现有记录";
|
||||
btnSubmit.Enabled = true;
|
||||
}
|
||||
|
||||
private void ClearDetail()
|
||||
{
|
||||
txtTitle.Text = "";
|
||||
txtDesc.Text = "";
|
||||
|
||||
DataDetail.Visible = false;
|
||||
}
|
||||
|
||||
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void BindTree(string id, TreeNode pNode, DataView dv)
|
||||
{
|
||||
|
||||
dv.RowFilter = "auth_uplevel = '" + id + "'";
|
||||
foreach (DataRowView row in dv)
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = row["auth_name"].ToString();
|
||||
node.Value = row["pk_authority"].ToString();
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
|
||||
TreeAuth.Nodes.Add(node);
|
||||
node.Expanded = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pNode.ChildNodes.Add(node);
|
||||
node.Expanded = true;
|
||||
|
||||
}
|
||||
BindTree(node.Value, node, new DataView(dv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void TreeAuth_SelectedNodeChanged1(object sender, EventArgs e)
|
||||
{
|
||||
GridView1.SelectedIndex = -1;
|
||||
DataView dv = new DataView(_logic.QueryNews(Convert.ToInt32(TreeAuth.SelectedValue)));
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
ClearDetail();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
switch (e.Row.RowType)
|
||||
{
|
||||
case DataControlRowType.DataRow:
|
||||
if (e.Row.Cells[2].Text.Trim().Length > 30) e.Row.Cells[2].Text = e.Row.Cells[2].Text.Substring(0,30)+"....";
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master" AutoEventWireup="true" CodeFile="PublicNewsMain.aspx.cs" Inherits="PublicNewsMain" %>
|
||||
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
|
||||
Namespace="System.Web.UI" TagPrefix="asp" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<table width="100%" class="Table_NoBorder">
|
||||
|
||||
<tr><td>
|
||||
<table width="100%" class="Table_Border">
|
||||
<tr><td width="50" height="200" align="left" valign="top">
|
||||
<asp:TreeView ID="TreeAuth" runat="server" ShowLines="True" ImageSet="Arrows" OnSelectedNodeChanged="TreeAuth_SelectedNodeChanged1">
|
||||
<SelectedNodeStyle BackColor="Azure" BorderColor="Transparent" />
|
||||
<Nodes>
|
||||
<asp:TreeNode Text="公共信息发布" Selected="True" Value="0" Expanded="True"></asp:TreeNode>
|
||||
</Nodes>
|
||||
</asp:TreeView>
|
||||
</td>
|
||||
<td width="1" class="VLine" ></td>
|
||||
<td width="100%" align="left" valign="top"> <!------ THE DATA GRID AREA ------>
|
||||
|
||||
<asp:Label ID="lbDataGridTitle" Visible="false" runat="server" CssClass="Label" Text="信息维护" />
|
||||
<asp:Label ID="lbEdit" Visible="false" runat="server" CssClass="Label" Text=""></asp:Label>
|
||||
<asp:gridview id="GridView1" CssClass="DataGrid"
|
||||
PageSize="10" PagerStyle-HorizontalAlign="Right"
|
||||
runat="server"
|
||||
AutoGenerateColumns="False"
|
||||
DataKeyNames="PK_NEWS"
|
||||
OnRowDeleting="GridView1_RowDeleting"
|
||||
AllowPaging="True"
|
||||
OnPageIndexChanging="GridView1_PageIndexChanging"
|
||||
|
||||
OnSorting="GridView1_Sorting" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="100%" ShowFooter="True" EmptyDataText='没有数据。' OnRowDataBound="GridView1_RowDataBound">
|
||||
|
||||
<SelectedRowStyle CssClass="SelectedItemStyle"></SelectedRowStyle>
|
||||
<HeaderStyle CssClass="HeaderStyle" ></HeaderStyle>
|
||||
<RowStyle CssClass="ItemStyle" HorizontalAlign="Center"></RowStyle>
|
||||
<AlternatingRowStyle CssClass="AlternatingItemStyle"></AlternatingRowStyle>
|
||||
|
||||
<Columns>
|
||||
<asp:BoundField ReadOnly="True" DataField="PK_NEWS" visible="false" HeaderText="权限id" SortExpression="PK_DEPARTMENT" ></asp:BoundField>
|
||||
<asp:BoundField DataField="news_title" HeaderText="信息标题" SortExpression="news_title" ></asp:BoundField>
|
||||
<asp:BoundField DataField="news_content" HeaderText="信息内容" SortExpression="news_content" ></asp:BoundField>
|
||||
<asp:BoundField DataField="create_time" HeaderText="发布时间" SortExpression="create_time" ></asp:BoundField>
|
||||
<asp:BoundField DataField="dr" HeaderText="可用" SortExpression="dr" Visible="False" ></asp:BoundField>
|
||||
|
||||
<asp:CommandField HeaderText="编 辑" ShowDeleteButton="True" DeleteText="<img src=../Images/Delete.gif border=0 title=删除 onclick='return delete_click()'>" ShowHeader="True" ShowSelectButton="True" SelectText="<img src=../Images/edit.gif border=0 title=修改 >">
|
||||
<HeaderStyle HorizontalAlign="Center" Width="15%" />
|
||||
<ItemStyle HorizontalAlign="Center" Width="15%" />
|
||||
</asp:CommandField>
|
||||
</Columns>
|
||||
<PagerStyle HorizontalAlign="Right" />
|
||||
<emptydatatemplate> 没有数据</emptydatatemplate>
|
||||
</asp:gridview>
|
||||
<asp:Button ID="btn_addNew" runat="server" Text="新增记录" CssClass="Button" OnClick="btnAddnew_Click" />
|
||||
|
||||
|
||||
<asp:Panel ID ="DataDetail" runat="server" Width="100%" Visible="false">
|
||||
|
||||
<!------ THE ADD /DELETE AREA ------>
|
||||
<table class="Table_NoBorder" width="100%">
|
||||
<tr>
|
||||
<td colspan ="4" class="ALine" >
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td nowrap>
|
||||
<asp:Label ID="Label2" runat="server" CssClass="Label" Text="标题"></asp:Label></td>
|
||||
<td >
|
||||
|
||||
<asp:TextBox ID="txtTitle" runat="server" CssClass="TextBox" MaxLength="100" width="400px"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTitle"
|
||||
ErrorMessage="*" ValidationGroup="1">*</asp:RequiredFieldValidator></td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<td style="height: 218px">
|
||||
<asp:Label ID="Label3" runat="server" CssClass="Label" Text="内容"></asp:Label></td><td style="height: 218px" >
|
||||
<asp:TextBox ID="txtDesc" CssClass="Long_TextBox" runat="server" MaxLength="50" Width="803px" Height="300px" TextMode="MultiLine"></asp:TextBox></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan ="4" class="ALine" >
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!------ BUTTONS ------>
|
||||
<table class="Table_NoBorder" width="80%">
|
||||
<tr>
|
||||
<td align="center" > <asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存数据" OnClick="btnSubmit_Click" ValidationGroup="1" />
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Panel>
|
||||
|
||||
</td></tr>
|
||||
|
||||
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
</asp:Content>
|
||||
|
|
@ -0,0 +1,279 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using System.Transactions;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using ZhangPu.Gov.Logical;
|
||||
using Tracen.Utils;
|
||||
|
||||
public partial class RoleAuth : PageBase
|
||||
{
|
||||
private LRoleAuthority _logic;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
_logic = new LRoleAuthority();
|
||||
Databound();
|
||||
bindAuth();
|
||||
bindRoles();
|
||||
|
||||
}
|
||||
SessionSeting();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
// bindAuth();
|
||||
// bindRoles();
|
||||
|
||||
bindGV();
|
||||
UpdateSession();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定权限
|
||||
/// </summary>
|
||||
void bindAuth()
|
||||
{
|
||||
treeAuth.Nodes.Clear();
|
||||
BindAuthTree("0", treeAuth.SelectedNode, _logic.QueryNonePublicAuthority().DefaultView);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///绑定角色
|
||||
/// </summary>
|
||||
private void bindRoles()
|
||||
{
|
||||
DataView dv = _logic.GetAllRoles().DefaultView;
|
||||
dv.RowFilter = "role_4Approve =0";
|
||||
listRoles.DataSource =dv;
|
||||
listRoles.DataTextField = "role_name";
|
||||
listRoles.DataValueField = "pk_role";
|
||||
listRoles.DataBind();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void BindAuthTree(string id, TreeNode pNode, DataView dv )
|
||||
{
|
||||
|
||||
dv.RowFilter = "auth_uplevel = '" + id + "'";
|
||||
foreach (DataRowView row in dv)
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
string authLink = row["auth_link"].ToString();
|
||||
node.Value = row["pk_authority"].ToString();
|
||||
node.Expanded = true;
|
||||
if (authLink == string.Empty || authLink.Trim().Length < 6) //not *.aspx
|
||||
{
|
||||
node.Text = "<strong>" + row["auth_name"] + "</strong>";
|
||||
node.SelectAction = TreeNodeSelectAction.None;
|
||||
node.ShowCheckBox = false;
|
||||
} else
|
||||
|
||||
{
|
||||
node.Text = row["auth_name"].ToString() ;
|
||||
}
|
||||
|
||||
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
|
||||
treeAuth.Nodes.Add(node);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
pNode.ChildNodes.Add(node);
|
||||
|
||||
}
|
||||
BindAuthTree(node.Value, node, new DataView(dv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LRoleAuthority)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listRoles.SelectedValue == string.Empty) return;
|
||||
//角色,权限
|
||||
ArrayList al = new ArrayList();
|
||||
GetCheckedNode(treeAuth.Nodes, al);
|
||||
_logic.Initialize();
|
||||
// using (TransactionScope trans = new TransactionScope())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
_logic.GetRoleAuthority.Delete(Convert.ToInt32(listRoles.SelectedValue));
|
||||
// _logic.Initialize();
|
||||
foreach (string id in al)
|
||||
{
|
||||
_logic.GetRoleAuthority.ra_role = Convert.ToInt32(listRoles.SelectedValue);
|
||||
_logic.GetRoleAuthority.ra_authority = Convert.ToInt32(id);
|
||||
_logic.GetRoleAuthority.Add();
|
||||
}
|
||||
|
||||
// trans.Complete();
|
||||
}
|
||||
catch (MyException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception("出现异常,保存失败。");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Databound();
|
||||
}
|
||||
|
||||
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
ClearDetail();
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GetCheckedNode(TreeNodeCollection tnc, ArrayList checkedvalues )
|
||||
{
|
||||
foreach(TreeNode node in tnc)
|
||||
{
|
||||
if(node.Checked)
|
||||
{
|
||||
checkedvalues.Add(node.Value);
|
||||
|
||||
}
|
||||
GetCheckedNode(node.ChildNodes, checkedvalues);
|
||||
}
|
||||
}
|
||||
|
||||
void SetCheckedNode(TreeNodeCollection tnc, ArrayList setcheckedvalues)
|
||||
{
|
||||
foreach (TreeNode node in tnc)
|
||||
{
|
||||
node.Checked = setcheckedvalues.Contains(Convert.ToInt32(node.Value));
|
||||
|
||||
SetCheckedNode(node.ChildNodes, setcheckedvalues);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
|
||||
btnSubmit.Enabled = true;
|
||||
|
||||
}
|
||||
|
||||
private void ClearDetail()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void listRoles_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
if (treeAuth.SelectedNode != null) treeAuth.SelectedNode.Selected = false;
|
||||
lbAuthRole.Text = "权限角色清单" ;
|
||||
GvRole.DataSource = null;
|
||||
GvRole.DataBind();
|
||||
*/
|
||||
|
||||
//--重置权限树的选择
|
||||
ArrayList autList = new ArrayList();
|
||||
DataView dv = _logic.GetRoleAuthority.QueryActived().Tables[0].DefaultView;
|
||||
dv.RowFilter = "ra_role ='" + listRoles.SelectedValue + "'";
|
||||
foreach (DataRowView drv in dv)
|
||||
{
|
||||
autList.Add(drv["ra_authority"]);
|
||||
}
|
||||
SetCheckedNode(treeAuth.Nodes, autList);
|
||||
|
||||
bindGV();
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void treeAuth_SelectedNodeChanged(object sender, EventArgs e)
|
||||
{
|
||||
bindGV();
|
||||
|
||||
}
|
||||
|
||||
void bindGV()
|
||||
{
|
||||
//角色对应的人员清单
|
||||
if (listRoles.SelectedItem != null)
|
||||
{
|
||||
|
||||
lbRoleEm.Text = listRoles.SelectedItem.Text + " 角色人员清单";
|
||||
GvEm.DataSource = _logic.GetEmListByRole(Convert.ToInt32(listRoles.SelectedValue));
|
||||
}
|
||||
GvEm.DataBind();
|
||||
|
||||
|
||||
//权限对应的角色,人员清单
|
||||
if (treeAuth.SelectedNode != null)
|
||||
{
|
||||
lbAuthEm.Text = treeAuth.SelectedNode.Text + " 权限人员清单";
|
||||
GvAuthEm.DataSource = _logic.GetEmListByAuth(Convert.ToInt32(treeAuth.SelectedValue));
|
||||
lbAuthRole.Text = treeAuth.SelectedNode.Text + " 权限角色清单";
|
||||
GvRole.DataSource = _logic.GetRoleListByAuth(Convert.ToInt32(treeAuth.SelectedValue));
|
||||
|
||||
}
|
||||
GvAuthEm.DataBind();
|
||||
GvRole.DataBind();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master" AutoEventWireup="true" CodeFile="RoleAuth.aspx.cs" Inherits="RoleAuth" %>
|
||||
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<table width="100%" class="Table_NoBorder">
|
||||
|
||||
<tr><td>
|
||||
<table width="100%" class="Table_NoBorder" border="1">
|
||||
<tr class="HeaderStyle">
|
||||
<td style="width: 120px"><asp:Label ID="lbrole" runat="server" Font-Bold="True" Text="角色列表" /> </td>
|
||||
<td style="width: 180px"> <asp:Label ID="lbAuth" runat="server" Font-Bold="True" Text="权限列表" /></td>
|
||||
<td style="width: 200px" nowrap>
|
||||
<asp:Label ID="lbAuthRole" runat="server" Font-Bold="True" Text="角色清单" /></td>
|
||||
<td valign ="top" style="width: 200px" nowrap>
|
||||
<asp:Label ID="lbRoleEm" runat="server" Font-Bold="True" Text="人员清单" /></td>
|
||||
<td style="width: 200px" nowrap><asp:Label ID="lbAuthEm" runat="server" Font-Bold="True" Text="人员清单" /></td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign ="top" >
|
||||
<asp:ListBox id="listRoles" runat="server" width="120px" Height="360px" OnSelectedIndexChanged="listRoles_SelectedIndexChanged" AutoPostBack="True">
|
||||
</asp:ListBox></td>
|
||||
<td valign ="top">
|
||||
|
||||
|
||||
<asp:TreeView ID="treeAuth" runat="server" ShowLines="True" ImageSet="Arrows" OnSelectedNodeChanged="treeAuth_SelectedNodeChanged" ShowCheckBoxes="All" >
|
||||
<SelectedNodeStyle BackColor="Azure" BorderColor="Transparent" />
|
||||
<Nodes>
|
||||
<asp:TreeNode Text="" Selected="True" Value="0" Expanded="True"></asp:TreeNode>
|
||||
</Nodes>
|
||||
</asp:TreeView>
|
||||
|
||||
</td>
|
||||
<td valign ="top">
|
||||
|
||||
<asp:gridview id="GvRole" runat="server" AllowPaging="True" AutoGenerateColumns="False"
|
||||
CssClass="DataGrid" emptydatatext="没有数据。"
|
||||
ShowFooter="True"
|
||||
Width="100%">
|
||||
<columns>
|
||||
|
||||
<asp:BoundField DataField="ROLE_NAME" SortExpression="ROLE_NAME" HeaderText="角色名称"></asp:BoundField>
|
||||
<asp:BoundField DataField="ROLE_DESC" SortExpression="ROLE_DESC" HeaderText="角色描述"></asp:BoundField>
|
||||
|
||||
</columns>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center" />
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center" />
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle" />
|
||||
</asp:gridview>
|
||||
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
<td valign ="top">
|
||||
|
||||
<asp:gridview id="GvEm" runat="server" AllowPaging="True" AutoGenerateColumns="False"
|
||||
CssClass="DataGrid" emptydatatext="没有数据。"
|
||||
ShowFooter="True"
|
||||
Width="100%">
|
||||
<columns>
|
||||
|
||||
<asp:BoundField DataField="EM_NAME" SortExpression="EM_NAME" HeaderText="人员名称"></asp:BoundField>
|
||||
<asp:BoundField DataField="Dep_name" SortExpression="Dep_name" HeaderText="所属部门"></asp:BoundField>
|
||||
|
||||
</columns>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center" />
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center" />
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle" />
|
||||
</asp:gridview>
|
||||
|
||||
|
||||
</td>
|
||||
<td valign ="top">
|
||||
<asp:gridview id="GvAuthEm" runat="server" AllowPaging="True" AutoGenerateColumns="False"
|
||||
CssClass="DataGrid" emptydatatext="没有数据。"
|
||||
ShowFooter="True"
|
||||
Width="100%">
|
||||
<columns>
|
||||
|
||||
<asp:BoundField DataField="EM_NAME" SortExpression="EM_NAME" HeaderText="人员名称"></asp:BoundField>
|
||||
<asp:BoundField DataField="Dep_name" SortExpression="Dep_name" HeaderText="所属部门"></asp:BoundField>
|
||||
|
||||
</columns>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center" />
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center" />
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle" />
|
||||
</asp:gridview></td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td></tr>
|
||||
<tr><td class="ALine" >
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<td align="center" > <asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存数据" OnClick="btnSubmit_Click" />
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td style="width: 532px">
|
||||
|
||||
<br/></td></tr>
|
||||
</table>
|
||||
|
||||
</asp:Content>
|
||||
|
|
@ -0,0 +1,277 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using System.Transactions;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using ZhangPu.Gov.Logical;
|
||||
using Tracen.Utils;
|
||||
|
||||
public partial class RoleEmp : PageBase
|
||||
{
|
||||
private LRoleAuthority _logic;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
_logic = new LRoleAuthority();
|
||||
Databound();
|
||||
bindRoles();
|
||||
bindDeptEmp(); //分配角色时初始化部门人员树
|
||||
}
|
||||
SessionSeting();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
// bindAuth();
|
||||
// bindRoles();
|
||||
// if (!isRoleAuth) bindDeptEmp(); //分配角色时初始化部门人员树
|
||||
bindGV();
|
||||
UpdateSession();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 绑定部门及用户
|
||||
/// </summary>
|
||||
private void bindDeptEmp()
|
||||
{
|
||||
TreeDeptEmp.Nodes.Clear();
|
||||
BindTree("0", TreeDeptEmp.SelectedNode, new LEmployee().GetDepartments().DefaultView, new LEmployee().GetActivedEmpDept().DefaultView);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///绑定角色
|
||||
/// </summary>
|
||||
private void bindRoles()
|
||||
{
|
||||
|
||||
listRoles.DataSource = _logic.GetAllRoles();
|
||||
listRoles.DataTextField = "role_name";
|
||||
listRoles.DataValueField = "pk_role";
|
||||
listRoles.DataBind();
|
||||
}
|
||||
|
||||
public void BindTree(string id, TreeNode pNode, DataView deptdv,DataView empdv)
|
||||
{
|
||||
|
||||
deptdv.RowFilter = "dep_mastdept = '" + id + "'";
|
||||
foreach (DataRowView row in deptdv)
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = "<em>" + row["dep_name"] + "</em>" + row["pk_department"];
|
||||
node.Value = row["pk_department"].ToString();
|
||||
node.SelectAction = TreeNodeSelectAction.None;
|
||||
node.ShowCheckBox = false;
|
||||
node.Expanded = true;
|
||||
empdv.RowFilter = "de_dept=" + node.Value;
|
||||
foreach (DataRowView emrow in empdv)
|
||||
{
|
||||
TreeNode tnEmp = new TreeNode("<Strong>" + emrow["em_name"] + "</Strong>" , emrow["pk_employee"].ToString());
|
||||
node.ChildNodes.Add(tnEmp);
|
||||
}
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
|
||||
TreeDeptEmp.Nodes.Add(node);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
pNode.ChildNodes.Add(node);
|
||||
|
||||
}
|
||||
BindTree(node.Value, node, new DataView(deptdv.Table), new DataView(empdv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LRoleAuthority)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listRoles.SelectedValue == string.Empty) return;
|
||||
ArrayList al = new ArrayList();
|
||||
|
||||
GetCheckedNode(TreeDeptEmp.Nodes, al);
|
||||
_logic.Initialize();
|
||||
// using (TransactionScope trans = new TransactionScope())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
_logic.GetRoleEmp.Delete(Convert.ToInt32(listRoles.SelectedValue));
|
||||
|
||||
foreach (string id in al)
|
||||
{
|
||||
_logic.GetRoleEmp.re_role = Convert.ToInt32(listRoles.SelectedValue);
|
||||
_logic.GetRoleEmp.re_employee = Convert.ToInt32(id);
|
||||
_logic.GetRoleEmp.Add();
|
||||
}
|
||||
|
||||
// trans.Complete();
|
||||
}
|
||||
catch (MyException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception("出现异常,保存失败。");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Databound();
|
||||
}
|
||||
|
||||
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GetCheckedNode(TreeNodeCollection tnc, ArrayList checkedvalues )
|
||||
{
|
||||
foreach(TreeNode node in tnc)
|
||||
{
|
||||
if(node.Checked)
|
||||
{
|
||||
checkedvalues.Add(node.Value);
|
||||
|
||||
}
|
||||
GetCheckedNode(node.ChildNodes, checkedvalues);
|
||||
}
|
||||
}
|
||||
|
||||
void SetCheckedNode(TreeNodeCollection tnc, ArrayList setcheckedvalues)
|
||||
{
|
||||
foreach (TreeNode node in tnc)
|
||||
{
|
||||
node.Checked = setcheckedvalues.Contains(Convert.ToInt32(node.Value));
|
||||
|
||||
SetCheckedNode(node.ChildNodes, setcheckedvalues);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
|
||||
btnSubmit.Enabled = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void listRoles_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
//--重置人员树的选择
|
||||
/*
|
||||
if (TreeDeptEmp.SelectedNode != null) TreeDeptEmp.SelectedNode.Selected = false;
|
||||
|
||||
lbAuthRole.Text = "人员角色清单";
|
||||
GvRole.DataSource = null;
|
||||
GvRole.DataBind();
|
||||
* */
|
||||
//--选择人员树复选框
|
||||
|
||||
ArrayList empList = new ArrayList();
|
||||
DataTable dt =_logic.GetEmListByRole(Convert.ToInt32(listRoles.SelectedValue)) ;
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
empList.Add(dr["pk_employee"]);
|
||||
}
|
||||
SetCheckedNode(TreeDeptEmp.Nodes, empList);
|
||||
|
||||
bindGV();
|
||||
|
||||
}
|
||||
protected void TreeDeptEmp_SelectedNodeChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
bindGV();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void bindGV( )
|
||||
{
|
||||
//人员角色,权限清单
|
||||
string nodevalue = TreeDeptEmp.SelectedValue;
|
||||
if (nodevalue.Length >0 && nodevalue != "0") //selected node is an employee
|
||||
{
|
||||
|
||||
lbEmRole.Text = TreeDeptEmp.SelectedNode.Text + " 人员角色清单";
|
||||
GvRole.DataSource = _logic.GetRoleByEm(Convert.ToInt32(nodevalue));
|
||||
|
||||
lbEmAuth.Text = TreeDeptEmp.SelectedNode.Text + " 人员权限清单";
|
||||
GVauth.DataSource = _logic.GetAuthByEm(Convert.ToInt32(nodevalue));
|
||||
|
||||
}
|
||||
GvRole.DataBind();
|
||||
GVauth.DataBind();
|
||||
|
||||
//角色对应的人员清单
|
||||
if (listRoles.SelectedItem != null)
|
||||
{
|
||||
|
||||
lbRoleEm.Text = listRoles.SelectedItem.Text + " 角色人员清单";
|
||||
GvEm.DataSource = _logic.GetEmListByRole(Convert.ToInt32(listRoles.SelectedValue));
|
||||
}
|
||||
GvEm.DataBind();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master" AutoEventWireup="true" CodeFile="RoleEmp.aspx.cs" Inherits="RoleEmp" %>
|
||||
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<table class="Table_NoBorder" width="100%">
|
||||
|
||||
<tr><td>
|
||||
<table width="100%" class="Table_NoBorder" border="1">
|
||||
<tr class="HeaderStyle">
|
||||
<td style="width: 120px" ><asp:Label ID="lbrole" runat="server" Font-Bold="True" Text="角色列表" /> </td>
|
||||
<td style="width: 180px"> <asp:Label ID="lbemp" runat="server" Font-Bold="True" Text="人员列表" /></td>
|
||||
<td style="width: 200px" nowrap>
|
||||
<asp:Label ID="lbRoleEm" runat="server" Font-Bold="True" Text="角色人员清单" /></td>
|
||||
<td valign ="top" style="width: 200px" nowrap>
|
||||
<asp:Label ID="lbEmRole" runat="server" Font-Bold="True" Text="人员角色清单" /></td>
|
||||
<td valign ="top" style="width: 200px" nowrap>
|
||||
<asp:Label ID="lbEmAuth" runat="server" Font-Bold="True" Text="人员权限清单" /></td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign ="top">
|
||||
|
||||
<asp:ListBox id="listRoles" runat="server" width="120px" Height="360px" OnSelectedIndexChanged="listRoles_SelectedIndexChanged" AutoPostBack="True">
|
||||
</asp:ListBox></td>
|
||||
<td valign ="top">
|
||||
|
||||
|
||||
<asp:TreeView id="TreeDeptEmp" runat="server" ShowLines="True" ImageSet="Arrows"
|
||||
ShowCheckBoxes="All" OnSelectedNodeChanged="TreeDeptEmp_SelectedNodeChanged" >
|
||||
|
||||
<nodes>
|
||||
<asp:TreeNode Text="张浦镇" Selected="True" Value="0" Expanded="True" SelectAction="None" ></asp:TreeNode>
|
||||
</nodes>
|
||||
<SelectedNodeStyle BackColor="Azure" BorderColor="Transparent" />
|
||||
</asp:TreeView>
|
||||
|
||||
</td>
|
||||
<td valign ="top">
|
||||
<asp:gridview id="GvEm" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="DataGrid" emptydatatext="没有数据。"
|
||||
ShowFooter="True"
|
||||
Width="100%">
|
||||
<columns>
|
||||
|
||||
<asp:BoundField DataField="EM_NAME" SortExpression="EM_NAME" HeaderText="人员名称"> <ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="Dep_name" SortExpression="Dep_name" HeaderText="所属部门">
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
|
||||
</columns>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center" />
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center" />
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle" />
|
||||
</asp:gridview>
|
||||
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
<td valign ="top" ><asp:gridview id="GvRole" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="DataGrid" emptydatatext="没有数据。"
|
||||
ShowFooter="True"
|
||||
Width="100%" TabIndex="1">
|
||||
<columns>
|
||||
|
||||
<asp:BoundField DataField="ROLE_NAME" SortExpression="ROLE_NAME" HeaderText="角色名称"> <ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="ROLE_DESC" SortExpression="ROLE_DESC" HeaderText="角色描述">
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
|
||||
</columns>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center" />
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center" />
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle" />
|
||||
</asp:gridview></td>
|
||||
<td valign ="top">
|
||||
<asp:gridview id="GVauth" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="DataGrid" emptydatatext="没有数据。"
|
||||
ShowFooter="True"
|
||||
Width="100%" TabIndex="1">
|
||||
<columns>
|
||||
|
||||
<asp:BoundField DataField="auth_name" SortExpression="auth_name" HeaderText="权限名称"> <ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="auth_desc" SortExpression="auth_desc" HeaderText="权限描述">
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
|
||||
</columns>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center" />
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center" />
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle" />
|
||||
</asp:gridview>
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
</td></tr>
|
||||
<tr><td class="ALine" >
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<td align="center" > <asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存数据" OnClick="btnSubmit_Click" />
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td style="width: 532px">
|
||||
|
||||
<br/></td></tr>
|
||||
</table>
|
||||
|
||||
</asp:Content>
|
||||
|
|
@ -0,0 +1,235 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using ZhangPu.Gov.Logical;
|
||||
using Tracen.Utils;
|
||||
|
||||
public partial class RoleMain : PageBase
|
||||
{
|
||||
private LRole _logic;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
_logic = new LRole();
|
||||
Databound();
|
||||
}
|
||||
SessionSeting();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
GridView1.DataSource = _logic.GetAllActiveData().Tables[0];
|
||||
GridView1.DataBind();
|
||||
UpdateSession();
|
||||
|
||||
ClearDetail();
|
||||
}
|
||||
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LRole)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set data from shift object to page
|
||||
/// </summary>
|
||||
private void DetailDataBind()
|
||||
{
|
||||
DataDetail.Visible = true;
|
||||
chkApprove.Checked=_logic.GetRole.role_4Approve ;
|
||||
txtJobName.Text = _logic.GetRole.role_name;
|
||||
txtJobDesc.Text = _logic.GetRole.role_desc;
|
||||
// chkStatus.Checked = _logic.GetRole.dr;
|
||||
}
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
protected void btnAddnew_Click(object sender, EventArgs e)
|
||||
{
|
||||
Databound();
|
||||
chgOperTxt(true);
|
||||
_logic.Initialize();
|
||||
DetailDataBind();
|
||||
txtJobName.Focus();
|
||||
GridView1.SelectedIndex = -1;
|
||||
|
||||
}
|
||||
|
||||
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
txtJobName.Focus();
|
||||
}
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetDataBack();
|
||||
//shifts id eq 0 means this is new one,to add; else an old one, to update
|
||||
if (txtJobDesc.Text.Trim().Length + txtJobName.Text.Trim().Length == 0)
|
||||
{
|
||||
txtJobName.Focus();
|
||||
Databound();
|
||||
DataDetail.Visible = true;
|
||||
ScriptManager.RegisterStartupScript(btnSubmit, typeof(UpdatePanel), "alert",
|
||||
"alert('请输入角色名称。');", true);
|
||||
return;
|
||||
|
||||
}
|
||||
int oper = 0;
|
||||
oper = _logic.GetRole.ID > 0 ? _logic.GetRole.Update() : _logic.GetRole.Add();
|
||||
ClearDetail();
|
||||
|
||||
}
|
||||
|
||||
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
||||
{
|
||||
|
||||
if (GridView1 != null)
|
||||
{
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
}
|
||||
/*
|
||||
_logic.GetRole.dr = false;
|
||||
_logic.GetRole.Update();
|
||||
|
||||
*/
|
||||
_logic.GetRole.Delete();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
||||
{
|
||||
GridView1.PageIndex = e.NewPageIndex;
|
||||
Databound();
|
||||
|
||||
//GridView1.DataSource = shiftLgc.getAllShifts().Tables[0];
|
||||
// GridView1.DataBind();
|
||||
}
|
||||
|
||||
protected void GridView1_DataBinding(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
CheckBox chk;
|
||||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
chk = new CheckBox();
|
||||
chk.Text = "";
|
||||
chk.Enabled = false;
|
||||
chk.Checked = e.Row.Cells[3].Text.Trim().Equals("True");
|
||||
e.Row.Cells[3].Controls.Add(chk);
|
||||
}
|
||||
}
|
||||
|
||||
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
|
||||
{
|
||||
|
||||
string sortExpression = e.SortExpression;
|
||||
if (GridView1.SortDirection == SortDirection.Ascending) //设置排序方向
|
||||
{
|
||||
|
||||
SortGridView(sortExpression, " DESC");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
SortGridView(sortExpression, " ASC");
|
||||
}
|
||||
}
|
||||
private void SortGridView(string sortExpression, string direction)
|
||||
{
|
||||
DataView dv = new DataView(_logic.GetAllActiveData().Tables[0]);
|
||||
dv.Sort = sortExpression + direction;
|
||||
GridView1.DataSource = dv; //将DataView绑定到GridView上
|
||||
GridView1.DataBind();
|
||||
|
||||
}
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
ClearDetail();
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
// _logic.GetRole.operater = Session["CurrentUserID"].ToString(); todo: write a public method to handle operater,createtime,lastmodfied ... log info.
|
||||
if (_logic.GetRole.ID > 0)
|
||||
_logic.GetRole.lastmodified = DateTime.Now.ToString();
|
||||
_logic.GetRole.dr = true;
|
||||
_logic.GetRole.role_name = txtJobName.Text;
|
||||
_logic.GetRole.role_desc = txtJobDesc.Text;
|
||||
_logic.GetRole.role_4Approve = chkApprove.Checked;
|
||||
}
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
btnSubmit.Enabled = true;
|
||||
DataDetail.Visible = true;
|
||||
}
|
||||
|
||||
private void ClearDetail()
|
||||
{
|
||||
chkApprove.Checked = false;
|
||||
txtJobName.Text = "";
|
||||
txtJobDesc.Text = "";
|
||||
DataDetail.Visible = false;
|
||||
}
|
||||
|
||||
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master" AutoEventWireup="true" CodeFile="RoleMain.aspx.cs" Inherits="RoleMain" %>
|
||||
<%@ MasterType VirtualPath="~/masterPage.master" %>
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
|
||||
Namespace="System.Web.UI" TagPrefix="asp" %>
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<table width="100%" class="Table_NoBorder">
|
||||
|
||||
<tr><td>
|
||||
|
||||
<!------ THE DATA GRID AREA ------>
|
||||
|
||||
<asp:gridview id="GridView1" CssClass="DataGrid" PagerStyle-HorizontalAlign="Right"
|
||||
runat="server"
|
||||
emptydatatext="没有数据。"
|
||||
|
||||
OnRowEditing="GridView1_RowEditing"
|
||||
DataKeyNames="pk_role"
|
||||
OnRowDeleting="GridView1_RowDeleting"
|
||||
AllowPaging="True"
|
||||
OnPageIndexChanging="GridView1_PageIndexChanging"
|
||||
OnRowDataBound="GridView1_RowDataBound"
|
||||
OnSorting="GridView1_Sorting" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="100%" ShowFooter="True" AutoGenerateColumns="False">
|
||||
|
||||
<Columns>
|
||||
<asp:BoundField ReadOnly="True" DataField="PK_ROLE" SortExpression="PK_ROLE" HeaderText="角色id" visible="false"></asp:BoundField>
|
||||
<asp:BoundField DataField="ROLE_NAME" SortExpression="ROLE_NAME" HeaderText="角色名称">
|
||||
<ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" />
|
||||
</asp:BoundField>
|
||||
|
||||
<asp:BoundField DataField="ROLE_DESC" SortExpression="ROLE_DESC" HeaderText="角色描述"><ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" /></asp:BoundField>
|
||||
<asp:BoundField DataField="ROLE_4Approve" SortExpression="ROLE_4Approve" HeaderText="审核角色"><ItemStyle Wrap="False" />
|
||||
<HeaderStyle Wrap="False" /></asp:BoundField>
|
||||
<asp:BoundField DataField="dr" Visible="False" SortExpression="dr" HeaderText="可用"></asp:BoundField>
|
||||
<asp:CommandField SelectText="<img src=../Images/edit.gif border=0 title=修改 >" ShowDeleteButton="True" ShowHeader="True" DeleteText="<img src=../Images/Delete.gif border=0 title=删除 onclick='return delete_click()'>" ShowSelectButton="True" HeaderText="编 辑">
|
||||
<HeaderStyle Width="15%" HorizontalAlign="Center"></HeaderStyle>
|
||||
|
||||
<ItemStyle Width="15%" HorizontalAlign="Center"></ItemStyle>
|
||||
</asp:CommandField>
|
||||
</Columns>
|
||||
<RowStyle CssClass="ItemStyle" HorizontalAlign="Center"></RowStyle>
|
||||
<EmptyDataTemplate>
|
||||
|
||||
|
||||
</EmptyDataTemplate>
|
||||
|
||||
<SelectedRowStyle CssClass="SelectedItemStyle"></SelectedRowStyle>
|
||||
<PagerStyle HorizontalAlign="Right" />
|
||||
<HeaderStyle CssClass="HeaderStyle" HorizontalAlign="Center"></HeaderStyle>
|
||||
<AlternatingRowStyle CssClass="AlternatingItemStyle"></AlternatingRowStyle>
|
||||
|
||||
</asp:gridview>
|
||||
|
||||
<asp:Button ID="btn_addNew" runat="server" Text="新增记录" CssClass="Button" OnClick="btnAddnew_Click" />
|
||||
</td></tr>
|
||||
<tr><td class="ALine" ></td>
|
||||
</tr>
|
||||
<tr><td>
|
||||
|
||||
|
||||
<!------ THE ADD /DELETE AREA ------>
|
||||
|
||||
<asp:Panel ID ="DataDetail" runat="server" Width="100%" Visible="false">
|
||||
<table class="Table_NoBorder" width="100%">
|
||||
<tr><td align="right">
|
||||
<asp:Label ID="Label2" runat="server" CssClass="Label" Text="角色名称"></asp:Label></td><td >
|
||||
|
||||
<asp:TextBox ID="txtJobName" runat="server" CssClass="TextBox" MaxLength="25" ></asp:TextBox>
|
||||
|
||||
|
||||
<asp:RequiredFieldValidator id="RequiredFieldValidator4" runat="server" ControlToValidate="txtJobName"
|
||||
ErrorMessage="请输入角色名称。" SetFocusOnError="True" ValidationGroup="1">*</asp:RequiredFieldValidator>
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
<td align="right">
|
||||
<asp:Label ID="Label3" runat="server" CssClass="Label" Text="角色描述"></asp:Label></td><td >
|
||||
<asp:TextBox ID="txtJobDesc" runat="server" CssClass="TextBox_Long" MaxLength="100" Width="255px" ></asp:TextBox>
|
||||
|
||||
|
||||
<asp:RequiredFieldValidator id="RequiredFieldValidator5" runat="server" ControlToValidate="txtJobDesc"
|
||||
ErrorMessage="请输入角色描述。" SetFocusOnError="True" ValidationGroup="1">*</asp:RequiredFieldValidator>
|
||||
</td></tr>
|
||||
<tr><td align="right">
|
||||
<asp:Label ID="Label1" runat="server" CssClass="Label" Text="审核角色" Visible="true"></asp:Label></td><td colspan ="3" >
|
||||
<asp:CheckBox id="chkApprove" runat="server">
|
||||
</asp:CheckBox></td></tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="4" >
|
||||
<asp:ValidationSummary id="ValidationSummary1" runat="server" ValidationGroup="1" HeaderText="错误提示"></asp:ValidationSummary>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr>
|
||||
<td colspan ="4" class="ALine" >
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!------ BUTTONS ------>
|
||||
<table class="Table_NoBorder" width="80%">
|
||||
<tr>
|
||||
<td align="center" > <asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存数据" OnClick="btnSubmit_Click" ValidationGroup="1" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Panel>
|
||||
|
||||
|
||||
|
||||
|
||||
</td></tr>
|
||||
<tr><td style="width: 532px">
|
||||
|
||||
<br/></td></tr>
|
||||
</table>
|
||||
|
||||
</asp:Content>
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master" AutoEventWireup="true"
|
||||
CodeFile="AuthorityMain.aspx.cs" Inherits="ajax.Dict.AuthorityMain" %>
|
||||
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
|
||||
Namespace="System.Web.UI" TagPrefix="asp" %>
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<table width="100%" class="Table_NoBorder">
|
||||
<tr>
|
||||
<td>
|
||||
<table width="100%" class="Table_Border">
|
||||
<tr>
|
||||
<td width="100" height="200" align="left" valign="top" >
|
||||
<asp:TreeView ID="TreeAuth" runat="server" ShowLines="True" ImageSet="Arrows" OnSelectedNodeChanged="TreeAuth_SelectedNodeChanged1">
|
||||
<SelectedNodeStyle BackColor="Azure" BorderColor="Transparent" />
|
||||
<Nodes>
|
||||
<asp:TreeNode Text="所有权限" Selected="True" Value="0" Expanded="True"></asp:TreeNode>
|
||||
</Nodes>
|
||||
</asp:TreeView>
|
||||
</td>
|
||||
<td width="1" class="VLine">
|
||||
</td>
|
||||
<td width="85%" align="left" valign="top">
|
||||
<!------ THE DATA GRID AREA ------>
|
||||
<asp:Label ID="lbDataGridTitle" Visible="false" runat="server" CssClass="Label" Text="权限维护" />
|
||||
<asp:Label ID="lbEdit" runat="server" CssClass="Label" Visible="false" Text="" />
|
||||
<asp:GridView ID="GridView1" CssClass="DataGrid" PageSize="10" PagerStyle-HorizontalAlign="Right"
|
||||
runat="server" AutoGenerateColumns="False" DataKeyNames="ID" OnRowDeleting="GridView1_RowDeleting"
|
||||
AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging" OnSorting="GridView1_Sorting"
|
||||
OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="100%" ShowFooter="True"
|
||||
EmptyDataText='没有数据。' OnRowDataBound="GridView1_RowDataBound1">
|
||||
<SelectedRowStyle CssClass="SelectedItemStyle"></SelectedRowStyle>
|
||||
<HeaderStyle CssClass="HeaderStyle" HorizontalAlign="Center"></HeaderStyle>
|
||||
<RowStyle CssClass="ItemStyle" HorizontalAlign="Center"></RowStyle>
|
||||
<AlternatingRowStyle CssClass="AlternatingItemStyle"></AlternatingRowStyle>
|
||||
<Columns>
|
||||
<asp:BoundField ReadOnly="True" DataField="ID" Visible="false" HeaderText="权限id"
|
||||
SortExpression="ID"></asp:BoundField>
|
||||
<asp:BoundField DataField="AUTH_NAME" HeaderText="权限名称" SortExpression="DEP_NAME">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
|
||||
<asp:BoundField DataField="AUTH_LINK" HeaderText="权限连接" SortExpression="AUTH_LINK">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="AUTH_CLASS" HeaderText="视窗窗体" SortExpression="AUTH_CLASS">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="AUTH_PUBLIC" HeaderText="公共权限" SortExpression="AUTH_PUBLIC">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="AUTH_SPECIAL" HeaderText="特殊权限" SortExpression="AUTH_SPECIAL">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="AUTH_ORDER" HeaderText="权限编号" SortExpression="DEP_CODE">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
|
||||
<asp:BoundField DataField="AUTH_DESC" HeaderText="权限描述" SortExpression="DEP_CODE">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="dr" HeaderText="可用" SortExpression="dr" Visible="False">
|
||||
</asp:BoundField>
|
||||
<asp:CommandField HeaderText="编 辑" ShowDeleteButton="True" DeleteText=""
|
||||
ShowHeader="True" ShowSelectButton="True" SelectText="<img src=../Images/edit.gif border=0 title=修改 >">
|
||||
<HeaderStyle HorizontalAlign="Center" Wrap="False" />
|
||||
<ItemStyle HorizontalAlign="Center" Wrap="False" />
|
||||
|
||||
</asp:CommandField>
|
||||
</Columns>
|
||||
<PagerStyle HorizontalAlign="Right" />
|
||||
<EmptyDataTemplate>
|
||||
没有数据</EmptyDataTemplate>
|
||||
</asp:GridView><!--DeleteText="" <img src=../Images/Delete.gif border=0 title=删除 onclick='return delete_click()'>-->
|
||||
<asp:Button ID="btn_addNew" runat="server" Text="新增记录" CssClass="Button" OnClick="btnAddnew_Click" />
|
||||
<asp:Panel ID="DataDetail" runat="server" Width="100%" Visible="false">
|
||||
<!------ THE ADD /DELETE AREA ------>
|
||||
<table class="Table_NoBorder" width="90%">
|
||||
<tr>
|
||||
<td colspan="6" class="ALine">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap>
|
||||
<asp:Label ID="Label2" runat="server" CssClass="Label" Text="权限名称"></asp:Label>
|
||||
</td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtName" runat="server" CssClass="TextBox" MaxLength="25"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName"
|
||||
ErrorMessage="*">*</asp:RequiredFieldValidator>
|
||||
</td>
|
||||
<td nowrap>
|
||||
<asp:Label ID="Label5" runat="server" CssClass="Label" Text="权限连接"></asp:Label>
|
||||
</td>
|
||||
<td >
|
||||
<asp:TextBox ID="txtLink" CssClass="TextBox" runat="server" MaxLength="400" Width="200px"></asp:TextBox>
|
||||
</td>
|
||||
<td nowrap>
|
||||
<asp:Label ID="Label4" runat="server" CssClass="Label" Text="视窗窗体"></asp:Label>
|
||||
</td>
|
||||
<td >
|
||||
<asp:TextBox ID="txtFormClass" CssClass="TextBox" runat="server" MaxLength="200" Width="200px"></asp:TextBox>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<td>
|
||||
<asp:CheckBox ID="chkPublic" Text="公共权限" runat="server"></asp:CheckBox>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<asp:CheckBox ID="chkSpecial" runat="server" Text="特殊权限" ></asp:CheckBox>
|
||||
</td>
|
||||
<td>
|
||||
<asp:Label ID="Label1" runat="server" CssClass="Label" Text="公共信息"></asp:Label>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<asp:CheckBox ID="chkPublicInfo" runat="server" OnCheckedChanged="chkPublicInfo_CheckedChanged"
|
||||
AutoPostBack="true"></asp:CheckBox>
|
||||
<asp:CheckBox ID="chkAlert" runat="server" Text="跑马灯"></asp:CheckBox>
|
||||
<asp:CheckBox ID="chkEnable" runat="server" Text="可用"></asp:CheckBox>
|
||||
</td>
|
||||
<td>
|
||||
<asp:Label ID="Label3" runat="server" CssClass="Label" Text="权限描述"></asp:Label>
|
||||
</td>
|
||||
<td >
|
||||
<asp:TextBox ID="txtDesc" CssClass="Long_TextBox" runat="server" MaxLength="50"
|
||||
Width="200px" ></asp:TextBox>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
||||
<td>
|
||||
<asp:Label ID="Label6" runat="server" CssClass="Label" Text="标签编号"></asp:Label>
|
||||
</td>
|
||||
<td >
|
||||
<asp:TextBox ID="txtOrder" CssClass="TextBox" runat="server" MaxLength="5"
|
||||
Width="100px" ></asp:TextBox>
|
||||
</td>
|
||||
<td colspan="4" class="ALine">
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6" class="ALine">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" colspan="6">
|
||||
<asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存数据" OnClick="btnSubmit_Click" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Panel>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Content>
|
|
@ -0,0 +1,350 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using DeiNiu.wms.Logical;
|
||||
using DeiNiu.Utils;
|
||||
|
||||
namespace ajax.Dict
|
||||
{
|
||||
public partial class AuthorityMain :PageBase
|
||||
{
|
||||
private LAuthority _logic;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
_logic = new LAuthority();
|
||||
Databound();
|
||||
}
|
||||
SessionSeting();
|
||||
}
|
||||
|
||||
/***************************************** private methods ******************************************/
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
|
||||
|
||||
//装载选定部门节点的部门数据
|
||||
DataView dv = new DataView(_logic.getAllActiveData().Tables[0]);
|
||||
|
||||
if (TreeAuth.SelectedNode != null)
|
||||
{
|
||||
TreeAuth.SelectedNode.ChildNodes.Clear();
|
||||
BindTree(TreeAuth.SelectedNode.Value, TreeAuth.SelectedNode, dv);
|
||||
|
||||
//绑定树列表里选中的部门下的所有部门数据
|
||||
dv.RowFilter = "auth_uplevel = '" + TreeAuth.SelectedValue + "'";
|
||||
}
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
UpdateSession();
|
||||
ClearDetail();
|
||||
}
|
||||
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LAuthority)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set data from shift object to page
|
||||
/// </summary>
|
||||
private void DetailDataBind()
|
||||
{
|
||||
//公共信息不可以有url,必须为public
|
||||
LAuthority ltmp = new LAuthority();
|
||||
ltmp.Initialize(Convert.ToInt32(TreeAuth.SelectedValue));
|
||||
chkPublic.Enabled = !ltmp.GetAuthority.auth_publicInfomation;
|
||||
chkPublicInfo.Enabled = !ltmp.GetAuthority.auth_publicInfomation;
|
||||
chkAlert.Enabled =!chkPublicInfo.Enabled; //跑马灯的上级必须是公共信息
|
||||
if (chkPublicInfo.Checked)
|
||||
{
|
||||
txtLink.Enabled = false;
|
||||
txtFormClass.Enabled = false;
|
||||
}
|
||||
DataDetail.Visible = true;
|
||||
txtName.Text = _logic.GetAuthority.auth_name;
|
||||
txtDesc.Text = _logic.GetAuthority.auth_desc;
|
||||
txtLink.Text = _logic.GetAuthority.auth_link;
|
||||
txtFormClass.Text = _logic.GetAuthority.auth_class;
|
||||
chkPublic.Checked = _logic.GetAuthority.auth_public;
|
||||
chkPublicInfo.Checked = _logic.GetAuthority.auth_publicInfomation;
|
||||
chkSpecial.Checked = _logic.GetAuthority.auth_special;
|
||||
txtOrder.Text = _logic.GetAuthority.auth_order + "";
|
||||
//上级为公共信息,则下级也必须是
|
||||
if(ltmp.GetAuthority.auth_publicInfomation)
|
||||
chkPublicInfo.Checked = ltmp.GetAuthority.auth_publicInfomation;
|
||||
if (ltmp.GetAuthority.auth_public)
|
||||
chkPublic.Checked = ltmp.GetAuthority.auth_public;
|
||||
chkAlert.Checked = _logic.GetAuthority.auth_marqueen;
|
||||
chkPublic.Checked = _logic.GetAuthority.auth_public;
|
||||
chkEnable.Checked = _logic.GetAuthority.dr;
|
||||
ltmp = null;
|
||||
|
||||
// chkStatus.Checked = _logic.GetRole.dr;
|
||||
}
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
protected void btnAddnew_Click(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(true);
|
||||
_logic.Initialize();
|
||||
GridView1.SelectedIndex = -1;
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetDataBack();
|
||||
//shifts id eq 0 means this is new one,to add; else an old one, to update
|
||||
|
||||
int oper = 0;
|
||||
oper = _logic.GetAuthority.ID > 0 ? _logic.GetAuthority.Update() : _logic.GetAuthority.Add();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
lbEdit.Text = "";
|
||||
}
|
||||
|
||||
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
||||
{
|
||||
|
||||
if (GridView1 != null)
|
||||
{
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
}
|
||||
/*
|
||||
_logic.GetRole.dr = false;
|
||||
_logic.GetRole.Update();
|
||||
|
||||
*/
|
||||
_logic.GetAuthority.Delete();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
||||
{
|
||||
GridView1.PageIndex = e.NewPageIndex;
|
||||
Databound();
|
||||
|
||||
//GridView1.DataSource = shiftLgc.getAllShifts().Tables[0];
|
||||
// GridView1.DataBind();
|
||||
}
|
||||
|
||||
protected void GridView1_DataBinding(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
// _logic.GetRole.operater = Session["CurrentUserID"].ToString(); todo: write a public method to handle operater,createtime,lastmodfied ... log info.
|
||||
|
||||
if (!(_logic.GetAuthority.ID > 0))
|
||||
{
|
||||
// _logic.GetAuthority.lastmodified = DateTime.Now.ToString();
|
||||
_logic.GetAuthority.auth_uplevel = Convert.ToInt32(TreeAuth.SelectedValue);
|
||||
}
|
||||
|
||||
_logic.GetAuthority.auth_name = txtName.Text;
|
||||
_logic.GetAuthority.auth_desc = txtDesc.Text;
|
||||
_logic.GetAuthority.auth_link = txtLink.Text;
|
||||
_logic.GetAuthority.auth_class = txtFormClass.Text;
|
||||
_logic.GetAuthority.auth_public = chkPublic.Checked;
|
||||
_logic.GetAuthority.auth_publicInfomation =chkPublicInfo.Checked ;
|
||||
_logic.GetAuthority.auth_marqueen = chkAlert.Checked;
|
||||
_logic.GetAuthority.auth_special = chkSpecial.Checked;
|
||||
_logic.GetAuthority.auth_order = Convert.ToInt16( txtOrder.Text.Trim());
|
||||
_logic.GetAuthority.dr = chkEnable.Checked;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
DataDetail.Visible = true;
|
||||
lbEdit.Text = addNew ? "增加新记录" : "修改现有记录";
|
||||
btnSubmit.Enabled = true;
|
||||
}
|
||||
|
||||
private void ClearDetail()
|
||||
{
|
||||
txtName.Text = "";
|
||||
txtDesc.Text = "";
|
||||
txtLink.Text ="";
|
||||
txtLink.Text = "";
|
||||
chkPublic.Checked = false;
|
||||
chkPublicInfo.Checked = false;
|
||||
DataDetail.Visible = false;
|
||||
chkSpecial.Checked = false;
|
||||
}
|
||||
|
||||
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void BindTree(string id, TreeNode pNode, DataView dv)
|
||||
{
|
||||
|
||||
dv.RowFilter = "auth_uplevel = '" + id + "'";
|
||||
foreach (DataRowView row in dv)
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = row["auth_name"].ToString();
|
||||
node.Value = row["ID"].ToString();
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
|
||||
TreeAuth.Nodes.Add(node);
|
||||
node.Expanded = false;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pNode.ChildNodes.Add(node);
|
||||
node.Expanded = false;
|
||||
|
||||
}
|
||||
BindTree(node.Value, node, new DataView(dv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void TreeAuth_SelectedNodeChanged1(object sender, EventArgs e)
|
||||
{
|
||||
GridView1.SelectedIndex = -1;
|
||||
DataView dv = new DataView(_logic.getAllActiveData().Tables[0]);
|
||||
dv.RowFilter = "auth_uplevel = '" + TreeAuth.SelectedValue + "'";
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
ClearDetail();
|
||||
if(TreeAuth.SelectedNode.ChildNodes.Count>0)TreeAuth.SelectedNode.Expand();
|
||||
}
|
||||
|
||||
protected void chkPublicInfo_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
switch (chkPublicInfo.Checked)
|
||||
{
|
||||
case true:
|
||||
txtLink.Text = string.Empty;
|
||||
txtLink.Enabled = false;
|
||||
txtFormClass.Text = string.Empty;
|
||||
txtFormClass.Enabled = false;
|
||||
chkPublic.Checked = true;
|
||||
chkPublic.Enabled = false;
|
||||
break;
|
||||
|
||||
case false:
|
||||
txtLink.Text = _logic.GetAuthority.auth_link;
|
||||
txtFormClass.Text = _logic.GetAuthority.auth_class;
|
||||
txtFormClass.Enabled = true;
|
||||
txtLink.Enabled = true ;
|
||||
chkPublic.Checked = false;
|
||||
chkPublic.Enabled = true;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void chkSpecial_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
|
||||
CheckBox chk;
|
||||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
chk = new CheckBox();
|
||||
chk.Text = "";
|
||||
chk.Enabled = false;
|
||||
chk.Checked = e.Row.Cells[4].Text.Trim().Equals("True");
|
||||
e.Row.Cells[4].Controls.Add(chk);
|
||||
|
||||
|
||||
chk = new CheckBox();
|
||||
chk.Text = "";
|
||||
chk.Enabled = false;
|
||||
chk.Checked = e.Row.Cells[5].Text.Trim().Equals("True");
|
||||
e.Row.Cells[5].Controls.Add(chk);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master" AutoEventWireup="true"
|
||||
CodeFile="DeptEmp.aspx.cs" Inherits="DeptEmp" %>
|
||||
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<table class="Table_NoBorder" width="100%">
|
||||
<tr>
|
||||
<td>
|
||||
<table width="100%" class="Table_NoBorder" border="1">
|
||||
<tr>
|
||||
<td style="width: 300px">
|
||||
<asp:Label ID="lbrole" runat="server" Font-Bold="True" Text="人员列表" />
|
||||
</td>
|
||||
<td style="width: 300px">
|
||||
<asp:Label ID="lbemp" runat="server" Font-Bold="True" Text="部门列表" />
|
||||
</td>
|
||||
<td style="width: 300px" nowrap>
|
||||
<asp:Label ID="lbEmDept" runat="server" Font-Bold="True" Text="人员部门清单" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<asp:TreeView ID="TreeDeptEmp" runat="server" ShowLines="True" ImageSet="Arrows"
|
||||
OnSelectedNodeChanged="TreeDeptEmp_SelectedNodeChanged">
|
||||
<SelectedNodeStyle BackColor="Azure" BorderColor="Transparent" />
|
||||
<Nodes>
|
||||
<asp:TreeNode Text="WMS" Selected="True" Value="0" Expanded="True" SelectAction="None">
|
||||
</asp:TreeNode>
|
||||
</Nodes>
|
||||
</asp:TreeView>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<asp:TreeView ID="TreeDept" runat="server" ShowLines="True" ImageSet="Arrows" ShowCheckBoxes="All"
|
||||
OnSelectedNodeChanged="TreeDeptEmp_SelectedNodeChanged">
|
||||
<SelectedNodeStyle BackColor="Azure" BorderColor="Transparent" />
|
||||
<Nodes>
|
||||
<asp:TreeNode Text="WMS" Selected="True" Value="0" Expanded="True" SelectAction="None">
|
||||
</asp:TreeNode>
|
||||
</Nodes>
|
||||
</asp:TreeView>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<asp:GridView ID="GvDept" runat="server" AutoGenerateColumns="False" CssClass="DataGrid"
|
||||
EmptyDataText="没有数据。" ShowFooter="True" DataKeyNames="ID" Width="100%" TabIndex="1"
|
||||
OnRowCancelingEdit="GvDept_RowCancelingEdit" OnRowUpdating="GvDept_RowUpdating"
|
||||
OnRowEditing="GvDept_RowEditing">
|
||||
<Columns>
|
||||
<asp:BoundField ReadOnly="True" DataField="ID" Visible="False" SortExpression="ID"
|
||||
HeaderText="id"></asp:BoundField>
|
||||
<asp:BoundField ReadOnly="True" DataField="DEP_NAME" SortExpression="DEP_NAME" HeaderText="部门名称">
|
||||
</asp:BoundField>
|
||||
<asp:BoundField ReadOnly="True" DataField="DEP_DESC" SortExpression="DEP_DESC" HeaderText="部门描述">
|
||||
</asp:BoundField>
|
||||
<asp:TemplateField SortExpression="DE_TITLE" HeaderText="职务">
|
||||
<EditItemTemplate>
|
||||
<asp:TextBox runat="server" Text='<%# Bind("DE_TITLE") %>' ID="TextBox1"></asp:TextBox>
|
||||
</EditItemTemplate>
|
||||
<ItemTemplate>
|
||||
<asp:Label runat="server" Text='<%# Bind("DE_TITLE") %>' ID="Label1"></asp:Label>
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
<asp:CommandField InsertVisible="False" CancelImageUrl="~/Images/undo.gif" EditImageUrl="~/Images/edit.gif"
|
||||
ShowHeader="True" UpdateImageUrl="~/Images/save.gif" ButtonType="Image" ShowEditButton="True">
|
||||
</asp:CommandField>
|
||||
</Columns>
|
||||
<RowStyle CssClass="ItemStyle" HorizontalAlign="Center" />
|
||||
<HeaderStyle CssClass="HeaderStyle" HorizontalAlign="Center" />
|
||||
<AlternatingRowStyle CssClass="AlternatingItemStyle" />
|
||||
<SelectedRowStyle CssClass="SelectedItemStyle"></SelectedRowStyle>
|
||||
</asp:GridView>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="ALine">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存数据" OnClick="btnSubmit_Click" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 532px">
|
||||
<br />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Content>
|
|
@ -0,0 +1,309 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using System.Transactions;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using DeiNiu.wms.Logical;
|
||||
using DeiNiu.Utils;
|
||||
using DeiNiu.wms.Data.Model;
|
||||
|
||||
public partial class DeptEmp : PageBase
|
||||
{
|
||||
private LEmployee _logic;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
_logic = new LEmployee();
|
||||
|
||||
Databound();
|
||||
|
||||
//分配角色时初始化部门人员树
|
||||
|
||||
}
|
||||
SessionSeting();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
bindGV();
|
||||
UpdateSession();
|
||||
bindDept();
|
||||
bindDeptEmp();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定部门
|
||||
/// </summary>
|
||||
private void bindDept()
|
||||
{
|
||||
TreeDept.Nodes.Clear();
|
||||
BindTree(TreeDept, "0", TreeDept.SelectedNode, _logic.GetDepartments().DefaultView);
|
||||
SetTreeDeptChecked();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 绑定部门及用户
|
||||
/// </summary>
|
||||
private void bindDeptEmp()
|
||||
{
|
||||
TreeDeptEmp.Nodes.Clear();
|
||||
BindEmpTree(TreeDeptEmp, "0", TreeDeptEmp.SelectedNode, _logic.GetDepartments().DefaultView, _logic.GetActivedEmpDept().DefaultView);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void BindEmpTree(TreeView tree, string id, TreeNode pNode, DataView deptdv,DataView empdv)
|
||||
{
|
||||
|
||||
deptdv.RowFilter = "dep_mastdept = '" + id + "'";
|
||||
foreach (DataRowView row in deptdv)
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = row["ID"].ToString() + "_<em>" + row["dep_name"] + "</em>" ;
|
||||
node.Value = row["ID"].ToString();
|
||||
node.SelectAction = TreeNodeSelectAction.None;
|
||||
node.ShowCheckBox = false;
|
||||
node.Expanded = true;
|
||||
empdv.RowFilter = "de_dept=" + node.Value;
|
||||
foreach (DataRowView emrow in empdv)
|
||||
{
|
||||
TreeNode tnEmp = new TreeNode("<Strong>" + emrow["em_name"] + "</Strong>" , emrow["empId"].ToString());
|
||||
node.ChildNodes.Add(tnEmp);
|
||||
}
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
|
||||
tree.Nodes.Add(node);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
pNode.ChildNodes.Add(node);
|
||||
|
||||
}
|
||||
BindEmpTree(tree,node.Value, node, new DataView(deptdv.Table), new DataView(empdv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void BindTree(TreeView tree, string id, TreeNode pNode, DataView deptdv )
|
||||
{
|
||||
|
||||
deptdv.RowFilter = "dep_mastdept = '" + id + "'";
|
||||
foreach (DataRowView row in deptdv)
|
||||
{
|
||||
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = row["ID"].ToString() +"_<Strong>" + row["dep_name"].ToString() + "</Strong>";
|
||||
node.Value = row["ID"].ToString();
|
||||
|
||||
node.SelectAction = TreeNodeSelectAction.None;
|
||||
|
||||
// node.ShowCheckBox = Convert.ToInt16(row["dep_type"].ToString()) == 1;
|
||||
|
||||
node.Expanded = true;
|
||||
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
tree.Nodes.Add(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
pNode.ChildNodes.Add(node);
|
||||
}
|
||||
BindTree(tree, node.Value, node, new DataView(deptdv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LEmployee)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (TreeDeptEmp.SelectedNode== null) return;
|
||||
ArrayList al = new ArrayList();
|
||||
|
||||
GetCheckedNode(TreeDept.Nodes, al);
|
||||
_logic.Initialize();
|
||||
// using (TransactionScope trans = new TransactionScope())
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.GetDeptEmp.Delete(Convert.ToInt32(TreeDeptEmp.SelectedValue));
|
||||
|
||||
foreach (string id in al)
|
||||
{
|
||||
_logic.GetDeptEmp.de_dept = Convert.ToInt32(id);
|
||||
_logic.GetDeptEmp.de_employee = Convert.ToInt32(TreeDeptEmp.SelectedValue);
|
||||
_logic.GetDeptEmp.Add();
|
||||
}
|
||||
|
||||
// trans.Complete();
|
||||
}
|
||||
catch (MyException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception("出现异常,保存失败。");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Databound();
|
||||
}
|
||||
|
||||
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GetCheckedNode(TreeNodeCollection tnc, ArrayList checkedvalues )
|
||||
{
|
||||
foreach(TreeNode node in tnc)
|
||||
{
|
||||
if(node.Checked)
|
||||
{
|
||||
checkedvalues.Add(node.Value);
|
||||
|
||||
}
|
||||
GetCheckedNode(node.ChildNodes, checkedvalues);
|
||||
}
|
||||
}
|
||||
|
||||
void SetCheckedNode(TreeNodeCollection tnc, ArrayList setcheckedvalues)
|
||||
{
|
||||
foreach (TreeNode node in tnc)
|
||||
{
|
||||
node.Checked = setcheckedvalues.Contains(Convert.ToInt32(node.Value));
|
||||
|
||||
SetCheckedNode(node.ChildNodes, setcheckedvalues);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
|
||||
btnSubmit.Enabled = true;
|
||||
|
||||
}
|
||||
void SetTreeDeptChecked()
|
||||
{
|
||||
if( TreeDeptEmp.SelectedNode ==null) return;
|
||||
ArrayList deptList = new ArrayList();
|
||||
DataTable dt = _logic.GetDepartments(Convert.ToInt32(TreeDeptEmp.SelectedValue));
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
deptList.Add(dr["de_dept"]);
|
||||
}
|
||||
SetCheckedNode(TreeDept.Nodes, deptList);
|
||||
}
|
||||
|
||||
protected void TreeDeptEmp_SelectedNodeChanged(object sender, EventArgs e)
|
||||
{
|
||||
GvDept.SelectedIndex = -1;
|
||||
SetTreeDeptChecked();
|
||||
bindGV();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void bindGV( )
|
||||
{
|
||||
//人员部门清单
|
||||
string nodevalue = TreeDeptEmp.SelectedValue;
|
||||
if (nodevalue.Length >0 && nodevalue != "0") //selected node is an employee
|
||||
{
|
||||
|
||||
lbEmDept.Text = TreeDeptEmp.SelectedNode.Text + " 人员部门清单";
|
||||
GvDept.DataSource = _logic.GetDepartments(Convert.ToInt32(nodevalue));
|
||||
|
||||
|
||||
}
|
||||
GvDept.DataBind();
|
||||
|
||||
}
|
||||
|
||||
protected void GvDept_RowUpdating(object sender, GridViewUpdateEventArgs e)
|
||||
{
|
||||
if (GvDept.DataKeys != null)
|
||||
{
|
||||
string id = GvDept.DataKeys[e.RowIndex].Value.ToString();
|
||||
|
||||
_logic.GetDeptEmp.ID = Convert.ToInt32(id);
|
||||
_logic.GetDeptEmp.getModel();
|
||||
|
||||
_logic.GetDeptEmp.de_title = ((TextBox)GvDept.Rows[e.RowIndex].Cells[3].Controls[1]).Text;
|
||||
|
||||
//_logic.GetTrainingDetail.operater =
|
||||
_logic.GetDeptEmp.Update();
|
||||
}
|
||||
GvDept.EditIndex = -1;
|
||||
GvDept.SelectedIndex = e.RowIndex;
|
||||
bindGV();
|
||||
}
|
||||
protected void GvDept_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
|
||||
{
|
||||
GvDept.EditIndex = -1;
|
||||
GvDept.SelectedIndex = e.RowIndex;
|
||||
bindGV();
|
||||
}
|
||||
protected void GvDept_RowEditing(object sender, GridViewEditEventArgs e)
|
||||
{
|
||||
GvDept.EditIndex = e.NewEditIndex;
|
||||
GvDept.SelectedIndex = e.NewEditIndex;
|
||||
bindGV();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master" AutoEventWireup="true" CodeFile="DeptMain.aspx.cs" Inherits="DeptMain" %>
|
||||
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<table width="100%" class="Table_NoBorder">
|
||||
|
||||
<tr><td>
|
||||
<table width="100%" class="Table_Border">
|
||||
<tr><td width="50" height="200" align="left" valign="top">
|
||||
<asp:TreeView ID="TreeDept" runat="server" ShowLines="True" OnSelectedNodeChanged="TreeDept_SelectedNodeChanged" ImageSet="Arrows">
|
||||
<Nodes>
|
||||
<asp:TreeNode Text="WMS" Value="0" Expanded="True" Selected="True"></asp:TreeNode>
|
||||
</Nodes>
|
||||
<SelectedNodeStyle BackColor="Azure" BorderColor="Transparent" />
|
||||
</asp:TreeView>
|
||||
</td>
|
||||
<td width="1" class="VLine" ></td>
|
||||
<td align="left" valign="top"> <!------ THE DATA GRID AREA ------>
|
||||
|
||||
<asp:Label ID="lbDataGridTitle" Visible="false" runat="server" CssClass="Label" Text="部门维护" />
|
||||
<asp:Label ID="lbEdit" Visible="false" runat="server" CssClass="Label" Text=""></asp:Label>
|
||||
<asp:gridview id="GridView1" CssClass="DataGrid"
|
||||
PageSize="10" PagerStyle-HorizontalAlign="Right"
|
||||
runat="server"
|
||||
AutoGenerateColumns="False"
|
||||
DataKeyNames="ID"
|
||||
OnRowDeleting="GridView1_RowDeleting"
|
||||
AllowPaging="True"
|
||||
OnPageIndexChanging="GridView1_PageIndexChanging"
|
||||
OnRowDataBound="GridView1_RowDataBound"
|
||||
OnSorting="GridView1_Sorting" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="95% " ShowFooter="True" EmptyDataText='没有数据。'>
|
||||
|
||||
<Columns>
|
||||
<asp:BoundField ReadOnly="True" DataField="ID" Visible="true" SortExpression="ID" HeaderText="部门编号"></asp:BoundField>
|
||||
<asp:BoundField DataField="DEP_NAME" SortExpression="DEP_NAME" HeaderText="部门名称"></asp:BoundField>
|
||||
<asp:BoundField DataField="DEP_CODE" SortExpression="DEP_CODE" HeaderText="部门代码"></asp:BoundField>
|
||||
<asp:BoundField DataField="EM_NAME" SortExpression="DEP_CODE" HeaderText="负责人"></asp:BoundField>
|
||||
<asp:BoundField DataField="typeName" SortExpression="typeName" HeaderText="部门类型"></asp:BoundField>
|
||||
<asp:BoundField DataField="DEP_DESC" SortExpression="DEP_DESC" HeaderText="部门描述"></asp:BoundField>
|
||||
<asp:BoundField DataField="dr" Visible="False" SortExpression="dr" HeaderText="可用"></asp:BoundField>
|
||||
<asp:CommandField SelectText="<img src=../Images/edit.gif border=0 title=修改 >" ShowDeleteButton="True" ShowHeader="True" DeleteText="<img src=../Images/Delete.gif border=0 title=删除 onclick='return delete_click()'>" ShowSelectButton="True" HeaderText="编 辑">
|
||||
<HeaderStyle Width="15%" HorizontalAlign="Center"></HeaderStyle>
|
||||
|
||||
<ItemStyle Width="15%" HorizontalAlign="Center"></ItemStyle>
|
||||
</asp:CommandField>
|
||||
</Columns>
|
||||
<RowStyle CssClass="ItemStyle" HorizontalAlign="Center"></RowStyle>
|
||||
|
||||
<SelectedRowStyle CssClass="SelectedItemStyle"></SelectedRowStyle>
|
||||
<PagerStyle HorizontalAlign="Right" />
|
||||
<HeaderStyle CssClass="HeaderStyle" HorizontalAlign="Center"></HeaderStyle>
|
||||
<AlternatingRowStyle CssClass="AlternatingItemStyle"></AlternatingRowStyle>
|
||||
<emptydatatemplate> 没有数据</emptydatatemplate>
|
||||
</asp:gridview>
|
||||
<asp:Button ID="btn_addNew" runat="server" Text="新增记录" CssClass="Button" OnClick="btnAddnew_Click" />
|
||||
|
||||
<asp:Panel ID ="DataDetail" runat="server" Width="100%" Visible="false">
|
||||
|
||||
<!------ THE ADD /DELETE AREA ------>
|
||||
<table class="Table_NoBorder" width="90%">
|
||||
<tr>
|
||||
<td colspan ="4" class="ALine" >
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td>
|
||||
<asp:Label ID="Label2" runat="server" CssClass="Label" Text="部门名称"></asp:Label></td><td >
|
||||
|
||||
<asp:TextBox ID="txtDepName" runat="server" CssClass="TextBox" MaxLength="25"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtDepName"
|
||||
ErrorMessage="*" ValidationGroup="1">*</asp:RequiredFieldValidator></td>
|
||||
<td>
|
||||
<asp:Label ID="Label4" runat="server" CssClass="Label" Text="部门代码"></asp:Label></td><td >
|
||||
<asp:TextBox ID="txtDepcode" runat="server" CssClass="TextBox" MaxLength="25"></asp:TextBox>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<asp:Label ID="Label15" runat="server" CssClass="Label" Text="部门类别"></asp:Label></td>
|
||||
<td >
|
||||
|
||||
<asp:DropDownList ID="dlstDeptType" runat="server" CssClass="DropDownList">
|
||||
|
||||
</asp:DropDownList></td>
|
||||
|
||||
<td>
|
||||
<asp:Label ID="Label3" runat="server" CssClass="Label" Text="部门描述"></asp:Label></td>
|
||||
<td >
|
||||
<asp:TextBox ID="txtDepDesc" CssClass="Long_TextBox" runat="server" MaxLength="50"></asp:TextBox>
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td >
|
||||
<asp:Label ID="Label1" runat="server" CssClass="Label" Text="部门负责人"></asp:Label></td>
|
||||
<td >
|
||||
|
||||
<asp:DropDownList ID="DropDownList1" runat="server" CssClass="DropDownList">
|
||||
</asp:DropDownList></td>
|
||||
|
||||
<td >
|
||||
<asp:Label ID="Label5" runat="server" CssClass="Label" Text="上级部门"></asp:Label></td>
|
||||
<td >
|
||||
|
||||
<asp:DropDownList ID="drplstDept" runat="server" CssClass="DropDownList">
|
||||
</asp:DropDownList></td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td >
|
||||
<asp:Label ID="Label7" runat="server" CssClass="Label" Text="服务地址"></asp:Label></td>
|
||||
<td colspan ="3" >
|
||||
|
||||
<asp:TextBox ID="txtSvrAddress" CssClass="Long_TextBox" runat="server" MaxLength="50"></asp:TextBox>
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
<td colspan ="4" class="ALine" >
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" colspan ="4" > <asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存数据" OnClick="btnSubmit_Click" ValidationGroup="1" />
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Panel>
|
||||
</td></tr>
|
||||
|
||||
|
||||
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
</asp:Content>
|
||||
|
|
@ -0,0 +1,429 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using DeiNiu.wms.Logical;
|
||||
using DeiNiu.Utils;
|
||||
using DeiNiu.wms.Data.Model;
|
||||
|
||||
public partial class DeptMain : PageBase
|
||||
{
|
||||
private LDepartment _logic;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
_logic = new LDepartment();
|
||||
Databound();
|
||||
}
|
||||
SessionSeting();
|
||||
}
|
||||
|
||||
/***************************************** private methods ******************************************/
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
//绑定部门列表
|
||||
drplstDept.DataSource = _logic.GetAllActiveData();
|
||||
drplstDept.DataTextField = "dep_name";
|
||||
drplstDept.DataValueField = "ID";
|
||||
drplstDept.DataBind();
|
||||
|
||||
|
||||
|
||||
|
||||
drplstDept.Items.Insert(0, (new ListItem("WMS", "0")));
|
||||
drplstDept.SelectedItem.Selected = false;
|
||||
drplstDept.Items.FindByText("WMS").Selected = true;
|
||||
|
||||
|
||||
|
||||
//绑定部门人员列表
|
||||
DropDownList1.DataSource = _logic.GetEmployees();
|
||||
DropDownList1.DataTextField = "em_name";
|
||||
DropDownList1.DataValueField = "ID";
|
||||
DropDownList1.DataBind();
|
||||
DropDownList1.Items.Insert(0,(new ListItem("请选择...","0")));
|
||||
DropDownList1.SelectedItem.Selected = false;
|
||||
DropDownList1.Items.FindByText("请选择...").Selected = true;
|
||||
//装载选定部门节点的部门数据
|
||||
|
||||
dlstDeptType.Items.Clear();
|
||||
dlstDeptType.Items.Add(new ListItem("普通", "0"));
|
||||
dlstDeptType.Items.Add(new ListItem("仓管", "1"));
|
||||
dlstDeptType.Items.Add(new ListItem("仓库", "2"));
|
||||
dlstDeptType.Items.Add(new ListItem("三方", "3"));
|
||||
DataView dv = _logic.GetAllActiveData().DefaultView;
|
||||
string selectedValue = TreeDept.SelectedValue;
|
||||
TreeDept.Nodes.Clear();
|
||||
TreeDept.Nodes.Add(new TreeNode("WMS", "0"));
|
||||
TreeDept.Nodes[0].Expanded = true;
|
||||
BindTree("0", TreeDept.Nodes[0], dv);
|
||||
// TreeDept.SelectedNode.ChildNodes.Clear();
|
||||
// BindTree(TreeDept.SelectedValue, TreeDept.SelectedNode, dv);
|
||||
// TreeDept.Nodes.AddAt(0, new TreeNode("WMS", "0"));
|
||||
if (selectedValue == "0") TreeDept.Nodes[0].Selected = true;
|
||||
else
|
||||
{
|
||||
setTreeDeptSelected(selectedValue, TreeDept.Nodes[0]);
|
||||
}
|
||||
dv.RowFilter = "dep_mastdept = '" + selectedValue + "'";
|
||||
bindGridview(dv);
|
||||
|
||||
UpdateSession();
|
||||
// btnSubmit.Enabled = false;
|
||||
// ClearDetail();
|
||||
|
||||
|
||||
drplstDept.Items.Clear();
|
||||
initializeDrlstDept(TreeDept.Nodes, drplstDept ,"");
|
||||
}
|
||||
|
||||
void bindGridview(DataView dv )
|
||||
{
|
||||
|
||||
//绑定树列表里选中的部门下的所有部门数据
|
||||
|
||||
|
||||
foreach (DataRowView drv in dv)
|
||||
{
|
||||
foreach (ListItem li in dlstDeptType.Items)
|
||||
{
|
||||
if (drv["dep_type"].ToString().Equals(li.Value))
|
||||
{
|
||||
drv.Row["typeName"] = li.Text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
}
|
||||
|
||||
void initializeDrlstDept(TreeNodeCollection nds, DropDownList drplist, string emptyString)
|
||||
{
|
||||
|
||||
|
||||
foreach (TreeNode nd in nds)
|
||||
{
|
||||
|
||||
ListItem li = new ListItem(emptyString + nd.Text,nd.Value);
|
||||
drplist.Items.Add(li);
|
||||
string NextemptyString = emptyString+ "----";
|
||||
foreach (TreeNode nd1 in nd.ChildNodes)
|
||||
{
|
||||
li = new ListItem(NextemptyString + nd1.Text, nd1.Value);
|
||||
drplist.Items.Add(li);
|
||||
|
||||
if (nd1.ChildNodes.Count > 0)
|
||||
{
|
||||
NextemptyString +="----";
|
||||
initializeDrlstDept(nd1.ChildNodes, drplist, NextemptyString);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setTreeDeptSelected(string toFind,TreeNode nd)
|
||||
{
|
||||
foreach (TreeNode cnd in nd.ChildNodes)
|
||||
{
|
||||
if (cnd.Value == toFind)
|
||||
{
|
||||
cnd.Selected = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
setTreeDeptSelected(toFind,cnd);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LDepartment)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set data from shift object to page
|
||||
/// </summary>
|
||||
private void DetailDataBind()
|
||||
{
|
||||
DataDetail.Visible = true;
|
||||
txtDepName.Text = _logic.GetDepartment.dep_name ;
|
||||
txtDepcode.Text = _logic.GetDepartment.dep_code;
|
||||
txtDepDesc.Text = _logic.GetDepartment.dep_desc;
|
||||
txtSvrAddress.Text = _logic.GetDepartment.svrAdress;
|
||||
// txtDepType.Text = _logic.GetDepartment.dep_type+"";
|
||||
DropDownList1.SelectedItem.Selected = false;
|
||||
if(DropDownList1.Items.FindByValue(_logic.GetDepartment.dep_manager.ToString())!=null)
|
||||
{
|
||||
DropDownList1.Items.FindByValue(_logic.GetDepartment.dep_manager.ToString()).Selected = true;
|
||||
}
|
||||
drplstDept.SelectedItem.Selected = false;
|
||||
if (drplstDept.Items.FindByValue(_logic.GetDepartment.dep_mastdept.ToString()) != null)
|
||||
{
|
||||
drplstDept.Items.FindByValue(_logic.GetDepartment.dep_mastdept.ToString()).Selected = true;
|
||||
}
|
||||
dlstDeptType.SelectedItem.Selected = false;
|
||||
if (dlstDeptType.Items.FindByValue(_logic.GetDepartment.dep_type.ToString()) != null)
|
||||
{
|
||||
dlstDeptType.Items.FindByValue(_logic.GetDepartment.dep_type.ToString()).Selected = true;
|
||||
}
|
||||
|
||||
|
||||
// chkStatus.Checked = _logic.GetRole.dr;
|
||||
}
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
protected void btnAddnew_Click(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(true);
|
||||
_logic.Initialize();
|
||||
DetailDataBind();
|
||||
GridView1.SelectedIndex = -1;
|
||||
Databound();
|
||||
drplstDept.SelectedItem.Selected = false;
|
||||
if (drplstDept.Items.FindByValue(TreeDept.SelectedNode.Value) != null)
|
||||
{
|
||||
drplstDept.Items.FindByValue(TreeDept.SelectedNode.Value).Selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetDataBack();
|
||||
//shifts id eq 0 means this is new one,to add; else an old one, to update
|
||||
|
||||
if (_logic.GetDepartment.ID > 0)
|
||||
{
|
||||
_logic.GetDepartment.Update();
|
||||
}
|
||||
else
|
||||
{
|
||||
_logic.GetDepartment.Add();
|
||||
if (_logic.GetDepartment.warehouse == 0 && _logic.GetDepartment.dep_type==1)
|
||||
{
|
||||
_logic.GetDepartment.warehouse = _logic.GetDepartment.ID;
|
||||
_logic.GetDepartment.Update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ClearDetail();
|
||||
Databound();
|
||||
}
|
||||
|
||||
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
||||
{
|
||||
|
||||
if (GridView1 != null)
|
||||
{
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
}
|
||||
/*
|
||||
_logic.GetRole.dr = false;
|
||||
_logic.GetRole.Update();
|
||||
|
||||
*/
|
||||
_logic.GetDepartment.Delete();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
||||
{
|
||||
GridView1.PageIndex = e.NewPageIndex;
|
||||
Databound();
|
||||
|
||||
//GridView1.DataSource = shiftLgc.getAllShifts().Tables[0];
|
||||
// GridView1.DataBind();
|
||||
}
|
||||
|
||||
protected void GridView1_DataBinding(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
/*
|
||||
CheckBox chk;
|
||||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
chk = new CheckBox();
|
||||
chk.Text = "激活";
|
||||
chk.Enabled = false;
|
||||
chk.Checked = e.Row.Cells[3].Text.Trim().Equals("1");
|
||||
e.Row.Cells[3].Controls.Add(chk);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
// _logic.GetRole.operater = Session["CurrentUserID"].ToString(); todo: write a public method to handle operater,createtime,lastmodfied ... log info.
|
||||
|
||||
if (!(_logic.GetDepartment.ID > 0 ))
|
||||
{
|
||||
// _logic.GetDepartment.lastmodified = DateTime.Now.ToString();
|
||||
_logic.GetDepartment.dep_mastdept = Convert.ToInt32(TreeDept.SelectedValue);
|
||||
}
|
||||
|
||||
// _logic.GetDepartment.dr = true;
|
||||
_logic.GetDepartment.dep_name = txtDepName.Text;
|
||||
_logic.GetDepartment.dep_desc = txtDepDesc.Text;
|
||||
_logic.GetDepartment.dep_code = txtDepcode.Text;
|
||||
_logic.GetDepartment.svrAdress = txtSvrAddress.Text;
|
||||
if (dlstDeptType.SelectedItem != null) _logic.GetDepartment.dep_type = Convert.ToInt16(dlstDeptType.SelectedValue);
|
||||
if (DropDownList1.SelectedItem != null ) _logic.GetDepartment.dep_manager = Convert.ToInt32(DropDownList1.SelectedValue);
|
||||
if (drplstDept.SelectedItem != null) _logic.GetDepartment.dep_mastdept = Convert.ToInt32(drplstDept.SelectedValue);
|
||||
|
||||
if (_logic.GetDepartment.dep_type != (int)enumDepartmentType.仓库)//本部门不是仓库类型
|
||||
{
|
||||
if (_logic.GetDepartment.dep_mastdept > 0) //继承上级部门的仓库属性
|
||||
{
|
||||
Department dept = new Department(_logic.GetDepartment.dep_mastdept);
|
||||
if (dept.dep_type != 1)
|
||||
{
|
||||
_logic.GetDepartment.warehouse = dept.warehouse;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logic.GetDepartment.warehouse = dept.ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logic.GetDepartment.warehouse = _logic.GetDepartment.ID;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
DataDetail.Visible = true;
|
||||
lbEdit.Text = addNew ? "增加新记录" : "修改现有记录";
|
||||
btnSubmit.Enabled = true;
|
||||
}
|
||||
|
||||
private void ClearDetail()
|
||||
{
|
||||
txtDepName.Text = "";
|
||||
txtDepcode.Text = "";
|
||||
txtDepDesc.Text = "";
|
||||
//txtDepType.Text ="";
|
||||
DataDetail.Visible = false;
|
||||
}
|
||||
|
||||
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void BindTree(string id, TreeNode pNode, DataView dv)
|
||||
{
|
||||
|
||||
dv.RowFilter = "dep_mastdept = '" + id + "'";
|
||||
foreach (DataRowView row in dv)
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = row["dep_name"].ToString();
|
||||
node.Value = row["ID"].ToString();
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
|
||||
TreeDept.Nodes.Add(node);
|
||||
node.Expanded = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pNode.ChildNodes.Add(node);
|
||||
node.Expanded = true;
|
||||
|
||||
}
|
||||
BindTree(node.Value, node, new DataView(dv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
protected void TreeDept_SelectedNodeChanged(object sender, EventArgs e)
|
||||
{
|
||||
GridView1.SelectedIndex = -1;
|
||||
DataView dv = new DataView(_logic.GetAllActiveData());
|
||||
dv.RowFilter = "dep_mastdept = '" + TreeDept.SelectedValue + "'";
|
||||
bindGridview(dv);
|
||||
ClearDetail();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,290 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master"
|
||||
AutoEventWireup="true" CodeFile="EmployeeMain.aspx.cs" Inherits="EmployeeMain" %>
|
||||
|
||||
<%@ MasterType VirtualPath="~/masterPage.master" %>
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
|
||||
<table width="100%" class="Table_NoBorder">
|
||||
<tr>
|
||||
<td>
|
||||
<table width="100%" class="Table_Border">
|
||||
<tr>
|
||||
<td width="50" height="200" align="left" valign="top">
|
||||
<asp:TreeView ID="TreeDept" runat="server" ShowLines="True" OnSelectedNodeChanged="TreeDept_SelectedNodeChanged"
|
||||
ImageSet="Arrows">
|
||||
<nodes>
|
||||
<asp:TreeNode Text="WMS" Value="0" Expanded="True" Selected="True"></asp:TreeNode>
|
||||
</nodes>
|
||||
<selectednodestyle backcolor="Azure" bordercolor="Transparent" />
|
||||
</asp:TreeView>
|
||||
<asp:TextBox id="TextBox11" runat="server" visible=false>
|
||||
</asp:TextBox>
|
||||
|
||||
<cc1:calendarextender id="CalendarExtender11" runat="server" targetcontrolid="TextBox11"></cc1:calendarextender>
|
||||
|
||||
</td>
|
||||
<td width="1" class="VLine">
|
||||
</td>
|
||||
<td align="left" valign="top" width="90%">
|
||||
<!------ THE DATA GRID AREA ------>
|
||||
<asp:Label ID="lbDataGridTitle" Visible="false" runat="server" CssClass="Label" Text="人员维护" />
|
||||
<asp:Label ID="lbEdit" Visible="false" runat="server" CssClass="Label" Text=""></asp:Label>
|
||||
<asp:gridview id="GridView1" CssClass="DataGrid" PageSize="10" PagerStyle-HorizontalAlign="Right"
|
||||
runat="server" AutoGenerateColumns="False" OnRowEditing="GridView1_RowEditing"
|
||||
DataKeyNames="de_employee" OnRowDeleting="GridView1_RowDeleting" AllowPaging="True"
|
||||
OnPageIndexChanging="GridView1_PageIndexChanging" OnRowDataBound="GridView1_RowDataBound"
|
||||
OnSorting="GridView1_Sorting" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
|
||||
Width="99%" ShowFooter="True" EmptyDataText='没有数据。'>
|
||||
<selectedrowstyle cssclass="SelectedItemStyle"></selectedrowstyle>
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center"></headerstyle>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center"></rowstyle>
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle"></alternatingrowstyle>
|
||||
<columns>
|
||||
<asp:BoundField Visible="TRUE" ReadOnly="True" DataField="de_employee" HeaderText="人员编号" SortExpression="de_employee" >
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="EM_NAME" HeaderText="姓名" SortExpression="EM_NAME">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="DEP_NAME" HeaderText="部门" SortExpression="DEP_NAME" >
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="EM_SEX" HeaderText="性别" SortExpression="EM_SEX" HtmlEncode="False" DataFormatString="{0:True:男;False:女}">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="EM_BIRTHDAY" HeaderText="出生日期" SortExpression="EM_BIRTHDAY" DataFormatString="{0:yyyy-MM-dd}" HtmlEncode="False" Visible="False">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="de_title" HeaderText="职务" SortExpression="de_title">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="em_education" HeaderText="学历" SortExpression="em_education" Visible="False">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="em_politic" HeaderText="人员性质" SortExpression="em_politic" Visible="False">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="em_date_in_party" HeaderText="入党时间" SortExpression="em_date_in_party" DataFormatString="{0:yyyy-MM-dd}" HtmlEncode="False" Visible="False">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="em_date_work" HeaderText="参加工作时间" SortExpression="em_date_work" DataFormatString="{0:yyyy-MM-dd}" HtmlEncode="False" Visible="False">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="dr" HeaderText="可用" SortExpression="dr" Visible="False" ></asp:BoundField>
|
||||
|
||||
<asp:CommandField HeaderText="编 辑" ShowDeleteButton="True" DeleteText=" " ShowHeader="True" ShowSelectButton="True" SelectText="<img src=../Images/edit.gif border=0 title=修改 >">
|
||||
<HeaderStyle HorizontalAlign="Center" Width="10%" />
|
||||
<ItemStyle HorizontalAlign="Center" Width="10%" />
|
||||
</asp:CommandField>
|
||||
</columns>
|
||||
<pagerstyle horizontalalign="Right" />
|
||||
<emptydatatemplate> 没有数据</emptydatatemplate>
|
||||
</asp:gridview>
|
||||
<!--DeleteText="<img src=../Images/Delete.gif border=0 title=删除 onclick='return delete_click()'>" -->
|
||||
<asp:Button ID="btn_addNew" runat="server" Text="新增记录" CssClass="Button" OnClick="btnAddnew_Click" />
|
||||
<asp:Button ID="Button1" runat="server" Text="导出Excel" CssClass="Button" OnClick="Excel_Click" />
|
||||
|
||||
<asp:Panel ID="DataDetail" runat="server" Width="100%" Visible="false">
|
||||
<!------ THE ADD /DELETE AREA ------>
|
||||
<table class="Table_NoBorder" border="0" width="95%">
|
||||
<tr>
|
||||
<td colspan="6" class="ALine">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<asp:Label ID="Label2" runat="server" CssClass="Label" Text='姓名'></asp:Label></td>
|
||||
<td nowrap>
|
||||
<asp:TextBox ID="txtName" runat="server" CssClass="TextBox" MaxLength="25">
|
||||
</asp:TextBox>
|
||||
<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ControlToValidate="txtName"
|
||||
ErrorMessage="请输入用户名。" SetFocusOnError="True" ValidationGroup="1">*</asp:RequiredFieldValidator></td>
|
||||
<td>
|
||||
<asp:Label ID="Label4" runat="server" CssClass="Label" Text='性别'></asp:Label></td>
|
||||
<td>
|
||||
<asp:DropDownList ID="drplstSex" runat="server" CssClass="DropDownList">
|
||||
<asp:ListItem Value="1">男</asp:ListItem>
|
||||
<asp:ListItem Value="0">女</asp:ListItem>
|
||||
</asp:DropDownList></td>
|
||||
<td nowrap>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<asp:Label ID="Label6" runat="server" CssClass="Label" Text="身份证号"></asp:Label></td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtID" CssClass="TextBox" runat="server" MaxLength="25">
|
||||
</asp:TextBox>
|
||||
</td>
|
||||
<td nowrap>
|
||||
<asp:Label ID="Label3" runat="server" CssClass="Label" Text="人员性质"></asp:Label></td>
|
||||
<td>
|
||||
<asp:DropDownList ID="drlstPlitics" runat="server" CssClass="DropDownList">
|
||||
<asp:ListItem Value="0">仓库员工</asp:ListItem>
|
||||
<asp:ListItem Value="1">三方人员</asp:ListItem>
|
||||
</asp:DropDownList></td>
|
||||
<td nowrap>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<asp:Label ID="Label10" runat="server" CssClass="Label" Text="电子信箱"></asp:Label></td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtMail" CssClass="TextBox" runat="server" MaxLength="25" CausesValidation="True"></asp:TextBox>
|
||||
<asp:RegularExpressionValidator id="RegularExpressionValidator1" runat="server" ControlToValidate="txtMail"
|
||||
ErrorMessage="电子信箱格式不正确,正确格式如zhangsan@163.net。" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
|
||||
ValidationGroup="1">*
|
||||
</asp:RegularExpressionValidator>
|
||||
</td>
|
||||
<td>
|
||||
出生日期</td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtBirthday" runat="server" CssClass="TextBox" MaxLength="25">
|
||||
</asp:TextBox>
|
||||
</td>
|
||||
<td>
|
||||
学历</td>
|
||||
<td>
|
||||
<asp:DropDownList ID="drplstEducation" CssClass="DropDownList" runat="server">
|
||||
<asp:ListItem>博士</asp:ListItem>
|
||||
<asp:ListItem>硕士研究生</asp:ListItem>
|
||||
<asp:ListItem>本科</asp:ListItem>
|
||||
<asp:ListItem>专科</asp:ListItem>
|
||||
<asp:ListItem>中专</asp:ListItem>
|
||||
<asp:ListItem>高中</asp:ListItem>
|
||||
<asp:ListItem>初中</asp:ListItem>
|
||||
<asp:ListItem>小学</asp:ListItem>
|
||||
<asp:ListItem>其他</asp:ListItem>
|
||||
</asp:DropDownList></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap>
|
||||
<asp:Label ID="Label7" runat="server" CssClass="Label" Text="账号"></asp:Label></td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtAccount" CssClass="TextBox" runat="server" MaxLength="25">
|
||||
</asp:TextBox>
|
||||
<asp:RequiredFieldValidator id="RequiredFieldValidator2" runat="server" ControlToValidate="txtAccount"
|
||||
ErrorMessage="请输入账号。" ValidationGroup="1">*</asp:RequiredFieldValidator></td>
|
||||
<td nowrap>
|
||||
<asp:Label ID="Label8" runat="server" CssClass="Label" Text="密码"></asp:Label></td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtPasswd" CssClass="TextBox" runat="server" MaxLength="25" TextMode="Password">
|
||||
</asp:TextBox></td>
|
||||
<td>
|
||||
<asp:Label ID="Label9" runat="server" CssClass="Label" Text="手机"></asp:Label></td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtCell" CssClass="TextBox" runat="server" MaxLength="25" CausesValidation="True"></asp:TextBox>
|
||||
<asp:RegularExpressionValidator id="RegularExpressionValidator2" runat="server" ControlToValidate="txtCell"
|
||||
Display="Dynamic" ErrorMessage="手机号码格式不正确,应为11位数字。" ValidationExpression="^\d{11}$" ValidationGroup="1">*
|
||||
</asp:RegularExpressionValidator></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap>
|
||||
<asp:Label ID="lableDept" runat="server" CssClass="Label" Text="当前部门"></asp:Label></td>
|
||||
<td>
|
||||
<asp:Label ID="lbSelectedDept" runat="server" CssClass="Label" Text="" /></td>
|
||||
<td nowrap>
|
||||
<asp:Label ID="lbTitle" runat="server" CssClass="Label" Text="职务"></asp:Label></td>
|
||||
<td>
|
||||
<asp:TextBox ID="txtTitle" CssClass="TextBox" runat="server" MaxLength="25">
|
||||
</asp:TextBox></td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<asp:Label ID="lbempdept" runat="server" CssClass="Label" Text="部门分配"></asp:Label></td>
|
||||
<td colspan="4" align="center">
|
||||
<asp:gridview id="GvDept" runat="server" AutoGenerateColumns="False" CssClass="DataGrid"
|
||||
DataKeyNames="ID" emptydatatext="没有数据。" ShowFooter="True" tabIndex="1"
|
||||
Width="100%" OnRowCancelingEdit="GvDept_RowCancelingEdit" OnRowUpdating="GvDept_RowUpdating"
|
||||
OnRowEditing="GvDept_RowEditing">
|
||||
<columns>
|
||||
<asp:BoundField ReadOnly="True" DataField="ID" Visible="False" SortExpression="ID" HeaderText="id"></asp:BoundField>
|
||||
<asp:BoundField ReadOnly="True" DataField="DEP_NAME" SortExpression="DEP_NAME" HeaderText="部门名称"></asp:BoundField>
|
||||
<asp:BoundField ReadOnly="True" DataField="DEP_DESC" SortExpression="DEP_DESC" HeaderText="部门描述"></asp:BoundField>
|
||||
<asp:TemplateField SortExpression="DE_TITLE" HeaderText="职务"><EditItemTemplate>
|
||||
<asp:TextBox runat="server" Text='<%# Bind("DE_TITLE") %>' id="TextBox1"></asp:TextBox>
|
||||
|
||||
</EditItemTemplate>
|
||||
<ItemTemplate>
|
||||
<asp:Label runat="server" Text='<%# Bind("DE_TITLE") %>' id="Label1"></asp:Label>
|
||||
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
<asp:CommandField InsertVisible="False" CancelImageUrl="~/Images/undo.gif" EditImageUrl="~/Images/edit.gif" ShowHeader="True" UpdateImageUrl="~/Images/save.gif" ButtonType="Image" ShowEditButton="True"></asp:CommandField>
|
||||
</columns>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center" />
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center" />
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle" />
|
||||
<selectedrowstyle cssclass="SelectedItemStyle" />
|
||||
</asp:gridview>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtBirthday"
|
||||
FirstDayOfWeek="Monday" CssClass="MyCalendar">
|
||||
</cc1:CalendarExtender>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6" >
|
||||
<asp:ValidationSummary id="ValidationSummary1" runat="server" ValidationGroup="1" HeaderText="错误提示"></asp:ValidationSummary>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6" class="ALine">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="6" align="center">
|
||||
<asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存" OnClick="btnSubmit_Click" ValidationGroup="1" />
|
||||
<!--input type="button" id="ButtonCancel" onClick="reset()" class="Button" value="取消修改" name="ButtonCancel"/-->
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Panel>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="ALine">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align="center" style="height: 309px" valign="top">
|
||||
<!------ THE ADD /DELETE AREA ------>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Content>
|
|
@ -0,0 +1,534 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using view.App_Code;
|
||||
using DeiNiu.wms.Logical;
|
||||
using DeiNiu.Utils;
|
||||
|
||||
public partial class EmployeeMain : PageBase
|
||||
{
|
||||
private LEmployee _logic;
|
||||
protected void Page_Init()
|
||||
{
|
||||
|
||||
PostBackTrigger trigger = new PostBackTrigger();
|
||||
trigger.ControlID = Button1.UniqueID;
|
||||
|
||||
// (Button)pnGridViewProcess.FindControl("btnExcel")).UniqueID.ToString();
|
||||
|
||||
// (UpdatePanel)(Page.Controls[0].FindControl("UpdatePanel1")).Triggers.Add(trigger);
|
||||
|
||||
((UpdatePanel)Master.FindControl("UpdatePanel1")).Triggers.Add(trigger);
|
||||
|
||||
}
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
|
||||
_logic = new LEmployee();
|
||||
bindDeptTree();
|
||||
Databound();
|
||||
}
|
||||
SessionSeting();
|
||||
}
|
||||
|
||||
/***************************************** private methods ******************************************/
|
||||
|
||||
void bindDeptTree()
|
||||
{
|
||||
|
||||
DataView dvDept = new DataView(_logic.GetDepartments());
|
||||
|
||||
//装载选定部门节点的部门数据
|
||||
|
||||
TreeDept.SelectedNode.ChildNodes.Clear();
|
||||
BindTree(TreeDept.SelectedNode.Value, TreeDept.SelectedNode, dvDept);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
|
||||
//绑定部门树选中的部门下的所有员工数据
|
||||
bindGrid();
|
||||
|
||||
|
||||
|
||||
UpdateSession();
|
||||
// btnSubmit.Enabled = false;
|
||||
ClearDetail();
|
||||
}
|
||||
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LEmployee)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set data from shift object to page
|
||||
/// </summary>
|
||||
private void DetailDataBind()
|
||||
{
|
||||
DataDetail.Visible = true;
|
||||
txtAccount.ReadOnly = true;
|
||||
txtName.Text = _logic.GetEmployee.em_name;
|
||||
txtBirthday.Text = _logic.GetEmployee.em_birthday.ToString();
|
||||
txtCell.Text = _logic.GetEmployee.em_cellnum;
|
||||
|
||||
txtID.Text = _logic.GetEmployee.em_idnum;
|
||||
txtMail.Text = _logic.GetEmployee.em_email;
|
||||
//txtPasswd.Text = _logic.GetEmployee.em_passwd;
|
||||
txtAccount.Text = _logic.GetEmployee.em_account;
|
||||
lbSelectedDept.Text = TreeDept.SelectedNode.Text;
|
||||
drplstSex.Items.FindByValue("1").Selected = true;
|
||||
|
||||
if (_logic.GetEmployee.em_sex)
|
||||
{
|
||||
drplstSex.Items.FindByValue("0").Selected = false;
|
||||
drplstSex.Items.FindByValue("1").Selected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
drplstSex.Items.FindByValue("1").Selected = false;
|
||||
drplstSex.Items.FindByValue("0").Selected = true;
|
||||
}
|
||||
if (drplstEducation.Items.FindByValue(_logic.GetEmployee.em_education) != null)
|
||||
// drplstEducation.Items.FindByValue(_logic.GetEmployee.em_education).Selected=true; //ListItemColleciton can only select one item, if another has been selected, this will case error.
|
||||
SetDropDownlistSelection(drplstEducation, _logic.GetEmployee.em_education);
|
||||
|
||||
bindGV();
|
||||
|
||||
if (drlstPlitics.Items.FindByValue(_logic.GetEmployee.em_type) != null)
|
||||
//drlstPlitics.Items.FindByValue(_logic.GetEmployee.em_politic).Selected = true;
|
||||
SetDropDownlistSelection(drlstPlitics, _logic.GetEmployee.em_type);
|
||||
|
||||
// chkStatus.Checked = _logic.GetRole.dr;
|
||||
}
|
||||
|
||||
|
||||
void bindGV()
|
||||
{
|
||||
GvDept.DataSource = _logic.GetDepartments(_logic.GetEmployee.ID);
|
||||
GvDept.DataBind();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
protected void btnAddnew_Click(object sender, EventArgs e)
|
||||
{
|
||||
if(TreeDept.SelectedValue == "0" )
|
||||
{
|
||||
ScriptManager.RegisterStartupScript(btnSubmit, typeof(UpdatePanel), "alert",
|
||||
"alert('请选择用户所属部门。');", true);
|
||||
return;
|
||||
}
|
||||
txtAccount.ReadOnly = false;
|
||||
chgOperTxt(true);
|
||||
_logic.Initialize();
|
||||
ClearDetail();
|
||||
GridView1.SelectedIndex = -1;
|
||||
Databound();
|
||||
txtTitle.Enabled = true;
|
||||
lbTitle.Visible = true;
|
||||
txtTitle.Visible = true;
|
||||
lbSelectedDept.Text = TreeDept.SelectedNode.Text;
|
||||
// DetailDataBind();
|
||||
DataDetail.Visible = true;
|
||||
bindGV();
|
||||
}
|
||||
|
||||
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
bool userNotExist = true;
|
||||
SetDataBack();
|
||||
if (txtName.Text.Trim().Length == 0)
|
||||
{
|
||||
txtName.Focus();
|
||||
bindGrid();
|
||||
// ScriptManager.RegisterStartupScript(btnSubmit, typeof(UpdatePanel), "alert",
|
||||
// "alert('请输入用户姓名。');", true);
|
||||
return;
|
||||
|
||||
}
|
||||
if (txtAccount.Text.Trim().Length == 0)
|
||||
{
|
||||
txtAccount.Focus();
|
||||
bindGrid();
|
||||
// ScriptManager.RegisterStartupScript(btnSubmit, typeof (UpdatePanel), "alert",
|
||||
// "alert('请输入用户账号。');", true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
if(lem.GetEmployee.em_account !="mysec" )
|
||||
if (_logic != null)
|
||||
if (_logic.GetEmployee != null)
|
||||
if(_logic.GetEmployee.QueryActived().Tables[0].Rows.Count>20)
|
||||
return;
|
||||
*/
|
||||
|
||||
if (_logic != null)
|
||||
if (_logic.GetEmployee != null)
|
||||
if (_logic.GetEmployee.ID > 0)
|
||||
_logic.GetEmployee.Update();
|
||||
else
|
||||
{
|
||||
userNotExist = _logic.AddEmployee();
|
||||
|
||||
|
||||
}
|
||||
if (!userNotExist)
|
||||
{
|
||||
ScriptManager.RegisterStartupScript(btnSubmit, typeof (UpdatePanel), "alert",
|
||||
"alert('用户名 " + txtAccount.Text
|
||||
+ " 已经存在,请重新输入,操作失败。');", true);
|
||||
|
||||
bindGrid();
|
||||
|
||||
txtAccount.Text ="";
|
||||
txtAccount.Focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearDetail();
|
||||
Databound();
|
||||
DataDetail.Visible = false;
|
||||
}
|
||||
|
||||
}
|
||||
void bindGrid()
|
||||
{
|
||||
_logic.GetEmployee.em_dept = TreeDept.SelectedValue;
|
||||
DataView dv = TreeDept.SelectedValue != "0"
|
||||
? new DataView(_logic.GetActiveEmpByDept(Convert.ToInt32(TreeDept.SelectedValue)))
|
||||
: new DataView(_logic.GetActivedEmpDept());
|
||||
dv.RowFilter = "em_name <>'Root'";
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
|
||||
}
|
||||
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
||||
{
|
||||
|
||||
if (GridView1 != null)
|
||||
{
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
}
|
||||
|
||||
_logic.GetEmployee.Delete();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
||||
{
|
||||
GridView1.PageIndex = e.NewPageIndex;
|
||||
Databound();
|
||||
|
||||
//GridView1.DataSource = shiftLgc.getAllShifts().Tables[0];
|
||||
// GridView1.DataBind();
|
||||
}
|
||||
|
||||
protected void GridView1_DataBinding(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
Label lb;
|
||||
switch (e.Row.RowType)
|
||||
{
|
||||
case DataControlRowType.DataRow:
|
||||
lb = new Label();
|
||||
lb.Text = e.Row.Cells[3].Text.Trim().Equals("True") ? "男" : "女";
|
||||
e.Row.Cells[3].Controls.Add(lb);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
// _logic.GetRole.operater = Session["CurrentUserID"].ToString(); todo: write a public method to handle operater,createtime,lastmodfied ... log info.
|
||||
|
||||
if ( _logic.GetEmployee.ID >0 )
|
||||
{
|
||||
// _logic.GetEmployee.lastmodified = DateTime.Now.ToString();
|
||||
|
||||
if(txtPasswd.Text.Trim().Length>0)
|
||||
_logic.GetEmployee.em_passwd = Util.Encrypt(txtPasswd.Text.Trim());
|
||||
}
|
||||
else
|
||||
{
|
||||
_logic.GetEmployee.em_passwd = Util.Encrypt(txtPasswd.Text.Trim());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// _logic.GetEmployee.dr = true;
|
||||
_logic.GetEmployee.em_name = txtName.Text;
|
||||
_logic.GetEmployee.em_account = txtAccount.Text;
|
||||
_logic.GetEmployee.em_birthday = txtBirthday.Text;
|
||||
_logic.GetEmployee.em_cellnum = txtCell.Text;
|
||||
|
||||
_logic.GetEmployee.em_education = drplstEducation.SelectedValue;
|
||||
_logic.GetEmployee.em_email = txtMail.Text;
|
||||
_logic.GetEmployee.em_idnum = txtID.Text;
|
||||
|
||||
_logic.GetEmployee.em_type = drlstPlitics.SelectedValue;
|
||||
_logic.GetEmployee.em_sex = drplstSex.SelectedIndex == 0;
|
||||
|
||||
|
||||
_logic.GetEmployee.em_dept = TreeDept.SelectedValue;
|
||||
_logic.GetEmployee.em_jobcode = txtTitle.Text;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
DataDetail.Visible = true;
|
||||
lbEdit.Text = addNew ? "增加新记录" : "修改现有记录";
|
||||
btnSubmit.Enabled = true;
|
||||
}
|
||||
|
||||
private void ClearDetail()
|
||||
{
|
||||
lbEdit.Text = "";
|
||||
|
||||
txtName.Text = "" ;
|
||||
txtBirthday.Text = "";
|
||||
txtCell.Text = "";
|
||||
|
||||
txtID.Text = "";
|
||||
txtMail.Text ="";
|
||||
txtPasswd.Text ="";
|
||||
txtAccount.Text ="";
|
||||
txtTitle.Text = "";
|
||||
lbSelectedDept.Text = TreeDept.SelectedNode.Text;
|
||||
txtPasswd.Text = "";
|
||||
InitDropdownlist();
|
||||
//装载选定部门节点的部门数据
|
||||
// drlstPlitics.SelectedIndex = -1;
|
||||
DataDetail.Visible = false;
|
||||
}
|
||||
|
||||
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
lbTitle.Visible = false;
|
||||
txtTitle.Visible = false;
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
txtTitle.Enabled = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void BindTree(string id, TreeNode pNode, DataView dv)
|
||||
{
|
||||
|
||||
dv.RowFilter = "dep_mastdept = '" + id + "'";
|
||||
foreach (DataRowView row in dv)
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = row["dep_name"].ToString();
|
||||
node.Value = row["ID"].ToString();
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
|
||||
TreeDept.Nodes.Add(node);
|
||||
node.Expanded = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pNode.ChildNodes.Add(node);
|
||||
node.Expanded = true;
|
||||
|
||||
}
|
||||
BindTree(node.Value, node, new DataView(dv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
protected void TreeDept_SelectedNodeChanged(object sender, EventArgs e)
|
||||
{
|
||||
/*
|
||||
DataView dv = new DataView(_logic.GetAllActiveData().Tables[0]);
|
||||
if(TreeDept.SelectedValue !="0")
|
||||
dv.RowFilter = "em_dept = '" + TreeDept.SelectedValue + "'";
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
ClearDetail();
|
||||
*/
|
||||
if (_logic != null) _logic.Initialize();
|
||||
GridView1.SelectedIndex = -1;
|
||||
Databound();
|
||||
|
||||
|
||||
}
|
||||
protected void drplstSex_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
ListItem selectedItem = drplstSex.Items[1];
|
||||
selectedItem.Selected = true;
|
||||
}
|
||||
|
||||
protected void InitDropdownlist()
|
||||
{
|
||||
|
||||
drplstSex.Items[ drplstSex.SelectedIndex].Selected = false;
|
||||
drplstSex.Items.FindByValue("1").Selected = true;
|
||||
|
||||
drlstPlitics.Items[drlstPlitics.SelectedIndex].Selected = false;
|
||||
drlstPlitics.Items[0].Selected = true;
|
||||
|
||||
}
|
||||
|
||||
protected void SetDropDownlistSelection(DropDownList drdlst,string value)
|
||||
{
|
||||
drdlst.Items[drdlst.SelectedIndex].Selected = false;
|
||||
if (drdlst.Items.FindByValue(value)!=null)
|
||||
drdlst.Items.FindByValue(value).Selected = true;
|
||||
}
|
||||
|
||||
//如果没有下面方法会报错类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内
|
||||
public override void VerifyRenderingInServerForm(Control control)
|
||||
{
|
||||
}
|
||||
protected void Excel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Master.ScriptMgr.RegisterPostBackControl(this.Button1);
|
||||
GridView1.AllowPaging = false;
|
||||
GridView1.Columns[11].Visible = false;
|
||||
Databound();
|
||||
Export("application/ms-excel", "WMS系统用户列表.xls");
|
||||
GridView1.AllowPaging = false;
|
||||
GridView1.Columns[11].Visible = true;
|
||||
Databound();
|
||||
|
||||
}
|
||||
|
||||
private void Export(string FileType, string FileName)
|
||||
{
|
||||
|
||||
Response.Charset = "GB2312";
|
||||
Response.ContentEncoding = Encoding.UTF7;
|
||||
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
|
||||
Response.ContentType = FileType;
|
||||
EnableViewState = false;
|
||||
StringWriter tw = new StringWriter();
|
||||
HtmlTextWriter hw = new HtmlTextWriter(tw);
|
||||
GridView1.RenderControl(hw);
|
||||
Response.Write(tw.ToString());
|
||||
Response.End();
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void GvDept_RowUpdating(object sender, GridViewUpdateEventArgs e)
|
||||
{
|
||||
if (GvDept.DataKeys != null)
|
||||
{
|
||||
string id = GvDept.DataKeys[e.RowIndex].Value.ToString();
|
||||
|
||||
_logic.GetDeptEmp.ID = Convert.ToInt32(id);
|
||||
_logic.GetDeptEmp.getModel();
|
||||
|
||||
_logic.GetDeptEmp.de_title = ((TextBox)GvDept.Rows[e.RowIndex].Cells[3].Controls[1]).Text;
|
||||
|
||||
//_logic.GetTrainingDetail.operater =
|
||||
_logic.GetDeptEmp.Update();
|
||||
}
|
||||
GvDept.EditIndex = -1;
|
||||
GvDept.SelectedIndex = e.RowIndex;
|
||||
bindGV();
|
||||
}
|
||||
protected void GvDept_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
|
||||
{
|
||||
GvDept.EditIndex = -1;
|
||||
GvDept.SelectedIndex = e.RowIndex;
|
||||
bindGV();
|
||||
}
|
||||
protected void GvDept_RowEditing(object sender, GridViewEditEventArgs e)
|
||||
{
|
||||
GvDept.EditIndex = e.NewEditIndex;
|
||||
GvDept.SelectedIndex = e.NewEditIndex;
|
||||
bindGV();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master" AutoEventWireup="true" CodeFile="PublicNewsMain.aspx.cs" Inherits="PublicNewsMain" %>
|
||||
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
|
||||
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<table width="100%" class="Table_NoBorder">
|
||||
|
||||
<tr><td>
|
||||
<table width="100%" class="Table_Border">
|
||||
<tr><td width="50" height="200" align="left" valign="top">
|
||||
<asp:TreeView ID="TreeAuth" runat="server" ShowLines="True" ImageSet="Arrows" OnSelectedNodeChanged="TreeAuth_SelectedNodeChanged1">
|
||||
<SelectedNodeStyle BackColor="Azure" BorderColor="Transparent" />
|
||||
<Nodes>
|
||||
<asp:TreeNode Text="公共信息发布" Selected="True" Value="0" Expanded="True"></asp:TreeNode>
|
||||
</Nodes>
|
||||
</asp:TreeView>
|
||||
</td>
|
||||
<td width="1" class="VLine" ></td>
|
||||
<td width="100%" align="left" valign="top"> <!------ THE DATA GRID AREA ------>
|
||||
|
||||
<asp:Label ID="lbDataGridTitle" Visible="false" runat="server" CssClass="Label" Text="信息维护" />
|
||||
<asp:Label ID="lbEdit" Visible="false" runat="server" CssClass="Label" Text=""></asp:Label>
|
||||
<asp:gridview id="GridView1" CssClass="DataGrid"
|
||||
PageSize="10" PagerStyle-HorizontalAlign="Right"
|
||||
runat="server"
|
||||
AutoGenerateColumns="False"
|
||||
DataKeyNames="ID"
|
||||
OnRowDeleting="GridView1_RowDeleting"
|
||||
AllowPaging="True"
|
||||
OnPageIndexChanging="GridView1_PageIndexChanging"
|
||||
|
||||
OnSorting="GridView1_Sorting" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="100%" ShowFooter="True" EmptyDataText='没有数据。' OnRowDataBound="GridView1_RowDataBound">
|
||||
|
||||
<SelectedRowStyle CssClass="SelectedItemStyle"></SelectedRowStyle>
|
||||
<HeaderStyle CssClass="HeaderStyle" ></HeaderStyle>
|
||||
<RowStyle CssClass="ItemStyle" HorizontalAlign="Center"></RowStyle>
|
||||
<AlternatingRowStyle CssClass="AlternatingItemStyle"></AlternatingRowStyle>
|
||||
|
||||
<Columns>
|
||||
<asp:BoundField ReadOnly="True" DataField="ID" visible="false" HeaderText="权限id" SortExpression="ID" ></asp:BoundField>
|
||||
<asp:BoundField DataField="news_title" HeaderText="信息标题" SortExpression="news_title" ></asp:BoundField>
|
||||
<asp:BoundField DataField="news_content" HeaderText="信息内容" SortExpression="news_content" ></asp:BoundField>
|
||||
<asp:BoundField DataField="create_time" HeaderText="发布时间" SortExpression="create_time" ></asp:BoundField>
|
||||
<asp:BoundField DataField="dr" HeaderText="可用" SortExpression="dr" Visible="False" ></asp:BoundField>
|
||||
|
||||
<asp:CommandField HeaderText="编 辑" ShowDeleteButton="True" DeleteText="<img src=../Images/Delete.gif border=0 title=删除 onclick='return delete_click()'>" ShowHeader="True" ShowSelectButton="True" SelectText="<img src=../Images/edit.gif border=0 title=修改 >">
|
||||
<HeaderStyle HorizontalAlign="Center" Width="15%" />
|
||||
<ItemStyle HorizontalAlign="Center" Width="15%" />
|
||||
</asp:CommandField>
|
||||
</Columns>
|
||||
<PagerStyle HorizontalAlign="Right" />
|
||||
<emptydatatemplate> 没有数据</emptydatatemplate>
|
||||
</asp:gridview>
|
||||
<asp:Button ID="btn_addNew" runat="server" Text="新增记录" CssClass="Button" OnClick="btnAddnew_Click" />
|
||||
|
||||
|
||||
<asp:Panel ID ="DataDetail" runat="server" Width="100%" Visible="false">
|
||||
|
||||
<!------ THE ADD /DELETE AREA ------>
|
||||
<table class="Table_NoBorder" width="100%">
|
||||
<tr>
|
||||
<td colspan ="4" class="ALine" >
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td nowrap>
|
||||
<asp:Label ID="Label2" runat="server" CssClass="Label" Text="标题"></asp:Label></td>
|
||||
<td >
|
||||
|
||||
<asp:TextBox ID="txtTitle" runat="server" CssClass="TextBox" MaxLength="100" width="400px"></asp:TextBox>
|
||||
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTitle"
|
||||
ErrorMessage="*" ValidationGroup="1">*</asp:RequiredFieldValidator></td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<td style="height: 218px">
|
||||
<asp:Label ID="Label3" runat="server" CssClass="Label" Text="内容"></asp:Label></td><td style="height: 218px" >
|
||||
<asp:TextBox ID="txtDesc" CssClass="Long_TextBox" runat="server" MaxLength="50" Width="803px" Height="300px" TextMode="MultiLine"></asp:TextBox></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan ="4" class="ALine" >
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!------ BUTTONS ------>
|
||||
<table class="Table_NoBorder" width="80%">
|
||||
<tr>
|
||||
<td align="center" > <asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存数据" OnClick="btnSubmit_Click" ValidationGroup="1" />
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Panel>
|
||||
|
||||
</td></tr>
|
||||
|
||||
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
</asp:Content>
|
||||
|
|
@ -0,0 +1,266 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using DeiNiu.Utils;
|
||||
using DeiNiu.wms.Logical;
|
||||
|
||||
public partial class PublicNewsMain : PageBase
|
||||
{
|
||||
private LPublicNews _logic;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
_logic = new LPublicNews();
|
||||
Databound();
|
||||
}
|
||||
SessionSeting();
|
||||
}
|
||||
|
||||
/***************************************** private methods ******************************************/
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
|
||||
|
||||
//装载选定节点的数据
|
||||
DataView dv = new DataView(_logic.QueryPublicInfomation());
|
||||
|
||||
TreeAuth.SelectedNode.ChildNodes.Clear();
|
||||
BindTree(TreeAuth.SelectedNode.Value, TreeAuth.SelectedNode, dv);
|
||||
//绑定树列表里选中的所有数据
|
||||
|
||||
GridView1.DataSource = _logic.QueryNews(Convert.ToInt32(TreeAuth.SelectedValue));
|
||||
GridView1.DataBind();
|
||||
|
||||
// GVFiles.DataSource = null;
|
||||
// GVFiles.DataBind();
|
||||
UpdateSession();
|
||||
ClearDetail();
|
||||
}
|
||||
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LPublicNews)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set data from shift object to page
|
||||
/// </summary>
|
||||
private void DetailDataBind()
|
||||
{
|
||||
|
||||
DataDetail.Visible = true;
|
||||
txtTitle.Text = _logic.GetPublicNews.news_title;
|
||||
txtDesc.Text = _logic.GetPublicNews.news_content;
|
||||
}
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
protected void btnAddnew_Click(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(true);
|
||||
_logic.Initialize();
|
||||
|
||||
GridView1.SelectedIndex = -1;
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
//todo bind attached files infomationsss\\
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetDataBack();
|
||||
//shifts id eq 0 means this is new one,to add; else an old one, to update
|
||||
|
||||
int oper = 0;
|
||||
oper = _logic.GetPublicNews.ID > 0 ? _logic.GetPublicNews.Update() : _logic.GetPublicNews.Add();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
lbEdit.Text = "";
|
||||
}
|
||||
|
||||
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
||||
{
|
||||
|
||||
if (GridView1 != null)
|
||||
{
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
}
|
||||
/*
|
||||
_logic.GetRole.dr = false;
|
||||
_logic.GetRole.Update();
|
||||
|
||||
*/
|
||||
_logic.GetPublicNews.Delete();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
||||
{
|
||||
GridView1.PageIndex = e.NewPageIndex;
|
||||
Databound();
|
||||
|
||||
//GridView1.DataSource = shiftLgc.getAllShifts().Tables[0];
|
||||
// GridView1.DataBind();
|
||||
}
|
||||
|
||||
protected void GridView1_DataBinding(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
// _logic.GetRole.operater = Session["CurrentUserID"].ToString(); todo: write a public method to handle operater,createtime,lastmodfied ... log info.
|
||||
|
||||
if (!(_logic.GetPublicNews.ID > 0))
|
||||
{
|
||||
//_logic.GetPublicNews.last_modified = DateTime.Now.ToString();
|
||||
_logic.GetPublicNews.news_authority = Convert.ToInt32(TreeAuth.SelectedValue);
|
||||
}
|
||||
|
||||
_logic.GetPublicNews.news_title = txtTitle.Text;
|
||||
_logic.GetPublicNews.news_content = txtDesc.Text;
|
||||
|
||||
//todo bind files
|
||||
}
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
DataDetail.Visible = true;
|
||||
lbEdit.Text = addNew ? "增加新记录" : "修改现有记录";
|
||||
btnSubmit.Enabled = true;
|
||||
}
|
||||
|
||||
private void ClearDetail()
|
||||
{
|
||||
txtTitle.Text = "";
|
||||
txtDesc.Text = "";
|
||||
|
||||
DataDetail.Visible = false;
|
||||
}
|
||||
|
||||
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void BindTree(string id, TreeNode pNode, DataView dv)
|
||||
{
|
||||
|
||||
dv.RowFilter = "auth_uplevel = '" + id + "'";
|
||||
foreach (DataRowView row in dv)
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = row["auth_name"].ToString();
|
||||
node.Value = row["ID"].ToString();
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
|
||||
TreeAuth.Nodes.Add(node);
|
||||
node.Expanded = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pNode.ChildNodes.Add(node);
|
||||
node.Expanded = true;
|
||||
|
||||
}
|
||||
BindTree(node.Value, node, new DataView(dv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void TreeAuth_SelectedNodeChanged1(object sender, EventArgs e)
|
||||
{
|
||||
GridView1.SelectedIndex = -1;
|
||||
DataView dv = new DataView(_logic.QueryNews(Convert.ToInt32(TreeAuth.SelectedValue)));
|
||||
GridView1.DataSource = dv;
|
||||
GridView1.DataBind();
|
||||
ClearDetail();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
switch (e.Row.RowType)
|
||||
{
|
||||
case DataControlRowType.DataRow:
|
||||
if (e.Row.Cells[2].Text.Trim().Length > 30) e.Row.Cells[2].Text = e.Row.Cells[2].Text.Substring(0,30)+"....";
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master" AutoEventWireup="true" CodeFile="RoleAuth.aspx.cs" Inherits="RoleAuth" %>
|
||||
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<table width="100%" class="Table_NoBorder">
|
||||
|
||||
<tr><td>
|
||||
<table width="100%" class="Table_NoBorder" border="1">
|
||||
<tr class="HeaderStyle">
|
||||
<td style="width: 120px"><asp:Label ID="lbrole" runat="server" Font-Bold="True" Text="角色列表" /> </td>
|
||||
<td style="width: 180px"> <asp:Label ID="lbAuth" runat="server" Font-Bold="True" Text="权限列表" /></td>
|
||||
<td style="width: 200px" nowrap>
|
||||
<asp:Label ID="lbAuthRole" runat="server" Font-Bold="True" Text="角色清单" /></td>
|
||||
<td valign ="top" style="width: 200px" nowrap>
|
||||
<asp:Label ID="lbRoleEm" runat="server" Font-Bold="True" Text="人员清单" /></td>
|
||||
<td style="width: 200px" nowrap><asp:Label ID="lbAuthEm" runat="server" Font-Bold="True" Text="人员清单" /></td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign ="top" >
|
||||
<asp:ListBox id="listRoles" runat="server" width="120px" Height="360px" OnSelectedIndexChanged="listRoles_SelectedIndexChanged" AutoPostBack="True">
|
||||
</asp:ListBox></td>
|
||||
<td valign ="top">
|
||||
|
||||
|
||||
<asp:TreeView ID="treeAuth" runat="server" ShowLines="True" ImageSet="Arrows" OnSelectedNodeChanged="treeAuth_SelectedNodeChanged" ShowCheckBoxes="All" >
|
||||
<SelectedNodeStyle BackColor="Azure" BorderColor="Transparent" />
|
||||
<Nodes>
|
||||
<asp:TreeNode Text="" Selected="True" Value="0" Expanded="True"></asp:TreeNode>
|
||||
</Nodes>
|
||||
</asp:TreeView>
|
||||
|
||||
</td>
|
||||
<td valign ="top">
|
||||
|
||||
<asp:gridview id="GvRole" runat="server" AllowPaging="True" AutoGenerateColumns="False"
|
||||
CssClass="DataGrid" emptydatatext="没有数据。"
|
||||
ShowFooter="True"
|
||||
Width="100%">
|
||||
<columns>
|
||||
|
||||
<asp:BoundField DataField="ROLE_NAME" SortExpression="ROLE_NAME" HeaderText="角色名称"></asp:BoundField>
|
||||
<asp:BoundField DataField="ROLE_DESC" SortExpression="ROLE_DESC" HeaderText="角色描述"></asp:BoundField>
|
||||
|
||||
</columns>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center" />
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center" />
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle" />
|
||||
</asp:gridview>
|
||||
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
<td valign ="top">
|
||||
|
||||
<asp:gridview id="GvEm" runat="server" AllowPaging="True" AutoGenerateColumns="False"
|
||||
CssClass="DataGrid" emptydatatext="没有数据。"
|
||||
ShowFooter="True"
|
||||
Width="100%">
|
||||
<columns>
|
||||
|
||||
<asp:BoundField DataField="EM_NAME" SortExpression="EM_NAME" HeaderText="人员名称"></asp:BoundField>
|
||||
<asp:BoundField DataField="Dep_name" SortExpression="Dep_name" HeaderText="所属部门"></asp:BoundField>
|
||||
|
||||
</columns>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center" />
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center" />
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle" />
|
||||
</asp:gridview>
|
||||
|
||||
|
||||
</td>
|
||||
<td valign ="top">
|
||||
<asp:gridview id="GvAuthEm" runat="server" AllowPaging="True" AutoGenerateColumns="False"
|
||||
CssClass="DataGrid" emptydatatext="没有数据。"
|
||||
ShowFooter="True"
|
||||
Width="100%">
|
||||
<columns>
|
||||
|
||||
<asp:BoundField DataField="EM_NAME" SortExpression="EM_NAME" HeaderText="人员名称"></asp:BoundField>
|
||||
<asp:BoundField DataField="Dep_name" SortExpression="Dep_name" HeaderText="所属部门"></asp:BoundField>
|
||||
|
||||
</columns>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center" />
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center" />
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle" />
|
||||
</asp:gridview></td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</td></tr>
|
||||
<tr><td class="ALine" >
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<td align="center" style="height: 27px" > <asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存数据" OnClick="btnSubmit_Click" />
|
||||
|
||||
|
||||
<asp:Label ID="lbmsg" runat="server"></asp:Label>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td style="width: 532px">
|
||||
|
||||
<br/></td></tr>
|
||||
</table>
|
||||
|
||||
</asp:Content>
|
||||
|
|
@ -0,0 +1,285 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using System.Transactions;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using DeiNiu.wms.Logical;
|
||||
using DeiNiu.Utils;
|
||||
|
||||
public partial class RoleAuth : PageBase
|
||||
{
|
||||
private LRoleAuthority _logic;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
_logic = new LRoleAuthority();
|
||||
Databound();
|
||||
bindAuth();
|
||||
bindRoles();
|
||||
|
||||
}
|
||||
SessionSeting();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
// bindAuth();
|
||||
// bindRoles();
|
||||
|
||||
bindGV();
|
||||
UpdateSession();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定权限
|
||||
/// </summary>
|
||||
void bindAuth()
|
||||
{
|
||||
treeAuth.Nodes.Clear();
|
||||
BindAuthTree("0", treeAuth.SelectedNode, _logic.QueryNonePublicAuthority().DefaultView);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///绑定角色
|
||||
/// </summary>
|
||||
private void bindRoles()
|
||||
{
|
||||
DataView dv = _logic.GetAllRoles().DefaultView;
|
||||
dv.RowFilter = "role_4Approve =0";
|
||||
listRoles.DataSource =dv;
|
||||
listRoles.DataTextField = "role_name";
|
||||
listRoles.DataValueField = "ID";
|
||||
listRoles.DataBind();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void BindAuthTree(string id, TreeNode pNode, DataView dv )
|
||||
{
|
||||
|
||||
dv.RowFilter = "auth_uplevel = '" + id + "'";
|
||||
foreach (DataRowView row in dv)
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
string authLink = row["auth_link"].ToString();
|
||||
string authForm = row["auth_class"].ToString();
|
||||
node.Value = row["ID"].ToString();
|
||||
node.Expanded = true;
|
||||
string authLevel = row["auth_uplevel"].ToString();
|
||||
// if (authForm == string.Empty && (authLink == string.Empty || authLink.Trim().Length < 6)) //not *.aspx
|
||||
if (authLevel.Equals("0"))
|
||||
{
|
||||
node.Text = "<strong>" + row["auth_name"] + "</strong>";
|
||||
node.SelectAction = TreeNodeSelectAction.None;
|
||||
// node.ShowCheckBox = false;
|
||||
} else
|
||||
|
||||
{
|
||||
node.Text = row["auth_name"].ToString() ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
|
||||
treeAuth.Nodes.Add(node);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
pNode.ChildNodes.Add(node);
|
||||
|
||||
}
|
||||
BindAuthTree(node.Value, node, new DataView(dv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LRoleAuthority)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
lbmsg.Text = " ";
|
||||
if (listRoles.SelectedValue == string.Empty) return;
|
||||
//角色,权限
|
||||
ArrayList al = new ArrayList();
|
||||
GetCheckedNode(treeAuth.Nodes, al);
|
||||
_logic.Initialize();
|
||||
// using (TransactionScope trans = new TransactionScope())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
_logic.GetRoleAuthority.Delete(Convert.ToInt32(listRoles.SelectedValue));
|
||||
// _logic.Initialize();
|
||||
foreach (string id in al)
|
||||
{
|
||||
_logic.GetRoleAuthority.ra_role = Convert.ToInt32(listRoles.SelectedValue);
|
||||
_logic.GetRoleAuthority.ra_authority = Convert.ToInt32(id);
|
||||
_logic.GetRoleAuthority.Add();
|
||||
}
|
||||
lbmsg.Text = "保存成功!";
|
||||
// trans.Complete();
|
||||
}
|
||||
catch (MyException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception("出现异常,保存失败。");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Databound();
|
||||
}
|
||||
|
||||
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
ClearDetail();
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GetCheckedNode(TreeNodeCollection tnc, ArrayList checkedvalues)
|
||||
{
|
||||
foreach (TreeNode node in tnc)
|
||||
{
|
||||
if (node.Checked)
|
||||
{
|
||||
checkedvalues.Add(node.Value);
|
||||
|
||||
}
|
||||
GetCheckedNode(node.ChildNodes, checkedvalues);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SetCheckedNode(TreeNodeCollection tnc, ArrayList setcheckedvalues)
|
||||
{
|
||||
foreach (TreeNode node in tnc)
|
||||
{
|
||||
node.Checked = setcheckedvalues.Contains(Convert.ToInt32(node.Value));
|
||||
|
||||
SetCheckedNode(node.ChildNodes, setcheckedvalues);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
|
||||
btnSubmit.Enabled = true;
|
||||
|
||||
}
|
||||
|
||||
private void ClearDetail()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void listRoles_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
lbmsg.Text = " ";
|
||||
/*
|
||||
if (treeAuth.SelectedNode != null) treeAuth.SelectedNode.Selected = false;
|
||||
lbAuthRole.Text = "权限角色清单" ;
|
||||
GvRole.DataSource = null;
|
||||
GvRole.DataBind();
|
||||
*/
|
||||
|
||||
//--重置权限树的选择
|
||||
ArrayList autList = new ArrayList();
|
||||
DataView dv = _logic.GetRoleAuthority.QueryActived().Tables[0].DefaultView;
|
||||
dv.RowFilter = "ra_role ='" + listRoles.SelectedValue + "'";
|
||||
foreach (DataRowView drv in dv)
|
||||
{
|
||||
autList.Add(drv["ra_authority"]);
|
||||
}
|
||||
SetCheckedNode(treeAuth.Nodes, autList);
|
||||
|
||||
bindGV();
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void treeAuth_SelectedNodeChanged(object sender, EventArgs e)
|
||||
{
|
||||
bindGV();
|
||||
|
||||
}
|
||||
|
||||
void bindGV()
|
||||
{
|
||||
//角色对应的人员清单
|
||||
if (listRoles.SelectedItem != null)
|
||||
{
|
||||
|
||||
lbRoleEm.Text = listRoles.SelectedItem.Text + " 角色人员清单";
|
||||
GvEm.DataSource = _logic.GetEmListByRole(Convert.ToInt32(listRoles.SelectedValue));
|
||||
}
|
||||
GvEm.DataBind();
|
||||
|
||||
|
||||
//权限对应的角色,人员清单
|
||||
if (treeAuth.SelectedNode != null)
|
||||
{
|
||||
lbAuthEm.Text = treeAuth.SelectedNode.Text + " 权限人员清单";
|
||||
GvAuthEm.DataSource = _logic.GetEmListByAuth(Convert.ToInt32(treeAuth.SelectedValue));
|
||||
lbAuthRole.Text = treeAuth.SelectedNode.Text + " 权限角色清单";
|
||||
GvRole.DataSource = _logic.GetRoleListByAuth(Convert.ToInt32(treeAuth.SelectedValue));
|
||||
|
||||
}
|
||||
GvAuthEm.DataBind();
|
||||
GvRole.DataBind();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master" AutoEventWireup="true" CodeFile="RoleEmp.aspx.cs" Inherits="RoleEmp" %>
|
||||
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<table class="Table_NoBorder" width="100%">
|
||||
|
||||
<tr><td>
|
||||
<table width="100%" class="Table_NoBorder" border="1">
|
||||
<tr class="HeaderStyle">
|
||||
<td style="width: 120px" ><asp:Label ID="lbrole" runat="server" Font-Bold="True" Text="角色列表" /> </td>
|
||||
<td style="width: 180px"> <asp:Label ID="lbemp" runat="server" Font-Bold="True" Text="人员列表" /></td>
|
||||
<td style="width: 200px" nowrap>
|
||||
<asp:Label ID="lbRoleEm" runat="server" Font-Bold="True" Text=" " />
|
||||
<asp:Label ID="Label1" runat="server" Text="角色人员清单" /></td>
|
||||
<td valign ="top" style="width: 200px" nowrap>
|
||||
<asp:Label ID="lbEmRole" runat="server" Font-Bold="True" Text="" />
|
||||
<asp:Label ID="Label2" runat="server" Text="人员角色清单" />
|
||||
</td>
|
||||
<td valign ="top" style="width: 200px" nowrap>
|
||||
<asp:Label ID="lbEmAuth" runat="server" Font-Bold="True" Text="人员权限清单" />
|
||||
<asp:Label ID="Label3" runat="server" Text="人员权限清单" />
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign ="top">
|
||||
|
||||
<asp:ListBox id="listRoles" runat="server" width="120px" Height="360px" OnSelectedIndexChanged="listRoles_SelectedIndexChanged" AutoPostBack="True">
|
||||
</asp:ListBox></td>
|
||||
<td valign ="top">
|
||||
|
||||
|
||||
<asp:TreeView id="TreeDeptEmp" runat="server" ShowLines="True" ImageSet="Arrows"
|
||||
ShowCheckBoxes="All" OnSelectedNodeChanged="TreeDeptEmp_SelectedNodeChanged" >
|
||||
|
||||
<nodes>
|
||||
<asp:TreeNode Text="WMS" Selected="True" Value="0" Expanded="True" SelectAction="None" ></asp:TreeNode>
|
||||
</nodes>
|
||||
<SelectedNodeStyle BackColor="Azure" BorderColor="Transparent" />
|
||||
</asp:TreeView>
|
||||
|
||||
</td>
|
||||
<td valign ="top">
|
||||
<asp:gridview id="GvEm" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="DataGrid" emptydatatext="没有数据。"
|
||||
ShowFooter="True"
|
||||
Width="100%">
|
||||
<columns>
|
||||
|
||||
<asp:BoundField DataField="EM_NAME" SortExpression="EM_NAME" HeaderText="人员名称"> <ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="Dep_name" SortExpression="Dep_name" HeaderText="所属部门">
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
|
||||
</columns>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center" />
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center" />
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle" />
|
||||
</asp:gridview>
|
||||
|
||||
|
||||
|
||||
|
||||
</td>
|
||||
<td valign ="top" ><asp:gridview id="GvRole" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="DataGrid" emptydatatext="没有数据。"
|
||||
ShowFooter="True"
|
||||
Width="100%" TabIndex="1">
|
||||
<columns>
|
||||
|
||||
<asp:BoundField DataField="ROLE_NAME" SortExpression="ROLE_NAME" HeaderText="角色名称"> <ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="ROLE_DESC" SortExpression="ROLE_DESC" HeaderText="角色描述">
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
|
||||
</columns>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center" />
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center" />
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle" />
|
||||
</asp:gridview></td>
|
||||
<td valign ="top">
|
||||
<asp:gridview id="GVauth" runat="server" AutoGenerateColumns="False"
|
||||
CssClass="DataGrid" emptydatatext="没有数据。"
|
||||
ShowFooter="True"
|
||||
Width="100%" TabIndex="1">
|
||||
<columns>
|
||||
|
||||
<asp:BoundField DataField="auth_name" SortExpression="auth_name" HeaderText="权限名称"> <ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="auth_desc" SortExpression="auth_desc" HeaderText="权限描述">
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
|
||||
</columns>
|
||||
<rowstyle cssclass="ItemStyle" horizontalalign="Center" />
|
||||
<headerstyle cssclass="HeaderStyle" horizontalalign="Center" />
|
||||
<alternatingrowstyle cssclass="AlternatingItemStyle" />
|
||||
</asp:gridview>
|
||||
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
</td></tr>
|
||||
<tr><td class="ALine" >
|
||||
</td></tr>
|
||||
|
||||
<tr>
|
||||
<td align="center" > <asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存数据" OnClick="btnSubmit_Click" />
|
||||
|
||||
<asp:Label ID="lbmsg" runat="server"></asp:Label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td style="width: 532px">
|
||||
|
||||
<br/></td></tr>
|
||||
</table>
|
||||
|
||||
</asp:Content>
|
||||
|
|
@ -0,0 +1,284 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Data;
|
||||
using System.Transactions;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using DeiNiu.wms.Logical;
|
||||
using DeiNiu.Utils;
|
||||
|
||||
public partial class RoleEmp : PageBase
|
||||
{
|
||||
private LRoleAuthority _logic;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
_logic = new LRoleAuthority();
|
||||
Databound();
|
||||
bindRoles();
|
||||
bindDeptEmp(); //分配角色时初始化部门人员树
|
||||
}
|
||||
SessionSeting();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
// bindAuth();
|
||||
// bindRoles();
|
||||
// if (!isRoleAuth) bindDeptEmp(); //分配角色时初始化部门人员树
|
||||
bindGV();
|
||||
UpdateSession();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 绑定部门及用户
|
||||
/// </summary>
|
||||
private void bindDeptEmp()
|
||||
{
|
||||
TreeDeptEmp.Nodes.Clear();
|
||||
BindTree("0", TreeDeptEmp.SelectedNode, new LEmployee().GetDepartments().DefaultView, new LEmployee().GetActivedEmpDept().DefaultView);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///绑定角色
|
||||
/// </summary>
|
||||
private void bindRoles()
|
||||
{
|
||||
|
||||
listRoles.DataSource = _logic.GetAllRoles();
|
||||
listRoles.DataTextField = "role_name";
|
||||
listRoles.DataValueField = "ID";
|
||||
listRoles.DataBind();
|
||||
}
|
||||
|
||||
public void BindTree(string id, TreeNode pNode, DataView deptdv,DataView empdv)
|
||||
{
|
||||
|
||||
deptdv.RowFilter = "dep_mastdept = '" + id + "'";
|
||||
foreach (DataRowView row in deptdv)
|
||||
{
|
||||
TreeNode node = new TreeNode();
|
||||
node.Text = "<em>" + row["dep_name"] + "</em>" +" "+ row["ID"];
|
||||
node.Value = row["ID"].ToString();
|
||||
node.SelectAction = TreeNodeSelectAction.None;
|
||||
node.ShowCheckBox = false;
|
||||
node.Expanded = true;
|
||||
empdv.RowFilter = "de_dept=" + node.Value;
|
||||
foreach (DataRowView emrow in empdv)
|
||||
{
|
||||
TreeNode tnEmp = new TreeNode("<Strong>" + emrow["em_name"] + "</Strong>" ,
|
||||
emrow["DE_EMPLOYEE"].ToString() + ";" + emrow["WAREHOUSE"].ToString());
|
||||
node.ChildNodes.Add(tnEmp);
|
||||
}
|
||||
if (pNode == null)
|
||||
//说明是根节点
|
||||
{
|
||||
|
||||
TreeDeptEmp.Nodes.Add(node);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
pNode.ChildNodes.Add(node);
|
||||
|
||||
}
|
||||
BindTree(node.Value, node, new DataView(deptdv.Table), new DataView(empdv.Table));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LRoleAuthority)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
lbmsg.Text = " ";
|
||||
if (listRoles.SelectedValue == string.Empty) return;
|
||||
ArrayList al = new ArrayList();
|
||||
|
||||
GetCheckedNode(TreeDeptEmp.Nodes, al);
|
||||
_logic.Initialize();
|
||||
|
||||
try
|
||||
{
|
||||
using (TransactionScope trans = new TransactionScope())
|
||||
{
|
||||
int roleId = Convert.ToInt32(listRoles.SelectedValue);
|
||||
_logic.GetRoleEmp.Delete(roleId);
|
||||
|
||||
foreach (string id in al)
|
||||
{
|
||||
string[] ls= id.Split(';');
|
||||
_logic.GetRoleEmp.re_role = roleId;
|
||||
_logic.GetRoleEmp.re_employee = Convert.ToInt32(ls[0]) ;
|
||||
if (ls.Length > 1)
|
||||
{
|
||||
_logic.GetRoleEmp.warehouse = Convert.ToInt32(ls[1]);
|
||||
}
|
||||
_logic.GetRoleEmp.Add();
|
||||
}
|
||||
|
||||
trans.Complete();
|
||||
}
|
||||
lbmsg.Text = "保存成功";
|
||||
}
|
||||
catch (MyException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception er)
|
||||
{
|
||||
throw new Exception("出现异常,保存失败。");
|
||||
}
|
||||
|
||||
|
||||
Databound();
|
||||
}
|
||||
|
||||
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GetCheckedNode(TreeNodeCollection tnc, ArrayList checkedvalues )
|
||||
{
|
||||
foreach(TreeNode node in tnc)
|
||||
{
|
||||
if(node.Checked)
|
||||
{
|
||||
checkedvalues.Add(node.Value);
|
||||
|
||||
}
|
||||
GetCheckedNode(node.ChildNodes, checkedvalues);
|
||||
}
|
||||
}
|
||||
|
||||
void SetCheckedNode(TreeNodeCollection tnc, ArrayList setcheckedvalues)
|
||||
{
|
||||
foreach (TreeNode node in tnc)
|
||||
{
|
||||
string[] ls = node.Value.Split(';');
|
||||
node.Checked = setcheckedvalues.Contains(Convert.ToInt32(ls[0]));
|
||||
|
||||
SetCheckedNode(node.ChildNodes, setcheckedvalues);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
|
||||
btnSubmit.Enabled = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void listRoles_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
//--重置人员树的选择
|
||||
/*
|
||||
if (TreeDeptEmp.SelectedNode != null) TreeDeptEmp.SelectedNode.Selected = false;
|
||||
|
||||
lbAuthRole.Text = "人员角色清单";
|
||||
GvRole.DataSource = null;
|
||||
GvRole.DataBind();
|
||||
* */
|
||||
//--选择人员树复选框
|
||||
|
||||
ArrayList empList = new ArrayList();
|
||||
DataTable dt =_logic.GetEmListByRole(Convert.ToInt32(listRoles.SelectedValue)) ;
|
||||
foreach (DataRow dr in dt.Rows)
|
||||
{
|
||||
empList.Add(dr["ID"]);
|
||||
}
|
||||
SetCheckedNode(TreeDeptEmp.Nodes, empList);
|
||||
|
||||
bindGV();
|
||||
|
||||
}
|
||||
protected void TreeDeptEmp_SelectedNodeChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
bindGV();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void bindGV( )
|
||||
{
|
||||
//人员角色,权限清单
|
||||
string nodevalue = TreeDeptEmp.SelectedValue;
|
||||
nodevalue = nodevalue.Split(';')[0];
|
||||
if (nodevalue.Length >0 && nodevalue != "0") //selected node is an employee
|
||||
{
|
||||
|
||||
lbEmRole.Text = TreeDeptEmp.SelectedNode.Text;// +" 人员角色清单";
|
||||
GvRole.DataSource = _logic.GetRoleByEm(Convert.ToInt32(nodevalue));
|
||||
|
||||
lbEmAuth.Text = TreeDeptEmp.SelectedNode.Text;// +" 人员权限清单";
|
||||
GVauth.DataSource = _logic.GetAuthByEm(Convert.ToInt32(nodevalue));
|
||||
|
||||
}
|
||||
GvRole.DataBind();
|
||||
GVauth.DataBind();
|
||||
|
||||
//角色对应的人员清单
|
||||
if (listRoles.SelectedItem != null)
|
||||
{
|
||||
|
||||
lbRoleEm.Text = listRoles.SelectedItem.Text;// +" 角色人员清单";
|
||||
GvEm.DataSource = _logic.GetEmListByRole(Convert.ToInt32(listRoles.SelectedValue));
|
||||
}
|
||||
GvEm.DataBind();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
<%@ Page Language="C#" MasterPageFile="../masterPage.master" AutoEventWireup="true" CodeFile="RoleMain.aspx.cs" Inherits="RoleMain" %>
|
||||
<%@ MasterType VirtualPath="~/masterPage.master" %>
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
|
||||
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
|
||||
Namespace="System.Web.UI" TagPrefix="asp" %>
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<table width="100%" class="Table_NoBorder">
|
||||
|
||||
<tr><td>
|
||||
|
||||
<!------ THE DATA GRID AREA ------>
|
||||
|
||||
<asp:gridview id="GridView1" CssClass="DataGrid" PagerStyle-HorizontalAlign="Right"
|
||||
runat="server"
|
||||
emptydatatext="没有数据。"
|
||||
|
||||
OnRowEditing="GridView1_RowEditing"
|
||||
DataKeyNames="ID"
|
||||
OnRowDeleting="GridView1_RowDeleting"
|
||||
AllowPaging="True"
|
||||
OnPageIndexChanging="GridView1_PageIndexChanging"
|
||||
OnRowDataBound="GridView1_RowDataBound"
|
||||
OnSorting="GridView1_Sorting" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="100%" ShowFooter="True" AutoGenerateColumns="False">
|
||||
|
||||
<Columns>
|
||||
<asp:BoundField ReadOnly="True" DataField="ID" SortExpression="ID" HeaderText="角色id" visible="false"></asp:BoundField>
|
||||
<asp:BoundField DataField="ROLE_NAME" SortExpression="ROLE_NAME" HeaderText="角色名称">
|
||||
<ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
</asp:BoundField>
|
||||
|
||||
<asp:BoundField DataField="ROLE_DESC" SortExpression="ROLE_DESC" HeaderText="角色描述"><ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/></asp:BoundField>
|
||||
<asp:BoundField DataField="ROLE_4Approve" SortExpression="ROLE_4Approve" HeaderText="审核角色"><ItemStyle Wrap="False" HorizontalAlign="Center"/>
|
||||
<HeaderStyle Wrap="False" HorizontalAlign="Center"/></asp:BoundField>
|
||||
<asp:BoundField DataField="dr" Visible="False" SortExpression="dr" HeaderText="可用"></asp:BoundField>
|
||||
<asp:CommandField SelectText="<img src=../Images/edit.gif border=0 title=修改 >" ShowDeleteButton="True" ShowHeader="True" DeleteText="<img src=../Images/Delete.gif border=0 title=删除 onclick='return delete_click()'>" ShowSelectButton="True" HeaderText="编 辑">
|
||||
<HeaderStyle Width="15%" HorizontalAlign="Center"></HeaderStyle>
|
||||
|
||||
<ItemStyle Width="15%" HorizontalAlign="Center"></ItemStyle>
|
||||
</asp:CommandField>
|
||||
</Columns>
|
||||
<RowStyle CssClass="ItemStyle" HorizontalAlign="Center"></RowStyle>
|
||||
<EmptyDataTemplate>
|
||||
|
||||
|
||||
</EmptyDataTemplate>
|
||||
|
||||
<SelectedRowStyle CssClass="SelectedItemStyle"></SelectedRowStyle>
|
||||
<PagerStyle HorizontalAlign="Right" />
|
||||
<HeaderStyle CssClass="HeaderStyle" HorizontalAlign="Center"></HeaderStyle>
|
||||
<AlternatingRowStyle CssClass="AlternatingItemStyle"></AlternatingRowStyle>
|
||||
|
||||
</asp:gridview>
|
||||
|
||||
<asp:Button ID="btn_addNew" runat="server" Text="新增记录" CssClass="Button" OnClick="btnAddnew_Click" />
|
||||
</td></tr>
|
||||
<tr><td class="ALine" ></td>
|
||||
</tr>
|
||||
<tr><td>
|
||||
|
||||
|
||||
<!------ THE ADD /DELETE AREA ------>
|
||||
|
||||
<asp:Panel ID ="DataDetail" runat="server" Width="100%" Visible="false">
|
||||
<table class="Table_NoBorder" width="100%">
|
||||
<tr><td align="right">
|
||||
<asp:Label ID="Label2" runat="server" CssClass="Label" Text="角色名称"></asp:Label></td><td >
|
||||
|
||||
<asp:TextBox ID="txtJobName" runat="server" CssClass="TextBox" MaxLength="25" ></asp:TextBox>
|
||||
|
||||
|
||||
<asp:RequiredFieldValidator id="RequiredFieldValidator4" runat="server" ControlToValidate="txtJobName"
|
||||
ErrorMessage="请输入角色名称。" SetFocusOnError="True" ValidationGroup="1">*</asp:RequiredFieldValidator>
|
||||
|
||||
|
||||
</td>
|
||||
|
||||
<td align="right">
|
||||
<asp:Label ID="Label3" runat="server" CssClass="Label" Text="角色描述"></asp:Label></td><td >
|
||||
<asp:TextBox ID="txtJobDesc" runat="server" CssClass="TextBox_Long" MaxLength="100" Width="255px" ></asp:TextBox>
|
||||
|
||||
|
||||
<asp:RequiredFieldValidator id="RequiredFieldValidator5" runat="server" ControlToValidate="txtJobDesc"
|
||||
ErrorMessage="请输入角色描述。" SetFocusOnError="True" ValidationGroup="1">*</asp:RequiredFieldValidator>
|
||||
</td></tr>
|
||||
<tr><td align="right">
|
||||
<asp:Label ID="Label1" runat="server" CssClass="Label" Text="审核角色" Visible="true"></asp:Label></td><td colspan ="3" >
|
||||
<asp:CheckBox id="chkApprove" runat="server">
|
||||
</asp:CheckBox></td></tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="4" >
|
||||
<asp:ValidationSummary id="ValidationSummary1" runat="server" ValidationGroup="1" HeaderText="错误提示"></asp:ValidationSummary>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr>
|
||||
<td colspan ="4" class="ALine" >
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!------ BUTTONS ------>
|
||||
<table class="Table_NoBorder" width="80%">
|
||||
<tr>
|
||||
<td align="center" > <asp:Button ID="btnSubmit" runat="server" CssClass="Button" Text="保存数据" OnClick="btnSubmit_Click" ValidationGroup="1" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Panel>
|
||||
|
||||
|
||||
|
||||
|
||||
</td></tr>
|
||||
<tr><td style="width: 532px">
|
||||
|
||||
<br/></td></tr>
|
||||
</table>
|
||||
|
||||
</asp:Content>
|
||||
|
|
@ -0,0 +1,236 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using DeiNiu.wms.Logical;
|
||||
using DeiNiu.Utils;
|
||||
|
||||
public partial class RoleMain : PageBase
|
||||
{
|
||||
private LRole _logic;
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
_logic = new LRole();
|
||||
Databound();
|
||||
}
|
||||
SessionSeting();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// bound the query list.
|
||||
/// </summary>
|
||||
private void Databound()
|
||||
{
|
||||
GridView1.DataSource = _logic.GetAllActiveData().Tables[0];
|
||||
GridView1.DataBind();
|
||||
UpdateSession();
|
||||
|
||||
ClearDetail();
|
||||
}
|
||||
|
||||
private void SessionSeting()
|
||||
{
|
||||
if (IsPostBack)
|
||||
{
|
||||
_logic = (LRole)Session[appScope.PagelevelObj];
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSession()
|
||||
{
|
||||
Session[appScope.PagelevelObj] = _logic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set data from shift object to page
|
||||
/// </summary>
|
||||
private void DetailDataBind()
|
||||
{
|
||||
DataDetail.Visible = true;
|
||||
chkApprove.Checked=_logic.GetRole.role_4Approve ;
|
||||
txtJobName.Text = _logic.GetRole.role_name;
|
||||
txtJobDesc.Text = _logic.GetRole.role_desc;
|
||||
// chkStatus.Checked = _logic.GetRole.dr;
|
||||
}
|
||||
|
||||
/************************************** protected methods (event listeners) ********************************/
|
||||
|
||||
protected void btnAddnew_Click(object sender, EventArgs e)
|
||||
{
|
||||
Databound();
|
||||
chgOperTxt(true);
|
||||
_logic.Initialize();
|
||||
DetailDataBind();
|
||||
txtJobName.Focus();
|
||||
GridView1.SelectedIndex = -1;
|
||||
|
||||
}
|
||||
|
||||
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
txtJobName.Focus();
|
||||
}
|
||||
|
||||
protected void btnSubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetDataBack();
|
||||
//shifts id eq 0 means this is new one,to add; else an old one, to update
|
||||
if (txtJobDesc.Text.Trim().Length + txtJobName.Text.Trim().Length == 0)
|
||||
{
|
||||
txtJobName.Focus();
|
||||
Databound();
|
||||
DataDetail.Visible = true;
|
||||
ScriptManager.RegisterStartupScript(btnSubmit, typeof(UpdatePanel), "alert",
|
||||
"alert('请输入角色名称。');", true);
|
||||
return;
|
||||
|
||||
}
|
||||
int oper = 0;
|
||||
oper = _logic.GetRole.ID > 0 ? _logic.GetRole.Update() : _logic.GetRole.Add();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
|
||||
}
|
||||
|
||||
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
||||
{
|
||||
|
||||
if (GridView1 != null)
|
||||
{
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
}
|
||||
/*
|
||||
_logic.GetRole.dr = false;
|
||||
_logic.GetRole.Update();
|
||||
|
||||
*/
|
||||
_logic.GetRole.Delete();
|
||||
ClearDetail();
|
||||
Databound();
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
||||
{
|
||||
GridView1.PageIndex = e.NewPageIndex;
|
||||
Databound();
|
||||
|
||||
//GridView1.DataSource = shiftLgc.getAllShifts().Tables[0];
|
||||
// GridView1.DataBind();
|
||||
}
|
||||
|
||||
protected void GridView1_DataBinding(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
CheckBox chk;
|
||||
if (e.Row.RowType == DataControlRowType.DataRow)
|
||||
{
|
||||
chk = new CheckBox();
|
||||
chk.Text = "";
|
||||
chk.Enabled = false;
|
||||
chk.Checked = e.Row.Cells[3].Text.Trim().Equals("True");
|
||||
e.Row.Cells[3].Controls.Add(chk);
|
||||
}
|
||||
}
|
||||
|
||||
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
|
||||
{
|
||||
|
||||
string sortExpression = e.SortExpression;
|
||||
if (GridView1.SortDirection == SortDirection.Ascending) //设置排序方向
|
||||
{
|
||||
|
||||
SortGridView(sortExpression, " DESC");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
SortGridView(sortExpression, " ASC");
|
||||
}
|
||||
}
|
||||
private void SortGridView(string sortExpression, string direction)
|
||||
{
|
||||
DataView dv = new DataView(_logic.GetAllActiveData().Tables[0]);
|
||||
dv.Sort = sortExpression + direction;
|
||||
GridView1.DataSource = dv; //将DataView绑定到GridView上
|
||||
GridView1.DataBind();
|
||||
|
||||
}
|
||||
//reset the page
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Initialize();
|
||||
Page_Load(this, e);
|
||||
ClearDetail();
|
||||
}
|
||||
|
||||
/***************************************** internal methods ********************************************/
|
||||
|
||||
/// <summary>
|
||||
/// set data from page to shift object
|
||||
/// </summary>
|
||||
private void SetDataBack()
|
||||
{
|
||||
// _logic.GetRole.operater = Session["CurrentUserID"].ToString(); todo: write a public method to handle operater,createtime,lastmodfied ... log info.
|
||||
// if (_logic.GetRole.ID > 0)
|
||||
// _logic.GetRole.lastmodified = DateTime.Now.ToString();
|
||||
// _logic.GetRole.dr = true;
|
||||
_logic.GetRole.role_name = txtJobName.Text;
|
||||
_logic.GetRole.role_desc = txtJobDesc.Text;
|
||||
_logic.GetRole.role_4Approve = chkApprove.Checked;
|
||||
}
|
||||
|
||||
private void chgOperTxt(bool addNew)
|
||||
{
|
||||
btnSubmit.Enabled = true;
|
||||
DataDetail.Visible = true;
|
||||
}
|
||||
|
||||
private void ClearDetail()
|
||||
{
|
||||
chkApprove.Checked = false;
|
||||
txtJobName.Text = "";
|
||||
txtJobDesc.Text = "";
|
||||
DataDetail.Visible = false;
|
||||
}
|
||||
|
||||
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
chgOperTxt(false);
|
||||
if (GridView1.DataKeys != null)
|
||||
{
|
||||
string id = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
|
||||
_logic.Initialize(int.Parse(id));
|
||||
}
|
||||
Databound();
|
||||
DetailDataBind();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<%@ Page Language="C#" MasterPageFile="masterPage.master" AutoEventWireup="true" CodeFile="FileNotFound.aspx.cs" Inherits="FileNotFound" %>
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
|
||||
<table width="80%" class="Table_Border" align="center">
|
||||
<tr>
|
||||
<td >
|
||||
<asp:Label ID="lbTitle" runat="server" ForeColor="Red" Text="³ö´íÁË"></asp:Label>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<br />
|
||||
<asp:Label ID="lbErrtrace" runat="server" ForeColor="Red" Height="130px" ></asp:Label>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</asp:Content>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using System.Text;
|
||||
public partial class FileNotFound : Page
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
lbErrtrace.Text = "没找到您要访问的文件。";
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
<%@ Application Language="C#" %>
|
||||
<%@ Import Namespace="view.App_Code"%>
|
||||
<%@ Import Namespace="DeiNiu.Utils"%>
|
||||
|
||||
<script runat="server">
|
||||
|
||||
void Application_Start(object sender, EventArgs e)
|
||||
{
|
||||
// Code that runs on application startup
|
||||
Application["usercnt"] = 0;
|
||||
Application["userlst"] = new ArrayList();
|
||||
|
||||
|
||||
SessionEndModule.SessionObjectKey = "CurrentUserId";
|
||||
SessionEndModule.SessionEnd += SessionTimoutModule_SessionEnd;
|
||||
}
|
||||
|
||||
void Application_End(object sender, EventArgs e)
|
||||
{
|
||||
// Code that runs on application shutdown
|
||||
Application.Clear();
|
||||
|
||||
}
|
||||
|
||||
void Application_Error(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
|
||||
Exception objErr = Server.GetLastError().GetBaseException();
|
||||
string error = "发生异常页: " + Request.Url.ToString() + "<br/>";
|
||||
if (Request.Url.ToString().IndexOf("ShowError.aspx") > 0) //避免循环调用
|
||||
{
|
||||
Server.ClearError();
|
||||
return;
|
||||
}
|
||||
error += "异常信息: " + objErr.Message + "<br/>";
|
||||
error += objErr.StackTrace + "<br/>";
|
||||
error += Request.Url.ToString() + "<br/>";
|
||||
Server.ClearError();
|
||||
Application["error"] = error;
|
||||
Response.Redirect("~/ShowError.aspx");
|
||||
|
||||
|
||||
/*
|
||||
Exception ev = Server.GetLastError();
|
||||
Server.ClearError();
|
||||
StringBuilder strResponse = new StringBuilder();
|
||||
myLog.RequestLog logobj = new myLog.RequestLog();
|
||||
logobj.RecordExceptionLog(ev);
|
||||
|
||||
strResponse.Append(ev);
|
||||
|
||||
if (ev is MyException) strResponse.Append(((MyException)ev).ExtrMsg);
|
||||
if (Session["currentSql"] != null)
|
||||
strResponse.Append("<br/>referenced sql is:<br/>" + HttpContext.Current.Session["currentSql"]);
|
||||
Session["ERROINFO"] = strResponse;
|
||||
Response.Redirect("~/ShowError.aspx");
|
||||
|
||||
if (ev.InnerException != null)
|
||||
{
|
||||
|
||||
strResponse.Append(ev.InnerException.ToString().Trim());
|
||||
|
||||
if (ev is MyException) strResponse.Append(((MyException) ev).ExtrMsg);
|
||||
if (Session["currentSql"] != null)
|
||||
strResponse.Append("<br/>referenced sql is:<br/>" + HttpContext.Current.Session["currentSql"]);
|
||||
Session["ERROINFO"] = strResponse;
|
||||
Response.Redirect("~/ShowError.aspx");
|
||||
|
||||
|
||||
}
|
||||
else if (ev is HttpException)
|
||||
{
|
||||
/// return;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Response.Redirect("~/fileNotFound.aspx");
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
void Session_Start(object sender, EventArgs e)
|
||||
{
|
||||
// Code that runs when a new session is started
|
||||
Session["CurrentUserId"] = "0";
|
||||
}
|
||||
|
||||
void Session_End(object sender, EventArgs e)
|
||||
{
|
||||
// Code that runs when a session ends.
|
||||
// Note: The Session_End event is raised only when the sessionstate mode
|
||||
// is set to InProc in the Web.config file. If session mode is set to StateServer
|
||||
// or SQLServer, the event is not raised.
|
||||
int cuid = Session["CurrentUserId"] == null ? 0 :Convert.ToInt32( Session["CurrentUserId"].ToString());
|
||||
//if (Session["CurrentUserId"] != null && (string)Session["CurrentUserId"] != "0")
|
||||
if(cuid >0)
|
||||
{
|
||||
((ArrayList)Application["userlst"]).Remove(Session["CurrentUserAccount"].ToString());
|
||||
|
||||
DeiNiu.RequestLog logobj = new DeiNiu.RequestLog();
|
||||
logobj.LogoutLog(Convert.ToInt32( Session["CurrentUserId"].ToString()));
|
||||
if (HttpContext.Current != null)
|
||||
{
|
||||
HttpContext.Current.Response.Redirect("~/index.aspx");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private static void SessionTimoutModule_SessionEnd(object sender,SessionEndedEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
// This will be the value in the session for the key specified in Application_Start
|
||||
object sessionObject = e.SessionObject;
|
||||
string val = (sessionObject == null) ? "[null]" : sessionObject.ToString();
|
||||
if (val ==null || val == "0") return;
|
||||
|
||||
DeiNiu.RequestLog logobj = new DeiNiu.RequestLog();
|
||||
logobj.LogoutLog(val);
|
||||
|
||||
}
|
||||
</script>
|
|
@ -0,0 +1,5 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 24
|
||||
application/octet-stream
|
||||
END
|
|
@ -0,0 +1,5 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 24
|
||||
application/octet-stream
|
||||
END
|
|
@ -0,0 +1,5 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 24
|
||||
application/octet-stream
|
||||
END
|
|
@ -0,0 +1,5 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 24
|
||||
application/octet-stream
|
||||
END
|
|
@ -0,0 +1,5 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 24
|
||||
application/octet-stream
|
||||
END
|
|
@ -0,0 +1,5 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 24
|
||||
application/octet-stream
|
||||
END
|
|
@ -0,0 +1,5 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 24
|
||||
application/octet-stream
|
||||
END
|
|
@ -0,0 +1,5 @@
|
|||
K 13
|
||||
svn:mime-type
|
||||
V 24
|
||||
application/octet-stream
|
||||
END
|