Example #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         try
         {
             if (!(bool)Session["Autentica"])
             {
                 Response.Redirect("/geface/Login.aspx");
             }
         }
         catch
         {
             Response.Redirect("/geface/Login.aspx");
         }
         AccesoDatos acd = new AccesoDatos();
         string qry = String.Format(querys.Companias,Session["User"].ToString());
         DataTable empresas = acd.RealizaConsulta(qry);
         DataTable temp = empresas.Clone();
         temp.Columns["NOMBRE"].MaxLength = 100;
         temp.Rows.Add("-1", "Seleccione Compañia...");
         if (empresas.Rows.Count > 0)
         {
             foreach (DataRow r in empresas.Rows)
             {
                 temp.Rows.Add(r[0].ToString(), r[1].ToString());
             }
         }
         ddlCompania.DataSource = temp;
         ddlCompania.DataValueField = "CODIGO";
         ddlCompania.DataTextField = "NOMBRE";
         ddlCompania.DataBind();
         Page.GetPostBackEventReference(btnCargaLote);
     }
 }
        protected void Button1_Click(object sender, EventArgs e)
        {
            AccesoDatos a = new AccesoDatos();
            DataTable _ds = new DataTable();
            _ds = a.MySQL_RealizaConsulta("SELECT archivo FROM documento where idDocumento=1");
            byte[] MyData = (byte[])_ds.Rows[0]["archivo"];
            int ArraySize = new int();
            ArraySize = MyData.GetUpperBound(0);

            System.IO.FileStream fs = new System.IO.FileStream(@"C:\essairecup.png"
                                 , System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write);
            fs.Write(MyData, 0, ArraySize);
            fs.Close();
        }
Example #3
0
 /// <summary>
 /// Llena el DropDownList con las compañias a las que tiene autorización
 /// </summary>
 /// <param name="ddlCompanias">DropDownList de compañias a llenar</param>
 public void mCargaCompanias(ref DropDownList ddlCompanias)
 {
     AccesoDatos acd = new AccesoDatos();
     string qry = String.Format(querys.Companias_EFACE_AS400, Usuario);
     DataTable empresas = acd.RealizaConsulta(qry);
     DataTable temp = empresas.Clone();
     temp.Columns["NOMBRE"].MaxLength = 100;
     temp.Rows.Add("-1", "Seleccione Compañia...");
     if (empresas.Rows.Count > 0)
     {
         foreach (DataRow r in empresas.Rows)
         {
             temp.Rows.Add(r[0].ToString(), r[1].ToString());
         }
     }
     ddlCompanias.DataSource = temp;
     ddlCompanias.DataValueField = "CODIGO";
     ddlCompanias.DataTextField = "NOMBRE";
     ddlCompanias.DataBind();
 }
