protected void eliminar(DataGridViewCellEventArgs e) { try { if (this.grw_ubicaciones.CurrentRow.IsNewRow) { return; } if (Mensaje.confirmacion("¿Desea eliminar la ubicación?")) { int idUbicacion = Convert.ToInt32(this.grw_ubicaciones.Rows[e.RowIndex].Cells["id"].Value); String mensaje = ""; if (UbicacionTR.eliminarUbicacion(ref mensaje, idUbicacion)) { this.grw_ubicaciones.Rows.RemoveAt(e.RowIndex); if (this.grw_ubicaciones.Rows.Count < 1) { this.grw_ubicaciones.Rows.Add(); } } else { Mensaje.advertencia(mensaje); } } }catch (Exception error) { Mensaje.error(error.Message); } }
private void btn_guardar_Click(object sender, EventArgs e) { try { if (this.cmb_ubicacion.SelectedIndex == -1) { Mensaje.advertencia("Por favor escoja una ubicación"); return; } if (hizoCambio) { this.guardarElegidos(); } foreach (int id in this.ubicacionesTemporal) { UbicacionTR.insertarProductosDesdeTemporal(id); } Mensaje.informacion("Productos ingresados con éxito."); this.estadoInicial(); //this.limpiar(false); } catch (Exception error) { Mensaje.error(error.Message); } }
protected void llenarUbicacion() { DataTable datos = UbicacionTR.consultarUbicaciones(); if (datos != null && datos.Rows.Count > 0) { this.cmb_ubicacion.DataSource = datos; this.cmb_ubicacion.ValueMember = "id"; this.cmb_ubicacion.DisplayMember = "nombre"; this.cmb_ubicacion.SelectedIndex = 0; } }
private void btn_guardar_Click(object sender, EventArgs e) { try { if (this.impresoraActual != this.cmb_impresora.SelectedValue.ToString()) { ParametroTR.actualizarParametroString("impresora", this.cmb_impresora.SelectedValue.ToString()); Global.nombreImpresora = this.cmb_impresora.SelectedValue.ToString(); } if (this.impresoraActual2 != this.cmb_impresora2.SelectedValue.ToString()) { ParametroTR.actualizarParametroString("impresora2", this.cmb_impresora2.SelectedValue.ToString()); } ParametroTR.actualizarParametroEntero("facturaCopias", Convert.ToInt32(this.txt_copias.Text)); ParametroTR.actualizarParametroEntero("facturaCopias2", Convert.ToInt32(this.txt_copias2.Text)); ParametroTR.actualizarParametroString("anchoHoja", this.txt_ancho.Text); ParametroTR.actualizarParametroString("altoHoja", this.txt_alto.Text); ParametroTR.actualizarParametroEntero("imprimirUbicaciones", (this.chk_ubicaciones.Checked) ? 1 : 0); List <Ubicacion> insertar = new List <Ubicacion>(); List <Ubicacion> actualizar = new List <Ubicacion>(); foreach (DataGridViewRow fila in this.grw_ubicaciones.Rows) { if (!General.filaVacia(fila)) { Ubicacion ubicacion = new Ubicacion(); ubicacion.nombre = fila.Cells["nombre"].Value.ToString(); ubicacion.impresora = fila.Cells["impresora"].Value.ToString(); ubicacion.estado = "A"; // fila.Cells["impresora"]; if (!General.celdaVacia(fila.Cells["id"])) { ubicacion.id = Convert.ToInt32(fila.Cells["id"].Value); actualizar.Add(ubicacion); } else { insertar.Add(ubicacion); } } } UbicacionTR.operacionUbicacion(insertar, true); UbicacionTR.operacionUbicacion(actualizar, false); Mensaje.informacion("Ubicaciones actualizadas satisfactoriamente"); this.Close(); } catch (Exception error) { Mensaje.advertencia(error.Message); } }
private void frm_parametro_Load(object sender, EventArgs e) { List <Object> lista = ParametroTR.ConsultarInt("41,42,15,43,55"); this.txt_ancho.Text = lista[1].ToString(); this.txt_alto.Text = lista[2].ToString(); this.txt_copias.Text = lista[0].ToString(); this.txt_copias2.Text = lista[3].ToString(); this.chk_ubicaciones.Checked = (Convert.ToInt32(lista[4]) == 1); if (Convert.ToInt32(lista[3]) < 1) { this.txt_copias2.Enabled = false; } else { this.chk_copiarprefactura.Checked = true; } this.llenarImpresoraPrincipal(); impresoras = Impresion.impresorasDisponibles(); List <Ubicacion> ubicaciones = UbicacionTR.listadoUbicaciones(); int i = 0; if (ubicaciones != null) { foreach (Ubicacion ubicacion in ubicaciones) { if (this.impresoras.Find(element => element.Text == ubicacion.impresora) == null) { this.impresoras.Add(new ComboboxItem(ubicacion.impresora, ubicacion.impresora)); } } } if (impresoras != null) { impresora.DataSource = impresoras; impresora.ValueMember = "Value"; impresora.DisplayMember = "Text"; } if (ubicaciones != null) { foreach (Ubicacion ubicacion in ubicaciones) { this.grw_ubicaciones.Rows.Add(); this.grw_ubicaciones["id", i].Value = ubicacion.id; this.grw_ubicaciones["nombre", i].Value = ubicacion.nombre; this.grw_ubicaciones["impresora", i].Value = ubicacion.impresora; i++; } } }
protected void guardarElegidos() { List <int[]> datos = new List <int[]>(); foreach (DataGridViewRow fila in this.grw_productos.Rows) { if (!String.IsNullOrEmpty(fila.Cells["elegido"].Value.ToString()) && Convert.ToBoolean(fila.Cells["elegido"].Value)) { int[] producto = new int[2]; producto[0] = Convert.ToInt32(fila.Cells["id"].Value); producto[1] = Convert.ToInt32(fila.Cells["categoria"].Value); datos.Add(producto); } } string mensaje = ""; UbicacionTR tran = new UbicacionTR(); tran.insertarProductos(ref mensaje, datos, this.idUbicacion, this.categoriaAnterior); this.categoriaAnterior = Convert.ToInt32(this.cmb_categoria.SelectedValue); }
protected void llenarGrid() { this.grw_productos.DataBindings.Clear(); grw_productos.Columns.Clear(); if (this.cmb_categoria.SelectedIndex == -1) { return; } string mensaje = ""; int idCategoria = (this.cmb_categoria.SelectedValue == null || this.cmb_categoria.SelectedIndex == 0) ? -1 : Convert.ToInt32(this.cmb_categoria.SelectedValue); DataTable datos = UbicacionTR.consultarProductos(this.idUbicacion, idCategoria); if (datos != null) { datos.Columns.Add("elegido", typeof(bool)).SetOrdinal(1); foreach (DataRow fila in datos.Rows) { fila["elegido"] = (Convert.ToBoolean(fila["temp"])); } this.grw_productos.DataSource = datos; this.grw_productos.Columns["id"].Visible = false; //this.grw_productos.Columns["categoria"].Visible = false; this.grw_productos.Columns["elegido"].HeaderText = ""; this.grw_productos.Columns["categoria"].Visible = false; this.grw_productos.Columns["temp"].Visible = false; int ancho = this.grw_productos.Width; this.grw_productos.Columns["elegido"].Width = Convert.ToInt16(ancho * 0.10); this.grw_productos.Columns["codigo"].Width = Convert.ToInt16(ancho * 0.15); this.grw_productos.Columns["nombre"].Width = Convert.ToInt16(ancho * 0.25); this.grw_productos.Columns["descripcion"].Width = Convert.ToInt16(ancho * 0.50); /* ----------------------------------- */ //this.grw_productos.Columns[4].Width = Convert.ToInt16(ancho * 0.45); //this.grw_productos.Columns[5].Width = Convert.ToInt16(ancho * 0.15); //if (this.grw_productos.Rows.Count > 0) this.grw_productos.Rows[0].Cells[1].Selected = true; } else { Mensaje.error(mensaje); } }
private void cmb_ubicacion_SelectedIndexChanged(object sender, EventArgs e) { if (this.cmb_ubicacion.SelectedIndex == -1) { return; } if (this.hizoCambio) { this.guardarElegidos(); } this.hizoCambio = false; this.idUbicacion = Convert.ToInt32(this.cmb_ubicacion.SelectedValue); if (!this.yaFueCargado(Convert.ToInt32(this.cmb_ubicacion.SelectedValue))) { UbicacionTR.cargarDatosTemporal(this.idUbicacion); this.ubicacionesTemporal.Add(this.idUbicacion); } this.cmb_categoria.SelectedIndexChanged -= cmb_categoria_SelectedIndexChanged_1; this.cmb_categoria.SelectedIndex = 0; this.llenarGrid(); this.cmb_categoria.SelectedIndexChanged += cmb_categoria_SelectedIndexChanged_1; }
private void btn_limpiar_Click(object sender, EventArgs e) { UbicacionTR.eliminarTemporal(); this.estadoInicial(); }
protected void eliminarTemporal() { UbicacionTR.eliminarTemporal(); }