public void Add_tipohab_mod(int tipo_id) { tipohabBO_mod = tipohabDAO.Buscar(tipo_id); btn_guardar_tipo.Text = "Guardar"; tipohabBO.Tipo_id = tipo_id; txt_tipo_id.Text = tipohabBO_mod.Tipo_id.ToString(); txt_nombre_tipo.Text = tipohabBO_mod.Nombre; }
public TipohabBO Buscar(int tipo_id) { string commandSQL = String.Format("SELECT * FROM tipo_habitacion WHERE tipo_id={0}", tipo_id); DataTable table = conexion.EjecutarSentencia(commandSQL); if (table.Rows.Count > 0) { DataRowCollection row = table.Rows; TipohabBO tipohabBO = new TipohabBO(); tipohabBO.Tipo_id = Convert.ToInt32(row[0]["tipo_id"]); tipohabBO.Nombre = row[0]["nombre_tipo"].ToString(); return(tipohabBO); } else { return(null); } }
public Frm_configuracion() { InitializeComponent(); tipohabBO = new TipohabBO(); tipohabDAO = new TipohabDAO(); estadohabBO = new EstadohabBO(); estadohabDAO = new EstadohabDAO(); datos = tipohabDAO.Buscar(); datos2 = estadohabDAO.Buscar(); dgv_tipo_hab.DataSource = datos; dgv_tipo_hab.AllowUserToAddRows = false; dgv_tipo_hab.ReadOnly = true; dgv_tipo_hab.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dgv_estado_hab.DataSource = datos2; dgv_estado_hab.AllowUserToAddRows = false; dgv_estado_hab.ReadOnly = true; dgv_estado_hab.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; setColumNames(); }
public void ValidarTexboxTipo() { if (txt_nombre_tipo.Text == "") { MessageBox.Show("Debe completar todos los campos"); } else { if (tipohabBO_mod != null) { if (tipohabDAO.Modificar(RecuperarInformacionTipo()) == 1) { MessageBox.Show("Se ha modificado el tipo de habitación"); } else { MessageBox.Show("Ha habido un error al modificar el tipo de habitación!"); } tipohabBO_mod = null; } else { if (tipohabDAO.Agregar(RecuperarInformacionTipo()) == 1) { MessageBox.Show("Se ha registrado el tipo de habitación"); } else { MessageBox.Show("Ha habido un error al registrar el tipo de habitación!"); } } Clean(); dgv_tipo_hab.DataSource = tipohabDAO.Buscar(); dgv_tipo_hab.Update(); } }
public int Eliminar(TipohabBO tipohabBO) { string ComandoSQL = string.Format("DELETE FROM tipo_habitacion WHERE tipo_id={0}", tipohabBO.Tipo_id); return(conexion.EjecutarComando(ComandoSQL)); }
public int Modificar(TipohabBO tipohabBO) { string ComandoSQL = string.Format("UPDATE tipo_habitacion SET nombre_tipo='{1}' WHERE tipo_id={0}", tipohabBO.Tipo_id, tipohabBO.Nombre); return(conexion.EjecutarComando(ComandoSQL)); }
public int Agregar(TipohabBO tipohabBO) { string ComandoSQL = string.Format("INSERT INTO tipo_habitacion(nombre_tipo)VALUES('{0}');", tipohabBO.Nombre); return(conexion.EjecutarComando(ComandoSQL)); }