private void btn_imprimir_Click(object sender, EventArgs e)
        {
            if (dgv_detalle.Rows.Count >= 1)
            {
                if (res == null && chk_Venta_Rapida.Checked == true || res != null && chk_Venta_Rapida.Checked == false)
                {
                    List <DetalleFactura> detalle = new List <DetalleFactura>();
                    Factura fact = new Factura();
                    Persona per  = new Persona();
                    Estado  est  = new Estado();
                    if (chk_Venta_Rapida.Checked == true)
                    {
                        per.idPersona = 17;
                    }
                    else
                    {
                        per.idPersona = res.idPersona;
                    }
                    fact.cliente       = per;
                    fact.fechaCreacion = DateTime.Now.Date;
                    est.idEstado       = 27;
                    fact.estado        = est;
                    fact.importeTotal  = int.Parse(txt_monto_total.Text);
                    fact.tipoFactura   = char.Parse(cmb_tipo_factura.Text);
                    fact.totalIVA      = double.Parse(txt_totalIva.Text);
                    for (int c = 0; c < dgv_detalle.RowCount; c++)
                    {
                        DetalleFactura de = new DetalleFactura();
                        Producto       p  = new Producto();

                        p.idProducto = (int)dgv_detalle.Rows[c].Cells["idProductodetalle"].Value;
                        de.subTotal  = (double)dgv_detalle.Rows[c].Cells["preciodetalle"].Value;
                        de.cantidad  = Convert.ToDouble(dgv_detalle.Rows[c].Cells["cantidad"].Value);
                        de.iva       = Convert.ToDouble(dgv_detalle.Rows[c].Cells["iva"].Value);
                        de.producto  = p;
                        detalle.Add(de);
                    }
                    fact.detalleFactura = detalle;

                    try
                    {
                        //iniciador.idFactura = FacturaDAO.InsertFacturaDirecta(fact);
                        MessageBox.Show("Registrado con Exito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                        btn_guardar.Enabled = false;
                    }
                    catch (ApplicationException ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    }
                    Emitir_Factura factura = new Emitir_Factura();
                    factura.ShowDialog();
                    btn_nuevo_Click(sender, e);
                }
            }
            EmitirPresupuesto emitir = new EmitirPresupuesto();

            emitir.ShowDialog();
        }
        private void btn_imprimir_Click(object sender, EventArgs e)
        {
            EmitirPresupuesto emitir = new EmitirPresupuesto();
            if (dgv_detalle.Rows.Count >= 1)
            {
                if (res != null)
                {
                    //List<DetalleFactura> detalle = new List<DetalleFactura>();
                    //Presupuesto fact = new Presupuesto();
                    //Persona per = new Persona();
                    //Estado est = new Estado();
                    //if (chk_Venta_Rapida.Checked == true)
                    //{
                    //    per.idPersona = 17;
                    //}
                    //else
                    //{
                    //    per.idPersona = res.idPersona;

                    //}

                    DataTable tabla = new DataTable();

                    tabla.Columns.AddRange(new DataColumn[12] { new DataColumn("fecha",typeof(DateTime)),
                                                                new DataColumn("cliente",typeof(String)),
                                                                new DataColumn("razonSocial",typeof(String)),
                                                                new DataColumn("importe",typeof(Double)),
                                                                new DataColumn("totalIVA",typeof(Double)),
                                                                new DataColumn("cantidad",typeof(Double)),
                                                                new DataColumn("subtotal",typeof(Double)),
                                                                new DataColumn("iva",typeof(Double)),
                                                                new DataColumn("CUIT",typeof(String)),
                                                                new DataColumn("condicionIVA",typeof(String)),
                                                                new DataColumn("idProducto",typeof(Int32)),
                                                                new DataColumn("nombreProd",typeof(String)),
                                                              });

                    for (int c = 0; c < dgv_detalle.RowCount; c++)
                    {
                        string RazonSocial = txt_razon_social.Text;
                        string cliente = txt_nombre.Text +" "+ txt_apellido.Text;
                        string cuit=txt_cuit.Text;
                        string condiva=((CondicionIVA)cmb_iva.SelectedItem).Nombre;

                        //fact.cliente = per;

                        DateTime fechaCreacion = DateTime.Now.Date;
                        //est.idEstado = 27;
                        //fact.estado = est;
                        Double importeTotal = double.Parse(txt_monto_total.Text);
                        //fact.tipoFactura = char.Parse(cmb_tipo_factura.Text);
                        Double totalIVA = double.Parse(txt_totalIva.Text);

                        //DetalleFactura de = new DetalleFactura();
                        //Producto p = new Producto();

                        Int32 idProducto = (int)dgv_detalle.Rows[c].Cells["idProductodetalle"].Value;
                        String Nombre = dgv_detalle.Rows[c].Cells["nombreproductodetalle"].Value.ToString();
                        Double subTotal = (double)dgv_detalle.Rows[c].Cells["preciodetalle"].Value;
                        Double cantidad = Convert.ToDouble(dgv_detalle.Rows[c].Cells["cantidad"].Value);
                        Double iva = Convert.ToDouble(dgv_detalle.Rows[c].Cells["iva"].Value);

                        tabla.Rows.Add(fechaCreacion, cliente, RazonSocial, importeTotal, totalIVA, cantidad, subTotal, iva, cuit, condiva, idProducto, Nombre);
                        //de.producto = p;
                        //detalle.Add(de);
                    }
                    //try
                    //{

                    //    btn_guardar.Enabled = false;
                    //}
                    //catch (ApplicationException ex)
                    //{
                    //    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    //}
                    //Emitir_Factura factura = new Emitir_Factura();
                    //factura.ShowDialog();

                    emitir._cargarPresupuesto = tabla;
                    emitir.ShowDialog();
                    btn_nuevo_Click(sender, e);
                }
            }
        }
        private void btn_imprimir_Click(object sender, EventArgs e)
        {
            if (dgv_detalle.Rows.Count >= 1)
            {
                if (res == null && chk_Venta_Rapida.Checked == true || res != null && chk_Venta_Rapida.Checked == false)
                {
                    List<DetalleFactura> detalle = new List<DetalleFactura>();
                    Factura fact = new Factura();
                    Persona per = new Persona();
                    Estado est = new Estado();
                    if (chk_Venta_Rapida.Checked == true)
                    {
                        per.idPersona = 17;
                    }
                    else
                    {
                        per.idPersona = res.idPersona;
                    }
                    fact.cliente = per;
                    fact.fechaCreacion = DateTime.Now.Date;
                    est.idEstado = 27;
                    fact.estado = est;
                    fact.importeTotal = int.Parse(txt_monto_total.Text);
                    fact.tipoFactura = char.Parse(cmb_tipo_factura.Text);
                    fact.totalIVA = double.Parse(txt_totalIva.Text);
                    for (int c = 0; c < dgv_detalle.RowCount; c++)
                    {
                        DetalleFactura de = new DetalleFactura();
                        Producto p = new Producto();

                        p.idProducto = (int)dgv_detalle.Rows[c].Cells["idProductodetalle"].Value;
                        de.subTotal = (double)dgv_detalle.Rows[c].Cells["preciodetalle"].Value;
                        de.cantidad = Convert.ToDouble(dgv_detalle.Rows[c].Cells["cantidad"].Value);
                        de.iva = Convert.ToDouble(dgv_detalle.Rows[c].Cells["iva"].Value);
                        de.producto = p;
                        detalle.Add(de);
                    }
                    fact.detalleFactura = detalle;

                    try
                    {
                        //iniciador.idFactura = FacturaDAO.InsertFacturaDirecta(fact);
                        MessageBox.Show("Registrado con Exito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                        btn_guardar.Enabled = false;
                    }
                    catch (ApplicationException ex)
                    {
                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    }
                    Emitir_Factura factura = new Emitir_Factura();
                    factura.ShowDialog();
                    btn_nuevo_Click(sender, e);
                }
            }
            EmitirPresupuesto emitir = new EmitirPresupuesto();
            emitir.ShowDialog();
        }
Пример #4
0
        private void btn_imprimir_Click(object sender, EventArgs e)
        {
            EmitirPresupuesto emitir = new EmitirPresupuesto();

            if (dgv_detalle.Rows.Count >= 1)
            {
                if (res != null)
                {
                    //List<DetalleFactura> detalle = new List<DetalleFactura>();
                    //Presupuesto fact = new Presupuesto();
                    //Persona per = new Persona();
                    //Estado est = new Estado();
                    //if (chk_Venta_Rapida.Checked == true)
                    //{
                    //    per.idPersona = 17;
                    //}
                    //else
                    //{
                    //    per.idPersona = res.idPersona;

                    //}

                    DataTable tabla = new DataTable();

                    tabla.Columns.AddRange(new DataColumn[12] {
                        new DataColumn("fecha", typeof(DateTime)),
                        new DataColumn("cliente", typeof(String)),
                        new DataColumn("razonSocial", typeof(String)),
                        new DataColumn("importe", typeof(Double)),
                        new DataColumn("totalIVA", typeof(Double)),
                        new DataColumn("cantidad", typeof(Double)),
                        new DataColumn("subtotal", typeof(Double)),
                        new DataColumn("iva", typeof(Double)),
                        new DataColumn("CUIT", typeof(String)),
                        new DataColumn("condicionIVA", typeof(String)),
                        new DataColumn("idProducto", typeof(Int32)),
                        new DataColumn("nombreProd", typeof(String)),
                    });



                    for (int c = 0; c < dgv_detalle.RowCount; c++)
                    {
                        string RazonSocial = txt_razon_social.Text;
                        string cliente     = txt_nombre.Text + " " + txt_apellido.Text;
                        string cuit        = txt_cuit.Text;
                        string condiva     = ((CondicionIVA)cmb_iva.SelectedItem).Nombre;

                        //fact.cliente = per;

                        DateTime fechaCreacion = DateTime.Now.Date;
                        //est.idEstado = 27;
                        //fact.estado = est;
                        Double importeTotal = double.Parse(txt_monto_total.Text);
                        //fact.tipoFactura = char.Parse(cmb_tipo_factura.Text);
                        Double totalIVA = double.Parse(txt_totalIva.Text);

                        //DetalleFactura de = new DetalleFactura();
                        //Producto p = new Producto();

                        Int32  idProducto = (int)dgv_detalle.Rows[c].Cells["idProductodetalle"].Value;
                        String Nombre     = dgv_detalle.Rows[c].Cells["nombreproductodetalle"].Value.ToString();
                        Double subTotal   = (double)dgv_detalle.Rows[c].Cells["preciodetalle"].Value;
                        Double cantidad   = Convert.ToDouble(dgv_detalle.Rows[c].Cells["cantidad"].Value);
                        Double iva        = Convert.ToDouble(dgv_detalle.Rows[c].Cells["iva"].Value);

                        tabla.Rows.Add(fechaCreacion, cliente, RazonSocial, importeTotal, totalIVA, cantidad, subTotal, iva, cuit, condiva, idProducto, Nombre);
                        //de.producto = p;
                        //detalle.Add(de);
                    }
                    //try
                    //{

                    //    btn_guardar.Enabled = false;
                    //}
                    //catch (ApplicationException ex)
                    //{
                    //    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                    //}
                    //Emitir_Factura factura = new Emitir_Factura();
                    //factura.ShowDialog();

                    emitir._cargarPresupuesto = tabla;
                    emitir.ShowDialog();
                    btn_nuevo_Click(sender, e);
                }
            }
        }