Пример #1
0
        public FileResult Nuevo(ats_Info model)
        {
            model.info_periodo.IdPeriodo = Convert.ToInt32(Session["IdPeriodo"]);
            bus_ats = new ats_Bus();
            string nombre_file = model.info_periodo.IdPeriodo.ToString();

            if (model.info_periodo.IdPeriodo.ToString().Length == 6)
            {
                nombre_file = "AT-" + model.info_periodo.IdPeriodo.ToString().Substring(4, 2) + model.info_periodo.IdPeriodo.ToString().Substring(0, 4);
            }
            string xml        = "";
            iva    ats        = new iva();
            int    IdEmpresa  = Convert.ToInt32(SessionFixed.IdEmpresa);
            int    IdSucursal = Convert.ToInt32(SessionFixed.IdSucursal);

            ats = bus_ats.get_ats(IdEmpresa, model.info_periodo.IdPeriodo, IdSucursal);
            var ms = new MemoryStream();
            var xw = XmlWriter.Create(ms);


            var serializer             = new XmlSerializer(ats.GetType());
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();

            ns.Add("", "");
            serializer.Serialize(xw, ats, ns);
            xw.Flush();
            ms.Seek(0, SeekOrigin.Begin);
            using (var sr = new StreamReader(ms, Encoding.UTF8))
            {
                xml = sr.ReadToEnd();
            }
            byte[] fileBytes = ms.ToArray();
            return(File(fileBytes, "application/xml", nombre_file + ".xml"));
        }
Пример #2
0
        public JsonResult get_ats(int IdPeriodo)
        {
            bus_ats = new ats_Bus();
            ats_Info model     = new ats_Info();
            int      IdEmpresa = Convert.ToInt32(SessionFixed.IdEmpresa);

            model = bus_ats.get_info(IdEmpresa, IdPeriodo);
            Session["lst_compras"]       = model.lst_compras;
            Session["lst_ventas"]        = model.lst_ventas;
            Session["lst_retenciones"]   = model.lst_retenciones;
            Session["lst_exportaciones"] = model.lst_exportaciones;
            Session["lst_anulados"]      = model.lst_anulados;
            Session["IdPeriodo"]         = IdPeriodo;

            return(Json("", JsonRequestBehavior.AllowGet));
        }