Ejemplo n.º 1
0
        private void LoadScreenList(string LangCD, string keyFilter)
        {
            try
            {
                AuthorizedMaintenanceController ctlAuthorize = new AuthorizedMaintenanceController();

                m_dtScreenList = (DataTable)ctlAuthorize.LoadAllDatabyLangCD(LangCD);
                LoadScreenListFromMemory(LangCD, keyFilter);
            }
            catch (ValidateException err)
            {
                for (int i = 0; i < err.ErrorResults.Count; i++)
                {
                    MessageBox.Show(err.ErrorResults[i].Message.MessageDescription);
                    err.ErrorResults[i].FocusOnControl();
                }
            }
            catch (BusinessException err)
            {
                MessageDialog.ShowBusiness(this, err.Error.Message.MessageDescription);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowBusiness(this, ex.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Use this method to open screen by ScreenCode.
        /// </summary>
        /// <param name="ScreenCD"></param>
        private void OpenScreen(string ScreenCD)
        {
            ProgramScreen screen = m_programScreenCache[ScreenCD];

            if (screen == null)
            {
                MessageDialog.ShowBusiness(this, "Not found screen on class library.");
                return;
            }

            // check for view permission
            AuthorizedMaintenanceController authorizedMntCtrl = new AuthorizedMaintenanceController();
            DataTable dtUser            = authorizedMntCtrl.LoadUserPermissionJoinScreen(ScreenCD);
            bool      hasViewPermission = false;
            string    Userpermission    = string.Empty;
            string    Grouppermission   = string.Empty;

            if (dtUser != null)
            {
                // Check User Permission First
                DataRow[] dr = dtUser.Select(String.Format("USER_CD = '{0}'", Common.CurrentUserInfomation.UserCD.StrongValue));
                Userpermission = dr[0][PermissionValue.eUserPermission.FLG_VIEW.ToString()].ToString();
                if (dr.Length != 0)
                {
                    if (Userpermission == "1")
                    {
                        hasViewPermission = true;
                    }
                }
            }
            if (Userpermission == "2")
            {
                // Check Group Permission
                DataTable dtGroup = authorizedMntCtrl.LoadGroupPermissionJoinScreen(ScreenCD);

                if (dtGroup != null)
                {
                    DataRow[] dr = dtGroup.Select(String.Format("GROUP_CD = '{0}'", Common.CurrentUserInfomation.GroupCode.StrongValue));
                    Grouppermission = dr[0][PermissionValue.eGroupPermission.FLG_VIEW.ToString()].ToString();
                    if ((Grouppermission == "1"))
                    {
                        hasViewPermission = true;
                    }
                }
            }
            if (hasViewPermission)
            {
                screen.CreateScreen(null);
            }
            else
            {
                EVOFramework.Windows.Forms.MessageDialog.ShowInformation(this, "Permissionn Control"
                                                                         , EVOFramework.Message.LoadMessage(Messages.eInformation.INF9004.ToString()).MessageDescription);
            }
        }
Ejemplo n.º 3
0
        private void Load_UserScreenPermission(string ScreenCD)
        {
            AuthorizedMaintenanceController ctlAuthor = new AuthorizedMaintenanceController();

            shtUserPermission.DataSource = ctlAuthor.LoadUserPermissionJoinScreen(ScreenCD);

            shtUserPermission.Columns[(int)eColUserScreenPermission.USER_ACCOUNT].DataField = "USER_ACCOUNT";
            shtUserPermission.Columns[(int)eColUserScreenPermission.USER_CD].DataField      = UserScreenPermissionDTO.eColumns.USER_CD.ToString();
            shtUserPermission.Columns[(int)eColUserScreenPermission.FLG_VIEW].DataField     = UserScreenPermissionDTO.eColumns.FLG_VIEW.ToString();
            shtUserPermission.Columns[(int)eColUserScreenPermission.FLG_ADD].DataField      = UserScreenPermissionDTO.eColumns.FLG_ADD.ToString();
            shtUserPermission.Columns[(int)eColUserScreenPermission.FLG_CHG].DataField      = UserScreenPermissionDTO.eColumns.FLG_CHG.ToString();
            shtUserPermission.Columns[(int)eColUserScreenPermission.FLG_DEL].DataField      = UserScreenPermissionDTO.eColumns.FLG_DEL.ToString();
        }
Ejemplo n.º 4
0
        private void Load_GroupScreenPermission(string ScreenCD)
        {
            AuthorizedMaintenanceController ctlAuthor = new AuthorizedMaintenanceController();

            shtGroupPermission.DataSource = ctlAuthor.LoadGroupPermissionJoinScreen(ScreenCD);

            shtGroupPermission.Columns[(int)eColGroupScreenPermission.GROUP_NAME].DataField = "GROUP_NAME";
            shtGroupPermission.Columns[(int)eColGroupScreenPermission.GROUP_CD].DataField   = GroupScreenPermissionDTO.eColumns.GROUP_CD.ToString();
            shtGroupPermission.Columns[(int)eColGroupScreenPermission.FLG_VIEW].DataField   = GroupScreenPermissionDTO.eColumns.FLG_VIEW.ToString();
            shtGroupPermission.Columns[(int)eColGroupScreenPermission.FLG_ADD].DataField    = GroupScreenPermissionDTO.eColumns.FLG_ADD.ToString();
            shtGroupPermission.Columns[(int)eColGroupScreenPermission.FLG_CHG].DataField    = GroupScreenPermissionDTO.eColumns.FLG_CHG.ToString();
            shtGroupPermission.Columns[(int)eColGroupScreenPermission.FLG_DEL].DataField    = GroupScreenPermissionDTO.eColumns.FLG_DEL.ToString();
        }
Ejemplo n.º 5
0
        protected void InitialPermissionValue()
        {
            if (Common.CurrentUserInfomation == null)
            {
                return;
            }
            UserPermission.View   = PermissionValue.ePermission.No;
            UserPermission.Add    = PermissionValue.ePermission.No;
            UserPermission.Edit   = PermissionValue.ePermission.No;
            UserPermission.Delete = PermissionValue.ePermission.No;

            GroupPermission.View   = PermissionValue.ePermission.No;
            GroupPermission.Add    = PermissionValue.ePermission.No;
            GroupPermission.Edit   = PermissionValue.ePermission.No;
            GroupPermission.Delete = PermissionValue.ePermission.No;



            #region Get Permission value from database
            AuthorizedMaintenanceController authorizedMntCtrl = new AuthorizedMaintenanceController();

            EVOFramework.Windows.Forms.ScreenAttribute screenAttribute = EVOFramework.Windows.Forms.ScreenAttribute.GetScreenAttribute(this.GetType());

            if (screenAttribute != null)
            {
                DataTable dtUser = authorizedMntCtrl.LoadUserPermissionJoinScreen(screenAttribute.ScreenCD);
                // Check User Permission First
                if (dtUser != null)
                {
                    DataRow[] dr = dtUser.Select(String.Format("USER_CD = '{0}'", Common.CurrentUserInfomation.UserCD.StrongValue));

                    if (dr.Length != 0)
                    {
                        UserPermission.View = (PermissionValue.ePermission)Enum.Parse(typeof(PermissionValue.ePermission), dr[0][(int)PermissionValue.eUserPermission.FLG_VIEW].ToString());

                        UserPermission.Add = (PermissionValue.ePermission)Enum.Parse(typeof(PermissionValue.ePermission), dr[0][(int)PermissionValue.eUserPermission.FLG_ADD].ToString());

                        UserPermission.Edit = (PermissionValue.ePermission)Enum.Parse(typeof(PermissionValue.ePermission), dr[0][(int)PermissionValue.eUserPermission.FLG_CHG].ToString());

                        UserPermission.Delete = (PermissionValue.ePermission)Enum.Parse(typeof(PermissionValue.ePermission), dr[0][(int)PermissionValue.eUserPermission.FLG_DEL].ToString());

                        //if (dr[0][PermissionValue.eUserPermission.FLG_VIEW.ToString()].ToString() == "1")
                        //    UserPermission.View = PermissionValue.ePermission.Yes;

                        //if (dr[0][PermissionValue.eUserPermission.FLG_ADD.ToString()].ToString() == "1")
                        //    UserPermission.Add = PermissionValue.ePermission.Yes;

                        //if (dr[0][PermissionValue.eUserPermission.FLG_CHG.ToString()].ToString() == "1")
                        //    UserPermission.Edit = PermissionValue.ePermission.Yes;

                        //if (dr[0][PermissionValue.eUserPermission.FLG_DEL.ToString()].ToString() == "1")
                        //    UserPermission.Delete = PermissionValue.ePermission.Yes;

                        //if (dr[0][PermissionValue.eUserPermission.FLG_VIEW.ToString()].ToString() == "0")
                        //    UserPermission.View = PermissionValue.ePermission.No;

                        //if (dr[0][PermissionValue.eUserPermission.FLG_ADD.ToString()].ToString() == "0")
                        //    UserPermission.Add = PermissionValue.ePermission.No;

                        //if (dr[0][PermissionValue.eUserPermission.FLG_CHG.ToString()].ToString() == "0")
                        //    UserPermission.Edit = PermissionValue.ePermission.No;

                        //if (dr[0][PermissionValue.eUserPermission.FLG_DEL.ToString()].ToString() == "0")
                        //    UserPermission.Delete = PermissionValue.ePermission.No;

                        //if (dr[0][PermissionValue.eUserPermission.FLG_VIEW.ToString()].ToString() == "-1")
                        //    UserPermission.View = PermissionValue.ePermission.UpToGroup;

                        //if (dr[0][PermissionValue.eUserPermission.FLG_ADD.ToString()].ToString() == "-1")
                        //    UserPermission.Add = PermissionValue.ePermission.UpToGroup;

                        //if (dr[0][PermissionValue.eUserPermission.FLG_CHG.ToString()].ToString() == "-1")
                        //    UserPermission.Edit = PermissionValue.ePermission.UpToGroup;

                        //if (dr[0][PermissionValue.eUserPermission.FLG_DEL.ToString()].ToString() == "-1")
                        //    UserPermission.Delete = PermissionValue.ePermission.UpToGroup;
                    }
                }

                // Check Group Permission
                DataTable dtGroup = authorizedMntCtrl.LoadGroupPermissionJoinScreen(screenAttribute.ScreenCD);

                if (dtGroup != null)
                {
                    DataRow[] dr = dtGroup.Select(String.Format("GROUP_CD = '{0}'", Common.CurrentUserInfomation.GroupCode.StrongValue));

                    GroupPermission.View = (PermissionValue.ePermission)Enum.Parse(typeof(PermissionValue.ePermission), dr[0][(int)PermissionValue.eUserPermission.FLG_VIEW].ToString());

                    GroupPermission.Add = (PermissionValue.ePermission)Enum.Parse(typeof(PermissionValue.ePermission), dr[0][(int)PermissionValue.eUserPermission.FLG_ADD].ToString());

                    GroupPermission.Edit = (PermissionValue.ePermission)Enum.Parse(typeof(PermissionValue.ePermission), dr[0][(int)PermissionValue.eUserPermission.FLG_CHG].ToString());

                    GroupPermission.Delete = (PermissionValue.ePermission)Enum.Parse(typeof(PermissionValue.ePermission), dr[0][(int)PermissionValue.eUserPermission.FLG_DEL].ToString());


                    //if (dr[0][PermissionValue.eGroupPermission.FLG_VIEW.ToString()].ToString() == "1")
                    //    GroupPermission.View = PermissionValue.ePermission.Yes;

                    //if (dr[0][PermissionValue.eGroupPermission.FLG_ADD.ToString()].ToString() == "1")
                    //    GroupPermission.Add = PermissionValue.ePermission.Yes;

                    //if (dr[0][PermissionValue.eGroupPermission.FLG_CHG.ToString()].ToString() == "1")
                    //    GroupPermission.Edit = PermissionValue.ePermission.Yes;

                    //if (dr[0][PermissionValue.eGroupPermission.FLG_DEL.ToString()].ToString() == "1")
                    //    GroupPermission.Delete = PermissionValue.ePermission.Yes;

                    //if (dr[0][PermissionValue.eGroupPermission.FLG_VIEW.ToString()].ToString() == "0")
                    //    GroupPermission.View = PermissionValue.ePermission.No;

                    //if (dr[0][PermissionValue.eGroupPermission.FLG_ADD.ToString()].ToString() == "0")
                    //    GroupPermission.Add = PermissionValue.ePermission.No;

                    //if (dr[0][PermissionValue.eGroupPermission.FLG_CHG.ToString()].ToString() == "0")
                    //    GroupPermission.Edit = PermissionValue.ePermission.No;

                    //if (dr[0][PermissionValue.eGroupPermission.FLG_DEL.ToString()].ToString() == "0")
                    //    GroupPermission.Delete = PermissionValue.ePermission.No;
                }
            }
            #endregion

            #region Set Active Permission Value
            ActivePermission.View   = GetActivePermission(GroupPermission.View, UserPermission.View);
            ActivePermission.Add    = GetActivePermission(GroupPermission.Add, UserPermission.Add);
            ActivePermission.Edit   = GetActivePermission(GroupPermission.Edit, UserPermission.Edit);
            ActivePermission.Delete = GetActivePermission(GroupPermission.Delete, UserPermission.Delete);
            #endregion
        }
Ejemplo n.º 6
0
        private void SaveUserScreenPermission(eColUserScreenPermission eColUserScreenPermission)
        {
            AuthorizedMaintenanceController ctlAuthor = new AuthorizedMaintenanceController();

            CellRange[] screen_ranges = shtScreenList.GetSelections();

            //Check if selected screen multiline.
            for (int iRange = 0; iRange < screen_ranges.Length; iRange++)
            {
                CellRange screen_range = screen_ranges[iRange];

                if (screen_range.RowCount > 1 || screen_ranges.Length > 1)
                {
                    // รวบรวมรายการ SCREEN_CD ทั้งหมด
                    List <string> listScreenCD = new List <string>();
                    for (int iScreen = 0; iScreen < screen_range.RowCount; iScreen++)
                    {
                        string SCREEN_CD = shtScreenList.GetText(screen_range.Row + iScreen, (int)eColScreenList.SCREEN_CD);
                        listScreenCD.Add(SCREEN_CD);
                    }

                    //for (int iGroup = 0; iGroup < shtUserPermission.RowCount; iGroup++)
                    //{
                    //    string GROUP_CD = shtUserPermission.GetText(iGroup, (int)eColUserScreenPermission.GROUP_CD);
                    string UserCD      = shtUserPermission.Cells[shtUserPermission.ActiveRowIndex, (int)eColUserScreenPermission.USER_CD].Text;
                    int    iGroup      = shtUserPermission.ActiveRowIndex;
                    int    objFLG_VIEW = Convert.ToInt32(shtUserPermission.Cells[iGroup, (int)eColUserScreenPermission.FLG_VIEW].Value);
                    int    objFLG_ADD  = Convert.ToInt32(shtUserPermission.Cells[iGroup, (int)eColUserScreenPermission.FLG_ADD].Value);
                    int    objFLG_CHG  = Convert.ToInt32(shtUserPermission.Cells[iGroup, (int)eColUserScreenPermission.FLG_CHG].Value);
                    int    objFLG_DEL  = Convert.ToInt32(shtUserPermission.Cells[iGroup, (int)eColUserScreenPermission.FLG_DEL].Value);

                    if (objFLG_VIEW != 0 && objFLG_VIEW != 1)
                    {
                        objFLG_VIEW = -1;
                    }

                    if (objFLG_ADD != 0 && objFLG_ADD != 1)
                    {
                        objFLG_ADD = -1;
                    }

                    if (objFLG_CHG != 0 && objFLG_CHG != 1)
                    {
                        objFLG_CHG = -1;
                    }

                    if (objFLG_DEL != 0 && objFLG_DEL != 1)
                    {
                        objFLG_DEL = -1;
                    }

                    // วนรอบทุก SCREEN_CD เพื่อ Update ค่าให้ตรงกับที่เลือกไว้
                    for (int i = 0; i < listScreenCD.Count; i++)
                    {
                        if (!ctlAuthor.isExistUserScreenPermission(listScreenCD[i], UserCD))
                        {
                            ctlAuthor.AddUserScreenPermissionFlag(objFLG_VIEW, objFLG_ADD, objFLG_CHG, objFLG_DEL, UserCD, listScreenCD[i]);
                        }
                        else
                        {
                            switch (eColUserScreenPermission)
                            {
                            case eColUserScreenPermission.FLG_VIEW:
                                ctlAuthor.UpdateUserScreenPermissionFlagVIEW(objFLG_VIEW, UserCD, listScreenCD[i]);
                                break;

                            case eColUserScreenPermission.FLG_ADD:
                                ctlAuthor.UpdateUserScreenPermissionFlagADD(objFLG_ADD, UserCD, listScreenCD[i]);
                                break;

                            case eColUserScreenPermission.FLG_CHG:
                                ctlAuthor.UpdateUserScreenPermissionFlagCHG(objFLG_CHG, UserCD, listScreenCD[i]);
                                break;

                            case eColUserScreenPermission.FLG_DEL:
                                ctlAuthor.UpdateUserScreenPermissionFlagDEL(objFLG_DEL, UserCD, listScreenCD[i]);
                                break;
                            }
                        }
                    }
                }
                else
                {
                    string ScreenCD = shtScreenList.Cells[shtScreenList.ActiveRowIndex, (int)eColScreenList.SCREEN_CD].Text;
                    string UserCD   = shtUserPermission.Cells[shtUserPermission.ActiveRowIndex, (int)eColUserScreenPermission.USER_CD].Text;

                    int objFLG_VIEW = Convert.ToInt32(shtUserPermission.Cells[shtUserPermission.ActiveRowIndex, (int)eColUserScreenPermission.FLG_VIEW].Value);
                    int objFLG_ADD  = Convert.ToInt32(shtUserPermission.Cells[shtUserPermission.ActiveRowIndex, (int)eColUserScreenPermission.FLG_ADD].Value);
                    int objFLG_CHG  = Convert.ToInt32(shtUserPermission.Cells[shtUserPermission.ActiveRowIndex, (int)eColUserScreenPermission.FLG_CHG].Value);
                    int objFLG_DEL  = Convert.ToInt32(shtUserPermission.Cells[shtUserPermission.ActiveRowIndex, (int)eColUserScreenPermission.FLG_DEL].Value);

                    if (objFLG_VIEW != 0 && objFLG_VIEW != 1)
                    {
                        objFLG_VIEW = -1;
                    }

                    if (objFLG_ADD != 0 && objFLG_ADD != 1)
                    {
                        objFLG_ADD = -1;
                    }

                    if (objFLG_CHG != 0 && objFLG_CHG != 1)
                    {
                        objFLG_CHG = -1;
                    }

                    if (objFLG_DEL != 0 && objFLG_DEL != 1)
                    {
                        objFLG_DEL = -1;
                    }


                    if (!ctlAuthor.isExistUserScreenPermission(ScreenCD, UserCD))
                    {
                        ctlAuthor.AddUserScreenPermissionFlag(objFLG_VIEW, objFLG_ADD, objFLG_CHG, objFLG_DEL, UserCD, ScreenCD);
                    }
                    else
                    {
                        switch (eColUserScreenPermission)
                        {
                        case eColUserScreenPermission.FLG_VIEW:
                            ctlAuthor.UpdateUserScreenPermissionFlagVIEW(objFLG_VIEW, UserCD, ScreenCD);
                            break;

                        case eColUserScreenPermission.FLG_ADD:
                            ctlAuthor.UpdateUserScreenPermissionFlagADD(objFLG_ADD, UserCD, ScreenCD);
                            break;

                        case eColUserScreenPermission.FLG_CHG:
                            ctlAuthor.UpdateUserScreenPermissionFlagCHG(objFLG_CHG, UserCD, ScreenCD);
                            break;

                        case eColUserScreenPermission.FLG_DEL:
                            ctlAuthor.UpdateUserScreenPermissionFlagDEL(objFLG_DEL, UserCD, ScreenCD);
                            break;
                        }
                    }
                }
            }
        }