protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // Authenticate
            if (c.qsAct == ConfigFormAction.edit && !(empAuth.CanEditThisPage() || c.IsMyAccount()) ||
                c.qsAct == ConfigFormAction.add && !empAuth.CanAddSubItemInThisPage())
            {
                string jsClose = "closeThisForm();";
                ClientScript.RegisterStartupScript(this.GetType(), "invalid", jsClose, true);
                return;
            }

            LoadUIData();
            DisplayAccountData();
            txtEmpAccount.Focus();
        }
        else
        {
            if (txtPsw.Text.Trim() != "")
            {
                rfvPswConfirm.Enabled = true;
            }
        }

        LoadTitle();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!artPicMgr.Initialize(c.qsPicId, c.qsArtId))
        {
            string errMsg = ResUtility.GetErrMsgOfAttFileErrState(artPicMgr.GetErrState());
            Master.ShowErrorMsg(errMsg);
            return;
        }

        if (!IsPostBack)
        {
            // Authenticate
            if (!empAuth.CanEditThisPage())
            {
                string jsClose = "closeThisForm();";
                ClientScript.RegisterStartupScript(this.GetType(), "invalid", jsClose, true);
                return;
            }

            LoadUIData();
            DisplayArticlePictureData();
            txtSortNo.Focus();
        }

        LoadTitle();
    }
Esempio n. 3
0
    protected void rptRoles_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        EmployeeRoleForBackend role = (EmployeeRoleForBackend)e.Item.DataItem;

        int    roleId          = role.RoleId;
        string roleName        = role.RoleName;
        string roleDisplayName = role.RoleDisplayName;
        int    empTotal        = role.EmpTotal;

        HtmlGenericControl ctlRoleName = (HtmlGenericControl)e.Item.FindControl("ctlRoleName");

        ctlRoleName.InnerHtml           = roleName;
        ctlRoleName.Attributes["class"] = "RoleDisplay-" + roleName;

        HtmlGenericControl ctlRoleDisplayName = (HtmlGenericControl)e.Item.FindControl("ctlRoleDisplayName");

        ctlRoleDisplayName.InnerHtml           = roleDisplayName;
        ctlRoleDisplayName.Attributes["class"] = "RoleDisplay-" + roleName;

        HtmlAnchor btnEdit = (HtmlAnchor)e.Item.FindControl("btnEdit");

        btnEdit.Attributes["onclick"] = string.Format("popWin('Role-Config.aspx?act={0}&roleid={1}', 700, 600); return false;", ConfigFormAction.edit, roleId);
        btnEdit.Title = Resources.Lang.Main_btnEdit_Hint;

        Literal ltrEdit = (Literal)e.Item.FindControl("ltrEdit");

        ltrEdit.Text = Resources.Lang.Main_btnEdit;

        HtmlAnchor btnGrant = (HtmlAnchor)e.Item.FindControl("btnGrant");

        btnGrant.Attributes["onclick"] = string.Format("popWin('Role-Privilege.aspx?roleid={0}', 700, 600); return false;", roleId);
        btnGrant.Title = Resources.Lang.Main_btnGrant_Hint;

        Literal ltrGrant = (Literal)e.Item.FindControl("ltrGrant");

        ltrGrant.Text = Resources.Lang.Main_btnGrant;

        LinkButton btnDelete = (LinkButton)e.Item.FindControl("btnDelete");

        btnDelete.CommandArgument = string.Join(",", roleId.ToString(), roleName);
        btnDelete.Text            = "<i class='fa fa-trash-o'></i> " + Resources.Lang.Main_btnDelete;
        btnDelete.ToolTip         = Resources.Lang.Main_btnDelete_Hint;
        btnDelete.OnClientClick   = string.Format("return confirm('" + Resources.Lang.Role_ConfirmDelete_Format + "');",
                                                  roleName, roleDisplayName);

        string ownerAccount = role.PostAccount;
        int    ownerDeptId  = role.PostDeptId.Value;

        btnEdit.Visible  = empAuth.CanEditThisPage(false, ownerAccount, ownerDeptId);
        btnGrant.Visible = btnEdit.Visible && (roleName != "admin");

        if (!empAuth.CanDelThisPage(ownerAccount, ownerDeptId) ||
            roleName == "admin" ||
            empTotal > 0)
        {
            btnDelete.Visible = false;
        }
    }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // Authenticate
            if (!empAuth.CanEditThisPage())
            {
                string jsClose = "closeThisForm();";
                ClientScript.RegisterStartupScript(this.GetType(), "invalid", jsClose, true);
                return;
            }

            LoadUIData();
            DisplayArticleVideoData();
            txtSortNo.Focus();
        }

        LoadTitle();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // Authenticate
            if (!empAuth.CanEditThisPage())
            {
                string jsClose = "closeThisForm();";
                ClientScript.RegisterStartupScript(this.GetType(), "invalid", jsClose, true);
                return;
            }

            LoadUIData();
            DisplayOperations();
            c.ClearRoleDataOfRoleOpPvgs(ltrRoleName.Text);
        }

        LoadTitle();
    }
