using System; using System.Data; using System.Text; using Swift.DAL.BL.System.UserManagement; using Swift.DAL.SwiftDAL; using Swift.web.Library; namespace Swift.web.SwiftSystem.UserManagement.AdminUserSetup { public partial class UserFunction : System.Web.UI.Page { private const string ViewFunctionId = "10101300"; private readonly SwiftLibrary _sl = new SwiftLibrary(); protected void Page_PreInit(object sender, EventArgs e) { //MasterPageFile = GetMode().ToString() != "1" ? "~/Swift.Master" : "~/ProjectMaster.Master"; } protected void Page_Load(object sender, EventArgs e) { Authenticate(); if (!IsPostBack) { //LoadTab(); LoadGrid(); } } //private void LoadTab() //{ // pnlBreadCrumb.Visible = GetMode() != 1; //} protected string GetUserName() { return GetStatic.ReadQueryString("userName", ""); } private void Authenticate() { _sl.CheckAuthentication(ViewFunctionId); btnSave.Visible = _sl.HasRight(ViewFunctionId); } public void LoadGrid() { string userId = GetStatic.ReadQueryString("userId", ""); var roleDao = new ApplicationRoleDao(); DataTable dt = roleDao.GetUserFunctionList(userId, GetStatic.GetUser()); if (dt.Rows.Count == 0) { rpt_grid.InnerHtml = "
No function available
"; return; } var str = new StringBuilder( ""); str.Append(""); foreach (DataColumn dc in dt.Columns) { str.Append(""); } str.Append(""); foreach (DataRow dr in dt.Rows) { str.Append(""); foreach (DataColumn dc in dt.Columns) { str.Append(""); } str.Append(""); } str.Append("
" + dc.ColumnName + "
" + dr[dc.ColumnName] + "
"); rpt_grid.InnerHtml = str.ToString(); } private void ManageMessage(DbResult dbResult) { GetStatic.SetMessage(dbResult); if (dbResult.ErrorCode == "0") { Response.Redirect("List.aspx"); } else { GetStatic.PrintMessage(Page); } } protected void btnSave_Click(object sender, EventArgs e) { string userId = GetStatic.ReadQueryString("userId", ""); string function = GetStatic.ReadFormData("functionId", "NULL"); var roleDao = new ApplicationRoleDao(); DbResult dbResult = roleDao.SaveUserFunction(function, userId, GetStatic.GetUser()); ManageMessage(dbResult); } protected void btnBack_Click(object sender, EventArgs e) { Response.Redirect("List.aspx"); } } }