Example #4
0
 protected void ddlCompania_SelectedIndexChanged(object sender, EventArgs e)
 {
     AccesoDatos acd = new AccesoDatos();
     string qry = String.Format(querys.TipoDocumentos, ddlCompania.SelectedValue);
     DataTable documentos = acd.RealizaConsulta(qry);
     DataTable temp = documentos.Clone();
     temp.Columns["NOMBRE"].MaxLength = 100;
     temp.Rows.Add("-1", "Seleccione Tipo...");
     if (documentos.Rows.Count > 0)
     {
         foreach (DataRow r in documentos.Rows)
         {
             temp.Rows.Add(r[0], r[1]);
         }
     }
     ddlTipoDocumento.DataSource = temp;
     ddlTipoDocumento.DataTextField = "NOMBRE";
     ddlTipoDocumento.DataValueField = "TIPO";
     ddlTipoDocumento.DataBind();
 }
 protected void armaCuadro(string nCia, string mes, string anio, string tipoDoc, string td, string mesReporte, string tCia)
 {
     AccesoDatos ad = new AccesoDatos();
     DataTable dtEface = new DataTable();
     DataTable dtVentas = new DataTable();
     DataTable dtDatos = new DataTable();
     DataTable dtDatos2 = new DataTable();
     String strQry_Eface = "";
     String strQry_Ventas = "";
     String periodo = "<> -1";
     String gsucod =  "<>-1";
     strQry_Eface = string.Format(tipoDoc.Equals("4") ? querys.CuadroEfaceFAC : querys.CuadroEfaceNC, mes, anio, nCia, tipoDoc, periodo, gsucod);
     strQry_Ventas = querys.LoteTotalCofal;//string.Format(querys.CuadroVentas, tCia, (int.Parse(mes) < 10) ? String.Format("0{0}", int.Parse(mes).ToString()) : mes, anio.Substring(2, 2), td, periodo, gsucod);
     dtEface = getDataSQLSvr(strQry_Eface);
     dtVentas = ad.RealizaConsulta(strQry_Ventas);
     GeneraExcell ge = new GeneraExcell();
     ge.depurarDatos2(ref dtEface, ref dtVentas);
     //dtDatos = ge.UneTablas(dtEface, dtVentas);
     //dtDatos2 = ge.UneTablas2(dtEface, dtVentas);
     gvResultEFACEDDE.DataSource = dtEface;
     gvResultEFACEDDE.DataBind();
     gvResultAS400DDE.DataSource = dtVentas;
     gvResultAS400DDE.DataBind();
 }
        protected void btnBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                string codCliente = txtCodigoCliente.Text;

                //--------------CONSULTA NUEVA
                string qry = "";
                string qryDocumentos = "";

                if (!(codCliente.Trim().Length == 9) && !(codCliente.Trim().Length == 6))
                {
                    MsgBox1.alert("El código proporcionado no es NDC ni de un cliente existente");
                }
                else
                {
                    AccesoDatos ad = new AccesoDatos();
                    if (codCliente.Trim().Length == 9)
                        qry = String.Format("select LNUCSO AS NDC, lclnoc as CLIENTE, LCLNOC AS NOMBRE, '' AS DIRECCION, '' AS NIT, LEMAIL AS EMAIL  from cdicrm.cr0029f where LNUCSO='{0}'", codCliente);
                    else if (codCliente.Trim().Length == 6)
                        qry = String.Format("select '' AS NDC, gclcod as CLIENTE, gclnom as NOMBRE, ( gcldir||gclcod||gclciu ) as DIRECCION, gclnit as nit, GCLTX1 as EMAIL from intgen.fgen035 where gclcod='{0}'", codCliente);

                    qryDocumentos = @"select d.seqdocto as nodocumento, d.vcocia as compania, d.subare as area, t.nombretipo as tipo_documento, d.nombredoc
                            from cdigen.twgen0003 d left join cdigen.twgen0002 t on d.idtipodoc=t.idtipodoc
                            where d.clondc='{0}'  and UPPER(coalesce(d.estado,''))<>'X'";

                    DataTable dtDatosCliente = new DataTable();
                    dtDatosCliente = ad.RealizaConsulta(qry);

                    DataTable dtDocumentosCliente = new DataTable();
                    dtDocumentosCliente = ad.RealizaConsulta(String.Format(qryDocumentos,txtCodigoCliente.Text));

                    if (dtDatosCliente != null && dtDatosCliente.Rows.Count > 0)
                    {
                        //this.ViewState["CLIENTE"] = dtDatosCliente;
                        //if (dtDatosCliente.Rows.Count > 0)
                        {
                            gvDatosCliente.DataSource = dtDatosCliente;
                            gvDatosCliente.DataBind();
                            pDatosCliente.Visible = true;

                            gvDocumentosCliente.DataSource = dtDocumentosCliente;
                            gvDocumentosCliente.DataBind();
                            pDocumentosCliente.Visible = true;
                        }
                        //else
                        //{
                        //    this.obtenerDatos(0);
                        //}
                    }
                    else
                    {
                        gvDatosCliente.DataSource = dtDatosCliente;
                        gvDatosCliente.DataBind();
                        pDatosCliente.Visible = true;
                    }
                }
            }
            catch (Exception arg_146_0)
            {
                Exception exception = arg_146_0;
                MsgBox1.alert("Error al cargar los datos " + exception.Message);
            }
        }
