Пример #1
0
        private void Rol_Detalle_Load(object sender, System.EventArgs e)
        {
            RolService rolService = (RolService)ServiceFactory.GetService("Rol");

            list_funcionalidades.DataSource = rolService.getAllFuncionalidades();
            textBox_nombre.Text             = rol.Nombre;

            if (rol.Estado)
            {
                habilitado.CheckState = CheckState.Checked;
            }

            for (int i = 0; i < list_funcionalidades.Items.Count; i++)
            {
                Funcionalidad fun = (Funcionalidad)list_funcionalidades.Items[i];
                foreach (Funcionalidad fun_rol in rol.GetFuncionalidades())
                {
                    if (fun_rol.GetId().Equals(fun.GetId()))
                    {
                        list_funcionalidades.SetItemChecked(i, true);
                        fun.SetEstado(Funcionalidad.EstadoFuncionalidad.SIN_CAMBIOS);
                    }
                }
            }
        }
Пример #2
0
        public void saveRol(Rol rol)
        {
            DatabaseEntity dbEntity     = new DatabaseEntity();
            int            rol_nuevo_id = dbEntity.spExecuteScalar("ESECUELE.SaveRol", new List <SqlParameter>
            {
                new SqlParameter("@rol_nombre_nuevo", rol.Nombre)
            });

            DataTable dt = new DataTable("Nuevo_rol");

            dt.Columns.Add("frol_rol_id", typeof(int));
            dt.Columns.Add("frol_func_id", typeof(int));

            foreach (Funcionalidad funcionalidad in rol.GetFuncionalidades())
            {
                dt.Rows.Add(rol_nuevo_id, funcionalidad.GetId());
            }

            var sqlParam = new SqlParameter("@func_nuevo_rol", SqlDbType.Structured);

            sqlParam.Value = dt;
            dbEntity.spExecute("ESECUELE.SaveRolFuncionalidades", new List <SqlParameter> {
                sqlParam
            });
        }
Пример #3
0
        private void agregarFuncionalidades(Rol rol)
        {
            Panel panelFuncionalidades = new Panel();

            panelFuncionalidades.AutoSize = true;
            this.AutoSizeMode             = AutoSizeMode.GrowAndShrink;

            panelFuncionalidades.Location = new Point(this.Width / 10, this.Height / 6);

            int totalHeight = this.Height / 6 + 80;
            int buttonLeft  = 12;
            int buttonTop   = 20;
            int i           = 0;

            foreach (Funcionalidad f in rol.GetFuncionalidades())
            {
                Button newButton = new Button();
                newButton.Text      = f.GetDescripcion();
                newButton.Name      = f.GetNombre();
                newButton.BackColor = System.Drawing.SystemColors.Highlight;
                newButton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
                newButton.Font      = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                newButton.ForeColor = System.Drawing.SystemColors.Window;
                newButton.Margin    = new System.Windows.Forms.Padding(0);
                newButton.Size      = new System.Drawing.Size(200, 52);
                newButton.UseVisualStyleBackColor = false;
                totalHeight = totalHeight + 35;
                i++;
                if (i > rol.GetFuncionalidades().Count / 2)
                {
                    buttonTop  = 20;
                    buttonLeft = 250;
                    i          = 0;
                }

                newButton.Top      = buttonTop;
                newButton.Left     = buttonLeft;
                newButton.AutoSize = true;
                newButton.Click   += (s, e) =>
                {
                    if (f.GetNombre() == "Empresa_Registro" || f.GetNombre() == "Cliente_Registro")
                    {
                        Registro registro = new Registro(this);
                        registro.Show();
                        this.Hide();
                    }
                    else
                    {
                        Master funcForm = Utilities.createInstance("PalcoNet.Src.Forms.Vistas." +
                                                                   rol.Nombre + "." + f.GetNombre()) as Master;
                        if (funcForm == null)
                        {
                            funcForm = Utilities.createInstance("PalcoNet.Src.Forms.Vistas.Administrador" + "." + f.GetNombre()) as Master;
                        }
                        if (f.GetNombre() == "Cliente_Edicion")
                        {
                            funcForm = new Cliente_Edicion(this.user);
                            ((Cliente_Edicion)funcForm).fromMenu = true;
                        }

                        if (f.GetNombre() == "Empresa_Edicion")
                        {
                            funcForm = new Empresa_Edicion(this.user);
                            ((Empresa_Edicion)funcForm).fromMenu = true;
                        }
                        funcForm.setPrevious(this);
                        funcForm.setUsuario(this.user);
                        funcForm.Show();
                        this.Hide();
                    }
                };

                buttonTop += (newButton.Height + 24);
                panelFuncionalidades.Controls.Add(newButton);
            }
            this.Controls.Add(panelFuncionalidades);
            this.Refresh();
            //
            // menuPrincipalSalir
            //
            Button menuPrincipalSalir = new Button();

            menuPrincipalSalir.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
            menuPrincipalSalir.Font      = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            menuPrincipalSalir.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
            menuPrincipalSalir.Location  = new System.Drawing.Point(480, Math.Max(totalHeight, 320));
            menuPrincipalSalir.Margin    = new System.Windows.Forms.Padding(4, 5, 25, 25);
            menuPrincipalSalir.Name      = "menuPrincipalSalir";
            menuPrincipalSalir.Size      = new System.Drawing.Size(120, 40);
            menuPrincipalSalir.TabIndex  = 2;
            menuPrincipalSalir.Text      = "Salir";
            menuPrincipalSalir.UseVisualStyleBackColor = true;
            menuPrincipalSalir.Click += new System.EventHandler(this.menuPrincipalSalir_Click);
            this.Controls.Add(menuPrincipalSalir);
            this.Refresh();
        }