private void btnModificar_Click(object sender, EventArgs e) { if (ValidarHab()) { ModelHabitaciones model = new ModelHabitaciones(); model.IdHabitacion = Convert.ToInt32(txtId_hab.Text); model.NumeroHabitacion = Convert.ToInt32(txtNumero_hab.Text); model.IdTipoHabitacion = Convert.ToInt32(cmbTipo_hab.SelectedValue.ToString()); model.IdEstado = Convert.ToInt32(cmbEstado_hab.SelectedValue.ToString()); int datos = DALHabitaciones.modificar(model); if (datos > 0) { MessageBox.Show("Registro modificado correctamente", "Operacón exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvHabitaciones.DataSource = DALHabitaciones.mostrartabla(); txtNumero_hab.Clear(); cmbTipo_hab.SelectedIndex = 0; cmbEstado_hab.SelectedIndex = 0; } else { MessageBox.Show("Registro no modificado", "Operacón fallida", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //MessageBox.Show("", "Operacón fallida", MessageBoxButtons.OK); } }
private void button2_Click(object sender, EventArgs e) { if (ModelPermiso.TipoUsuarioP != "Empleado") { //Validar contraseñas que sean iguales if (ValidarHab()) { ModelHabitaciones model = new ModelHabitaciones(); model.NumeroHabitacion = Convert.ToInt32(txtNumero_hab.Text); model.IdTipoHabitacion = Convert.ToInt32(cmbTipo_hab.SelectedValue.ToString()); model.IdEstado = Convert.ToInt32(cmbEstado_hab.SelectedValue.ToString()); int datos = DALHabitaciones.agregar(model); if (datos > 0) { MessageBox.Show("Registro ingresado correctamente", "Operacón exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvHabitaciones.DataSource = DALHabitaciones.mostrartabla(); txtNumero_hab.Clear(); cmbTipo_hab.SelectedIndex = 0; cmbEstado_hab.SelectedIndex = 0; } else { MessageBox.Show("Registro no ingresado", "Operacón fallida", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //MessageBox.Show("", "Operacón fallida", MessageBoxButtons.OK); } } else { MessageBox.Show("No posee los permisos para completar la acción", "Permiso denegado", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnEliminar_Click(object sender, EventArgs e) { ModelHabitaciones model = new ModelHabitaciones(); model.IdHabitacion = Convert.ToInt32(txtId_hab.Text); model.IdEstado = Convert.ToInt32(cmbEstado_hab.SelectedValue.ToString()); DALHabitaciones.eliminar(model); MessageBox.Show("Registro eliminado exitosamente", "Eliminado", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvHabitaciones.DataSource = DALHabitaciones.mostrartabla(); }
private void tabControl1_Click(object sender, EventArgs e) { dgvHabitaciones.DataSource = DALHabitaciones.mostrartabla(); dgvTipoHabitacion.DataSource = DALTipoHabitaciones.mostrartabla(); Conexion.obtenerconexion(); cmbTipo_hab.DataSource = DALHabitaciones.ObtenerTipo_Hab(); cmbTipo_hab.DisplayMember = "TipoHabitacion"; cmbTipo_hab.ValueMember = "IdTipoHabitacion"; cmbEstado_hab.DataSource = DALHabitaciones.ObtenerEstado(); cmbEstado_hab.DisplayMember = "Estado"; cmbEstado_hab.ValueMember = "IdEstado"; cmbTipo_hab.SelectedIndex = 0; cmbEstado_hab.SelectedIndex = 0; }
private void Habitaciones_Load_1(object sender, EventArgs e) { dgvHabitaciones.DataSource = DALHabitaciones.mostrartabla(); dgvTipoHabitacion.DataSource = DALTipoHabitaciones.mostrartabla(); Conexion.obtenerconexion(); cmbTipo_hab.DataSource = DALHabitaciones.ObtenerTipo_Hab(); cmbTipo_hab.DisplayMember = "TipoHabitacion"; cmbTipo_hab.ValueMember = "IdTipoHabitacion"; cmbEstado_hab.DataSource = DALHabitaciones.ObtenerEstado(); cmbEstado_hab.DisplayMember = "Estado"; cmbEstado_hab.ValueMember = "IdEstado"; cmbTipo_hab.SelectedIndex = 0; cmbEstado_hab.SelectedIndex = 0; btnEliminarT.Enabled = false; btnModificarT.Enabled = false; btnModificarT.Enabled = false; btnEliminarT.Enabled = false; }
private void btnEliminar_Click(object sender, EventArgs e) { if (ModelPermiso.TipoUsuarioP != "Empleado") { if (MessageBox.Show("¿Estas seguro de eliminar este cliente?", "Precaución!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } ModelHabitaciones model = new ModelHabitaciones(); model.IdHabitacion = Convert.ToInt32(txtId_hab.Text); model.IdEstado = Convert.ToInt32(cmbEstado_hab.SelectedValue.ToString()); DALHabitaciones.eliminar(model); MessageBox.Show("Registro eliminado exitosamente", "Eliminado", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvHabitaciones.DataSource = DALHabitaciones.mostrartabla(); txtId_hab.Clear(); txtNumero_hab.Clear(); cmbTipo_hab.SelectedIndex = 0; cmbEstado_hab.SelectedIndex = 0; } else { MessageBox.Show("No posee los permisos para completar la acción", "Permiso denegado", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnConsultar_Click(object sender, EventArgs e) { dgvHabitaciones.DataSource = DALHabitaciones.mostrartabla(); }