private void GuardarDevolucion() { DevolucionesCompra d = new DevolucionesCompra(); d.IDVenta = id; d.Total = total; foreach (DataGridViewRow dr in dgvProductos02.Rows) { d.IDProductos.Add((int)dr.Cells[0].Value); d.CantidadProductos.Add((int)dr.Cells[4].Value); d.PrecioProductos.Add((decimal)dr.Cells[3].Value); } d.Insertar(); }
private void LlenarDataGrid() { try { dgvCompras.Rows.Clear(); foreach (DataRow dr in dt.Rows) { decimal total = (decimal)dr["total"], totalDev = DevolucionesCompra.TotalDevolucion((int)dr["id"]); string tipoPago = ""; switch ((TipoPago)Enum.Parse(typeof(TipoPago), dr["tipo_pago"].ToString())) { case TipoPago.Efectivo: tipoPago = "Efectivo"; break; case TipoPago.Cheque: tipoPago = "Cheque"; break; case TipoPago.Crédito: tipoPago = "Crédito"; break; case TipoPago.Débito: tipoPago = "Débito"; break; case TipoPago.Transferencia: tipoPago = "Transferencia"; break; } if ((total - totalDev) > 0) { dgvCompras.Rows.Add(new object[] { dr["id"], Cliente.NombreCliente((int)dr["id_proveedor"]), Trabajador.NombreTrabajador((int)dr["id_comprador"]), total - totalDev, tipoPago, dr["create_time"], totalDev }); } Application.DoEvents(); } dgvCompras_RowEnter(dgvCompras, new DataGridViewCellEventArgs(0, 0)); } catch (Exception ex) { FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al mostrar las compras.", Config.shrug, ex); } }
private void frmDevolucionesCompra_Load(object sender, EventArgs e) { try { cantProds = DevolucionesCompra.CantidadProductosDevolucion(id); } catch (MySqlException ex) { FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al obtener los datos de devoluciones anteriores. No se ha podido conectar a la base de datos. La ventana se cerrará.", Config.shrug, ex); this.Close(); return; } catch (Exception ex) { FuncionesGenerales.Mensaje(this, Mensajes.Error, "Ocurrió un error al obtener los datos de devoluciones anteriores. La ventana se cerrará.", Config.shrug, ex); this.Close(); return; } CargarDatos(); }