Example #7
0
 protected void ddlCiaFac_SelectedIndexChanged(object sender, EventArgs e)
 {
     AccesoDatos ad = new AccesoDatos();
     DataTable Sucursal = AD.SQLSvr_RealizaConsulta(String.Format(querys.Sucursal_PDF, ddlCiaFac.SelectedValue.ToString()));
     DataTable temp = Sucursal.Clone();
     temp.Columns["NOMBRE"].MaxLength = 300;
     temp.Rows.Add("-1", "Seleccione Sucursal...");
     temp.Rows.Add("0", "TODAS");
     if (Sucursal.Rows.Count > 0)
     {
         foreach (DataRow r in Sucursal.Rows)
         {
             temp.Rows.Add(r[0].ToString(), r[1].ToString());
         }
     }
     ddlSucursalFac.DataSource = temp;
     ddlSucursalFac.DataValueField = "CODIGO";
     ddlSucursalFac.DataTextField = "NOMBRE";
     ddlSucursalFac.DataBind();
 }
Example #8
0
 private void LimpiarDatos()
 {
     ddlCompania.Items.Clear();
     ddlTipoDocumento.Items.Clear();
     txtDocumento.Text = "";
     ddlCompania.Focus();
     AccesoDatos acd = new AccesoDatos();
     string qry = String.Format(querys.Companias, Session["User"].ToString());
     DataTable empresas = acd.RealizaConsulta(qry);
     DataTable temp = empresas.Clone();
     temp.Columns["NOMBRE"].MaxLength = 100;
     temp.Rows.Add("-1", "Seleccione Compañia...");
     if (empresas.Rows.Count > 0)
     {
         foreach (DataRow r in empresas.Rows)
         {
             temp.Rows.Add(r[0].ToString(), r[1].ToString());
         }
     }
     ddlCompania.DataSource = temp;
     ddlCompania.DataValueField = "CODIGO";
     ddlCompania.DataTextField = "NOMBRE";
     ddlCompania.DataBind();
 }
Example #9
0
        private string obtieneDatosSAT(String Cia, String CentroCosto, String NumFac, String Dato, String tDocIfacere, String pSerie)
        {
            string resultado = "";
            string qry ="";
            AccesoDatos add = new AccesoDatos();
            if (TipoFactura.Equals(PFACW0001.ENUMS.TFactura.VehiculoNuevo) || TipoFactura.Equals(PFACW0001.ENUMS.TFactura.VehiculoUsado) || TipoFactura.Equals(PFACW0001.ENUMS.TFactura.Oficina))
                qry = String.Format(Query.DatosSATVOFN, Cia, CentroCosto,pSerie);
            else
                qry = String.Format(Query.DatosSAT, Cia);
            DataTable Sat = add.RealizaConsulta(qry);
                if (Dato.Equals("RES"))//Resolucion
                {
                    resultado = getDataSQLSvr("RES", Cia, CentroCosto, NumFac, tDocIfacere, pSerie);
                }
                if (Dato.Equals("SER"))//Serie
                {
                    resultado = getDataSQLSvr("SER", Cia, CentroCosto, NumFac, tDocIfacere, pSerie);
                }
                if (Dato.Equals("EMP"))//Empresa
                {
                    if (Sat.Rows.Count > 0)
                    {
                        resultado = Sat.Rows[0]["EMPRESA"].ToString();
                    }
                    else
                    {
                        resultado = "S/D";
                    }
                }
                if (Dato.Equals("SUC"))//Sucursal
                {
                    resultado = getDataSQLSvr("SUC", Cia, "", "", tDocIfacere, pSerie);
                }

            return resultado;
        }
