コード例 #1
0
        private int cantDTERestantes(string sql, bdConexion conexion)
        {
            string    strCount = string.Empty;
            DataTable result;

            strCount = sql.Replace("select distinct", "select count(*) from (select distinct");
            strCount = strCount.Replace("--cantDTEOracle", " ) ");

            result = conexion.EjecutaSelect(strCount);

            return(Int32.Parse(result.Rows[0][0].ToString()));
        }
コード例 #2
0
        private List <Referencia> getRefencias(string corrDocu, bdConexion conexion)
        {
            string            sql = string.Empty;
            DataTable         result;
            List <Referencia> list_refe_temp = new List <Referencia>();

            sql  = " select foli_refe, tipo_refe ";
            sql += " from dto_docu_refe_p ";
            sql += " where corr_docu = {0} ";

            result = conexion.EjecutaSelect(String.Format(sql, corrDocu));
            int dte_num = result.Rows.Count;

            for (int i = 0; i < dte_num; i++)
            {
                string     foliRefe = result.Rows[i][0].ToString();
                string     tipoRefe = result.Rows[i][1].ToString();
                Referencia ref_temp = new Referencia(foliRefe, tipoRefe);
                list_refe_temp.Add(ref_temp);
            }
            return(list_refe_temp);
        }
コード例 #3
0
        private void recuperarDTEs(DTEPendietes dtes, int cantDTERecuperar, bdConexion conexion, log logs)
        {
            string    sql = string.Empty;
            DataTable result;

            sql  = " select distinct dto.rutt_rece, dto.digi_rece, dto.rutt_emis, dto.digi_emis, dto.tipo_docu, dto.foli_docu, dto.fech_emis, dto.mont_neto, dto.mont_exen, dto.mont_tota, dto.corr_docu, dto.codi_empr ";
            sql += " FROM dto_enca_docu_p dto ";
            sql += " LEFT OUTER JOIN dto_docu_refe_p ref ON dto.corr_docu=ref.corr_docu ";
            sql += " where dto.esta_docu in ('INI', 'ERA') ";
            sql += " and dto.tipo_docu in ('33','34') ";
            sql += " and dto.esta_tras is null ";
            sql += " and dto.corr_docu not in ( ";
            sql += "     SELECT dto.corr_docu ";
            sql += "     FROM dto_enca_docu_p dto ";
            sql += "     LEFT OUTER JOIN dto_docu_refe_p ref ON dto.corr_docu=ref.corr_docu ";
            sql += "     where dto.esta_docu in ('INI', 'ERA') ";
            sql += "     and dto.tipo_docu in ('33','34') ";
            sql += "     and ref.TIPO_REFE = 803 and ref.foli_refe = 'COM' ";
            sql += " ) --cantDTEOracle ";

            string sqlCantDTE = cantidadDTE(sql, cantDTERecuperar, conexion.baseDatos);

            result = conexion.EjecutaSelect(sqlCantDTE);

            int dte_num = result.Rows.Count;

            logs.putLog(1, "-- Cantidad de DTE a entregar (dte_num): " + dte_num);

            if (dte_num == 0)
            {
                dtes.cantRestantes = 0;
                logs.putLog(1, "-- No hay DTE pendientes por entregar: ");
                logs.putLog(1, "-- cantRestantes: 0");
            }
            else
            {
                for (int i = 0; i < dte_num; i++)
                {
                    string ruttRece = result.Rows[i][0].ToString();
                    string digiRece = result.Rows[i][1].ToString();
                    string ruttEmis = result.Rows[i][2].ToString();
                    string digiEmis = result.Rows[i][3].ToString();
                    string tipoDocu = result.Rows[i][4].ToString();
                    string foliDocu = result.Rows[i][5].ToString();
                    string fechEmis = result.Rows[i][6].ToString();
                    string montNeto = result.Rows[i][7].ToString();
                    string montExen = result.Rows[i][8].ToString();
                    string montTota = result.Rows[i][9].ToString();
                    string corrDocu = result.Rows[i][10].ToString();
                    string codiEmpr = result.Rows[i][11].ToString();

                    List <Referencia> Refencias = new List <Referencia>();
                    Refencias = getRefencias(corrDocu, conexion);
                    string xml = getXML(corrDocu, conexion, logs);

                    string pdf = getPDF(codiEmpr, ruttRece, ruttEmis, tipoDocu, foliDocu, logs);

                    Documento dte_temp = new Documento(ruttRece, digiRece, ruttEmis, digiEmis, tipoDocu, foliDocu, fechEmis, montNeto, montExen, montTota, xml, pdf, Refencias);
                    dtes.DTE.Add(dte_temp);

                    logs.putLog(1, "-- Recuperado DTE Folio: " + foliDocu);
                }
                dtes.cantRestantes = cantDTERestantes(sql, conexion) - dte_num;
                logs.putLog(1, "-- Cantidad restante de DTE (cantRestantes) " + dtes.cantRestantes);
            }
        }