private void DisplayAccounts() { AccountListQueryParams param = new AccountListQueryParams() { ListMode = c.qsEmpRange, DeptId = c.qsDeptId, Kw = c.qsKw }; param.PagedParams = new PagedListQueryParams() { BeginNum = 0, EndNum = 0, SortField = c.qsSortField, IsSortDesc = c.qsIsSortDesc }; param.AuthParams = new AuthenticationQueryParams() { CanReadSubItemOfOthers = empAuth.CanReadSubItemOfOthers(), CanReadSubItemOfCrew = empAuth.CanReadSubItemOfCrew(), CanReadSubItemOfSelf = empAuth.CanReadSubItemOfSelf(), MyAccount = c.GetEmpAccount(), MyDeptId = c.GetDeptId() }; // get total of items empAuth.GetAccountList(param); // update pager and get begin end of item numbers int itemTotalCount = param.PagedParams.RowCount; ucDataPager.Initialize(itemTotalCount, c.qsPageCode); if (IsPostBack) { ucDataPager.RefreshPagerAfterPostBack(); } param.PagedParams = new PagedListQueryParams() { BeginNum = ucDataPager.BeginItemNumberOfPage, EndNum = ucDataPager.EndItemNumberOfPage, SortField = c.qsSortField, IsSortDesc = c.qsIsSortDesc }; List <EmployeeForBackend> accounts = empAuth.GetAccountList(param); if (accounts != null) { rptAccounts.DataSource = accounts; rptAccounts.DataBind(); } if (c.qsPageCode > 1 || c.qsSortField != "") { ClientScript.RegisterStartupScript(this.GetType(), "isSearchPanelCollapsingAtBeginning", "isSearchPanelCollapsingAtBeginning = true;", true); } }
private void DisplayAccountData() { bool isOwner = false; int curRoleId = 0; if (c.qsAct == ConfigFormAction.edit) { EmployeeForBackend account = empAuth.GetEmployeeData(c.qsEmpId); if (account != null) { string empAccount = account.EmpAccount; //account txtEmpAccount.Text = account.EmpAccount; txtEmpAccount.Enabled = false; //name txtEmpName.Text = account.EmpName; //password rfvPsw.Enabled = false; hidEmpPasswordOri.Text = account.EmpPassword; hidPasswordHashed.Text = account.PasswordHashed.ToString(); hidDefaultRandomPassword.Text = account.DefaultRandomPassword; //email txtEmail.Text = account.Email; //remarks txtRemarks.Text = account.Remarks; // is access denied chkIsAccessDenied.Checked = account.IsAccessDenied; ltrIsAccessDenied.Text = chkIsAccessDenied.Checked ? Resources.Lang.Account_IsAccessDenied_Checked : Resources.Lang.Account_IsAccessDenied_Unchecked; //valid date txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", account.StartDate.Value); txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", account.EndDate.Value); ltrDateRange.Text = txtStartDate.Text + " ~ " + txtEndDate.Text; if (empAccount == "admin") { DateRangeArea.Visible = false; } //department ddlDept.SelectedValue = account.DeptId.ToString(); if (ddlDept.SelectedItem != null) { ltrDept.Text = ddlDept.SelectedItem.Text; } //role curRoleId = account.RoleId; ddlRoles.SelectedValue = curRoleId.ToString(); ltrRoles.Text = account.RoleDisplayText; //owner txtOwnerAccount.Text = account.OwnerAccount; ltrOwnerAccount.Text = txtOwnerAccount.Text; isOwner = empAuth.CanEditThisPage(false, account.OwnerAccount, account.OwnerDeptId); //modification info ltrPostAccount.Text = account.PostAccount; ltrPostDate.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", account.PostDate); if (account.MdfDate.HasValue) { ltrMdfAccount.Text = account.MdfAccount; ltrMdfDate.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", account.MdfDate.Value); } btnSave.Visible = true; } } else { //add txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Today); DateTime endDate = DateTime.Today.AddYears(10); txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", endDate); txtOwnerAccount.Text = c.GetEmpAccount(); ltrOwnerAccount.Text = txtOwnerAccount.Text; isOwner = true; btnSave.Visible = true; } // owner privilege if (isOwner) { chkIsAccessDenied.Visible = true; ltrIsAccessDenied.Visible = false; DateRangeEditCtrl.Visible = true; ltrDateRange.Visible = false; ddlDept.Visible = true; ltrDept.Visible = false; ddlRoles.Visible = true; ltrRoles.Visible = false; } // role-admin privilege if (c.IsInRole("admin")) { //owner txtOwnerAccount.Visible = true; ltrOwnerAccount.Visible = false; } else { // only role-admin can assigns role-admin to another (但是,保留已經是role-admin的選項) if (curRoleId != 1) { ListItem liAdmin = ddlRoles.Items.FindByValue("1"); if (liAdmin != null) { ddlRoles.Items.Remove(liAdmin); } } } }