Пример #1
0
        public AulasForm(Usuario a)
        {
            user = a;
            InitializeComponent();
            //Cargar Elementos Necesarios
            try
            {
                edificios = db.getEdificios();
                this.cbEdificio.DataSource = edificios;
                this.cbEdificio.DisplayMember = "Descripcion";
                this.cbEdificio.ValueMember = "Id";

                aulatipos = db.getAulaTipos();
                this.cbTipo.DataSource = aulatipos;
                this.cbTipo.DisplayMember = "Descripcion";
                this.cbTipo.ValueMember = "Id";

                estados = db.getAulaEstado();
                this.cbEstado.DataSource = estados;
                this.cbEstado.DisplayMember = "Descripcion";
                this.cbEstado.ValueMember = "Id";

            }
            catch (Exception e)
            {

                MessageBox.Show(e.Message);
            }

            cantAulas = db.cantAulas();
            if (cantAulas!=0)
            {
                //cargar Lista de Aulas
                aulas = db.getAulas();

                cargarAulasDataGrid();
                this.txtId.DataBindings.Add("Text", AulasBindingSource, "Referencia");
                this.txtCapacidad.DataBindings.Add("Text", AulasBindingSource, "Capacidad");
                this.txtPiso.DataBindings.Add("Text", AulasBindingSource, "Piso");
                this.txtDescripcion.DataBindings.Add("Text", AulasBindingSource, "Nombre");

                sincronizarCombos();
                this.dgEquipos.CellEndEdit += dgEquipos_CellEndEdit;

                //Evento cuando se mueve el binding
                this.AulasBindingSource.PositionChanged+=new EventHandler(AulasBindingSource_PositionChanged);
                cargarEquipos();

            }
            editar(false);
        }
Пример #2
0
        public Menu_Principal(Usuario a)
        {
            InitializeComponent();
            usuario = a;
            labelNombre.Text = "Bienvenido "+ a.Nombre;
            if (a.Admin) {
                btnAdministrador.Visible = true;
                btnCrearSerie.Visible = true;
            }
            timer1_Tick(null, null);

            //Evento de escucha click usuario para cambiar contraseña
            this.labelNombre.Click += labelNombre_Click;
        }
Пример #3
0
 public void Borrar()
 {
     Usuario user = new Usuario();
     if (!this.txtCodUsuario.Text.Equals(""))
         user.Cod_Usua = Convert.ToInt32(this.txtCodUsuario.Text);
     try
     {
         db.borrarUsuario(user);
     }
     catch (Exception Ex)
     {
         MessageBox.Show("Hubo un problema al eliminar el registro");
     }
     finally
     {
     }
     cargarDataGrid();
 }
Пример #4
0
 public ControlNotificar(Aula a,Usuario user)
 {
     aula = a;
     usuario = user;
 }
Пример #5
0
        private Boolean guardarNotificacion()
        {
            //obtner inputs
            int id_aula = aula.Id;
            String descripcion = this.NotDescripcion.Text;
            DateTime fecha_evento = Convert.ToDateTime(this.dateTimeFecha.Text);
            DateTime fecha_recordatorio = Convert.ToDateTime(this.dateTimeRecordatorio.Text);
            String observaciones = this.NotObservacion.Text;
            int id_alerta_estado = Convert.ToInt32(this.cbAlertaEstado.SelectedValue);
            int usuario_emisor = this.usuario.Cod_Usua;
            int usuario_destinatario = Convert.ToInt32(this.cbDestinatario.SelectedValue);

            Alerta alerta = new Alerta();
            alerta.IdAula = id_aula;
            alerta.Aula = aula;
            alerta.Descripcion = descripcion;
            alerta.FechaEvento = fecha_evento;
            alerta.FechaRecordatorio = fecha_recordatorio;
            alerta.Observaciones = observaciones;
            alerta.IdAlertaEstado = id_alerta_estado;
            alerta.UsuarioEmisor = usuario_emisor;
            alerta.UsuarioDestinatario = usuario_destinatario;
            alerta.DescripcionEstado = this.cbAlertaEstado.Text;
            try
            {
                db.insertAlerta(alerta);
                destino = this.usuarios.Find(o=>o.Cod_Usua==usuario_destinatario);
                Email.send(usuario,destino, alerta);
                return true;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                return false;
            }
        }
