public Facturar() { InitializeComponent(); factura = new BE.Factura(); listadetallefactura = new BE.DetalleFactura(); listaproductos = new List <BE.Producto>(); ConfigurarGrilla(ref dgvFactura); ConfigurarGrilla(ref dgvProductos); FacturaDetalle(); }
private void btnAgregarProd_Click(object sender, EventArgs e) { BLL.Producto p1 = new BLL.Producto(); BE.DetalleFactura detallefactura = new BE.DetalleFactura(); try { if (txtid.Text == "") { MessageBox.Show("Debe seleccionar un producto"); } else { for (int i = 0; i < dgvProductos.SelectedRows.Count; i++) { foreach (DataRow item in p1.SelectAlldt().Rows) { if ((int)(dgvProductos.SelectedRows[i].Cells[0].Value) == int.Parse(item[0].ToString())) { DataRow dr = dtFact.NewRow(); dr[0] = int.Parse(item[0].ToString()); // int.Parse(dgvProductos.SelectedRows[i].Cells[0].Value.ToString()); dr[1] = item[1].ToString(); // dgvProductos.SelectedRows[i].Cells[1].Value.ToString(); dr[2] = decimal.Parse(item[2].ToString()); // decimal.Parse(dgvProductos.SelectedRows[i].Cells[2].Value.ToString()); dr[3] = int.Parse(item[3].ToString()); // int.Parse(dgvProductos.SelectedRows[i].Cells[3].Value.ToString()); dr[4] = int.Parse(cmbCantidad.SelectedItem.ToString()); dr[5] = int.Parse(cmbCantidad.SelectedItem.ToString()) * decimal.Parse(item[2].ToString()); //factura.setDetalle(detallefactura); foreach (DataRow aux in dtFact.Rows) { if (int.Parse(dr[0].ToString()) == int.Parse(aux[0].ToString())) { //Sumo cantidad dr[4] = int.Parse(aux[4].ToString()) + int.Parse(dr[4].ToString()); dr[5] = int.Parse(dr[4].ToString()) * decimal.Parse(item[2].ToString()); dtFact.Rows.Remove(aux); break; } } dtFact.Rows.Add(dr); Limpiarcontroles(); break; } } } ActualizarGrilla(); } } catch (Exception) { throw; } }
private void CargarVenta() { BLL.Factura f1 = new BLL.Factura(); BE.Factura f = new BE.Factura(); f.Id = int.Parse(txtidfactura.Text); f.Fecha = dateTimePicker1.Value.Date; BE.Cliente c1 = new BE.Cliente(); c1.Id = int.Parse(txtidcliente.Text); c1.Nombre = txtnombre.Text; c1.Apellido = txtapellido.Text; c1.Direccion = txtdireccion.Text; c1.Telefono = txttelefono.Text; f.Cliente = c1; // List<BE.DetalleFactura> listafd = new List<BE.DetalleFactura>(); BE.DetalleFactura df; // List<BE.Producto> listaprod =new List<BE.Producto>(); BE.Producto p1; f1.Add(f); txtidfactura.Text = f1.GetMaxId().ToString(); foreach (DataRow aux in _dtfact.Rows) { p1 = new BE.Producto(); df = new BE.DetalleFactura(); p1.Id = int.Parse(aux[0].ToString()); p1.Descripcion = aux[1].ToString(); p1.Precio = decimal.Parse(aux[2].ToString()); p1.Stock = int.Parse(aux[3].ToString()); df.Id = int.Parse(txtidfactura.Text); df.Producto = p1; df.Cantidad = int.Parse(aux[4].ToString()); f.setDetalle(df); p1 = null; df = null; } BLL.DetalleFactura fd1 = new BLL.DetalleFactura(); foreach (BE.DetalleFactura item in f.getDetalle()) { fd1.Add(item); } }
public void setDetalle(BE.DetalleFactura detalle) { this._detalle.Add(detalle); }