Esempio n. 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // Authenticate
            if (c.qsAct == ConfigFormAction.edit && !empAuth.CanEditThisPage() ||
                c.qsAct == ConfigFormAction.add && !empAuth.CanAddSubItemInThisPage())
            {
                string jsClose = "closeThisForm();";
                ClientScript.RegisterStartupScript(this.GetType(), "invalid", jsClose, true);
                return;
            }

            LoadUIData();
            DisplayDepartmentData();
            txtDeptName.Focus();
        }

        LoadTitle();
    }
    protected void rptDepartments_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        DepartmentForBackend deptData = (DepartmentForBackend)e.Item.DataItem;

        int    deptId   = deptData.DeptId;
        string deptName = deptData.DeptName;
        int    empTotal = deptData.EmpTotal;

        HtmlAnchor btnEdit = (HtmlAnchor)e.Item.FindControl("btnEdit");

        btnEdit.Attributes["onclick"] = string.Format("popWin('Department-Config.aspx?act={0}&id={1}', 700, 600); return false;", ConfigFormAction.edit, deptId);
        btnEdit.Title = Resources.Lang.Main_btnEdit_Hint;

        Literal ltrEdit = (Literal)e.Item.FindControl("ltrEdit");

        ltrEdit.Text = Resources.Lang.Main_btnEdit;

        LinkButton btnDelete = (LinkButton)e.Item.FindControl("btnDelete");

        btnDelete.CommandArgument = string.Join(",", deptId.ToString(), deptName);
        btnDelete.Text            = "<i class='fa fa-trash-o'></i> " + Resources.Lang.Main_btnDelete;
        btnDelete.ToolTip         = Resources.Lang.Main_btnDelete_Hint;
        btnDelete.OnClientClick   = string.Format("return confirm('" + Resources.Lang.Dept_ConfirmDelete_Format + "');",
                                                  deptId, deptName);

        string ownerAccount = deptData.PostAccount;
        int    ownerDeptId  = deptData.PostDeptId;

        btnEdit.Visible = empAuth.CanEditThisPage(false, ownerAccount, ownerDeptId);

        if (!empAuth.CanDelThisPage(ownerAccount, ownerDeptId) ||
            empTotal > 0)
        {
            btnDelete.Visible = false;
        }
    }
Esempio n. 8
0
    protected void rptAccounts_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        EmployeeForBackend empData = (EmployeeForBackend)e.Item.DataItem;

        int      empId          = empData.EmpId;
        string   empAccount     = empData.EmpAccount;
        string   roleName       = empData.RoleName;
        bool     isAccessDenied = empData.IsAccessDenied;
        DateTime startDate      = empData.StartDate.Value;
        DateTime endDate        = empData.EndDate.Value;
        string   remarks        = (empData.Remarks ?? "").Trim();

        HtmlGenericControl ctlRoleDisplayName = (HtmlGenericControl)e.Item.FindControl("ctlRoleDisplayName");

        ctlRoleDisplayName.InnerHtml           = empData.RoleDisplayName;
        ctlRoleDisplayName.Attributes["class"] = "RoleDisplay-" + roleName;

        HtmlTableRow EmpArea = (HtmlTableRow)e.Item.FindControl("EmpArea");

        if (isAccessDenied)
        {
            HtmlGenericControl ctlIsAccessDenied = (HtmlGenericControl)e.Item.FindControl("ctlIsAccessDenied");
            ctlIsAccessDenied.Attributes["title"] = Resources.Lang.Status_AccessDenied;
            ctlIsAccessDenied.Visible             = true;

            EmpArea.Attributes["class"] = "table-danger";
        }

        HtmlGenericControl ctlAccountState = (HtmlGenericControl)e.Item.FindControl("ctlAccountState");

        if (DateTime.Today < startDate && empAccount != "admin")
        {
            // on schedule
            ctlAccountState.Attributes["class"] = "fa fa-hourglass-start fa-lg text-info";
            ctlAccountState.Attributes["title"] = Resources.Lang.Status_OnSchedule;
        }
        else if (endDate < DateTime.Today && empAccount != "admin" || isAccessDenied)
        {
            // offline
            ctlAccountState.Attributes["class"] = "fa fa-ban fa-lg text-danger";
            ctlAccountState.Attributes["title"] = Resources.Lang.Status_AccessDeniedOrExpired;
            EmpArea.Attributes["class"]         = "table-danger";
        }
        else
        {
            // online
            ctlAccountState.Attributes["title"] = Resources.Lang.Status_Normal;
        }

        Literal ltrValidDateRange = (Literal)e.Item.FindControl("ltrValidDateRange");

        ltrValidDateRange.Text = string.Format("{0:yyyy-MM-dd} ~ {1:yyyy-MM-dd}", startDate, endDate);

        if (remarks != "")
        {
            HtmlGenericControl ctlRemarks = (HtmlGenericControl)e.Item.FindControl("ctlRemarks");
            ctlRemarks.Attributes["title"] = remarks;
            ctlRemarks.Visible             = true;
        }

        HtmlAnchor btnEdit = (HtmlAnchor)e.Item.FindControl("btnEdit");

        btnEdit.Attributes["onclick"] = string.Format("popWin('Account-Config.aspx?act={0}&empid={1}', 700, 600); return false;", ConfigFormAction.edit, empId);
        btnEdit.Title = Resources.Lang.Main_btnEdit_Hint;

        Literal ltrEdit = (Literal)e.Item.FindControl("ltrEdit");

        ltrEdit.Text = Resources.Lang.Main_btnEdit;

        LinkButton btnDelete = (LinkButton)e.Item.FindControl("btnDelete");

        btnDelete.CommandArgument = string.Join(",", empId.ToString(), empAccount);
        btnDelete.Text            = "<i class='fa fa-trash-o'></i> " + Resources.Lang.Main_btnDelete;
        btnDelete.ToolTip         = Resources.Lang.Main_btnDelete_Hint;
        btnDelete.OnClientClick   = string.Format("return confirm('" + Resources.Lang.Account_ConfirmDelete_Format + "');",
                                                  empData.EmpName, empData.EmpAccount);

        string ownerAccount = empData.OwnerAccount;
        int    ownerDeptId  = empData.OwnerDeptId;

        btnEdit.Visible = (empAuth.CanEditThisPage(false, ownerAccount, ownerDeptId) || c.IsMyAccount(empAccount));

        if (!empAuth.CanDelThisPage(ownerAccount, ownerDeptId) ||
            empAccount == "admin" ||
            empAccount == c.GetEmpAccount())
        {
            btnDelete.Visible = false;
        }
    }
