コード例 #1
0
        public List <AccessBE> ListaTodosActivo()
        {
            Database        db         = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand       dbCommand  = db.GetStoredProcCommand("usp_Access_ListaTodosActivo");
            IDataReader     reader     = db.ExecuteReader(dbCommand);
            List <AccessBE> Accesslist = new List <AccessBE>();
            AccessBE        Access;

            while (reader.Read())
            {
                Access            = new AccessBE();
                Access.IdProfile  = Int32.Parse(reader["IdProfile"].ToString());
                Access.IdMenu     = Int32.Parse(reader["idmenu"].ToString());
                Access.FlagRead   = Boolean.Parse(reader["flagRead"].ToString());
                Access.FlagAdd    = Boolean.Parse(reader["flagAdd"].ToString());
                Access.FlagUpdate = Boolean.Parse(reader["flagUpdate"].ToString());
                Access.FlagDelete = Boolean.Parse(reader["flagDelete"].ToString());
                Access.FlagPrint  = Boolean.Parse(reader["flagPrint"].ToString());
                Access.FlagState  = Boolean.Parse(reader["flagState"].ToString());
                Accesslist.Add(Access);
            }
            reader.Close();
            reader.Dispose();
            return(Accesslist);
        }
コード例 #2
0
        public List <AccessBE> SeleccionaPerfil(int IdProfile)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_Access_SeleccionaProfile");

            db.AddInParameter(dbCommand, "pIdProfile", DbType.Int32, IdProfile);

            IDataReader     reader     = db.ExecuteReader(dbCommand);
            List <AccessBE> Accesslist = new List <AccessBE>();
            AccessBE        Access;

            while (reader.Read())
            {
                Access            = new AccessBE();
                Access.IdProfile  = Int32.Parse(reader["IdProfile"].ToString());
                Access.IdMenu     = Int32.Parse(reader["idmenu"].ToString());
                Access.FlagRead   = Boolean.Parse(reader["flagRead"].ToString());
                Access.FlagAdd    = Boolean.Parse(reader["flagAdd"].ToString());
                Access.FlagUpdate = Boolean.Parse(reader["flagUpdate"].ToString());
                Access.FlagDelete = Boolean.Parse(reader["flagDelete"].ToString());
                Access.FlagPrint  = Boolean.Parse(reader["flagPrint"].ToString());
                Access.FlagState  = Boolean.Parse(reader["flagState"].ToString());
                Access.TipOper    = 4;
                Accesslist.Add(Access);
            }
            reader.Close();
            reader.Dispose();
            return(Accesslist);
        }
コード例 #3
0
        public void Elimina(AccessBE pItem)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_Access_Elimina");

            db.AddInParameter(dbCommand, "pIdProfile", DbType.Int32, pItem.IdProfile);
            db.AddInParameter(dbCommand, "pIdMenu", DbType.Int32, pItem.IdMenu);
            db.AddInParameter(dbCommand, "pLogin", DbType.String, pItem.Login);
            db.AddInParameter(dbCommand, "pMachine", DbType.String, pItem.Machine);
            db.AddInParameter(dbCommand, "pIdCompany", DbType.Int32, pItem.IdCompany);

            db.ExecuteNonQuery(dbCommand);
        }
