Пример #1
0
        public bool SesionLimpieza()
        {
            bool existe = false;

            using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
            {
                string   usu    = textBoxUsuario.Text;
                string   con    = textBoxContrasenia.Text;
                Limpieza nuevog = DB.Limpieza.Find(usu);
                if (nuevog == null)
                {
                    lblError.Visible = true;
                }
                else
                {
                    if (nuevog.contrasenia == con)
                    {
                        existe = true;
                    }
                    else
                    {
                        lblError.Visible = true;
                    }
                }
            }

            return(existe);
        }
 private void LlenarCamposUsuario(string id)
 {
     lblUsuario.Text = id;
     using (var DB = new SistemaHotelWaraEntitiesV1())
     {
         Limpieza nuevo = DB.Limpieza.Find(id);
         lblNombre.Text = nuevo.nombre + " " + nuevo.paterno + " " + nuevo.materno;
     }
 }
 private void buttonRecuperar_Click(object sender, EventArgs e)
 {
     if (txtContrasenia.Text == txtConfirmar.Text && txtConfirmar.Text != "" && txtContrasenia.Text != "")
     {
         using (var DB = new SistemaHotelWaraEntitiesV1())
         {
             if (Cargo == "R")
             {
                 Recepcionista nuevo = DB.Recepcionista.Find(idEmpleado);
                 nuevo.contrasenia     = txtContrasenia.Text;
                 DB.Entry(nuevo).State = System.Data.Entity.EntityState.Modified;
                 DB.SaveChanges();
                 MessageBox.Show("La contraseña se cambio con exito!");
                 this.Close();
             }
             else if (Cargo == "G")
             {
                 Gerente nuevo = DB.Gerente.Find(idEmpleado);
                 nuevo.contrasenia     = txtContrasenia.Text;
                 DB.Entry(nuevo).State = System.Data.Entity.EntityState.Modified;
                 DB.SaveChanges();
                 MessageBox.Show("La contraseña se cambio con exito!");
                 this.Close();
             }
             else if (Cargo == "L")
             {
                 Limpieza nuevo = DB.Limpieza.Find(idEmpleado);
                 nuevo.contrasenia     = txtContrasenia.Text;
                 DB.Entry(nuevo).State = System.Data.Entity.EntityState.Modified;
                 DB.SaveChanges();
                 MessageBox.Show("La contraseña se cambio con exito!");
                 this.Close();
             }
             else if (Cargo == "M")
             {
                 Mantenimiento nuevo = DB.Mantenimiento.Find(idEmpleado);
                 nuevo.contrasenia     = txtContrasenia.Text;
                 DB.Entry(nuevo).State = System.Data.Entity.EntityState.Modified;
                 DB.SaveChanges();
                 MessageBox.Show("La contraseña se cambio con exito!");
                 this.Close();
             }
         }
     }
     else
     {
         MessageBox.Show("Las contraseñas deben coincidir en ambos campos o no estar vacios!");
     }
 }
 public OlvidasteConstrasenia(string id, string Empleado)
 {
     InitializeComponent();
     idEmpleado = id;
     Cargo      = Empleado;
     using (var DB = new SistemaHotelWaraEntitiesV1())
     {
         if (Empleado == "R")
         {
             Recepcionista nuevo = DB.Recepcionista.Find(id);
             lblPregunta.Text  = nuevo.preguntaRecu;
             respuestaCorrecta = nuevo.respuestaRecu;
         }
         else if (Empleado == "G")
         {
             Gerente nuevo = DB.Gerente.Find(id);
             lblPregunta.Text  = nuevo.preguntaRecu;
             respuestaCorrecta = nuevo.respuestaRecu;
         }
         else if (Empleado == "L")
         {
             Limpieza nuevo = DB.Limpieza.Find(id);
             lblPregunta.Text  = nuevo.preguntaRecu;
             respuestaCorrecta = nuevo.respuestaRecu;
         }
         else if (Empleado == "M")
         {
             Mantenimiento nuevo = DB.Mantenimiento.Find(id);
             lblPregunta.Text  = nuevo.preguntaRecu;
             respuestaCorrecta = nuevo.respuestaRecu;
         }
         else
         {
             MessageBox.Show("Error con el cargo del empleado");
         }
     }
 }