Пример #6
0
        void loginControl_OnLogin(object sender, EventArgs e)
        {
            ThreadStart threadStart = delegate()
            {
                handleControls();
                List<Usuario> usuarios = db.getUsuario();
                try {

                    String user=loginControl.Username;
                    String pass=Encriptacion.EncryptPassphraseAlgorithm.EncryptSHA1(loginControl.Password);
                    if (usuarios!=null)
                    {
                        Usuario u = usuarios.Find(us => us.User.Equals(user) && us.Password.Equals(pass));
                        if (u != null)
                        {
                            usuario = u;
                            if (u.Active)
                                showEnvironment();
                            else {
                                MessageBox.Show("Usuario inactivo");
                            }
                        }
                        else
                        {
                            MessageBox.Show("El usuario o la contraseña introducidos son incorrectos.");
                        }
                    }
                }
                catch (System.Data.SqlClient.SqlException ex)
                {
                    MessageBox.Show("No se pudo establecer conexión con el servidor.");
                }
                finally {
                    handleControls();
                }
            };
            startLogin = new Thread(threadStart);
            startLogin.IsBackground = true;
            startLogin.Start();
        }
 public void setUsuario(Usuario usuario)
 {
     this.usuario = usuario;
 }
 public void setUsuario(Usuario usuario)
 {
     asignacionMultipleControl1.setUsuario(usuario);
 }
Пример #9
0
        public Boolean actualizarUsuario(Usuario Usuario)
        {
            this.connection.Open();
            this.command = this.connection.CreateCommand();
            this.transaction = this.connection.BeginTransaction();
            this.command.Connection = this.connection;
            this.command.Transaction = this.transaction;

            try
            {
                this.command.CommandText = "Update usuario set nombre=@nombre,email=@email,password=@pass,telf=@telefono,admin=@admin,usuario=@usuario,activo=@activo where cod_usua=@id;";
                this.command.Parameters.Add(new SqlParameter("@nombre", SqlDbType.NVarChar, 50));
                this.command.Parameters.Add(new SqlParameter("@id", SqlDbType.Int));
                this.command.Parameters.Add(new SqlParameter("@email", SqlDbType.NVarChar, 50));
                this.command.Parameters.Add(new SqlParameter("@pass", SqlDbType.NChar, 28));
                this.command.Parameters.Add(new SqlParameter("@telefono", SqlDbType.NVarChar, 50));
                this.command.Parameters.Add(new SqlParameter("@admin", SqlDbType.Bit));
                this.command.Parameters.Add(new SqlParameter("@usuario", SqlDbType.NVarChar, 30));
                this.command.Parameters.Add(new SqlParameter("@activo", SqlDbType.Bit));
                this.command.Parameters["@activo"].Value = Usuario.Active;
                this.command.Parameters["@pass"].Value = Usuario.Password;
                this.command.Parameters["@nombre"].Value = Usuario.Nombre;
                this.command.Parameters["@email"].Value = Usuario.Email;
                this.command.Parameters["@telefono"].Value = Usuario.Telefono;
                this.command.Parameters["@admin"].Value = Usuario.Admin;
                this.command.Parameters["@usuario"].Value = Usuario.User;
                this.command.Parameters["@id"].Value = Usuario.Cod_Usua;
                this.command.ExecuteNonQuery();
                this.transaction.Commit();
                return true;
            }
            catch (Exception e)
            {
                try
                {
                    this.transaction.Rollback();
                    throw new Exception("Error al Actualizar." + e.Message);
                    return false;
                }
                catch (Exception ex)
                {
                    throw new Exception("Error al rollback accion." + ex.Message);
                    return false;
                }
            }
            finally
            {
                this.connection.Close();
            }
        }
Пример #10
0
        public Boolean insertUsuario(Usuario Usuario,String password)
        {
            this.connection.Open();
            this.command = this.connection.CreateCommand();
            this.transaction = this.connection.BeginTransaction();
            this.command.Connection = this.connection;
            this.command.Transaction = this.transaction;

            try
            {
                this.command.CommandText = "insert into usuario(nombre,email,telf,admin,usuario,password,activo) values(@nombre,@email,@telefono,@admin,@usuario,@password,@activo);" + "SELECT CAST(scope_identity() AS int)";
                this.command.Parameters.Add(new SqlParameter("@nombre", SqlDbType.NVarChar, 50));
                this.command.Parameters.Add(new SqlParameter("@email", SqlDbType.NVarChar, 50));
                this.command.Parameters.Add(new SqlParameter("@telefono", SqlDbType.NVarChar, 50));
                this.command.Parameters.Add(new SqlParameter("@admin", SqlDbType.Bit));
                this.command.Parameters.Add(new SqlParameter("@usuario", SqlDbType.NVarChar, 30));
                this.command.Parameters.Add(new SqlParameter("@activo", SqlDbType.Bit));
                this.command.Parameters.Add(new SqlParameter("@password", SqlDbType.NVarChar, 28));

                this.command.Parameters["@nombre"].Value = Usuario.Nombre;
                this.command.Parameters["@email"].Value = Usuario.Email;
                this.command.Parameters["@telefono"].Value = Usuario.Telefono;
                this.command.Parameters["@admin"].Value = Usuario.Admin;
                this.command.Parameters["@usuario"].Value = Usuario.User;
                this.command.Parameters["@activo"].Value = Usuario.Active;
                this.command.Parameters["@password"].Value = password;

                this.lastUpdated = this.command.ExecuteScalar().ToString();
                this.transaction.Commit();
                return true;
            }
            catch (Exception e)
            {
                try
                {
                    transaction.Rollback();
                    throw new Exception("Error al insertar registro. " + e.Message);
                    return false;
                }
                catch (Exception ex)
                {
                    throw new Exception("Error al roolback accion. " + ex.Message);
                }
            }
            finally
            {
                this.connection.Close();
            }
        }
