Пример #1
0
 private void Button1_Click(object sender, EventArgs e)
 {
     using (var service = new Service.FacturaService())
     {
         var factura = service.FiltrarPorID(Convert.ToInt32(this.tb_numfactura.Text));
     }
 }
Пример #2
0
 private void AnularFacturas_Load(object sender, EventArgs e)
 {
     using (var service = new Service.FacturaService())
     {
         facturas = service.ObtenerFacturasNoAnuladas();
         dg_facturasPendientes.CargarGrid(facturas);
         DecorarGrid();
     }
 }
Пример #3
0
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            dg_orden.EndEdit();
            validaDatos = ValidarValores(validaDatos);

            if (validaDatos.EsValido)
            {
                using (var service = new Service.FacturaService())
                {
                    var esFacturaDuplicada = service.EsFacturaDuplicada(Convert.ToInt32(this.tb_numFactura.Text));

                    if (!esFacturaDuplicada)
                    {
                        Model.Factura factura = new Model.Factura();
                        factura.Id_Usuario     = 1;
                        factura.Num_Factura    = Convert.ToInt32(this.tb_numFactura.Text);
                        factura.Fecha          = this.fecha_fac.Value;
                        factura.IVA            = Convert.ToDouble(this.tb_IVA.Text);
                        factura.Monto          = Convert.ToDouble(this.tb_total.Text);
                        factura.Tcambio        = Convert.ToDouble(this.tb_tipoCambio.Text);
                        factura.Credito        = this.rb_credito.Checked;
                        factura.nRUC           = this.tb_ruc.Text;
                        factura.Nombre_Cliente = this.tb_nombre.Text;
                        factura.Fecha_Venc     = this.fecha_venc.Value;

                        foreach (DataGridViewRow articulo in dg_orden.Rows)
                        {
                            Model.FacturaDetalle detalle = new Model.FacturaDetalle();
                            detalle.Cantidad    = Convert.ToInt32(articulo.Cells[2].Value);
                            detalle.Porcentaje  = ObtenerPorcentajeComision(articulo);
                            detalle.Precio      = Convert.ToDouble(articulo.Cells[3].Value);
                            detalle.Id_Producto = Convert.ToInt32(articulo.Cells[0].Value);
                            factura.FacturaDetalle.Add(detalle);
                        }
                        if (service.CrearFactura(factura))
                        {
                            MessageBox.Show("Factura creada!", APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Controles.LimpiarControles(this.Controls);
                            this.dg_orden.Rows.Clear();
                            ObtenerProductos();
                            DecorarGrid();
                        }
                        else
                        {
                            MessageBox.Show("Ocurrio un error al guardar la factura", APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Factura duplicada", APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
Пример #4
0
        private void AnularFactura(object sender, DataGridViewCellEventArgs e)
        {
            using (var service = new Service.FacturaService())
            {
                int IdFactura = Convert.ToInt32(dg_facturasPendientes.Rows[e.RowIndex].Cells[0].Value);
                var factura   = service.FiltrarPorID(IdFactura);

                if (MessageBox.Show("¿Desea anular la factura " + factura.Num_Factura + "?", APP_NAME, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    if (service.AnularFactura(IdFactura))
                    {
                        dg_facturasPendientes.CargarGrid(facturas);
                        DecorarGrid();
                    }
                    MessageBox.Show("Ocurrio un error",
                                    APP_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }