Exemple #1
0
        public static u_UserRights_DL GetUserRightObj(string formID, string user)
        {
            u_UserRights objUserRight = new u_UserRights();

            objUserRight.User              = new u_User();
            objUserRight.MenuTag           = new u_MenuTag();
            objUserRight.User.strUserID    = Globals.g_strUser;
            objUserRight.MenuTag.strMenuID = formID.Trim();

            u_UserRights_DL objURightDL    = new u_UserRights_DL();
            u_UserRights_DL dtAllMenuItems = objURightDL.GetUserRightsForOneMenu(objUserRight);

            return(dtAllMenuItems);
        }
        /*FunctionButtonStatus Was created by Asanga Chandrakumara on 12:18 PM 6/24/2015*/
        /// <summary>
        /// THis function will enable and disable the button status as required
        /// </summary>
        /// <param name="typex">Enumaration to function type</param>
        public void FunctionButtonStatus(xEnums.PerformanceType typex)
        {
            u_UserRights objUserRight = new u_UserRights();

            objUserRight.User              = new u_User();
            objUserRight.MenuTag           = new u_MenuTag();
            objUserRight.User.strUserID    = Globals.g_strUser;
            objUserRight.MenuTag.strMenuID = formID.Trim();

            u_UserRights_DL objURightDL    = new u_UserRights_DL();
            u_UserRights_DL dtAllMenuItems = objURightDL.GetUserRightsForOneMenu(objUserRight);



            switch (typex)
            {
            case xEnums.PerformanceType.Save:
                if (dtAllMenuItems.boolCreate == false)
                {
                    btn_new.Enabled    = false;
                    btn_cancel.Enabled = false;
                    btn_save.Enabled   = false;
                    btn_delete.Enabled = dtAllMenuItems.boolDelete;
                    btn_edit.Enabled   = dtAllMenuItems.boolModify;
                    btn_print.Enabled  = dtAllMenuItems.boolPrint;
                }
                else
                {
                    btn_cancel.Enabled = false;
                    btn_save.Enabled   = false;
                    btn_new.Enabled    = true;
                    btn_delete.Enabled = dtAllMenuItems.boolDelete;
                    btn_edit.Enabled   = dtAllMenuItems.boolModify;
                    btn_print.Enabled  = dtAllMenuItems.boolPrint;
                }
                break;

            case xEnums.PerformanceType.Delete:     //when press the delete button
                if (dtAllMenuItems.boolCreate == false)
                {
                    btn_new.Enabled = false;
                }
                else
                {
                    btn_cancel.Enabled = false;
                    btn_save.Enabled   = false;
                    btn_new.Enabled    = true;
                    btn_delete.Enabled = false;
                    btn_edit.Enabled   = false;
                    btn_print.Enabled  = false;
                }
                break;

            case xEnums.PerformanceType.Existing:     //enter existing item to system
                if (dtAllMenuItems.boolCreate == false)
                {
                    btn_new.Enabled = false;
                }
                else
                {
                    btn_cancel.Enabled = true;
                    btn_save.Enabled   = false;
                    btn_new.Enabled    = false;
                    btn_delete.Enabled = dtAllMenuItems.boolDelete;
                    btn_edit.Enabled   = dtAllMenuItems.boolModify;
                    btn_print.Enabled  = dtAllMenuItems.boolPrint;
                }
                break;

            case xEnums.PerformanceType.Edit:     //enter existing item to system and press edit
                if (dtAllMenuItems.boolCreate == false)
                {
                    btn_new.Enabled    = false;
                    btn_cancel.Enabled = true;
                    btn_save.Enabled   = true;
                    btn_new.Enabled    = dtAllMenuItems.boolCreate;
                    btn_delete.Enabled = dtAllMenuItems.boolDelete;
                    btn_edit.Enabled   = false;
                    btn_print.Enabled  = dtAllMenuItems.boolPrint;
                }
                else
                {
                    btn_cancel.Enabled = true;
                    btn_save.Enabled   = true;
                    btn_new.Enabled    = false;
                    btn_delete.Enabled = false;
                    btn_edit.Enabled   = false;
                    btn_print.Enabled  = false;
                }
                break;

            case xEnums.PerformanceType.Exit:
                break;

            case xEnums.PerformanceType.New:
                if (dtAllMenuItems.boolCreate == false)
                {
                    btn_new.Enabled = false;
                }
                else
                {
                    btn_cancel.Enabled = true;
                    btn_save.Enabled   = true;
                    btn_new.Enabled    = false;
                    btn_delete.Enabled = false;
                    btn_edit.Enabled   = false;
                    btn_print.Enabled  = false;
                }
                break;

            case xEnums.PerformanceType.Default:
                if (dtAllMenuItems.boolCreate == false)
                {
                    btn_new.Enabled    = false;
                    btn_delete.Enabled = dtAllMenuItems.boolDelete;
                    btn_edit.Enabled   = dtAllMenuItems.boolModify;
                    btn_print.Enabled  = dtAllMenuItems.boolPrint;
                    btn_save.Enabled   = false;
                    btn_cancel.Enabled = false;
                }
                else
                {
                    btn_cancel.Enabled = false;
                    btn_save.Enabled   = false;
                    btn_new.Enabled    = true;
                    btn_delete.Enabled = dtAllMenuItems.boolDelete;
                    btn_edit.Enabled   = dtAllMenuItems.boolModify;
                    btn_print.Enabled  = dtAllMenuItems.boolPrint;
                }


                break;

            case xEnums.PerformanceType.Cancel:
                if (dtAllMenuItems.boolCreate == false)
                {
                    btn_new.Enabled = false;
                }
                else
                {
                    btn_cancel.Enabled = false;
                    btn_save.Enabled   = false;
                    btn_new.Enabled    = true;
                    btn_delete.Enabled = false;
                    btn_edit.Enabled   = false;
                    btn_print.Enabled  = false;
                }
                break;
            }
        }