Пример #5
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text != "NOMBRE" && txtPaterno.Text != "PATERNO" && txtMaterno.Text != "MATERNO" && txtEmail.Text != "E-MAIL" && txtPregunta.Text != "PREGUNTA RECUPERACIÓN" && txtRespuesta.Text != "RESPUESTA RECUPERACIÓN" && txtTelefono.Text != "TELEFONO")
            {
                try
                {
                    switch (cbTipoEmpleado.SelectedIndex)
                    {
                    case 0:
                        using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                        {
                            Gerente nuevog = new Gerente();
                            nuevog.idEmpleado      = lblUsuario.Text;
                            nuevog.contrasenia     = lblContra.Text;
                            nuevog.nombre          = txtNombre.Text;
                            nuevog.paterno         = txtPaterno.Text;
                            nuevog.materno         = txtMaterno.Text;
                            nuevog.email           = txtEmail.Text;
                            nuevog.telefono        = txtTelefono.Text;
                            nuevog.preguntaRecu    = txtPregunta.Text;
                            nuevog.respuestaRecu   = txtRespuesta.Text;
                            nuevog.fechaNacimiento = dtpFechaNacimiento.Value;
                            DB.Gerente.Add(nuevog);
                            DB.SaveChanges();
                            MessageBox.Show("EMPLEADO CREADO CON EXITO!");
                            limpiarCampos();
                        }
                        break;

                    case 1:
                        using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                        {
                            Recepcionista nuevog = new Recepcionista();
                            nuevog.idEmpleado      = lblUsuario.Text;
                            nuevog.contrasenia     = lblContra.Text;
                            nuevog.nombre          = txtNombre.Text;
                            nuevog.paterno         = txtPaterno.Text;
                            nuevog.materno         = txtMaterno.Text;
                            nuevog.email           = txtEmail.Text;
                            nuevog.telefono        = txtTelefono.Text;
                            nuevog.preguntaRecu    = txtPregunta.Text;
                            nuevog.respuestaRecu   = txtRespuesta.Text;
                            nuevog.fechaNacimiento = dtpFechaNacimiento.Value;
                            DB.Recepcionista.Add(nuevog);
                            DB.SaveChanges();
                            MessageBox.Show("EMPLEADO CREADO CON EXITO!");
                            limpiarCampos();
                        }
                        break;

                    case 2:
                        using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                        {
                            Limpieza nuevog = new Limpieza();
                            nuevog.idEmpleado      = lblUsuario.Text;
                            nuevog.contrasenia     = lblContra.Text;
                            nuevog.nombre          = txtNombre.Text;
                            nuevog.paterno         = txtPaterno.Text;
                            nuevog.materno         = txtMaterno.Text;
                            nuevog.email           = txtEmail.Text;
                            nuevog.telefono        = txtTelefono.Text;
                            nuevog.preguntaRecu    = txtPregunta.Text;
                            nuevog.respuestaRecu   = txtRespuesta.Text;
                            nuevog.fechaNacimiento = dtpFechaNacimiento.Value;
                            DB.Limpieza.Add(nuevog);
                            DB.SaveChanges();
                            MessageBox.Show("EMPLEADO CREADO CON EXITO!");
                            limpiarCampos();
                        }
                        break;

                    case 3:
                        using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                        {
                            Mantenimiento nuevog = new Mantenimiento();
                            nuevog.idEmpleado      = lblUsuario.Text;
                            nuevog.contrasenia     = lblContra.Text;
                            nuevog.nombre          = txtNombre.Text;
                            nuevog.paterno         = txtPaterno.Text;
                            nuevog.materno         = txtMaterno.Text;
                            nuevog.email           = txtEmail.Text;
                            nuevog.telefono        = txtTelefono.Text;
                            nuevog.preguntaRecu    = txtPregunta.Text;
                            nuevog.respuestaRecu   = txtRespuesta.Text;
                            nuevog.fechaNacimiento = dtpFechaNacimiento.Value;
                            DB.Mantenimiento.Add(nuevog);
                            DB.SaveChanges();
                            MessageBox.Show("EMPLEADO CREADO CON EXITO!");
                            limpiarCampos();
                        }
                        break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("ERROR CON LA LLAVE PRIMARIA: " + ex.Message);
                }
            }
            else
            {
                lblError.Visible = true;
            }
        }
        private void btnModificar_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text != "NOMBRE" && txtPaterno.Text != "PATERNO" && txtMaterno.Text != "MATERNO" && txtEmail.Text != "E-MAIL" && txtPregunta.Text != "PREGUNTA RECUPERACIÓN" && txtRespuesta.Text != "RESPUESTA RECUPERACIÓN" && txtTelefono.Text != "TELEFONO")
            {
                try
                {
                    switch (lblUsuario.Text[0])
                    {
                    case 'G':
                        using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                        {
                            Gerente nuevog = new Gerente();
                            nuevog.idEmpleado      = lblUsuario.Text;
                            nuevog.contrasenia     = lblContra.Text;
                            nuevog.nombre          = txtNombre.Text;
                            nuevog.paterno         = txtPaterno.Text;
                            nuevog.materno         = txtMaterno.Text;
                            nuevog.email           = txtEmail.Text;
                            nuevog.telefono        = txtTelefono.Text;
                            nuevog.preguntaRecu    = txtPregunta.Text;
                            nuevog.respuestaRecu   = txtRespuesta.Text;
                            nuevog.fechaNacimiento = dtpFechaNacimiento.Value;
                            DB.Entry(nuevog).State = System.Data.Entity.EntityState.Modified;
                            DB.SaveChanges();
                            MessageBox.Show("EMPLEADO MODIFICADO CON EXITO!");
                            limpiarCampos();
                            CargarGerentes("");
                        }
                        break;

                    case 'R':
                        using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                        {
                            Recepcionista nuevog = new Recepcionista();
                            nuevog.idEmpleado      = lblUsuario.Text;
                            nuevog.contrasenia     = lblContra.Text;
                            nuevog.nombre          = txtNombre.Text;
                            nuevog.paterno         = txtPaterno.Text;
                            nuevog.materno         = txtMaterno.Text;
                            nuevog.email           = txtEmail.Text;
                            nuevog.telefono        = txtTelefono.Text;
                            nuevog.preguntaRecu    = txtPregunta.Text;
                            nuevog.respuestaRecu   = txtRespuesta.Text;
                            nuevog.fechaNacimiento = dtpFechaNacimiento.Value;
                            DB.Entry(nuevog).State = System.Data.Entity.EntityState.Modified;
                            DB.SaveChanges();
                            MessageBox.Show("EMPLEADO MODIFICADO CON EXITO!");
                            limpiarCampos();
                            CargarRecepcionista("");
                        }
                        break;

                    case 'L':
                        using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                        {
                            Limpieza nuevog = new Limpieza();
                            nuevog.idEmpleado      = lblUsuario.Text;
                            nuevog.contrasenia     = lblContra.Text;
                            nuevog.nombre          = txtNombre.Text;
                            nuevog.paterno         = txtPaterno.Text;
                            nuevog.materno         = txtMaterno.Text;
                            nuevog.email           = txtEmail.Text;
                            nuevog.telefono        = txtTelefono.Text;
                            nuevog.preguntaRecu    = txtPregunta.Text;
                            nuevog.respuestaRecu   = txtRespuesta.Text;
                            nuevog.fechaNacimiento = dtpFechaNacimiento.Value;
                            DB.Entry(nuevog).State = System.Data.Entity.EntityState.Modified;
                            DB.SaveChanges();
                            MessageBox.Show("EMPLEADO MODIFICADO CON EXITO!");
                            limpiarCampos();
                            CargarLimpieza("");
                        }
                        break;

                    case 'M':
                        using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                        {
                            Mantenimiento nuevog = new Mantenimiento();
                            nuevog.idEmpleado      = lblUsuario.Text;
                            nuevog.contrasenia     = lblContra.Text;
                            nuevog.nombre          = txtNombre.Text;
                            nuevog.paterno         = txtPaterno.Text;
                            nuevog.materno         = txtMaterno.Text;
                            nuevog.email           = txtEmail.Text;
                            nuevog.telefono        = txtTelefono.Text;
                            nuevog.preguntaRecu    = txtPregunta.Text;
                            nuevog.respuestaRecu   = txtRespuesta.Text;
                            nuevog.fechaNacimiento = dtpFechaNacimiento.Value;
                            DB.Entry(nuevog).State = System.Data.Entity.EntityState.Modified;
                            DB.SaveChanges();
                            MessageBox.Show("EMPLEADO MODIFICADO CON EXITO!");
                            limpiarCampos();
                            CargarMantenimiento("");
                        }
                        break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("ERROR CON LA LLAVE PRIMARIA: " + ex.Message);
                }
            }
            else
            {
                lblError.Visible = true;
            }
        }
