private void CrearOferta_Load(object sender, EventArgs e) { esProveedor = ProveedorDAO.esProveedorHabilitado(usuario); dateTimePicker2.MinDate = utils.obtenerFecha(); dateTimePicker2.Value = utils.obtenerFecha(); dateTimePicker1.MinDate = utils.obtenerFecha(); dateTimePicker1.Value = utils.obtenerFecha().AddDays(1); if (usuario.roles.Any(rol => DBConnection.isAdmin(rol))) { List <Proveedor> proveedores = ProveedorDAO.getProveedores(); foreach (Proveedor p in proveedores) { if (p.habilitada) { ComboboxItem item = new ComboboxItem(p.razon_social, p); comboBoxProveedor.Items.Add(item); } } if (comboBoxProveedor.Items.Count > 0) { comboBoxProveedor.SelectedIndex = 0; } else { MessageBox.Show("Parece que no hay proveedores disponibles"); } } else if (esProveedor) { labelProveedor.Hide(); comboBoxProveedor.Hide(); } }
private void MenuAdministrador_Load(object sender, EventArgs e) { UsuarioDAO.cargarRolesUsuario(usuario); foreach (Button button in this.Controls.OfType <Button>()) { button.Visible = false; } label_credito.Visible = false; var texto_roles = new System.Text.StringBuilder(); if (usuario.roles.Count == 1) { texto_roles.AppendLine("Tiene activado el rol: "); } else { texto_roles.AppendLine("Tiene activado los roles: "); } // Cargamos los botones con funcionalidades segun rol foreach (Rol rol in usuario.roles) { texto_roles.AppendLine(" " + rol.nombre); DBConnection.asociar_roles_x_funciones(rol); if (rol.funcionalidades.Exists(f => f.nombre.Contains("Comprar"))) { label_credito.Visible = true; buttonCupones.Visible = true; label_credito.Text = "Su crédito es: \n" + ClienteDAO.montoUsuario(usuario).ToString(); } if (DBConnection.isAdmin(rol)) { button4.Visible = true; button12.Visible = true; button13.Visible = true; } if (DBConnection.isCliente(rol) && !ClienteDAO.esClienteHabilitado(usuario)) { button9.Enabled = false; button10.Enabled = false; MessageBox.Show("Tus funcionalidades como cliente estan restringidas. Si es un error, ponerse en contacto con un administrador"); } if (DBConnection.isProveedor(rol) && !ProveedorDAO.esProveedorHabilitado(usuario)) { button5.Enabled = false; MessageBox.Show("Tus funcionalidades como proveedor estan restringidas. Si es un error, ponerse en contacto con un administrador"); } foreach (Funcionalidad f in rol.funcionalidades) { foreach (Button button in this.Controls.OfType <Button>()) { //Si hay alguna funcionalidad que coincide con un buton button.Name = button.Text; if (button.Name == f.nombre) { button.Visible = true; } } } } //Funciones disponibles independientemente de los roles btn_cerrarsesion.Visible = true; label3.Text = "Su usuario es: \n" + usuario.username; labelroles.Text = texto_roles.ToString(); //cambiar contrasenia y agregar roles button8.Visible = true; }