Пример #11
0
 /*--------------------FIN CATALOGO AlertaEstados------------------------*/
 /*--------------------Catalogo de Usuarios-------------------------*/
 public List<Usuario> getUsuario()
 {
     SqlDataReader dataReader = null;
     List<Usuario> UsuarioUsos = new List<Usuario>();
     try
     {
         string query = "Select * from usuario";
         command = new SqlCommand(query, connection);
         command.Connection.Open();
         dataReader = command.ExecuteReader();
         while (dataReader.Read())
         {
             int id = Convert.ToInt32(dataReader["cod_usua"].ToString());
             String nombre = dataReader["nombre"].ToString();
             Boolean active = Convert.ToBoolean(dataReader["activo"].ToString());
             Usuario usuario = new Usuario(id,nombre,active);
             usuario.Email=dataReader["email"].ToString();
             usuario.Telefono=dataReader["telf"].ToString();
             usuario.Admin=Convert.ToBoolean(dataReader["admin"]);
             usuario.User = dataReader["usuario"].ToString();
             usuario.Password = dataReader["password"].ToString();
             UsuarioUsos.Add(usuario);
         }
         return UsuarioUsos;
     }
     catch (Exception e)
     {
         return null;
         //throw new Exception("Error al obtener datos de Usuario. " + e.Message.ToString());
     }
     finally
     {
         command.Connection.Close();
     }
 }
Пример #12
0
        public Boolean cambiarPassword(Usuario usuario,String password)
        {
            this.connection.Open();
            this.command = this.connection.CreateCommand();
            this.transaction = this.connection.BeginTransaction();

            this.command.Connection = this.connection;
            this.command.Transaction = this.transaction;

            try
            {
                this.command.CommandText = "update usuario set password=@password where cod_usua=@id;";
                this.command.Parameters.Add(new SqlParameter("@id", SqlDbType.Int));
                this.command.Parameters.Add(new SqlParameter("@password", SqlDbType.NVarChar, 28));
                this.command.Parameters["@id"].Value = usuario.Cod_Usua;
                this.command.Parameters["@password"].Value = password;
                this.command.ExecuteNonQuery();
                this.transaction.Commit();
                return true;
            }
            catch (Exception e)
            {
                try
                {
                    this.transaction.Rollback();
                    throw new Exception("Error al borrar registro. " + e.Message);
                    return false;
                }
                catch (Exception ex)
                {
                    throw new Exception("Error al rollback acción. " + ex.Message);
                    return false;
                }
            }
            finally
            {
                this.connection.Close();
            }
        }
Пример #13
0
        public Boolean borrarUsuario(Usuario Usuario)
        {
            this.connection.Open();
            this.command = this.connection.CreateCommand();
            this.transaction = this.connection.BeginTransaction();

            this.command.Connection = this.connection;
            this.command.Transaction = this.transaction;

            try
            {
                this.command.CommandText = "delete from usuario where cod_usua=@id;";
                this.command.Parameters.Add(new SqlParameter("@id", SqlDbType.Int));
                this.command.Parameters["@id"].Value = Usuario.Cod_Usua;
                this.command.ExecuteNonQuery();
                this.transaction.Commit();
                return true;
            }
            catch (Exception e)
            {
                try
                {
                    this.transaction.Rollback();
                    throw new Exception("Error al borrar registro. " + e.Message);
                    return false;
                }
                catch (Exception ex)
                {
                    throw new Exception("Error al rollback acción. " + ex.Message);
                    return false;
                }
            }
            finally
            {
                this.connection.Close();
            }
        }
Пример #14
0
 public ChangePassword(Usuario user)
 {
     InitializeComponent();
     old = user.Password;
     this.user = user;
 }