Пример #7
0
        private void btnDespedir_Click(object sender, EventArgs e)
        {
            if (lblUsuario.Text != "USUARIO")
            {
                try
                {
                    switch (lblUsuario.Text[0])
                    {
                    case 'G':
                        using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                        {
                            Gerente nuevog = DB.Gerente.Find(lblUsuario.Text);
                            DB.Gerente.Remove(nuevog);
                            DB.SaveChanges();
                            MessageBox.Show("EMPLEADO ELIMINADO CON EXITO!");
                            limpiarCampos();
                            CargarGerentes("");
                        }
                        break;

                    case 'R':
                        using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                        {
                            Recepcionista nuevog = DB.Recepcionista.Find(lblUsuario.Text);
                            DB.Recepcionista.Remove(nuevog);
                            DB.SaveChanges();
                            MessageBox.Show("EMPLEADO ELIMINADO CON EXITO!");
                            limpiarCampos();
                            CargarRecepcionista("");
                        }
                        break;

                    case 'L':
                        using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                        {
                            Limpieza nuevog = DB.Limpieza.Find(lblUsuario.Text);
                            DB.Limpieza.Remove(nuevog);
                            DB.SaveChanges();
                            MessageBox.Show("EMPLEADO ELIMINADO CON EXITO!");
                            limpiarCampos();
                            CargarLimpieza("");
                        }
                        break;

                    case 'M':
                        using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                        {
                            Mantenimiento nuevog = DB.Mantenimiento.Find(lblUsuario.Text);
                            DB.Mantenimiento.Remove(nuevog);
                            DB.SaveChanges();
                            MessageBox.Show("EMPLEADO ELIMINADO CON EXITO!");
                            limpiarCampos();
                            CargarMantenimiento("");
                        }
                        break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("ERROR CON LA LLAVE PRIMARIA: " + ex.Message);
                }
            }
            else
            {
                lblError.Visible = true;
            }
        }
Пример #8
0
        private void btnDespedir_Click(object sender, EventArgs e)
        {
            if (lblUsuario.Text == idEmpleadoConectado)
            {
                DialogResult resulta = MessageBox.Show("¿Esta seguro que desea dejar su cargo?", "Mensaje de Confirmacion", MessageBoxButtons.YesNo);
                if (resulta == DialogResult.Yes)
                {
                    try
                    {
                        using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                        {
                            Gerente nuevog = DB.Gerente.Find(lblUsuario.Text);
                            DB.Gerente.Remove(nuevog);
                            DB.SaveChanges();
                            MessageBox.Show("SU CARGO AH SIDO REMOVIDO CON EXITO! HASTA LUEGO...");
                            Application.Exit();
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
                else
                {
                    DialogResult result = MessageBox.Show("Esta seguro que desea despedirlo?", "Mensaje de Confirmacion", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {
                        if (lblUsuario.Text != "USUARIO")
                        {
                            try
                            {
                                switch (lblUsuario.Text[0])
                                {
                                case 'G':
                                    using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                                    {
                                        Gerente nuevog = DB.Gerente.Find(lblUsuario.Text);
                                        DB.Gerente.Remove(nuevog);
                                        DB.SaveChanges();
                                        MessageBox.Show("EMPLEADO ELIMINADO CON EXITO!");
                                        limpiarCampos();
                                        CargarGerentes("");
                                    }
                                    break;

                                case 'R':
                                    using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                                    {
                                        Recepcionista nuevog = DB.Recepcionista.Find(lblUsuario.Text);
                                        DB.Recepcionista.Remove(nuevog);
                                        DB.SaveChanges();
                                        MessageBox.Show("EMPLEADO ELIMINADO CON EXITO!");
                                        limpiarCampos();
                                        CargarRecepcionista("");
                                    }
                                    break;

                                case 'L':
                                    using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                                    {
                                        Limpieza nuevog = DB.Limpieza.Find(lblUsuario.Text);
                                        DB.Limpieza.Remove(nuevog);
                                        DB.SaveChanges();
                                        MessageBox.Show("EMPLEADO ELIMINADO CON EXITO!");
                                        limpiarCampos();
                                        CargarLimpieza("");
                                    }
                                    break;

                                case 'M':
                                    using (SistemaHotelWaraEntitiesV1 DB = new SistemaHotelWaraEntitiesV1())
                                    {
                                        Mantenimiento nuevog = DB.Mantenimiento.Find(lblUsuario.Text);
                                        DB.Mantenimiento.Remove(nuevog);
                                        DB.SaveChanges();
                                        MessageBox.Show("EMPLEADO ELIMINADO CON EXITO!");
                                        limpiarCampos();
                                        CargarMantenimiento("");
                                    }
                                    break;
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("ERROR CON LA LLAVE PRIMARIA: " + ex.Message);
                            }
                        }
                        else
                        {
                            lblError.Visible = true;
                        }
                    }
                }
            }
        }