Example #1
0
        void InitSecurity()
        {
            bool _allowEdit = FormBase.CheckRule("admin_patients_abm");

            uc_Persona1.Enabled = _allowEdit;
            btnAdd.Enabled      = uc_MedioContacto1.Enabled = _allowEdit;
            aceptCancelButtonBar1.AceptButtonEnabled = _allowEdit;
            gridControl_MutualXPatient.Enabled       = _allowEdit;
            gridControl2.Enabled = _allowEdit;
        }
 private void frmProfesionalCard_Load(object sender, EventArgs e)
 {
     if (this.DesignMode)
     {
         return;
     }
     uc_Profesionales_Card1.Populate(_IdProfesional, this.State);
     //uc_Profesionales_Card1.Refresh();
     aceptCancelButtonBar1.AceptButtonEnabled = FormBase.CheckRule("admin_professional_abm") || FormBase.CheckRule("admin_users_change_security") || FormBase.CheckRule("admin_professional_sheduling");
 }
 private void treeList2_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
 {
     if (e.Node == null)
     {
         return;
     }
     Fwk.UI.Controls.Menu.Tree.MenuItem item = (Fwk.UI.Controls.Menu.Tree.MenuItem)treeList2.GetDataRecordByNode(e.Node);
     if (!String.IsNullOrEmpty(item.AssemblyInfo))
     {
         if (FormBase.CheckRule(item.AuthRule))
         {
             AddContronToPannel(item, null);
         }
     }
 }
        private void treeList2_NodeCellStyle(object sender, GetCustomNodeCellStyleEventArgs e)
        {
            if (e.Column.FieldName != "DisplayName")
            {
                return;
            }

            Fwk.UI.Controls.Menu.Tree.MenuItem m = (Fwk.UI.Controls.Menu.Tree.MenuItem)treeList2.GetDataRecordByNode(e.Node);
            if (String.IsNullOrEmpty(m.AuthorizationRuleName))
            {
                return;
            }

            if (!FormBase.CheckRule(m.AuthorizationRuleName))
            {
                //e.Appearance.BackColor = Color.FromArgb(80, 255, 0, 255);
                e.Appearance.ForeColor = Color.Gray;

                //e.Appearance.Font = new Font(e.Appearance.Font, FontStyle.Bold);
            }
        }
        public void Init()
        {
            uc_Persona1.Init();

            cmbProfecion.Properties.DataSource = ServiceCalls.ProfecionesList;

            _EspecialidadList.AddRange(ServiceCalls.EspecialidadMedicaList.Where <ParametroBE>(p => p.IdParametro != (int)CommonValuesEnum.TodosComboBoxValue));

            cmbEspecialidad.Properties.DataSource = _EspecialidadList;
            cmbEspecialidad.Refresh();
            if (SecurityServiceCalls.AllRolList == null)
            {
                SecurityServiceCalls.RefreshSecurity();
            }

            var list = from rol in SecurityServiceCalls.AllRolList where rol.RolName.StartsWith("inst_") select rol.RolName;

            lstBoxRoles.Items.AddRange(list.ToArray());

            lstBoxRoles.Refresh();

            base.Refresh();

            btnCrearResourceScheduling.Enabled = gridControl1.Enabled = FormBase.CheckRule("admin_professional_sheduling");

            btnResetPwd.Enabled = FormBase.CheckRule("admin_users_change_security");
            if (this.State == EntityUpdateEnum.UPDATED)
            {
                lstBoxRoles.Enabled = FormBase.CheckRule("admin_users_change_security");
            }
            else
            {
                lstBoxRoles.Enabled = FormBase.CheckRule("admin_professional_abm");
            }

            uc_MedioContacto1.Enabled = panelControl2.Enabled = uc_Persona1.Enabled = FormBase.CheckRule("admin_professional_abm");

            //Las reglas se comtinuan validando en el Populate dado q tambien dependen del profesional consultado
        }