Пример #15
0
        public Entorno(Usuario a)
        {
            InitializeComponent();

            this.bar1.Style = eDotNetBarStyle.Office2010;

            this.bar1.Location = new Point((Screen.PrimaryScreen.Bounds.Width / 2) - (this.bar1.Width / 2), this.bar1.Location.Y);
            //Abrir Menu-Principal
            this.SuspendLayout();
            usuario = a;
            _StartControl = new Menu_Principal(a);

            this.Controls.Add(_StartControl);
            _StartControl.BringToFront();
            _StartControl.SlideSide = DevComponents.DotNetBar.Controls.eSlideSide.Right;

            //Controles de eventos de la lista de Adminstrador
            //_StartControl.listAdmControlUsuarios.Click+=new EventHandler(listAdmControlUsuarios_Click);

            //Eventos de los botones de los controles
            this.btnNuevo.Click +=new EventHandler(btnNuevo_Click);
            this.btnGuardar.Click +=new EventHandler(btnGuardar_Click);
            this.btnEditar.Click +=new EventHandler(btnEditar_Click);
            this.btnBorrar.Click+=new EventHandler(btnBorrar_Click);
            this.btnCancelar.Click+=new EventHandler(btnCancelar_Click);

                //navegacion
            this.btnPrimero.Click+=new EventHandler(btnPrimero_Click);
            this.btnAnterior.Click+=new EventHandler(btnAnterior_Click);
            this.btnSiguiente.Click+=new EventHandler(btnSiguiente_Click);
            this.btnUltimo.Click+=new EventHandler(btnUltimo_Click);
            this.btnBuscar.Click+=new EventHandler(btnBuscar_Click);

            /*------------Manejadores de Eventos del Menu Principal---------*/
            _StartControl.btnCrearSerie.Click+=new EventHandler(btnCrearSerie_Click);
            _StartControl.btnVerCalendario.Click+=new EventHandler(btnVerCalendario_Click);
            //_StartControl.btnComunicacion.Click += btnComunicacion_Click;

            _StartControl.listCatFacultad.Click += new EventHandler(listCatFacultad_Click);
            _StartControl.listCatEdificios.Click+=new EventHandler(listCatEdificios_Click);
            _StartControl.listCatDocentes.Click += new EventHandler(listCatDocentes_Click);
            _StartControl.listCatPeriodos.Click += new EventHandler(listCatPeriodos_Click);
            _StartControl.listCatAsignaturaCategorias.Click += new EventHandler(listCatAsignaturaCategorias_Click);
            _StartControl.listCatAsignaturas.Click += new EventHandler(listCatAsignaturas_Click);
            _StartControl.listCatAulaEstados.Click+=new EventHandler(listCatAulaEstados_Click);
            _StartControl.listCatAulaTipos.Click+=new EventHandler(listCatAulaTipos_Click);
            _StartControl.listCatAulaTipoUsos.Click += new EventHandler(listCatAulaTipoUsos_Click);
            _StartControl.listCatAulas.Click+=new EventHandler(listCatAulas_Click);
            _StartControl.listCatAlertaEstados.Click += listCatAlertaEstados_Click;
            _StartControl.listCatEquipos.Click += listCatEquipos_Click;
            _StartControl.lbCantidadNotificaciones.Click+=lbCantidadNotificaciones_Click;
            _StartControl.listAdmControlUsuarios.Click+=listAdmControlUsuarios_Click;
            /*----------------------FIN MENU PRINCIPAL---------------------*/

            this.KeyDown += Entorno_KeyDown;

            this.ResumeLayout(false);

            if (!usuario.Admin)
            {
                this.btnEditar.Enabled = false;
                this.btnBorrar.Enabled = false;
                this.btnNuevo.Enabled = false;
            }
        }
Пример #16
0
 public bool Guardar()
 {
     Boolean guardado = false;
     if (valUsuario.Validate()) {
         try
         {
             Usuario user=new Usuario();
             if(!this.txtCodUsuario.Text.Equals(""))
                 user.Cod_Usua=Convert.ToInt32(this.txtCodUsuario.Text);
             user.Nombre=this.txtNombre.Text;
             user.Email=this.txtEmail.Text;
             user.Telefono=this.txtTelefono.Text;
             user.Admin=this.chkAdmin.Checked;
             user.User=this.txtUser.Text.TrimEnd();
             if (oldPass.Trim() != txtPassword.Text.Trim())
             {
                 user.Password = Encriptacion.EncryptPassphraseAlgorithm.EncryptSHA1(txtPassword.Text.Trim());
             }
             else
             {
                 user.Password = oldPass;
             }
             user.Active = this.chkActivo.Checked;
             if (!n) {
                 db.actualizarUsuario(user);
             }
             else
             {
                db.insertUsuario(user,user.Password);
             }
             MessageBox.Show("Guardado");
             cargarDataGrid();
             lectura();
             guardado = true;
         }
         catch (Exception ex) {
             guardado = false;
         }
         finally {
             n = false;
         }
     }
     return guardado;
 }