/// <summary> /// /// </summary> private void CargarNumFactura() { using (GestorVenta recibo = new GestorVenta()) { dsVentas = recibo.ConsultarUltimoVenta(); dtVentas = this.dsVentas.Tables[0]; numRecibo = int.Parse(this.dtVentas.Rows[0]["siguiente"].ToString()); } }
private void GuardarDetalleVenta() { string fecha = DateTime.Now.ToShortDateString(); try { using (GestorVenta venta = new GestorVenta()) { dsVentas = venta.ConsultarUltimoVenta(); dtVentas = this.dsVentas.Tables[0]; foreach (DataGridViewRow fila in dgv_ventas.Rows) { //agregamos la cantidad, el precio y subtotal string codProd = Convert.ToString(fila.Cells[0].Value); int canti = Convert.ToInt32(fila.Cells[2].Value); string tipo = Convert.ToString(fila.Cells[3].Value); int prec = Convert.ToInt16(fila.Cells[4].Value); int subt = Convert.ToInt16(fila.Cells[5].Value); if (tipo.Equals("GRAVADO")) { double aux = subt * 0.13 + subt; subtotal = int.Parse(aux.ToString()); } else { subtotal = subt; } venta.InsertarDetalleVenta(numRecibo, codProd, canti, prec, subtotal, "A"); subtotal = 0; } } } catch (Exception e) { MessageBox.Show("Error " + e); } }