Пример #1
0
        //Metodos

        public List <Huespe> Listar()
        {
            List <Huespe> lista = new List <Huespe>();

            using (SqlConnection con = new SqlConnection(CadenaConexion))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("ListarHuesped", con);
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr != null && dr.HasRows)
                {
                    while (dr.Read())
                    {
                        Huespe c = new Huespe(
                            (int)dr["Id"],
                            (string)dr["Nombre"],
                            (string)dr["PrimerApellido"],
                            (string)dr["SegundoApellido"],
                            (string)dr["NoDocumento"],
                            (string)dr["TelefonoFijo"],
                            (string)dr["Celular"],
                            (string)dr["Correo"],
                            (string)dr["FechaNacimiento"]// Convert.ToString()

                            );
                        lista.Add(c);
                    }
                }
            }
            return(lista);
        }
Пример #2
0
        public Huespe TraerPorId(int Id)
        {
            Huespe Huespe = new Huespe();

            using (SqlConnection con = new SqlConnection(CadenaConexion))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("TraerCHuespedPorId", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ID", Id);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr != null && dr.HasRows)
                {
                    dr.Read();
                    Huespe = new Huespe(
                        (int)dr["Id"],
                        (string)dr["Nombre"],
                        (string)dr["PrimerApellido"],
                        (string)dr["SegundoApellido"],
                        (string)dr["NoDocumento"],
                        (string)dr["TelefonoFijo"],
                        (string)dr["Celular"],
                        (string)dr["Correo"],
                        (string)dr["FechaNacimiento"]
                        );
                }
            }

            return(Huespe);
        }
Пример #3
0
        private void BtnEditar_Click(object sender, EventArgs e)
        {
            _nuevo = false;
            if (btnEditar.Text == "Cancelar")
            {
                LimpiarControl(gbDatos); ActivarControlDatos(gbDatos, false);
                ActivarButton(true);
                dgvDatos.Enabled = true;
                btnEditar.Text   = "Editar";
            }
            else
            {
                if (dgvDatos.RowCount > 0)
                {
                    c = blHuesped.TraerPorId((int)dgvDatos[0, dgvDatos.CurrentRow.Index].Value);
                    txtNombre.Text           = c.Nombre;
                    txtPrimerApellido.Text   = c.PrimerApellido;
                    textSegundoApellido.Text = c.SegundoApellido;
                    textNoDocumento.Text     = c.NoDocumento;
                    textTelefonoFijo.Text    = c.TelefonoFijo;
                    textCelular.Text         = c.Celular;
                    textCorreo.Text          = c.Correo;
                    textFechaNacimiento.Text = c.FechaNacimiento;

                    ActivarControlDatos(gbDatos, true);
                    ActivarButton(false);
                    dgvDatos.Enabled = false;
                    btnEditar.Text   = "Cancelar";
                }
            }
        }
Пример #4
0
        private void BtnGrabar_Click(object sender, EventArgs e)
        {
            int n = -1;

            if (_nuevo)
            {
                c = new Huespe(0,
                               txtNombre.Text,
                               txtPrimerApellido.Text,
                               textSegundoApellido.Text,
                               textNoDocumento.Text,
                               textTelefonoFijo.Text,
                               textCelular.Text,
                               textCorreo.Text,
                               textFechaNacimiento.Text

                               );
                n = blHuesped.Insertar(c);
            }
            else
            {
                c.Nombre          = txtNombre.Text;
                c.PrimerApellido  = txtPrimerApellido.Text;
                c.SegundoApellido = textSegundoApellido.Text;
                c.NoDocumento     = textNoDocumento.Text;
                c.TelefonoFijo    = textTelefonoFijo.Text;
                c.Celular         = textCelular.Text;
                c.Correo          = textCorreo.Text;
                c.FechaNacimiento = textFechaNacimiento.Text;
                n = blHuesped.Actualizar(c);
            }
            if (n > 0)
            {
                MessageBox.Show("Datos Cliente grabados Correctamente", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ActivarControlDatos(gbDatos, false);
                ActivarButton(true);
                dgvDatos.Enabled = true;
                LimpiarControl(gbDatos);
                btnEditar.Text = "Editar";
                lista          = blHuesped.Listar();
                CargarDatos();
            }
            else
            {
                MessageBox.Show("Error al grabar Cliente", "Aviso",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #5
0
        public int Insertar(Huespe Huespe)
        {
            int n = -1;

            using (SqlConnection con = new SqlConnection(CadenaConexion))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("InsertarHuesped", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Nombre", Huespe.Nombre);
                cmd.Parameters.AddWithValue("@PrimerApellido", Huespe.PrimerApellido);
                cmd.Parameters.AddWithValue("@SegundoApellido", Huespe.SegundoApellido);
                cmd.Parameters.AddWithValue("@NoDocumento", Huespe.Celular);
                cmd.Parameters.AddWithValue("@TelefonoFijo", Huespe.TelefonoFijo);
                cmd.Parameters.AddWithValue("@Celular", Huespe.Celular);
                cmd.Parameters.AddWithValue("@Correo", Huespe.Correo);
                cmd.Parameters.AddWithValue("@FechaNacimiento", Huespe.FechaNacimiento);

                n = cmd.ExecuteNonQuery();
            }
            return(n);
        }
Пример #6
0
 private void BtnEliminar_Click(object sender, EventArgs e)
 {
     if (dgvDatos.RowCount > 0)
     {
         c = blHuesped.TraerPorId((int)dgvDatos[0, dgvDatos.CurrentRow.Index].Value);
         DialogResult rpta = MessageBox.Show("Desea eliminar el registro", "Eliminar", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (rpta == System.Windows.Forms.DialogResult.Yes)
         {
             int n = blHuesped.Eliminar(c.Id.ToString());
             if (n > 0)
             {
                 MessageBox.Show("Registro Cliente Eliminado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 lista = blHuesped.Listar();
                 CargarDatos();
             }
             else
             {
                 MessageBox.Show("Error al eliminar Cliente", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Пример #7
0
        public int Actualizar(Huespe Huespe)
        {
            DAOHuespedes daHuesped = new DAOHuespedes();

            return(daHuesped.Actualizar(Huespe));
        }
Пример #8
0
        public int Insertar(Huespe Huespe)
        {
            DAOHuespedes daHuesped = new DAOHuespedes();

            return(daHuesped.Insertar(Huespe));
        }