Example #6
0
 void CheckRule(BarItem i)
 {
     DevExpress.Utils.SuperToolTip superToolTip1 = null;
     DevExpress.Utils.ToolTipItem  toolTipItem1  = null;
     if (i.Tag != null)
     {
         try
         {
             i.Enabled = FormBase.CheckRule(i.Tag.ToString());
         }
         catch
         {
             superToolTip1     = new DevExpress.Utils.SuperToolTip();
             toolTipItem1      = new DevExpress.Utils.ToolTipItem();
             toolTipItem1.Text = string.Concat("Error regla de seguridad : ", i.Tag.ToString());
             superToolTip1.Items.Add(toolTipItem1);
             i.Enabled  = false;
             i.SuperTip = superToolTip1;
             i.AppearanceDisabled.ForeColor = Color.Red;
         }
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool HasErrors()
        {
            dxErrorProvider1.ClearErrors();

            if (String.IsNullOrEmpty(txtMatricula.Text))
            {
                dxErrorProvider1.SetError(txtMatricula, "Ingerse matrícula");
                xtraTabControl1.SelectedTabPage = xtraTabPage1;
                return(dxErrorProvider1.HasErrors);
            }

            if (cmbEspecialidad.EditValue == null)
            {
                dxErrorProvider1.SetError(cmbEspecialidad, "Debe seleccionar especialidad");
                xtraTabControl1.SelectedTabPage = xtraTabPage1;
                return(dxErrorProvider1.HasErrors);
            }

            #region Inicio sesion

            if (this.State == EntityUpdateEnum.NEW)
            {
                try
                {
                    bool exist = SecurityServiceCalls.ValidateUserExist(txtUsername.Text.Trim());

                    if (exist)
                    {
                        dxErrorProvider1.SetError(txtUsername, "El nombre de usuario ya se encuentra registrado \r\n por favor elija otro", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                        txtUsername.SelectAll();
                        xtraTabControl1.SelectedTabPage = xtraTabPage_Sesion;
                        btnCheckUserName.Image          = global::Health.Front.Base.Properties.Resource.User_3_Stop;

                        return(dxErrorProvider1.HasErrors);
                    }
                }
                catch (Exception ex)
                {
                    this.ExceptionViewer.Show(ex);
                }

                if (String.IsNullOrEmpty(txtPassword.Text))
                {
                    dxErrorProvider1.SetError(txtConfrirmPassword, "La clave de usuario no puede estar enblanco", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                    xtraTabControl1.SelectedTabPage = xtraTabPage_Sesion;
                    MessageViewer.Show(dxErrorProvider1.GetError(txtConfrirmPassword));
                    txtConfrirmPassword.SelectAll();
                    return(true);
                }
                if (!txtConfrirmPassword.Text.Equals(txtPassword.Text))
                {
                    dxErrorProvider1.SetError(txtConfrirmPassword, "La clave y confirmación de la misma deben ser iguales", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical);
                    xtraTabControl1.SelectedTabPage = xtraTabPage_Sesion;

                    txtConfrirmPassword.SelectAll();
                    MessageViewer.Show(dxErrorProvider1.GetError(txtConfrirmPassword));
                    return(true);
                }
            }
            #endregion

            //Si tiene permitido modificar seguridad
            if (FormBase.CheckRule("admin_users_change_security") == true)
            {
                if (GetCheckedRolList().Count == 0)
                {
                    dxErrorProvider1.SetError(lblSelRol, "Debe seleccionar al menos un rol para el usuario");

                    xtraTabControl1.SelectedTabPage = xtraTabPage_Sesion;;
                    return(true);
                }
            }
            //Si no tiene permitido modificar admin_professional_sheduling
            if (btnCrearResourceScheduling.Enabled) // -> admin_professional_sheduling
            {
                if (resourceSchedulingList == null || resourceSchedulingList.Count == 0)
                {
                    xtraTabControl1.SelectedTabPage = xtraTabPage2;;
                    MessageViewer.Show("No ah definido la programación de turnos del profesional");

                    return(true);
                }
            }
            return(false);
        }
Example #8
0
        //public static  void InitAuthorizationFactory()
        //{
        //    //FormBase.InitAuthorizationFactory();
        //}

        /// <summary>
        /// intenta autorizar el usuario registrado para la regla pasada por parametrio
        /// </summary>
        /// <param name="pRuleName">Nombre de la regla</param>
        /// <returns></returns>
        public static bool CheckRule(string pRuleName)
        {
            return(FormBase.CheckRule(pRuleName));
        }