Esempio n. 9
0
        public override ClientResult ProcessRequest()
        {
            ClientResult cr = null;

            roleName = GetParamValue("roleName");
            string strOpId      = GetParamValue("opId");
            int    opId         = 0;
            string strItemVal   = GetParamValue("itemVal");
            int    itemVal      = 0;
            string strSelfVal   = GetParamValue("selfVal");
            int    selfVal      = 0;
            string strCrewVal   = GetParamValue("crewVal");
            int    crewVal      = 0;
            string strOthersVal = GetParamValue("othersVal");
            int    othersVal    = 0;
            string strAddVal    = GetParamValue("addVal");
            bool   addVal       = false;
            string strRoleId    = GetParamValue("roleId");

            roleId = 0;

            if (!int.TryParse(strOpId, out opId))
            {
                throw new Exception("opId is invalid");
            }
            if (!int.TryParse(strItemVal, out itemVal))
            {
                throw new Exception("itemVal is invalid");
            }
            if (!int.TryParse(strSelfVal, out selfVal))
            {
                throw new Exception("selfVal is invalid");
            }
            if (!int.TryParse(strCrewVal, out crewVal))
            {
                throw new Exception("crewVal is invalid");
            }
            if (!int.TryParse(strOthersVal, out othersVal))
            {
                throw new Exception("othersVal is invalid");
            }
            if (!bool.TryParse(strAddVal, out addVal))
            {
                throw new Exception("addVal is invalid");
            }
            if (!int.TryParse(strRoleId, out roleId))
            {
                throw new Exception("roleId is invalid");
            }

            // authenticate
            empAuth = new EmployeeAuthorityLogic(c);
            empAuth.SetCustomEmployeeAuthorizationResult(this);
            empAuth.InitialAuthorizationResultOfSubPages();

            if (!empAuth.CanEditThisPage())
            {
                cr = new ClientResult()
                {
                    b   = false,
                    err = "invalid authentication"
                };

                return(cr);
            }

            // check limitation
            if (itemVal == 0 && selfVal > 0)
            {
                selfVal = 0;
            }

            if (selfVal < 2 && addVal == true)
            {
                addVal = false;
            }

            if (crewVal > selfVal)
            {
                crewVal = selfVal;
            }

            if (othersVal > crewVal)
            {
                othersVal = crewVal;
            }

            RoleOpPvg newPvg = GetRoleOpPvg(roleName, opId, itemVal,
                                            selfVal, crewVal, othersVal,
                                            addVal);

            // save into list in the session
            RoleOpPvg oldPvg = c.seRoleOpPvgs.Find(pvg => string.Compare(pvg.RoleName, roleName, true) == 0 && pvg.OpId == opId);

            if (oldPvg != null)
            {
                oldPvg.PvgOfItem          = newPvg.PvgOfItem;
                oldPvg.PvgOfSubitemSelf   = newPvg.PvgOfSubitemSelf;
                oldPvg.PvgOfSubitemCrew   = newPvg.PvgOfSubitemCrew;
                oldPvg.PvgOfSubitemOthers = newPvg.PvgOfSubitemOthers;
            }
            else
            {
                c.seRoleOpPvgs.Add(newPvg);
            }

            cr = new ClientResult()
            {
                b = true,
                o = newPvg
            };

            return(cr);
        }