public static ComboBox LlenarListaTipoBebidas(ComboBox lista) { lista.DataSource = NBebidas.BuscarTipoBebidas("COMPLETO", ""); lista.ValueMember = "Id_tipo_bebida"; lista.DisplayMember = "Tipo_bebida"; return(lista); }
private void BuscarBebidas(string tipo_busqueda, string texto_busqueda) { try { string estado = this.rdActivo.Checked ? "ACTIVO" : "INACTIVO"; DataTable Tabla = NBebidas.BuscarBebida(tipo_busqueda, texto_busqueda, estado, out string rpta); if (Tabla != null) { this.dgvBebidas.Enabled = true; this.dgvBebidas.Enabled = true; this.dgvBebidas.PageSize = 25; this.dgvBebidas.SetPagedDataSource(Tabla, this.bindingNavigator1); this.lblResultados.Text = "Se encontraron " + Tabla.Rows.Count + " bebidas"; string[] columns_header_text = { "Id bebida", "Nombre", "Precio", "Precio trago", "Precio trago doble", "Precio proveedor", "Id proveedor", "Imagen", "Id Tipo", "Cantidad (Unidades)","Cantidad por unidad", "Cantidad total", "Estado", "Id tipo", "Tipo" }; bool[] columns_visible = { false, true, true, false, false, false, false, false, false, true, true, true, false, false, true }; this.dgvBebidas = DatagridString.ChangeHeaderTextAndVisibleCustomDataGrid(this.dgvBebidas, columns_header_text, columns_visible); } else { this.dgvBebidas.clearDataSource(); this.dgvBebidas.Enabled = false; this.lblResultados.Text = "No se encontraron bebidas"; if (!rpta.Equals("OK")) { throw new Exception(rpta); } } } catch (Exception ex) { Mensajes.MensajeErrorCompleto(this.Name, "BuscarBebidas", "Hubo un error al buscar una bebida", ex.Message); } }
private void BtnGuardar_Click(object sender, EventArgs e) { try { int id_bebida = 0; string rpta = ""; if (this.Comprobaciones()) { if (this.IsEditar) { rpta = NBebidas.EditarBebida(this.Parametros()); } else { rpta = NBebidas.InsertarBebida(this.Parametros(), out id_bebida); } if (rpta.Equals("OK")) { if (!this.adjuntarImagen.Nombre_imagen.Equals("SIN IMAGEN")) { rpta = ArchivosAdjuntos.GuardarArchivo(id_bebida, "rutaImages", this.adjuntarImagen.Nombre_imagen, this.adjuntarImagen.RutaOrigen); } } if (rpta.Equals("OK")) { Mensajes.MensajeOkForm("Se agregó correctamente la bebida"); this.Close(); } else { throw new Exception(rpta); } } } catch (Exception ex) { Mensajes.MensajeErrorCompleto(this.Name, Metodo_error, Informacion_error, ex.Message); } }
private void DgvBebidas_DoubleClick(object sender, EventArgs e) { try { DataGridViewRow row = this.dgvBebidas.CurrentRow; if (this.dgvBebidas.Enabled & row != null) { string rpta = ""; if (this.FrmAgregarBebidas != null) { int fila = this.dgvBebidas.CurrentRow.Cells[0].RowIndex; this.FrmAgregarBebidas.AsignarDatos (DatagridString.ReturnValuesOfCells(sender, fila, out rpta)); this.Close(); } else if (this.InactivarBebidas) { Mensajes.MensajePregunta("¿Seguro desea inactivar la bebida?", "Continuar", "Cancelar", out DialogResult dialog); if (dialog == DialogResult.Yes) { int id_bebida = Convert.ToInt32(row.Cells["Id_bebida"].Value); rpta = NBebidas.InactivarBebida(id_bebida); if (rpta.Equals("OK")) { Mensajes.MensajeOkForm("Se inactivó la bebida correctamente"); this.BuscarBebidas("COMPLETO", ""); return; } else { throw new Exception(rpta); } } } } } catch (Exception ex) { Mensajes.MensajeErrorCompleto(this.Name, "DgvBebidas_DoubleClick", "Hubo un error con la tabla de datos", ex.Message); } }