Beispiel #1
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 = bLCliente.TraerPorId((string)dgvDatos[0, dgvDatos.CurrentRow.Index].Value);
                    txtNombre.Text            = c.Nombre;
                    txtPrimerApellido.Text    = c.PrimerApellido;
                    textSegundoApellido.Text  = c.SegundoApellido;
                    textTelefonoFijo.Text     = c.TelefonoFijo;
                    textCelular.Text          = c.Celular;
                    textCorreo.Text           = c.Correo;
                    textFechaNacimiento.Text  = c.FechaNacimiento;
                    textNoTarjetaCredito.Text = c.NoTarjetaCredito;

                    ActivarControlDatos(gbDatos, true);
                    ActivarButton(false);
                    dgvDatos.Enabled = false;
                    btnEditar.Text   = "Cancelar";
                }
            }
        }
Beispiel #2
0
        public ClientesHotel TraerPorId(string Id)
        {
            ClientesHotel Cliente = new ClientesHotel();

            using (SqlConnection con = new SqlConnection(CadenaConexion))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("TraerClientesPorId", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@ID", Id);
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr != null && dr.HasRows)
                {
                    dr.Read();
                    Cliente = new ClientesHotel((string)dr["Id"],
                                                (string)dr["Nombre"],
                                                (string)dr["PrimerApellido"],
                                                (string)dr["SegundoApellido"],
                                                (string)dr["TelefonoFijo"],
                                                (string)dr["Celular"],
                                                (string)dr["Correo"],
                                                (string)dr["FechaNacimiento"],// Convert.ToString()
                                                (string)dr["NoTarjetaCredito"]


                                                );
                }
            }

            return(Cliente);
        }
Beispiel #3
0
        //Metodos

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

            using (SqlConnection con = new SqlConnection(CadenaConexion))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("ListarClientes", con);
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr != null && dr.HasRows)
                {
                    while (dr.Read())
                    {
                        ClientesHotel c = new ClientesHotel((string)dr["Id"],
                                                            (string)dr["Nombre"],
                                                            (string)dr["PrimerApellido"],
                                                            (string)dr["SegundoApellido"],
                                                            (string)dr["TelefonoFijo"],
                                                            (string)dr["Celular"],
                                                            (string)dr["Correo"],
                                                            (string)dr["FechaNacimiento"],// Convert.ToString()
                                                            (string)dr["NoTarjetaCredito"]
                                                            );
                        lista.Add(c);
                    }
                }
            }
            return(lista);
        }
Beispiel #4
0
        private void BtnGrabar_Click(object sender, EventArgs e)
        {
            int n = -1;

            if (_nuevo)
            {
                c = new ClientesHotel("",
                                      txtNombre.Text,
                                      txtPrimerApellido.Text,
                                      textSegundoApellido.Text,
                                      textTelefonoFijo.Text,
                                      textCelular.Text,
                                      textCorreo.Text,
                                      textFechaNacimiento.Text,
                                      textNoTarjetaCredito.Text
                                      );
                n = bLCliente.Insertar(c);
            }
            else
            {
                c.Nombre           = txtNombre.Text;
                c.PrimerApellido   = txtPrimerApellido.Text;
                c.SegundoApellido  = textSegundoApellido.Text;
                c.TelefonoFijo     = textTelefonoFijo.Text;
                c.Celular          = textCelular.Text;
                c.Correo           = textCorreo.Text;
                c.FechaNacimiento  = textFechaNacimiento.Text;
                c.NoTarjetaCredito = textNoTarjetaCredito.Text;
                n = bLCliente.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          = bLCliente.Listar();
                CargarDatos();
            }
            else
            {
                MessageBox.Show("Error al grabar Cliente", "Aviso",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #5
0
 private void BtnEliminar_Click(object sender, EventArgs e)
 {
     if (dgvDatos.RowCount > 0)
     {
         c = bLCliente.TraerPorId((string)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 = bLCliente.Eliminar(c.Id);
             if (n > 0)
             {
                 MessageBox.Show("Registro Cliente Eliminado", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 lista = bLCliente.Listar();
                 CargarDatos();
             }
             else
             {
                 MessageBox.Show("Error al eliminar Cliente", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Beispiel #6
0
        public int Insertar(ClientesHotel Cliente)
        {
            int n = -1;

            using (SqlConnection con = new SqlConnection(CadenaConexion))
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("InsertarClientes", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@NoDocumento", Cliente.Celular);
                cmd.Parameters.AddWithValue("@Nombre", Cliente.Nombre);
                cmd.Parameters.AddWithValue("@PrimerApellido", Cliente.PrimerApellido);
                cmd.Parameters.AddWithValue("@SegundoApellido", Cliente.SegundoApellido);
                cmd.Parameters.AddWithValue("@TelefonoFijo", Cliente.TelefonoFijo);
                cmd.Parameters.AddWithValue("@Celular", Cliente.Celular);
                cmd.Parameters.AddWithValue("@Correo", Cliente.Correo);
                cmd.Parameters.AddWithValue("@FechaNacimiento", Cliente.FechaNacimiento);
                cmd.Parameters.AddWithValue("@NoTarjetaCredito", Cliente.NoTarjetaCredito);
                n = cmd.ExecuteNonQuery();
            }
            return(n);
        }
Beispiel #7
0
        public int Actualizar(ClientesHotel ClientesHotel)
        {
            DAOClientes daUsuario = new DAOClientes();

            return(daUsuario.Actualizar(ClientesHotel));
        }
Beispiel #8
0
        public int Insertar(ClientesHotel ClientesHotel)
        {
            DAOClientes daUsuario = new DAOClientes();

            return(daUsuario.Insertar(ClientesHotel));
        }