private void ToolstGuardar_Click(object sender, EventArgs e) { try { if (ValidarT()) { if (UP == true) { Factura entidad = new Factura(); FacturaBl actualizar = new FacturaBl(); } if (UP == false) { FacturaBl fac = new FacturaBl(); Factura entidad = new Factura(); DetalleFacturaBl dtf = new DetalleFacturaBl(); DetalleFacturas entidf = new DetalleFacturas(); ProductosBl pb = new ProductosBl(); Productos pd = new Productos(); // entidad.ID_Producto = ID; entidad.Fecha = Convert.ToDateTime(toolStripStatusLabel1.Text); entidad.Forma_Pago = CbxForamPago.Text; entidad.Vendedor = Usu.ToString(); entidad.Total = double.Parse(LblTotaApagar.Text); entidad.Id_Cliente = Id_Cliente; fac.RegFactura(entidad); foreach (DataGridViewRow row in dgvDetalleF.Rows) { entidf.Monto = Convert.ToDouble(row.Cells["Precio_Producto"].Value); entidf.Cantidad = Convert.ToInt16(row.Cells["Fecha"].Value); entidf.Itbis = Convert.ToDouble(row.Cells["Generales"].Value); entidf.ID_Producto = Convert.ToInt16(row.Cells["IDProducto"].Value); var dt = fac.ObtenerIDFactura(Id_Cliente, Convert.ToDouble(LblTotaApagar.Text)); var Id1 = dt.Rows[0]["ID_Factura"]; entidf.ID_Factura = Convert.ToInt16(Id1); ID_Factura = Convert.ToInt16(Id1); pd.ID_Producto = Convert.ToInt16(row.Cells["IDProducto"].Value);; pd.Inventario = Convert.ToInt16(row.Cells["Fecha"].Value); pb.ActualizarInventario(pd); dtf.RegDetalleFactura(entidf); } // dgvClientes.Update(); // LlenarGrid(); MessageBox.Show("Registro agregado con exito.", "Agregado", MessageBoxButtons.OK, MessageBoxIcon.Information); ToolstNuevo.PerformClick(); if (MessageBox.Show("¿Desea imprimir la factura? ", "Imprimir", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { tsImprimir.PerformClick(); } else { return; } } } else { MessageBox.Show("Hay campos que son obligatorios que se encuentran vacios.", "Error de validación", MessageBoxButtons.OK, MessageBoxIcon.Error); if (string.IsNullOrWhiteSpace(TxtProducto.Text)) { errorProvider1.SetError(TxtProducto, "Este Campo es requerido"); } if (string.IsNullOrWhiteSpace(TxtCliente.Text)) { errorProvider1.SetError(TxtCliente, "Este Campo es requerido"); } if (string.IsNullOrWhiteSpace(CbxForamPago.Text)) { errorProvider1.SetError(CbxForamPago, "Este Campo es requerido"); } } } catch (Exception) { throw; } }
public string RegistraFactura(Factura factura) { FacturaBl f = new FacturaBl(); return(f.RegistraFactura(factura)); }