Example #10
0
 private string obtieneCaja(String Cia, String Correlativo)
 {
     string caja = "";
     AccesoDatos cmp = new AccesoDatos();
     string qry = String.Format(Query.CajaFactura, Cia, Correlativo);
     DataTable Caja = cmp.RealizaConsulta(qry);
     if (Caja.Rows.Count > 0)
     {
         caja = Caja.Rows[0]["CAJA"].ToString();
     }
     else
     {
         caja = "S/N";
     }
     return caja;
 }
        private string ObtieneUltimoLote(String Cia, String TipoDocumento)
        {
            try
            {
                AccesoDatos cpm = new AccesoDatos();
                DataTable NumLote = cpm.RealizaConsulta(String.Format(Query.NumeroLote, Cia, TipoDocumento));
                Decimal lote = Convert.ToDecimal(NumLote.Rows[0]["NUMLOT"].ToString());
                string loteActual = Convert.ToString(lote + 1);
                string dml = String.Format(Query.IncrementaLote, loteActual, Cia, TipoDocumento);
                int valorUpdate = cpm.RealizaDml(dml);
                if (valorUpdate == 1)
                {
                    return lote.ToString();
                }
                else
                {
                    throw new Exception("Al Actualizar Numero Lote xTFAC045");
                }
            }
            catch (Exception err)
            {

                throw new Exception("Error al Obtener Numero de Pedido Lote - "+err.Message);
            }
        }
        private string ArmaLoteDocumentos(String tipoDocumento, String Compania, String tipoInventario, String fecha_inicio, String fecha_fin, String usuario, String NumLote)
        {
            string resultado = "";
            string pedido = NumLote;
            string tDoc = "";
            int pilaDocumento = 0;
            DataTable ListadoDocumentos = new DataTable();
            if (tipoDocumento.Equals("FIN") || tipoDocumento.Equals("FOF") || tipoDocumento.Equals("FVH") || tipoDocumento.Equals("FVU") || tipoDocumento.Equals("SER"))//Todas las Facturas
            {
                tDoc = "1";
            }
            else if (tipoDocumento.Equals("NIN") || tipoDocumento.Equals("NOF") || tipoDocumento.Equals("NVH") || tipoDocumento.Equals("NVU") || tipoDocumento.Equals("NSE"))//Todas las Notas de Credito
            {
                tDoc = "2";
            }
            try
            {
                AccesoDatos acd = new AccesoDatos();
                string Lote = "";
                if (tipoDocumento.Equals("FIN") || tipoDocumento.Equals("NIN") )
                {
                    Lote = String.Format(Query.LoteDocumentos, tDoc, Compania, tipoInventario,"<>", desglosaFecha(fecha_inicio, "D"), desglosaFecha(fecha_fin, "D"), desglosaFecha(fecha_inicio, "M"), desglosaFecha(fecha_fin, "M"), desglosaFecha(fecha_inicio, "A"), desglosaFecha(fecha_fin, "A"));
                }
                if (tipoDocumento.Equals("SER") || tipoDocumento.Equals("NSE"))
                {
                    Lote = String.Format(Query.LoteDocumentos, tDoc, Compania, tipoInventario, "=", desglosaFecha(fecha_inicio, "D"), desglosaFecha(fecha_fin, "D"), desglosaFecha(fecha_inicio, "M"), desglosaFecha(fecha_fin, "M"), desglosaFecha(fecha_inicio, "A"), desglosaFecha(fecha_fin, "A"));
                }
                if (tipoDocumento.Equals("FVH"))
                {
                    Lote = String.Format(Query.LoteDocumentosFVH,Compania, desglosaFecha(fecha_inicio, "D"), desglosaFecha(fecha_fin, "D"), desglosaFecha(fecha_inicio, "M"), desglosaFecha(fecha_fin, "M"), desglosaFecha(fecha_inicio, "A"), desglosaFecha(fecha_fin, "A"));
                }
                if (tipoDocumento.Equals("NVH"))
                {
                    Lote = String.Format(Query.LoteDocumentosNVH, Compania, desglosaFecha(fecha_inicio, "D"), desglosaFecha(fecha_fin, "D"), desglosaFecha(fecha_inicio, "M"), desglosaFecha(fecha_fin, "M"), desglosaFecha(fecha_inicio, "A"), desglosaFecha(fecha_fin, "A"));
                }
                if (tipoDocumento.Equals("NVU"))
                {
                    Lote = String.Format(Query.LoteDocumentosNVU, Compania, desglosaFecha(fecha_inicio, "D"), desglosaFecha(fecha_fin, "D"), desglosaFecha(fecha_inicio, "M"), desglosaFecha(fecha_fin, "M"), desglosaFecha(fecha_inicio, "A"), desglosaFecha(fecha_fin, "A"));
                }
                if (tipoDocumento.Equals("FVU"))
                {
                    string vsste="";
                    string serie = "";
                    if (Compania.Equals("CS"))
                    {
                        vsste = String.Format("'{0}',''", Compania);
                        serie = "U";
                    }
                    else if (Compania.Equals("RE"))
                    {
                        vsste = String.Format("'{0}'",Compania);
                        serie = "C";
                    }

                    Lote = String.Format(Query.LoteDocumentosFVU, desglosaFecha(fecha_inicio, "D"), desglosaFecha(fecha_fin, "D"), desglosaFecha(fecha_inicio, "M"), desglosaFecha(fecha_fin, "M"), desglosaFecha(fecha_inicio, "A"), desglosaFecha(fecha_fin, "A"),vsste,serie);
                }
                if (tipoDocumento.Equals("FOF"))
                {
                    Lote = String.Format(Query.LoteDocumentosOficina,Compania,"FAC", desglosaFecha(fecha_inicio, "D"), desglosaFecha(fecha_fin, "D"), desglosaFecha(fecha_inicio, "M"), desglosaFecha(fecha_fin, "M"), desglosaFecha(fecha_inicio, "A"), desglosaFecha(fecha_fin, "A"));
                }
                if (tipoDocumento.Equals("NOF"))
                {
                    Lote = String.Format(Query.LoteDocumentosOficina,Compania,"NCR", desglosaFecha(fecha_inicio, "D"), desglosaFecha(fecha_fin, "D"), desglosaFecha(fecha_inicio, "M"), desglosaFecha(fecha_fin, "M"), desglosaFecha(fecha_inicio, "A"), desglosaFecha(fecha_fin, "A"));
                }
                DataTable Todas = acd.RealizaConsulta(Lote);

                if (Todas.Rows.Count > 0)
                {
                    DataTable NoProcesadas = new DataTable();
                    DataRow[] rrr = Todas.Select("procesada <> ''");
                    if (rrr.Length > 0)
                        NoProcesadas = rrr.CopyToDataTable();
                    DataTable Procesadas = new DataTable();
                    DataRow[] ppp = Todas.Select("procesada = ''");
                    if (ppp.Length > 0)
                        Procesadas = ppp.CopyToDataTable();
                    //Aca va la Logica para guardar las NoProcesadas
                    if (NoProcesadas.Rows.Count > 0)
                    {
                        foreach (DataRow r in NoProcesadas.Rows)
                        {
                            AlmacenaFacturas_NoAceptadas(Compania, tipoDocumento, r["NO_DOC"].ToString().Trim(), "Factura aun no Procesada - Sin Detalle", "N");
                        }
                    }
                    //Fin de Logica
                    if (Procesadas.Rows.Count > 0)
                    {
                        ListadoDocumentos = Procesadas.Copy();
                    }
                }
                int CantidadDocumentos;
                if (ListadoDocumentos.Rows.Count > 0)
                {
                    CantidadDocumentos = ListadoDocumentos.Rows.Count;
                }
                else
                {
                    CantidadDocumentos = 0;
                }
                if (CantidadDocumentos > 0)
                {
                    String InitTag = @"<?xml version='1.0' encoding='ISO-8859-1' ?>"+Environment.NewLine+
                        "<LOTE>"+Environment.NewLine+"<PEDIDO>" + pedido + "</PEDIDO>" +Environment.NewLine+
                        "<TOTALDOCUMENTOS>" + CantidadDocumentos + "</TOTALDOCUMENTOS>"+Environment.NewLine+"<DOCUMENTOS>"+Environment.NewLine;
                    String EndTag = Environment.NewLine+"</DOCUMENTOS>"+Environment.NewLine+"</LOTE>";
                    String Cuerpo = "";
                    String DocumentoLote = "";
                    for (int i = 0; i < ListadoDocumentos.Rows.Count; i++)
                    {
                        pilaDocumento = i;
                        if (tipoDocumento.Equals("FIN"))//Facturas de Inventario
                        {
                            GeneraXML xml = new GeneraXML(PFACW0001.ENUMS.TDocumento.Factura, Compania, ListadoDocumentos.Rows[i]["ESTADO"].ToString().Trim(), tipoInventario, ListadoDocumentos.Rows[i]["NO_DOC"].ToString().Trim(), PFACW0001.ENUMS.TFactura.Repuesto, "");
                            string facturaTemp = xml.getXmlDocumentoElectronico();
                            facturaTemp = facturaTemp.Remove(0, 39);
                            Cuerpo = Cuerpo + facturaTemp;
                        }
                        if (tipoDocumento.Equals("NIN"))//NotaCredito Inventario
                        {
                            GeneraXML xml = new GeneraXML(PFACW0001.ENUMS.TDocumento.NotaCredito, Compania, ListadoDocumentos.Rows[i]["ESTADO"].ToString().Trim(), tipoInventario, ListadoDocumentos.Rows[i]["NO_DOC"].ToString().Trim(), PFACW0001.ENUMS.TFactura.Repuesto, "");
                            string NotaCreditoTemp = xml.getXmlDocumentoElectronico();
                            NotaCreditoTemp = NotaCreditoTemp.Remove(0, 39);
                            Cuerpo = Cuerpo + NotaCreditoTemp;
                        }
                        if (tipoDocumento.Equals("SER"))
                        {
                            GeneraXML xml = new GeneraXML(PFACW0001.ENUMS.TDocumento.Factura, Compania, ListadoDocumentos.Rows[i]["ESTADO"].ToString().Trim(), tipoInventario, ListadoDocumentos.Rows[i]["NO_DOC"].ToString().Trim(), PFACW0001.ENUMS.TFactura.Taller, "");
                            string facturaTempServ = xml.getXmlDocumentoElectronico();
                            facturaTempServ = facturaTempServ.Remove(0, 39);
                            Cuerpo = Cuerpo + facturaTempServ;
                        }
                        if (tipoDocumento.Equals("NSE")) //Notas de credito de servicios
                        {
                            GeneraXML xml = new GeneraXML(PFACW0001.ENUMS.TDocumento.NotaCredito, Compania, ListadoDocumentos.Rows[i]["ESTADO"].ToString().Trim(), tipoInventario, ListadoDocumentos.Rows[i]["NO_DOC"].ToString().Trim(), PFACW0001.ENUMS.TFactura.Taller, "");
                            string facturaTemp = xml.getXmlDocumentoElectronico();
                            facturaTemp = facturaTemp.Remove(0, 39);
                            Cuerpo = Cuerpo + facturaTemp;
                        }
                        if (tipoDocumento.Equals("FVH")) //Facturas vehiculos nuevos
                        {
                            GeneraXML xml = new GeneraXML(PFACW0001.ENUMS.TDocumento.Factura, Compania, ListadoDocumentos.Rows[i]["ESTADO"].ToString().Trim(), tipoInventario, ListadoDocumentos.Rows[i]["NO_DOC"].ToString().Trim(), PFACW0001.ENUMS.TFactura.VehiculoNuevo, "", ListadoDocumentos.Rows[i]["FECHA"].ToString());
                            string facturaTemp = xml.getXmlDocumentoElectronico();
                            facturaTemp = facturaTemp.Remove(0, 39);
                            Cuerpo = Cuerpo + facturaTemp;
                        }
                        if (tipoDocumento.Equals("NVH")) //Notas de credito vehiculos nuevos
                        {
                            GeneraXML xml = new GeneraXML(PFACW0001.ENUMS.TDocumento.NotaCredito, Compania, ListadoDocumentos.Rows[i]["ESTADO"].ToString().Trim(), tipoInventario, ListadoDocumentos.Rows[i]["NO_DOC"].ToString().Trim(), PFACW0001.ENUMS.TFactura.Oficina, "NCR");
                            string facturaTemp = xml.getXmlDocumentoElectronico();
                            facturaTemp = facturaTemp.Remove(0, 39);
                            Cuerpo = Cuerpo + facturaTemp;
                        }
                        if (tipoDocumento.Equals("FVU")) //Notas de credito vehiculos usados
                        {
                            GeneraXML xml = new GeneraXML(PFACW0001.ENUMS.TDocumento.Factura, Compania, ListadoDocumentos.Rows[i]["ESTADO"].ToString().Trim(), tipoInventario, ListadoDocumentos.Rows[i]["NO_DOC"].ToString().Trim(), PFACW0001.ENUMS.TFactura.VehiculoUsado, "", ListadoDocumentos.Rows[i]["FECHA"].ToString());
                            string facturaTemp = xml.getXmlDocumentoElectronico();
                            facturaTemp = facturaTemp.Remove(0, 39);
                            Cuerpo = Cuerpo + facturaTemp;
                        }
                        if (tipoDocumento.Equals("NVU")) //Notas de credito vehiculos usados
                        {
                            GeneraXML xml = new GeneraXML(PFACW0001.ENUMS.TDocumento.NotaCredito, Compania, ListadoDocumentos.Rows[i]["ESTADO"].ToString().Trim(), tipoInventario, ListadoDocumentos.Rows[i]["NO_DOC"].ToString().Trim(), PFACW0001.ENUMS.TFactura.Oficina, "NCR");
                            string facturaTemp = xml.getXmlDocumentoElectronico();
                            facturaTemp = facturaTemp.Remove(0, 39);
                            Cuerpo = Cuerpo + facturaTemp;
                        }
                        if (tipoDocumento.Equals("FOF")) //Facturas de Oficina
                        {
                            GeneraXML xml = new GeneraXML(PFACW0001.ENUMS.TDocumento.Factura, Compania, ListadoDocumentos.Rows[i]["ESTADO"].ToString().Trim(), tipoInventario, ListadoDocumentos.Rows[i]["NO_DOC"].ToString().Trim(), PFACW0001.ENUMS.TFactura.Oficina, "FAC");
                            string facturaTemp = xml.getXmlDocumentoElectronico();
                            facturaTemp = facturaTemp.Remove(0, 39);
                            Cuerpo = Cuerpo + facturaTemp;
                        }
                        if (tipoDocumento.Equals("NOF")) //Notas de credito de Oficina
                        {
                            GeneraXML xml = new GeneraXML(PFACW0001.ENUMS.TDocumento.NotaCredito, Compania, ListadoDocumentos.Rows[i]["ESTADO"].ToString().Trim(), tipoInventario, ListadoDocumentos.Rows[i]["NO_DOC"].ToString().Trim(), PFACW0001.ENUMS.TFactura.Oficina, "NCR");
                            string facturaTemp = xml.getXmlDocumentoElectronico();
                            facturaTemp = facturaTemp.Remove(0, 39);
                            Cuerpo = Cuerpo + facturaTemp;
                        }
                        if (tipoDocumento.Equals("3"))//NotaDebito
                        {
                        }
                    }
                    DocumentoLote = InitTag + Cuerpo + EndTag;
                    resultado = DocumentoLote;
                }
                else
                {
                    throw new Exception("No exiten documentos en la fecha indicada.");
                }
            }
            catch (Exception err)
            {
                if (ListadoDocumentos.Rows.Count>0)
                throw new Exception("PFACLOTEx - Doc. No: " + pilaDocumento.ToString() + "  Documento: " + ListadoDocumentos.Rows[pilaDocumento]["NO_DOC"].ToString() +".- "+ err.Message);
                else
                    throw new Exception("PFACLOTEx: " + err.Message);
            }
            return resultado;
        }
 private void AlmacenaFacturas_NoAceptadas(String Compania, String tipoFactura, String NumFactura, String Motivo, String Estado)
 {
     try
     {
         AccesoDatos ad = new AccesoDatos();
         string SigloOper = "1";
         string AnioOper = DateTime.Now.Year.ToString().Substring(2, 2).PadLeft(2,'0');
         string MesOper = DateTime.Now.Month.ToString().PadLeft(2,'0');
         string DiaOper = DateTime.Now.Day.ToString().PadLeft(2,'0');
         string HoraOper = DateTime.Now.Hour.ToString().PadLeft(2, '0') + DateTime.Now.Minute.ToString().PadLeft(2, '0') + DateTime.Now.Second.ToString().PadLeft(2, '0');
         string dml = String.Format(Query.AlmacenaNoAceptadas,Compania,tipoFactura,NumFactura,SigloOper,AnioOper,MesOper,DiaOper,HoraOper,(Motivo.Length>50)?Motivo.Substring(0,50):Motivo,Estado);
         int almacena = ad.RealizaDml(dml);
         if (almacena == 1)
         {
             ;
         }
         else
         {
             throw new Exception("Al Insertar el Registro xTFAC043");
         }
     }
     catch (Exception err)
     {
         throw new Exception("Error al Almacenar Facturas No Aceptadas - "+err.Message);
     }
 }
        private void AlmacenaEnvioDocumentos(bool Lote, String Cia, String TipoFactura, String FechaLoteI, String FechaLoteF, String horaEnvio, String UsuarioOperacion, String NumLote, String Factura)
        {
            try
            {
                AccesoDatos CapaMedia = new AccesoDatos();
                if (Lote)
                {
                    string AnioInicio= desglosaFecha(FechaLoteI,"A");
                    string MesInicio = desglosaFecha(FechaLoteI,"M");
                    string DiaInicio = desglosaFecha(FechaLoteI,"D");
                    string AnioFin = desglosaFecha(FechaLoteF,"A");
                    string MesFin = desglosaFecha(FechaLoteF,"M");
                    string DiaFin = desglosaFecha(FechaLoteF,"D");
                    string SigloInicio = "1";
                    string SigloFin = "1";
                    string SigloOper = "1";
                    string AnioOper = DateTime.Now.Year.ToString().Substring(2,2);
                    AnioOper = AnioOper.PadLeft(2, '0');
                    string MesOper = DateTime.Now.Month.ToString();
                    MesOper = MesOper.PadLeft(2, '0');
                    string DiaOper = DateTime.Now.Day.ToString();
                    DiaOper = DiaOper.PadLeft(2, '0');
                    string HoraOper = DateTime.Now.Hour.ToString().PadLeft(2, '0') + DateTime.Now.Minute.ToString().PadLeft(2, '0') + DateTime.Now.Second.ToString().PadLeft(2, '0');
                    if (CapaMedia.RealizaDml(String.Format(Query.AlmacenaDocumentoEnvio, Cia, TipoFactura, SigloInicio, AnioInicio, MesInicio, DiaInicio, SigloFin, AnioFin, MesFin, DiaFin, HoraOper, SigloOper, AnioOper, MesOper, DiaOper, UsuarioOperacion, NumLote, Factura)) == 1)
                    {
                        ;
                    }
                    else
                    {
                        throw new Exception("Error al Insertar Datos TFAC042");
                    }
                }
                else //si es Documento Individual
                {
                    string AnioInicio = "";
                    string MesInicio = "";
                    string DiaInicio = "";
                    string AnioFin = "";
                    string MesFin = "";
                    string DiaFin = "";
                    string SigloInicio = "";
                    string SigloFin = "";
                    string SigloOper = "1";
                    string AnioOper = DateTime.Now.Year.ToString().Substring(2, 2);
                    AnioOper = AnioOper.PadLeft(2, '0');
                    string MesOper = DateTime.Now.Month.ToString();
                    MesOper = MesOper.PadLeft(2, '0');
                    string DiaOper = DateTime.Now.Day.ToString();
                    DiaOper = DiaOper.PadLeft(2, '0');
                    string HoraOper = Convert.ToString(DateTime.Now.Hour.ToString().PadLeft(2, '0') + DateTime.Now.Minute.ToString().PadLeft(2, '0') + DateTime.Now.Second.ToString().PadLeft(2, '0'));
                    string dml = String.Format(Query.AlmacenaDocumentoEnvio, Cia, TipoFactura, SigloInicio, AnioInicio, MesInicio, DiaInicio, SigloFin, AnioFin, MesFin, DiaFin, HoraOper, SigloOper, AnioOper, MesOper, DiaOper, UsuarioOperacion, NumLote, Factura);
                    if (CapaMedia.RealizaDml(dml) == 1)
                    {
                        ;
                    }
                    else
                    {
                        throw new Exception("Error al Insertar Datos xTFAC042");
                    }
                }

            }
            catch (Exception err)
            {
                throw new Exception("Error al Almacenar el Envio del Lote - "+err.Message);
            }
        }