private string FabricarFacturaObjeto(Orden orden) { if (MessageBox.Show(this, "Desea crear factura?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Text File | *.txt"; sfd.ShowDialog(); string filename = sfd.FileName; using (var stream = new FileStream(filename, FileMode.OpenOrCreate)) { IGeneradorFactura generadorFactura = new GeneradorFactura(); StreamWriter sw = new StreamWriter(stream); FacturaXML factura = generadorFactura.CrearFacturaObjeto(orden, _articulos); string xml = SerializadorXml.CrearXml(factura); sw.WriteLine(xml); sw.Close(); return(xml); } } catch (Exception ex) { MessageBox.Show(this, "Ocurrio un error mostrar factura"); return(null); } } return(null); }
static void Main(string[] args) { PDF pdf = new PDF(); string xml = @"C:\Users\tonovarela\Desktop\f.XML"; FacturaXML facturaXML = new FacturaXML(xml, true); CFDI cfdi = facturaXML.ObtenerData(); pdf.cfdi = cfdi; pdf.obtenerRepresentacionImpresa(new CLRcfdi.models.Cliente() { NoCliente = "Varela" }); }
public static string createFile( string contentXML, string NoCliente = "", string LugarYFechaExpedicion = "", string Direccion = "", string CP = "", string Colonia = "", string DelegacionEstado = "", string Contacto = "", string Telefono = "", string Vencimiento = "", string DescripcionMetodoPago = "", string DescripcionFormaPago = "", string Referencia = "" ) { Cliente c = new Cliente(); c.NoCliente = NoCliente; c.LugarYFechaExpedicion = LugarYFechaExpedicion; c.Direccion = Direccion; c.CP = CP; c.Colonia = Colonia; c.DelegacionEstado = DelegacionEstado; c.Contacto = Contacto; c.Telefono = Telefono; c.Vencimiento = Vencimiento; c.DescripcionFormaPago = DescripcionFormaPago; c.DescripcionMetodoPago = DescripcionMetodoPago; c.Referencia = Referencia; try { FacturaXML facturaXML = new FacturaXML(contentXML, false); CFDI cfdi = facturaXML.ObtenerData(); PDF pdf = new PDF(); pdf.cfdi = cfdi; pdf.obtenerRepresentacionImpresa(c); }catch (Exception e) { return($"Error al crear archivo en la factura "); } return("Archivo Creado"); }
public ActionResult Facturar(int?id) { int.TryParse(id.ToString(), out int _id); if (id > 0) { //OBTENIENDO EL OBJETO FACTURA _base = new FacturaBL(); var _factura = (Factura)_base.ObtenerId(_id); FacturaXML _xml = new FacturaXML(); _xml.Cliente = _factura.Cliente.nombres; _xml.Vendedor = _factura.Usuario.userName; DateTime _fechaCompra = DateTime.Parse(_factura.fechaCompra.ToString()); _xml.FechaCompra = _fechaCompra.ToString("dd/MM/yyyy hh:mm:ss"); _xml.CodigoFactura = Encriptacion.Encrypt(_factura.id.ToString().PadRight(20)); _xml.Detalle = new List <FacturaXML.DetalleProducto>(); _xml.Detalle = new List <FacturaXML.DetalleProducto>(); foreach (var item in _factura.DetalleFactura) { _xml.Detalle.Add(new FacturaXML.DetalleProducto { NombreProducto = item.Producto.nombre, Precio = item.Producto.precio.ToString() } ); } string _serializado = SerializeObject(_xml); CargarArchivoXML(_serializado); return(RedirectToAction("Index", "Facturacion")); } else { return(RedirectToAction("Index", "Facturacion")); } }
public FormularioPresentarFactura(FacturaXML _facturaDTO) { InitializeComponent(); FacturaDTO = _facturaDTO; CrearGrilla(); }