コード例 #4
0
        private void trwMenu_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            try
            {
                string[] objectString = e.Node.Tag.ToString().Split(new char[] { ';' });
                this.lblMenu.Text = e.Node.Text;
                menuID = Convert.ToInt32(objectString[0]);

                if (pListaAccess.Count > 0)
                {
                    AccessBE Access = pListaAccess.Find(delegate(AccessBE _Acc)
                    {
                        if (_Acc.IdMenu == menuID)
                        {
                            return true;
                        }
                        return false;
                    });

                    if (Access != null)
                    {
                        //Mostrar datos en los checkbox
                        this.chkAllowRead.Checked = Access.FlagRead;
                        this.chkAllowWrite.Checked = Access.FlagAdd; ;
                        this.chkAllowUpdate.Checked = Access.FlagUpdate; ;
                        this.chkAllowDelete.Checked = Access.FlagDelete;
                        this.chkAllowPrint.Checked = Access.FlagPrint; ;
                    }
                    else
                    {
                        this.chkAllowRead.Checked = false;
                        this.chkAllowWrite.Checked = false;
                        this.chkAllowUpdate.Checked = false;
                        this.chkAllowDelete.Checked = false;
                        this.chkAllowPrint.Checked = false;
                    }

                }
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #5
0
        public void Actualiza(AccessBE pItem)
        {
            Database  db        = DatabaseFactory.CreateDatabase("cnERPBD");
            DbCommand dbCommand = db.GetStoredProcCommand("usp_Access_Actualiza");

            db.AddInParameter(dbCommand, "pIdProfile", DbType.Int32, pItem.IdProfile);
            db.AddInParameter(dbCommand, "pIdMenu", DbType.Int32, pItem.IdMenu);
            db.AddInParameter(dbCommand, "pFlagRead", DbType.Boolean, pItem.FlagRead);
            db.AddInParameter(dbCommand, "pFlagAdd", DbType.Boolean, pItem.FlagAdd);
            db.AddInParameter(dbCommand, "pFlagUpdate", DbType.Boolean, pItem.FlagUpdate);
            db.AddInParameter(dbCommand, "pFlagDelete", DbType.Boolean, pItem.FlagDelete);
            db.AddInParameter(dbCommand, "pFlagPrint", DbType.Boolean, pItem.FlagPrint);
            db.AddInParameter(dbCommand, "pFlagState", DbType.Boolean, pItem.FlagState);
            db.AddInParameter(dbCommand, "pLogin", DbType.String, pItem.Login);
            db.AddInParameter(dbCommand, "pMachine", DbType.String, pItem.Machine);
            db.AddInParameter(dbCommand, "pIdCompany", DbType.Int32, pItem.IdCompany);

            db.ExecuteNonQuery(dbCommand);
        }
コード例 #6
0
        void AddMenu(int IdMenu)
        {
            //verificar que no exista
            AccessBE Accesso = pListaAccess.Find(delegate(AccessBE _Acc)
            {
                if (_Acc.IdMenu == IdMenu)
                {
                    return true;
                }
                return false;
            });

            if (Accesso == null)
            {
                AccessBE Access = null;
                Access = new AccessBE();
                Access.IdProfile = IdProfile;
                Access.IdMenu = IdMenu;
                Access.FlagRead = true;
                Access.FlagAdd = true;
                Access.FlagUpdate = true;
                Access.FlagDelete = true;
                Access.FlagPrint = true;
                Access.FlagState = true;
                Access.TipOper = Convert.ToInt32(Operacion.Nuevo);
                pListaAccess.Add(Access);
            }
            else
            {
                if (IdProfile != 0)
                {
                    if (Accesso.TipOper != Convert.ToInt32(Operacion.Eliminar))
                    {
                        if (Accesso.TipOper == Convert.ToInt32(Operacion.Modificar))
                        { Accesso.TipOper = Convert.ToInt32(Operacion.Nuevo); }
                        if (Accesso.TipOper == Convert.ToInt32(Operacion.Consultar))
                        { Accesso.TipOper = Convert.ToInt32(Operacion.Nuevo); }
                    }
                }
            }
        }
コード例 #7
0
        void RemoveMenu(int IdMenu)
        {
            //Borrar en bloque
            AccessBE Access = pListaAccess.Find(delegate(AccessBE _Acc)
            {
                if (_Acc.IdMenu == IdMenu)
                {
                    return true;
                }
                return false;
            });
            if (Access != null)
            {
                if (Access.TipOper == Convert.ToInt32(Operacion.Nuevo))
                { Access.TipOper = Convert.ToInt32(Operacion.Consultar); }
                if (Access.TipOper == Convert.ToInt32(Operacion.Modificar) || Access.TipOper == Convert.ToInt32(Operacion.Consultar))
                    Access.TipOper = Convert.ToInt32(Operacion.Eliminar);

            }

        }
コード例 #8
0
        private void chkAllowRead_CheckedChanged(object sender, System.EventArgs e)
        {
            try
            {
                AccessBE Access = pListaAccess.Find(delegate(AccessBE _Acc)
                {
                    if (_Acc.IdMenu == menuID)
                    {
                        return true;
                    }
                    return false;
                });

                if (Access != null)
                {
                    CheckBox obj = new CheckBox();
                    obj = (CheckBox)sender;

                    AccessBE AccessMenu = pListaAccess.Find(delegate(AccessBE _Acc)
                    {
                        if (_Acc.IdMenu == menuID)
                        {
                            return true;
                        }
                        return false;
                    });

                    switch (obj.Name)
                    {
                        case "chkAllowRead":
                            if (IdProfile == 0)
                            {
                                if (AccessMenu != null)
                                {
                                    AccessMenu.FlagRead = chkAllowRead.Checked;
                                }
                            }
                            else
                            {
                                AccessMenu.FlagRead = chkAllowRead.Checked;

                                if (AccessMenu.TipOper == Convert.ToInt32(Operacion.Consultar))
                                    AccessMenu.TipOper = Convert.ToInt32(Operacion.Modificar);
                            }

                            break;
                        case "chkAllowWrite":
                            if (IdProfile == 0)
                            {
                                if (AccessMenu != null)
                                {
                                    AccessMenu.FlagAdd = chkAllowWrite.Checked;
                                }
                            }
                            else
                            {
                                AccessMenu.FlagAdd = chkAllowWrite.Checked;

                                if (AccessMenu.TipOper == Convert.ToInt32(Operacion.Consultar))
                                    AccessMenu.TipOper = Convert.ToInt32(Operacion.Modificar);
                            }

                            break;
                        case "chkAllowUpdate":
                            if (IdProfile == 0)
                            {
                                if (AccessMenu != null)
                                {
                                    AccessMenu.FlagUpdate = chkAllowUpdate.Checked;
                                }
                            }
                            else
                            {
                                AccessMenu.FlagUpdate = chkAllowUpdate.Checked;

                                if (AccessMenu.TipOper == Convert.ToInt32(Operacion.Consultar))
                                    AccessMenu.TipOper = Convert.ToInt32(Operacion.Modificar);
                            }
                            break;
                        case "chkAllowDelete":
                            if (IdProfile == 0)
                            {
                                if (AccessMenu != null)
                                {
                                    AccessMenu.FlagDelete = chkAllowDelete.Checked;
                                }
                            }
                            else
                            {
                                AccessMenu.FlagDelete = chkAllowDelete.Checked;

                                if (AccessMenu.TipOper == Convert.ToInt32(Operacion.Consultar))
                                    AccessMenu.TipOper = Convert.ToInt32(Operacion.Modificar);
                            }
                            break;
                        case "chkAllowPrint":
                            if (IdProfile == 0)
                            {
                                if (AccessMenu != null)
                                {
                                    AccessMenu.FlagPrint = chkAllowPrint.Checked;
                                }
                            }
                            else
                            {
                                AccessMenu.FlagPrint = chkAllowPrint.Checked;

                                if (AccessMenu.TipOper == Convert.ToInt32(Operacion.Consultar))
                                    AccessMenu.TipOper = Convert.ToInt32(Operacion.Modificar);
                            }
                            break;
                        default:
                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                Cursor = Cursors.Default;
                XtraMessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }