Exemplo n.º 1
0
        public void emitirnotasdecredito(string P_UNAME, string P_PASSWORD, string P_IDSISTEMA, string P_INSTANCIA, string P_MANDANTE
                                         , string P_SAPROUTER, string P_SERVER, string P_IDIOMA, string P_ID_CAJA, string P_MONEDA, string P_PAIS
                                         , List <T_DOCUMENTOS> P_DOCSAPAGAR, string P_CHKTRIB)
        {
            try
            {
                RETURN2 retorno;

                T_DOCUMENTOS docs;

                //DETALLE_REND detallerend;
                T_Retorno.Clear();
                documentos.Clear();
                errormessage = "";
                message      = "";
                IdCaja       = "";
                Efectivo     = "0";

                IRfcTable ls_RETORNO;
                IRfcTable lt_DOCS;

                connectorSap.idioma    = P_IDIOMA;
                connectorSap.idSistema = P_IDSISTEMA;
                connectorSap.instancia = P_INSTANCIA;
                connectorSap.mandante  = P_MANDANTE;
                connectorSap.paswr     = P_PASSWORD;
                connectorSap.sapRouter = P_SAPROUTER;
                connectorSap.user      = P_UNAME;
                connectorSap.server    = P_SERVER;

                string retval = connectorSap.connectionsSAP();

                //Si el valor de retorno es nulo o vacio, hay conexion a SAP y la RFC trae datos
                if (string.IsNullOrEmpty(retval))
                {
                    RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination(connectorSap.connectorConfig);
                    RfcRepository  SapRfcRepository  = SapRfcDestination.Repository;

                    IRfcFunction BapiGetUser = SapRfcRepository.CreateFunction("ZSCP_RFC_REC_Y_FAC_NC");

                    BapiGetUser.SetValue("ID_CAJA", P_ID_CAJA);
                    BapiGetUser.SetValue("PAY_CURRENCY", P_MONEDA);
                    BapiGetUser.SetValue("LAND", P_PAIS);
                    IRfcTable GralDat2 = BapiGetUser.GetTable("DOCUMENTOS");
                    try
                    {
                        for (var i = 0; i < P_DOCSAPAGAR.Count; i++)
                        {
                            GralDat2.Append();
                            GralDat2.SetValue("NDOCTO", P_DOCSAPAGAR[i].NDOCTO);
                            GralDat2.SetValue("MONTO", P_DOCSAPAGAR[i].MONTO);
                            GralDat2.SetValue("MONTOF", P_DOCSAPAGAR[i].MONTOF);
                            GralDat2.SetValue("MONEDA", P_DOCSAPAGAR[i].MONEDA);
                            GralDat2.SetValue("LAND", P_DOCSAPAGAR[i].LAND);
                            GralDat2.SetValue("FECVENCI", P_DOCSAPAGAR[i].FECVENCI);
                            GralDat2.SetValue("CONTROL_CREDITO", P_DOCSAPAGAR[i].CONTROL_CREDITO);
                            GralDat2.SetValue("CEBE", P_DOCSAPAGAR[i].CEBE);
                            GralDat2.SetValue("COND_PAGO", P_DOCSAPAGAR[i].COND_PAGO);
                            GralDat2.SetValue("RUTCLI", P_DOCSAPAGAR[i].RUTCLI);
                            GralDat2.SetValue("NOMCLI", P_DOCSAPAGAR[i].NOMCLI);
                            GralDat2.SetValue("ESTADO", P_DOCSAPAGAR[i].ESTADO);
                            GralDat2.SetValue("ICONO", P_CHKTRIB);
                            GralDat2.SetValue("DIAS_ATRASO", P_DOCSAPAGAR[i].DIAS_ATRASO);
                            string MontoAux = "";
                            MontoAux = P_DOCSAPAGAR[i].MONTO_ABONADO;
                            MontoAux = MontoAux.Replace(",", "");
                            MontoAux = MontoAux.Replace(".", "");
                            GralDat2.SetValue("MONTO_ABONADO", MontoAux);
                            MontoAux = P_DOCSAPAGAR[i].MONTOF_ABON;
                            MontoAux = MontoAux.Replace(",", "");
                            MontoAux = MontoAux.Replace(".", "");
                            GralDat2.SetValue("MONTOF_ABON", MontoAux);
                            MontoAux = P_DOCSAPAGAR[i].MONTO_PAGAR;
                            MontoAux = MontoAux.Replace(",", "");
                            MontoAux = MontoAux.Replace(".", "");
                            GralDat2.SetValue("MONTO_PAGAR", MontoAux);
                            MontoAux = P_DOCSAPAGAR[i].MONTOF_PAGAR;
                            MontoAux = MontoAux.Replace(",", "");
                            MontoAux = MontoAux.Replace(".", "");
                            GralDat2.SetValue("MONTOF_PAGAR", MontoAux);
                            GralDat2.SetValue("NREF", P_DOCSAPAGAR[i].NREF);
                            GralDat2.SetValue("FECHA_DOC", P_DOCSAPAGAR[i].FECHA_DOC);
                            GralDat2.SetValue("COD_CLIENTE", P_DOCSAPAGAR[i].COD_CLIENTE);
                            GralDat2.SetValue("SOCIEDAD", P_DOCSAPAGAR[i].SOCIEDAD);
                            GralDat2.SetValue("CLASE_DOC", P_DOCSAPAGAR[i].CLASE_DOC);
                            GralDat2.SetValue("CLASE_CUENTA", P_DOCSAPAGAR[i].CLASE_CUENTA);
                            GralDat2.SetValue("CME", P_DOCSAPAGAR[i].CME);
                            GralDat2.SetValue("ACC", P_DOCSAPAGAR[i].ACC);
                            GralDat2.SetValue("FACT_SD_ORIGEN", P_DOCSAPAGAR[i].FACT_SD_ORIGEN);
                            GralDat2.SetValue("FACT_ELECT", P_DOCSAPAGAR[i].FACT_ELECT);
                            GralDat2.SetValue("ID_COMPROBANTE", P_DOCSAPAGAR[i].ID_COMPROBANTE);
                            GralDat2.SetValue("ID_CAJA", P_DOCSAPAGAR[i].ID_CAJA);
                            GralDat2.SetValue("LAND", P_DOCSAPAGAR[i].LAND);
                            GralDat2.SetValue("BAPI", P_DOCSAPAGAR[i].BAPI);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message + ex.StackTrace);
                        //System.Windows.MessageBox.Show(ex.Message + ex.StackTrace);
                    }
                    BapiGetUser.SetValue("DOCUMENTOS", GralDat2);


                    BapiGetUser.Invoke(SapRfcDestination);
                    //BapiGetUser.SetValue("I_VBELN",P_NUMDOCSD);
                    //IRfcTable GralDat = BapiGetUser.GetTable("VIAS_PAGO");
                    lt_DOCS = BapiGetUser.GetTable("DOCUMENTOS");

                    if (lt_DOCS.Count > 0)
                    {
                        //LLenamos la tabla de salida lt_DatGen
                        for (int i = 0; i < lt_DOCS.RowCount; i++)
                        {
                            try
                            {
                                lt_DOCS.CurrentIndex = i;
                                docs = new T_DOCUMENTOS();

                                docs.NDOCTO = lt_DOCS[i].GetString("NDOCTO");
                                string Monto  = "";
                                int    indice = 0;
                                //*******
                                if (lt_DOCS[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_DOCS[i].GetString("MONTOF").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux = 0;
                                    if ((Valor == "00") | (Valor == "0"))
                                    {
                                        ValorAux = Convert.ToDecimal(Valor);
                                    }
                                    else
                                    {
                                        ValorAux = Convert.ToDecimal(Valor.Substring(0, Valor.Length - 2));
                                    }
                                    string Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                    docs.MONTOF = Cualquiernombre;
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_DOCS[i].GetString("MONTOF"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    docs.MONTOF = string.Format("{0:0,0.##}", ValorAux);
                                }
                                //if (lt_DOCS[i].GetString("MONTOF") == "")
                                //{
                                //    indice = lt_DOCS[i].GetString("MONTO").IndexOf(',');
                                //    Monto = lt_DOCS[i].GetString("MONTO").Substring(0, indice - 1);
                                //    docs.MONTOF = Monto;
                                //}
                                //else
                                //{
                                //    docs.MONTOF = lt_DOCS[i].GetString("MONTOF");
                                //}
                                if (lt_DOCS[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_DOCS[i].GetString("MONTO").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux = Convert.ToDecimal(Valor);
                                    if ((Valor == "00") | (Valor == "0"))
                                    {
                                        ValorAux = Convert.ToDecimal(Valor);
                                    }
                                    else
                                    {
                                        ValorAux = Convert.ToDecimal(Valor.Substring(0, Valor.Length - 2));
                                    }
                                    docs.MONTO = string.Format("{0:0,0}", ValorAux);
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_DOCS[i].GetString("MONTO"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    docs.MONTO = string.Format("{0:0,0.##}", ValorAux);
                                }
                                //if (lt_DOCS[i].GetString("MONTO") == "")
                                //{
                                //    indice = lt_DOCS[i].GetString("MONTO").IndexOf(',');
                                //    Monto = lt_DOCS[i].GetString("MONTO").Substring(0, indice - 1);
                                //    docs.MONTO = Monto;
                                //}
                                //else
                                //{
                                //    docs.MONTO = lt_DOCS[i].GetString("MONTO");
                                //}

                                docs.MONEDA          = lt_DOCS[i].GetString("MONEDA");
                                docs.FECVENCI        = lt_DOCS[i].GetString("FECVENCI");
                                docs.CONTROL_CREDITO = lt_DOCS[i].GetString("CONTROL_CREDITO");
                                docs.CEBE            = lt_DOCS[i].GetString("CEBE");
                                docs.COND_PAGO       = lt_DOCS[i].GetString("COND_PAGO");
                                docs.RUTCLI          = lt_DOCS[i].GetString("RUTCLI");
                                docs.NOMCLI          = lt_DOCS[i].GetString("NOMCLI");
                                docs.ESTADO          = lt_DOCS[i].GetString("ESTADO");
                                docs.ICONO           = lt_DOCS[i].GetString("ICONO");
                                docs.DIAS_ATRASO     = lt_DOCS[i].GetString("DIAS_ATRASO");
                                if (lt_DOCS[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_DOCS[i].GetString("MONTOF_ABON").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux;
                                    if ((Valor == "00") | (Valor == "0"))
                                    {
                                        ValorAux = Convert.ToDecimal(Valor);
                                    }
                                    else
                                    {
                                        ValorAux = Convert.ToDecimal(Valor.Substring(0, Valor.Length - 2));
                                    }
                                    docs.MONTOF_ABON = string.Format("{0:0,0}", ValorAux);
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_DOCS[i].GetString("MONTOF_ABON"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    docs.MONTOF_ABON = string.Format("{0:0,0.##}", ValorAux);
                                }
                                //if (lt_DOCS[i].GetString("MONTOF_ABON") == "")
                                //{
                                //    indice = lt_DOCS[i].GetString("MONTO_ABONADO").IndexOf(',');
                                //    Monto = lt_DOCS[i].GetString("MONTO_ABONADO").Substring(0, indice - 1);
                                //    docs.MONTOF = Monto;
                                //}
                                //else
                                //{
                                //    docs.MONTOF_ABON = lt_DOCS[i].GetString("MONTOF_ABON");
                                //}
                                if (lt_DOCS[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_DOCS[i].GetString("MONTOF_PAGAR").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux = Convert.ToDecimal(Valor);
                                    if ((Valor == "00") | (Valor == "0"))
                                    {
                                        ValorAux = Convert.ToDecimal(Valor);
                                    }
                                    else
                                    {
                                        ValorAux = Convert.ToDecimal(Valor.Substring(0, Valor.Length - 2));
                                    }
                                    docs.MONTOF_PAGAR = string.Format("{0:0,0}", ValorAux);
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_DOCS[i].GetString("MONTOF_PAGAR"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    docs.MONTOF_PAGAR = string.Format("{0:0,0.##}", ValorAux);
                                }
                                //if (lt_DOCS[i].GetString("MONTOF_PAGAR") == "")
                                //{
                                //    indice = lt_DOCS[i].GetString("MONTO_PAGAR").IndexOf(',');
                                //    Monto = lt_DOCS[i].GetString("MONTO_PAGAR").Substring(0, indice - 1);
                                //    docs.MONTOF = Monto;
                                //}
                                //else
                                //{
                                //    docs.MONTOF_PAGAR = lt_DOCS[i].GetString("MONTOF_PAGAR");
                                //}
                                docs.NREF           = lt_DOCS[i].GetString("NREF");
                                docs.FECHA_DOC      = lt_DOCS[i].GetString("FECHA_DOC");
                                docs.COD_CLIENTE    = lt_DOCS[i].GetString("COD_CLIENTE");
                                docs.SOCIEDAD       = lt_DOCS[i].GetString("SOCIEDAD");
                                docs.CLASE_DOC      = lt_DOCS[i].GetString("CLASE_DOC");
                                docs.CLASE_CUENTA   = lt_DOCS[i].GetString("CLASE_CUENTA");
                                docs.CME            = lt_DOCS[i].GetString("CME");
                                docs.ACC            = lt_DOCS[i].GetString("ACC");
                                docs.FACT_SD_ORIGEN = lt_DOCS[i].GetString("FACT_SD_ORIGEN");
                                docs.FACT_ELECT     = lt_DOCS[i].GetString("FACT_ELECT");
                                docs.ID_COMPROBANTE = lt_DOCS[i].GetString("ID_COMPROBANTE");
                                docs.ID_CAJA        = lt_DOCS[i].GetString("ID_CAJA");
                                docs.LAND           = lt_DOCS[i].GetString("LAND");
                                documentos.Add(docs);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message + ex.StackTrace);
                                System.Windows.MessageBox.Show(ex.Message + ex.StackTrace);
                            }
                        }
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show("No existe(n) registro(s)");
                    }

                    ls_RETORNO = BapiGetUser.GetTable("RETURN");
                    try
                    {
                        for (int i = 0; i < ls_RETORNO.Count(); i++)
                        {
                            ls_RETORNO.CurrentIndex = i;
                            retorno = new RETURN2();
                            if (ls_RETORNO.GetString("TYPE") == "S")
                            {
                                message    = message + "-" + ls_RETORNO.GetString("MESSAGE") + ":" + ls_RETORNO.GetString("MESSAGE_V1").Trim() + "\n";
                                NumComprob = ls_RETORNO.GetString("MESSAGE_V4").Trim();
                            }
                            if (ls_RETORNO.GetString("TYPE") == "E")
                            {
                                errormessage = errormessage + " - " + ls_RETORNO.GetString("MESSAGE") + "\n";
                            }
                            retorno.TYPE       = ls_RETORNO.GetString("TYPE");
                            retorno.ID         = ls_RETORNO.GetString("ID");
                            retorno.NUMBER     = ls_RETORNO.GetString("NUMBER");
                            retorno.MESSAGE    = ls_RETORNO.GetString("MESSAGE");
                            retorno.LOG_NO     = ls_RETORNO.GetString("LOG_NO");
                            retorno.LOG_MSG_NO = ls_RETORNO.GetString("LOG_MSG_NO");
                            retorno.MESSAGE_V1 = ls_RETORNO.GetString("MESSAGE_V1");
                            retorno.MESSAGE_V2 = ls_RETORNO.GetString("MESSAGE_V2");
                            retorno.MESSAGE_V3 = ls_RETORNO.GetString("MESSAGE_V3");
                            if (ls_RETORNO.GetString("MESSAGE_V4") != "")
                            {
                                // comprobante = ls_RETORNO.GetString("MESSAGE_V4");
                            }
                            retorno.MESSAGE_V4 = ls_RETORNO.GetString("MESSAGE_V4");
                            retorno.PARAMETER  = ls_RETORNO.GetString("PARAMETER");
                            retorno.ROW        = ls_RETORNO.GetString("ROW");
                            retorno.FIELD      = ls_RETORNO.GetString("FIELD");
                            retorno.SYSTEM     = ls_RETORNO.GetString("SYSTEM");
                            T_Retorno.Add(retorno);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message, ex.StackTrace);
                        MessageBox.Show(ex.Message + ex.StackTrace);
                    }
                }
                else
                {
                    errormessage = retval;
                    MessageBox.Show("No se pudo conectar a la RFC");
                }
                GC.Collect();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message, ex.StackTrace);
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Exemplo n.º 2
0
        public void monitor(string P_DATUM, string P_UNAME, string P_PASSWORD, string P_IDSISTEMA, string P_INSTANCIA, string P_MANDANTE, string P_SAPROUTER, string P_SERVER, string P_IDIOMA, string P_SOCIEDAD)
        {
            try
            {
                ObjDatosMonitor.Clear();
                IRfcTable lt_GET_MONITOR;

                T_DOCUMENTOS GET_MONITOR_resp;

                //Conexion a SAP
                connectorSap.idioma    = P_IDIOMA;
                connectorSap.idSistema = P_IDSISTEMA;
                connectorSap.instancia = P_INSTANCIA;
                connectorSap.mandante  = P_MANDANTE;
                connectorSap.paswr     = P_PASSWORD;
                connectorSap.sapRouter = P_SAPROUTER;
                connectorSap.user      = P_UNAME;
                connectorSap.server    = P_SERVER;

                string retval = connectorSap.connectionsSAP();
                //Si el valor de retorno es nulo o vacio, hay conexion a SAP y la RFC trae datos
                if (string.IsNullOrEmpty(retval))
                {
                    RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination(connectorSap.connectorConfig);
                    RfcRepository  SapRfcRepository  = SapRfcDestination.Repository;

                    IRfcFunction BapiGetUser = SapRfcRepository.CreateFunction("ZSCP_RFC_GET_MONITOR");
                    BapiGetUser.SetValue("DATUM", Convert.ToDateTime(P_DATUM));
                    BapiGetUser.SetValue("I_BUKRS", P_SOCIEDAD);

                    BapiGetUser.Invoke(SapRfcDestination);

                    lt_GET_MONITOR = BapiGetUser.GetTable("T_DOCUMENTOS");
                    //lt_PART_ABIERTAS = BapiGetUser.GetTable("ZCLSP_TT_LISTA_DOCUMENTOS");
                    if (lt_GET_MONITOR.Count > 0)
                    {
                        //LLenamos la tabla de salida lt_DatGen
                        for (int i = 0; i < lt_GET_MONITOR.RowCount; i++)
                        {
                            lt_GET_MONITOR.CurrentIndex = i;
                            GET_MONITOR_resp            = new T_DOCUMENTOS();

                            GET_MONITOR_resp.SOCIEDAD        = lt_GET_MONITOR[i].GetString("SOCIEDAD");
                            GET_MONITOR_resp.NDOCTO          = lt_GET_MONITOR[i].GetString("NDOCTO");
                            GET_MONITOR_resp.NREF            = lt_GET_MONITOR[i].GetString("NREF");
                            GET_MONITOR_resp.CLASE_CUENTA    = lt_GET_MONITOR[i].GetString("CLASE_CUENTA");
                            GET_MONITOR_resp.CLASE_DOC       = lt_GET_MONITOR[i].GetString("CLASE_DOC");
                            GET_MONITOR_resp.COD_CLIENTE     = lt_GET_MONITOR[i].GetString("COD_CLIENTE");
                            GET_MONITOR_resp.RUTCLI          = lt_GET_MONITOR[i].GetString("RUTCLI");
                            GET_MONITOR_resp.NOMCLI          = lt_GET_MONITOR[i].GetString("NOMCLI");
                            GET_MONITOR_resp.CEBE            = lt_GET_MONITOR[i].GetString("CEBE");
                            GET_MONITOR_resp.FECHA_DOC       = lt_GET_MONITOR[i].GetString("FECHA_DOC");
                            GET_MONITOR_resp.FECVENCI        = lt_GET_MONITOR[i].GetString("FECVENCI");
                            GET_MONITOR_resp.DIAS_ATRASO     = lt_GET_MONITOR[i].GetString("DIAS_ATRASO");
                            GET_MONITOR_resp.ESTADO          = lt_GET_MONITOR[i].GetString("ESTADO");
                            GET_MONITOR_resp.ICONO           = lt_GET_MONITOR[i].GetString("ICONO");
                            GET_MONITOR_resp.MONEDA          = lt_GET_MONITOR[i].GetString("MONEDA");
                            GET_MONITOR_resp.ACC             = lt_GET_MONITOR[i].GetString("ACC");
                            GET_MONITOR_resp.CLASE_CUENTA    = lt_GET_MONITOR[i].GetString("CLASE_CUENTA");
                            GET_MONITOR_resp.COND_PAGO       = lt_GET_MONITOR[i].GetString("COND_PAGO");
                            GET_MONITOR_resp.CME             = lt_GET_MONITOR[i].GetString("CME");
                            GET_MONITOR_resp.CONTROL_CREDITO = lt_GET_MONITOR[i].GetString("CONTROL_CREDITO");
                            string Monto  = "";
                            int    indice = 0;
                            if (lt_GET_MONITOR[i].GetString("MONTO").Contains(","))
                            {
                                indice = lt_GET_MONITOR[i].GetString("MONTO").IndexOf(',');
                                Monto  = lt_GET_MONITOR[i].GetString("MONTO").Substring(0, indice - 1);
                                GET_MONITOR_resp.MONTOF = Monto;
                            }
                            else
                            {
                                GET_MONITOR_resp.MONTOF = lt_GET_MONITOR[i].GetString("MONTOF");
                            }
                            if (lt_GET_MONITOR[i].GetString("MONTO").Contains(","))
                            {
                                indice = lt_GET_MONITOR[i].GetString("MONTO").IndexOf(',');
                                Monto  = lt_GET_MONITOR[i].GetString("MONTO").Substring(0, indice - 1);
                                GET_MONITOR_resp.MONTO = Monto;
                            }
                            else
                            {
                                GET_MONITOR_resp.MONTO = lt_GET_MONITOR[i].GetString("MONTO");
                            }
                            if (lt_GET_MONITOR[i].GetString("MONTO_ABONADO").Contains(","))
                            {
                                indice = lt_GET_MONITOR[i].GetString("MONTO_ABONADO").IndexOf(',');
                                Monto  = lt_GET_MONITOR[i].GetString("MONTO_ABONADO").Substring(0, indice - 1);
                                GET_MONITOR_resp.MONTOF = Monto;
                            }
                            else
                            {
                                GET_MONITOR_resp.MONTOF_ABON = lt_GET_MONITOR[i].GetString("MONTOF_ABON");
                            }
                            if (lt_GET_MONITOR[i].GetString("MONTO_PAGAR").Contains(","))
                            {
                                indice = lt_GET_MONITOR[i].GetString("MONTO_PAGAR").IndexOf(',');
                                Monto  = lt_GET_MONITOR[i].GetString("MONTO_PAGAR").Substring(0, indice - 1);
                                GET_MONITOR_resp.MONTOF = Monto;
                            }
                            else
                            {
                                GET_MONITOR_resp.MONTOF_PAGAR = lt_GET_MONITOR[i].GetString("MONTOF_PAGAR");
                            }

                            ObjDatosMonitor.Add(GET_MONITOR_resp);
                        }
                    }
                    //else
                    //{
                    //    MessageBox.Show("No existen registros para este fecha");
                    //}
                    GC.Collect();
                }
                else
                {
                    errormessage = retval;
                }
                GC.Collect();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + ex.StackTrace);
                System.Windows.MessageBox.Show(ex.Message + ex.StackTrace);
                GC.Collect();
            }
        }
Exemplo n.º 3
0
        public void notasdecredito(string P_UNAME, string P_PASSWORD, string P_IDSISTEMA, string P_INSTANCIA, string P_MANDANTE, string P_SAPROUTER, string P_SERVER, string P_IDIOMA, string P_DOCUMENTO, string P_RUT,
                                   string P_SOCIEDAD, string P_LAND, string TipoBusqueda, string IDCAJA)
        {
            ObjDatosNC.Clear();
            Retorno.Clear();
            ViasPago.Clear();
            errormessage = "";
            protesto     = "";
            IRfcTable    lt_t_documentos;
            IRfcTable    lt_viaspago;
            IRfcTable    lt_retorno;
            T_DOCUMENTOS NC_resp;
            ESTADO       retorno_resp;
            VIAS_PAGO2   VIASPAGO_resp;

            //Conexion a SAP
            connectorSap.idioma    = P_IDIOMA;
            connectorSap.idSistema = P_IDSISTEMA;
            connectorSap.instancia = P_INSTANCIA;
            connectorSap.mandante  = P_MANDANTE;
            connectorSap.paswr     = P_PASSWORD;
            connectorSap.sapRouter = P_SAPROUTER;
            connectorSap.user      = P_UNAME;
            connectorSap.server    = P_SERVER;

            string retval = connectorSap.connectionsSAP();

            //Si el valor de retorno es nulo o vacio, hay conexion a SAP y la RFC trae datos
            if (string.IsNullOrEmpty(retval))
            {
                RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination(connectorSap.connectorConfig);
                RfcRepository  SapRfcRepository  = SapRfcDestination.Repository;

                IRfcFunction BapiGetUser = SapRfcRepository.CreateFunction("ZSCP_RFC_GET_DOC_NC");
                BapiGetUser.SetValue("DOCUMENTO", P_DOCUMENTO);
                BapiGetUser.SetValue("LAND", P_LAND);
                BapiGetUser.SetValue("RUT", P_RUT);
                BapiGetUser.SetValue("SOCIEDAD", P_SOCIEDAD);
                BapiGetUser.SetValue("ID_CAJA", IDCAJA);
                BapiGetUser.Invoke(SapRfcDestination);

                lt_t_documentos = BapiGetUser.GetTable("T_DOCUMENTOS");
                lt_retorno      = BapiGetUser.GetTable("RETORNO");
                lt_viaspago     = BapiGetUser.GetTable("VIAS_PAGO");
                //lt_PART_ABIERTAS = BapiGetUser.GetTable("ZCLSP_TT_LISTA_DOCUMENTOS");
                try
                {
                    if (lt_t_documentos.Count > 0)
                    {
                        //LLenamos la tabla de salida lt_DatGen
                        for (int i = 0; i < lt_t_documentos.RowCount; i++)
                        {
                            try
                            {
                                lt_t_documentos.CurrentIndex = i;
                                NC_resp = new T_DOCUMENTOS();

                                NC_resp.NDOCTO = lt_t_documentos[i].GetString("NDOCTO");
                                string Monto  = "";
                                int    indice = 0;
                                //*******
                                //if (lt_t_documentos[i].GetString("MONTOF") == "")
                                //{
                                //    indice = lt_t_documentos[i].GetString("MONTO").IndexOf(',');
                                //    Monto = lt_t_documentos[i].GetString("MONTO").Substring(0, indice - 1);
                                //    NC_resp.MONTOF = Monto;
                                //}
                                //else
                                //{
                                //    NC_resp.MONTOF = lt_t_documentos[i].GetString("MONTOF");
                                //}
                                if (lt_t_documentos[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_t_documentos[i].GetString("MONTOF").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux        = Convert.ToDecimal(Valor);
                                    string  Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                    NC_resp.MONTOF = Cualquiernombre;
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_t_documentos[i].GetString("MONTOF"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    NC_resp.MONTOF = string.Format("{0:0,0.##}", ValorAux);
                                }
                                //if (lt_t_documentos[i].GetString("MONTO") == "")
                                //{
                                //    indice = lt_t_documentos[i].GetString("MONTO").IndexOf(',');
                                //    Monto = lt_t_documentos[i].GetString("MONTO").Substring(0, indice - 1);
                                //    NC_resp.MONTO = Monto;
                                //}
                                //else
                                //{
                                //    NC_resp.MONTO = lt_t_documentos[i].GetString("MONTO");
                                //}
                                if (lt_t_documentos[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_t_documentos[i].GetString("MONTO").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux        = Convert.ToDecimal(Valor.Substring(0, Valor.Length - 2));
                                    string  Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                    NC_resp.MONTO = Cualquiernombre;
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_t_documentos[i].GetString("MONTO"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    NC_resp.MONTO = string.Format("{0:0,0.##}", ValorAux);
                                }
                                NC_resp.MONEDA          = lt_t_documentos[i].GetString("MONEDA");
                                NC_resp.FECVENCI        = lt_t_documentos[i].GetString("FECVENCI");
                                NC_resp.CONTROL_CREDITO = lt_t_documentos[i].GetString("CONTROL_CREDITO");
                                NC_resp.CEBE            = lt_t_documentos[i].GetString("CEBE");
                                NC_resp.COND_PAGO       = lt_t_documentos[i].GetString("COND_PAGO");
                                NC_resp.RUTCLI          = lt_t_documentos[i].GetString("RUTCLI");
                                NC_resp.NOMCLI          = lt_t_documentos[i].GetString("NOMCLI");
                                NC_resp.ESTADO          = lt_t_documentos[i].GetString("ESTADO");
                                NC_resp.ICONO           = lt_t_documentos[i].GetString("ICONO");
                                NC_resp.DIAS_ATRASO     = lt_t_documentos[i].GetString("DIAS_ATRASO");
                                if (lt_t_documentos[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_t_documentos[i].GetString("MONTO_ABONADO").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux        = Convert.ToDecimal(Valor);
                                    string  Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                    NC_resp.MONTO_ABONADO = Cualquiernombre;
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_t_documentos[i].GetString("MONTO_ABONADO"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    NC_resp.MONTO_ABONADO = string.Format("{0:0,0.##}", ValorAux);
                                }
                                //if (lt_t_documentos[i].GetString("MONTOF_ABON") == "")
                                //{
                                //    indice = lt_t_documentos[i].GetString("MONTO_ABONADO").IndexOf(',');
                                //    Monto = lt_t_documentos[i].GetString("MONTO_ABONADO").Substring(0, indice - 1);
                                //    NC_resp.MONTOF = Monto;
                                //}
                                //else
                                //{
                                //    NC_resp.MONTOF_ABON = lt_t_documentos[i].GetString("MONTOF_ABON");
                                //}
                                if (lt_t_documentos[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_t_documentos[i].GetString("MONTOF_ABON").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux        = Convert.ToDecimal(Valor);
                                    string  Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                    NC_resp.MONTOF_ABON = Cualquiernombre;
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_t_documentos[i].GetString("MONTOF_ABON"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    NC_resp.MONTOF_ABON = string.Format("{0:0,0.##}", ValorAux);
                                }
                                if (lt_t_documentos[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_t_documentos[i].GetString("MONTO_PAGAR").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux        = Convert.ToDecimal(Valor);
                                    string  Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                    NC_resp.MONTO_PAGAR = Cualquiernombre;
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_t_documentos[i].GetString("MONTO_PAGAR"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    NC_resp.MONTO_PAGAR = string.Format("{0:0,0.##}", ValorAux);
                                }
                                //if (lt_t_documentos[i].GetString("MONTOF_PAGAR") == "")
                                //{
                                //    indice = lt_t_documentos[i].GetString("MONTO_PAGAR").IndexOf(',');
                                //    Monto = lt_t_documentos[i].GetString("MONTO_PAGAR").Substring(0, indice - 1);
                                //    NC_resp.MONTOF = Monto;
                                //}
                                //else
                                //{
                                //    NC_resp.MONTOF_PAGAR = lt_t_documentos[i].GetString("MONTOF_PAGAR");
                                //}
                                if (lt_t_documentos[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_t_documentos[i].GetString("MONTOF_PAGAR").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux        = Convert.ToDecimal(Valor);
                                    string  Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                    NC_resp.MONTOF_PAGAR = Cualquiernombre;
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_t_documentos[i].GetString("MONTOF_PAGAR"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    NC_resp.MONTOF_PAGAR = string.Format("{0:0,0.##}", ValorAux);
                                }
                                NC_resp.NREF           = lt_t_documentos[i].GetString("NREF");
                                NC_resp.FECHA_DOC      = lt_t_documentos[i].GetString("FECHA_DOC");
                                NC_resp.COD_CLIENTE    = lt_t_documentos[i].GetString("COD_CLIENTE");
                                NC_resp.SOCIEDAD       = lt_t_documentos[i].GetString("SOCIEDAD");
                                NC_resp.CLASE_DOC      = lt_t_documentos[i].GetString("CLASE_DOC");
                                NC_resp.CLASE_CUENTA   = lt_t_documentos[i].GetString("CLASE_CUENTA");
                                NC_resp.CME            = lt_t_documentos[i].GetString("CME");
                                NC_resp.ACC            = lt_t_documentos[i].GetString("ACC");
                                NC_resp.FACT_SD_ORIGEN = lt_t_documentos[i].GetString("FACT_SD_ORIGEN");
                                NC_resp.FACT_ELECT     = lt_t_documentos[i].GetString("FACT_ELECT");
                                NC_resp.ID_COMPROBANTE = lt_t_documentos[i].GetString("ID_COMPROBANTE");
                                NC_resp.ID_CAJA        = lt_t_documentos[i].GetString("ID_CAJA");
                                NC_resp.LAND           = lt_t_documentos[i].GetString("LAND");
                                NC_resp.BAPI           = lt_t_documentos[i].GetString("BAPI");
                                ObjDatosNC.Add(NC_resp);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message + ex.StackTrace);
                                System.Windows.MessageBox.Show(ex.Message + ex.StackTrace);
                            }
                        }
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show("No existe(n) registro(s)");
                    }

                    String Mensaje = "";
                    if (lt_retorno.Count > 0)
                    {
                        retorno_resp = new ESTADO();
                        for (int i = 0; i < lt_retorno.Count(); i++)
                        {
                            lt_retorno.CurrentIndex = i;

                            retorno_resp.TYPE       = lt_retorno.GetString("TYPE");
                            retorno_resp.ID         = lt_retorno.GetString("ID");
                            retorno_resp.NUMBER     = lt_retorno.GetString("NUMBER");
                            retorno_resp.MESSAGE    = lt_retorno.GetString("MESSAGE");
                            retorno_resp.LOG_NO     = lt_retorno.GetString("LOG_NO");
                            retorno_resp.LOG_MSG_NO = lt_retorno.GetString("LOG_MSG_NO");
                            retorno_resp.MESSAGE    = lt_retorno.GetString("MESSAGE");
                            retorno_resp.MESSAGE_V1 = lt_retorno.GetString("MESSAGE_V1");
                            if (i == 0)
                            {
                                Mensaje = Mensaje + " - " + lt_retorno.GetString("MESSAGE") + " - " + lt_retorno.GetString("MESSAGE_V1");
                            }
                            retorno_resp.MESSAGE_V2 = lt_retorno.GetString("MESSAGE_V2");
                            retorno_resp.MESSAGE_V3 = lt_retorno.GetString("MESSAGE_V3");
                            retorno_resp.MESSAGE_V4 = lt_retorno.GetString("MESSAGE_V4");
                            retorno_resp.PARAMETER  = lt_retorno.GetString("PARAMETER");
                            retorno_resp.ROW        = lt_retorno.GetString("ROW");
                            retorno_resp.FIELD      = lt_retorno.GetString("FIELD");
                            retorno_resp.SYSTEM     = lt_retorno.GetString("SYSTEM");
                            Retorno.Add(retorno_resp);
                        }
                        //   System.Windows.MessageBox.Show(Mensaje);
                    }

                    if (lt_viaspago.Count > 0)
                    {
                        //LLenamos la tabla de salida lt_DatGen
                        for (int i = 0; i < lt_viaspago.RowCount; i++)
                        {
                            try
                            {
                                lt_viaspago.CurrentIndex = i;
                                VIASPAGO_resp            = new VIAS_PAGO2();

                                VIASPAGO_resp.MANDT          = lt_viaspago[i].GetString("MANDT");
                                VIASPAGO_resp.LAND           = lt_viaspago[i].GetString("LAND");
                                VIASPAGO_resp.ID_COMPROBANTE = lt_viaspago[i].GetString("ID_COMPROBANTE");
                                VIASPAGO_resp.ID_DETALLE     = lt_viaspago[i].GetString("ID_DETALLE");
                                VIASPAGO_resp.VIA_PAGO       = lt_viaspago[i].GetString("VIA_PAGO");
                                if (lt_viaspago[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_viaspago[i].GetString("MONTO").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux        = Convert.ToDecimal(Valor.Substring(0, Valor.Length - 2));
                                    string  Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                    VIASPAGO_resp.MONTO = Cualquiernombre;
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_viaspago[i].GetString("MONTO"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    VIASPAGO_resp.MONTO = string.Format("{0:0,0.##}", ValorAux);
                                }


                                // VIASPAGO_resp.MONTO = Convert.ToDouble(lt_viaspago[i].GetString("MONTO"));
                                VIASPAGO_resp.MONEDA           = lt_viaspago[i].GetString("MONEDA");
                                VIASPAGO_resp.BANCO            = lt_viaspago[i].GetString("BANCO");
                                VIASPAGO_resp.EMISOR           = lt_viaspago[i].GetString("EMISOR");
                                VIASPAGO_resp.NUM_CHEQUE       = lt_viaspago[i].GetString("NUM_CHEQUE");
                                VIASPAGO_resp.COD_AUTORIZACION = lt_viaspago[i].GetString("COD_AUTORIZACION");
                                VIASPAGO_resp.NUM_CUOTAS       = lt_viaspago[i].GetString("NUM_CUOTAS");
                                VIASPAGO_resp.FECHA_VENC       = lt_viaspago[i].GetString("FECHA_VENC");
                                VIASPAGO_resp.TEXTO_POSICION   = lt_viaspago[i].GetString("TEXTO_POSICION");
                                VIASPAGO_resp.ANEXO            = lt_viaspago[i].GetString("ANEXO");
                                VIASPAGO_resp.SUCURSAL         = lt_viaspago[i].GetString("SUCURSAL");
                                VIASPAGO_resp.NUM_CUENTA       = lt_viaspago[i].GetString("NUM_CUENTA");
                                VIASPAGO_resp.NUM_TARJETA      = lt_viaspago[i].GetString("NUM_TARJETA");
                                VIASPAGO_resp.NUM_VALE_VISTA   = lt_viaspago[i].GetString("NUM_VALE_VISTA");
                                VIASPAGO_resp.PATENTE          = lt_viaspago[i].GetString("PATENTE");
                                VIASPAGO_resp.NUM_VENTA        = lt_viaspago[i].GetString("NUM_VENTA");
                                VIASPAGO_resp.PAGARE           = lt_viaspago[i].GetString("PAGARE");
                                VIASPAGO_resp.FECHA_EMISION    = lt_viaspago[i].GetString("FECHA_EMISION");
                                VIASPAGO_resp.NOMBRE_GIRADOR   = lt_viaspago[i].GetString("NOMBRE_GIRADOR");
                                VIASPAGO_resp.CARTA_CURSE      = lt_viaspago[i].GetString("CARTA_CURSE");
                                VIASPAGO_resp.NUM_TRANSFER     = lt_viaspago[i].GetString("NUM_TRANSFER");
                                VIASPAGO_resp.NUM_DEPOSITO     = lt_viaspago[i].GetString("NUM_DEPOSITO");
                                VIASPAGO_resp.CTA_BANCO        = lt_viaspago[i].GetString("CTA_BANCO");
                                VIASPAGO_resp.IFINAN           = lt_viaspago[i].GetString("IFINAN");
                                VIASPAGO_resp.CORRE            = lt_viaspago[i].GetString("CORRE");
                                VIASPAGO_resp.ZUONR            = lt_viaspago[i].GetString("ZUONR");
                                VIASPAGO_resp.HKONT            = lt_viaspago[i].GetString("HKONT");
                                VIASPAGO_resp.PRCTR            = lt_viaspago[i].GetString("PRCTR");
                                ViasPago.Add(VIASPAGO_resp);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message + ex.StackTrace);
                                System.Windows.MessageBox.Show(ex.Message + ex.StackTrace);
                            }
                        }
                    }
                    GC.Collect();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message + ex.StackTrace);
                    System.Windows.MessageBox.Show(ex.Message + ex.StackTrace);
                }
            }
            else
            {
                errormessage = retval;
                GC.Collect();
            }
        }
Exemplo n.º 4
0
        public void partidasopen(string P_UNAME, string P_PASSWORD, string P_IDSISTEMA, string P_INSTANCIA, string P_MANDANTE, string P_SAPROUTER, string P_SERVER, string P_IDIOMA, string P_CODCLIENTE, string P_DOCUMENTO, string P_RUT,
                                 string P_SOCIEDAD, DateTime P_FECHA_VENC, string P_LAND, string P_FACT_SAP, string TipoBusqueda)
        {
            ObjDatosPartidasOpen.Clear();
            Retorno.Clear();
            IRfcTable     lt_t_documentos;
            IRfcStructure lt_retorno;

            //  PART_ABIERTAS  PART_ABIERTAS_resp;
            T_DOCUMENTOS PART_ABIERTAS_resp;
            ESTADO       retorno_resp;

            //Conexion a SAP
            connectorSap.idioma    = P_IDIOMA;
            connectorSap.idSistema = P_IDSISTEMA;
            connectorSap.instancia = P_INSTANCIA;
            connectorSap.mandante  = P_MANDANTE;
            connectorSap.paswr     = P_PASSWORD;
            connectorSap.sapRouter = P_SAPROUTER;
            connectorSap.user      = P_UNAME;
            connectorSap.server    = P_SERVER;

            string retval = connectorSap.connectionsSAP();

            //Si el valor de retorno es nulo o vacio, hay conexion a SAP y la RFC trae datos
            if (string.IsNullOrEmpty(retval))
            {
                RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination(connectorSap.connectorConfig);
                RfcRepository  SapRfcRepository  = SapRfcDestination.Repository;

                IRfcFunction BapiGetUser = SapRfcRepository.CreateFunction("ZSCP_RFC_GET_DOC");
                BapiGetUser.SetValue("CODCLIENTE", P_CODCLIENTE);
                BapiGetUser.SetValue("DOCUMENTO", P_DOCUMENTO);
                BapiGetUser.SetValue("LAND", P_LAND);
                BapiGetUser.SetValue("RUT", P_RUT);
                BapiGetUser.SetValue("SOCIEDAD", P_SOCIEDAD);
                BapiGetUser.SetValue("FACTURA_SAP", P_DOCUMENTO);
                BapiGetUser.SetValue("FECHA_VENC", "");

                BapiGetUser.Invoke(SapRfcDestination);

                protesto        = BapiGetUser.GetString("PE_PROTESTADO");
                lt_t_documentos = BapiGetUser.GetTable("T_DOCUMENTOS");
                lt_retorno      = BapiGetUser.GetStructure("SE_ESTATUS");

                //lt_PART_ABIERTAS = BapiGetUser.GetTable("ZCLSP_TT_LISTA_DOCUMENTOS");
                try
                {
                    if (lt_t_documentos.Count > 0)
                    {
                        //LLenamos la tabla de salida lt_DatGen
                        for (int i = 0; i < lt_t_documentos.RowCount; i++)
                        {
                            try
                            {
                                lt_t_documentos.CurrentIndex = i;
                                PART_ABIERTAS_resp           = new T_DOCUMENTOS();

                                PART_ABIERTAS_resp.SOCIEDAD     = lt_t_documentos[i].GetString("SOCIEDAD");
                                PART_ABIERTAS_resp.NDOCTO       = lt_t_documentos[i].GetString("NDOCTO");
                                PART_ABIERTAS_resp.NREF         = lt_t_documentos[i].GetString("NREF");
                                PART_ABIERTAS_resp.CLASE_CUENTA = lt_t_documentos[i].GetString("CLASE_CUENTA");
                                PART_ABIERTAS_resp.CLASE_DOC    = lt_t_documentos[i].GetString("CLASE_DOC");
                                PART_ABIERTAS_resp.COD_CLIENTE  = lt_t_documentos[i].GetString("COD_CLIENTE");
                                PART_ABIERTAS_resp.RUTCLI       = lt_t_documentos[i].GetString("RUTCLI");
                                PART_ABIERTAS_resp.NOMCLI       = lt_t_documentos[i].GetString("NOMCLI");
                                PART_ABIERTAS_resp.CEBE         = lt_t_documentos[i].GetString("CEBE");
                                DateTime fec_doc = Convert.ToDateTime(lt_t_documentos[i].GetString("FECHA_DOC"));
                                PART_ABIERTAS_resp.FECHA_DOC = fec_doc.ToString("dd/MM/yyyy");
                                DateTime fec_venc = Convert.ToDateTime(lt_t_documentos[i].GetString("FECVENCI"));
                                PART_ABIERTAS_resp.FECVENCI        = fec_venc.ToString("dd/MM/yyyy");
                                PART_ABIERTAS_resp.DIAS_ATRASO     = lt_t_documentos[i].GetString("DIAS_ATRASO");
                                PART_ABIERTAS_resp.ESTADO          = lt_t_documentos[i].GetString("ESTADO");
                                PART_ABIERTAS_resp.ICONO           = lt_t_documentos[i].GetString("ICONO");
                                PART_ABIERTAS_resp.MONEDA          = lt_t_documentos[i].GetString("MONEDA");
                                PART_ABIERTAS_resp.ACC             = lt_t_documentos[i].GetString("ACC");
                                PART_ABIERTAS_resp.CLASE_CUENTA    = lt_t_documentos[i].GetString("CLASE_CUENTA");
                                PART_ABIERTAS_resp.COND_PAGO       = lt_t_documentos[i].GetString("COND_PAGO");
                                PART_ABIERTAS_resp.CME             = lt_t_documentos[i].GetString("CME");
                                PART_ABIERTAS_resp.CONTROL_CREDITO = lt_t_documentos[i].GetString("CONTROL_CREDITO");
                                string Monto = "";
                                //*******
                                if (lt_t_documentos[i].GetString("MONTOF") == "")
                                {
                                    if (lt_t_documentos[i].GetString("MONEDA") == "CLP")
                                    {
                                        string Valor = lt_t_documentos[i].GetString("MONTO").Trim();
                                        if (Valor.Contains("-"))
                                        {
                                            Valor = "-" + Valor.Replace("-", "");
                                        }
                                        Valor = Valor.Replace(".", "");
                                        Valor = Valor.Replace(",", "");
                                        decimal ValorAux        = Convert.ToDecimal(Valor);
                                        string  Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                        PART_ABIERTAS_resp.MONTOF = Cualquiernombre.Replace(",", ".");
                                    }
                                    else
                                    {
                                        string  moneda   = Convert.ToString(lt_t_documentos[i].GetString("MONTOF"));
                                        decimal ValorAux = Convert.ToDecimal(moneda);
                                        PART_ABIERTAS_resp.MONTOF = string.Format("{0:0,0.##}", ValorAux).Replace(",", ".");
                                    }
                                }
                                else
                                {
                                    if (lt_t_documentos[i].GetString("MONEDA") == "CLP")
                                    {
                                        string Valor = lt_t_documentos[i].GetString("MONTOF").Trim();
                                        if (Valor.Contains("-"))
                                        {
                                            Valor = "-" + Valor.Replace("-", "");
                                        }
                                        Valor = Valor.Replace(".", "");
                                        Valor = Valor.Replace(",", "");
                                        decimal ValorAux        = Convert.ToDecimal(Valor);
                                        string  Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                        PART_ABIERTAS_resp.MONTOF = Cualquiernombre.Replace(",", ".");
                                    }
                                    else
                                    {
                                        string  moneda   = Convert.ToString(lt_t_documentos[i].GetString("MONTOF"));
                                        decimal ValorAux = Convert.ToDecimal(moneda);
                                        PART_ABIERTAS_resp.MONTOF = string.Format("{0:0,0.##}", ValorAux).Replace(",", ".");
                                    }
                                }
                                if (lt_t_documentos[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_t_documentos[i].GetString("MONTO").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux        = Convert.ToDecimal(Valor);
                                    string  Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                    PART_ABIERTAS_resp.MONTO = Cualquiernombre.Replace(",", ".");
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_t_documentos[i].GetString("MONTO"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    PART_ABIERTAS_resp.MONTO = string.Format("{0:0,0.##}", ValorAux).Replace(",", ".");
                                }
                                if (lt_t_documentos[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_t_documentos[i].GetString("MONTOF_ABON").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux        = Convert.ToDecimal(Valor);
                                    string  Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                    PART_ABIERTAS_resp.MONTOF_ABON = Cualquiernombre.Replace(",", ".");
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_t_documentos[i].GetString("MONTOF_ABON"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    PART_ABIERTAS_resp.MONTOF_ABON = string.Format("{0:0,0.##}", ValorAux).Replace(",", ".");
                                }
                                //MONTO A PAGAR
                                if (lt_t_documentos[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_t_documentos[i].GetString("MONTOF_PAGAR").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux   = Convert.ToDecimal(Valor);
                                    string  monedachil = string.Format("{0:0,0}", ValorAux);
                                    PART_ABIERTAS_resp.MONTOF_PAGAR = monedachil.Replace(",", ".");
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_t_documentos[i].GetString("MONTOF_PAGAR"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    PART_ABIERTAS_resp.MONTOF_PAGAR = string.Format("{0:0,0.##}", ValorAux).Replace(",", ".");
                                }
                                ObjDatosPartidasOpen.Add(PART_ABIERTAS_resp);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message + ex.StackTrace);
                                System.Windows.MessageBox.Show(ex.Message + ex.StackTrace);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("No existe(n) registro(s) para este número de " + TipoBusqueda);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message + ex.StackTrace);
                    System.Windows.MessageBox.Show(ex.Message + ex.StackTrace);
                }
                String Mensaje = "";
                if (lt_retorno.Count > 0)
                {
                    string returning = "";
                    retorno_resp = new ESTADO();
                    for (int i = 0; i < lt_retorno.Count(); i++)
                    {
                        // lt_retorno.CurrentIndex = i;
                        if (i == 0)
                        {
                            returning = retorno_resp.TYPE = lt_retorno.GetString("TYPE");
                        }
                        retorno_resp.TYPE       = lt_retorno.GetString("TYPE");
                        retorno_resp.ID         = lt_retorno.GetString("ID");
                        retorno_resp.NUMBER     = lt_retorno.GetString("NUMBER");
                        retorno_resp.MESSAGE    = lt_retorno.GetString("MESSAGE");
                        retorno_resp.LOG_NO     = lt_retorno.GetString("LOG_NO");
                        retorno_resp.LOG_MSG_NO = lt_retorno.GetString("LOG_MSG_NO");
                        retorno_resp.MESSAGE    = lt_retorno.GetString("MESSAGE");
                        retorno_resp.MESSAGE_V1 = lt_retorno.GetString("MESSAGE_V1");
                        if (i == 0)
                        {
                            Mensaje = Mensaje + " - " + lt_retorno.GetString("MESSAGE") + " - " + lt_retorno.GetString("MESSAGE_V1");
                        }
                        retorno_resp.MESSAGE_V2 = lt_retorno.GetString("MESSAGE_V2");
                        retorno_resp.MESSAGE_V3 = lt_retorno.GetString("MESSAGE_V3");
                        retorno_resp.MESSAGE_V4 = lt_retorno.GetString("MESSAGE_V4");
                        retorno_resp.PARAMETER  = lt_retorno.GetString("PARAMETER");
                        retorno_resp.ROW        = lt_retorno.GetString("ROW");
                        retorno_resp.FIELD      = lt_retorno.GetString("FIELD");
                        retorno_resp.SYSTEM     = lt_retorno.GetString("SYSTEM");
                        Retorno.Add(retorno_resp);
                    }
                    if (returning != "")
                    {
                        System.Windows.MessageBox.Show(Mensaje);
                    }
                }
                GC.Collect();
            }
            else
            {
                errormessage = retval;
                GC.Collect();
            }
        }
Exemplo n.º 5
0
        public void anticiposopen(string P_UNAME, string P_PASSWORD, string P_IDSISTEMA, string P_INSTANCIA, string P_MANDANTE, string P_SAPROUTER, string P_SERVER, string P_IDIOMA
                                  , string P_DOCUMENTO, string P_RUT, string P_SOCIEDAD, string P_LAND, string TipoBusqueda)

        {
            ObjDatosAnticipos.Clear();
            Retorno.Clear();
            protesto     = "";
            errormessage = "";
            IRfcTable     lt_t_documentos;
            IRfcStructure lt_retorno;

            //  PART_ABIERTAS  PART_ABIERTAS_resp;
            T_DOCUMENTOS ANTICIPOS_resp;
            ESTADO       retorno_resp;

            //Conexion a SAP
            //connectorSap.idioma = "ES";
            //connectorSap.idSistema = "INS";
            //connectorSap.instancia = "00";
            //connectorSap.mandante = "400";
            //connectorSap.paswr = P_PASSWORD;
            //connectorSap.sapRouter = "/H/64.76.139.78/H/";
            //connectorSap.user = P_UNAME;
            //connectorSap.server = "10.9.100.4";
            //frm.txtIdSistema.Text = txtIdSistema.Text;
            //frm.txtInstancia.Text = txtInstancia.Text;
            //frm.txtMandante.Text = txtMandante.Text;
            //frm.txtSapRouter.Text = txtSapRouter.Text;
            //frm.txtServer.Text = txtServer.Text;
            //frm.txtIdioma.Text = txtIdioma.Text;
            connectorSap.idioma    = P_IDIOMA;
            connectorSap.idSistema = P_IDSISTEMA;
            connectorSap.instancia = P_INSTANCIA;
            connectorSap.mandante  = P_MANDANTE;
            connectorSap.paswr     = P_PASSWORD;
            connectorSap.sapRouter = P_SAPROUTER;
            connectorSap.user      = P_UNAME;
            connectorSap.server    = P_SERVER;

            string retval = connectorSap.connectionsSAP();

            //Si el valor de retorno es nulo o vacio, hay conexion a SAP y la RFC trae datos
            if (string.IsNullOrEmpty(retval))
            {
                RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination(connectorSap.connectorConfig);
                RfcRepository  SapRfcRepository  = SapRfcDestination.Repository;

                IRfcFunction BapiGetUser = SapRfcRepository.CreateFunction("ZSCP_RFC_GET_ANT");
                BapiGetUser.SetValue("DOCUMENTO", P_DOCUMENTO);
                BapiGetUser.SetValue("LAND", P_LAND);
                BapiGetUser.SetValue("RUT", P_RUT);
                BapiGetUser.SetValue("SOCIEDAD", P_SOCIEDAD);
                //BapiGetUser.SetValue("PROT", P_PROTESTO);
                BapiGetUser.Invoke(SapRfcDestination);
                protesto = BapiGetUser.GetString("PE_PROTESTADO");

                lt_t_documentos = BapiGetUser.GetTable("T_DOCUMENTOS");
                lt_retorno      = BapiGetUser.GetStructure("SE_ESTATUS");
                //lt_PART_ABIERTAS = BapiGetUser.GetTable("ZCLSP_TT_LISTA_DOCUMENTOS");
                try
                {
                    if (lt_t_documentos.Count > 0)
                    {
                        //LLenamos la tabla de salida lt_DatGen
                        for (int i = 0; i < lt_t_documentos.RowCount; i++)
                        {
                            try
                            {
                                lt_t_documentos.CurrentIndex = i;
                                ANTICIPOS_resp = new T_DOCUMENTOS();

                                ANTICIPOS_resp.NDOCTO = lt_t_documentos[i].GetString("NDOCTO");
                                string Monto  = "";
                                int    indice = 0;
                                //*******
                                if (lt_t_documentos[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_t_documentos[i].GetString("MONTOF").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux        = Convert.ToDecimal(Valor);
                                    string  Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                    ANTICIPOS_resp.MONTOF = Cualquiernombre;
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_t_documentos[i].GetString("MONTOF"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    ANTICIPOS_resp.MONTOF = string.Format("{0:0,0.##}", ValorAux);
                                }

                                //if (lt_t_documentos[i].GetString("MONTOF") == "")
                                //{
                                //    indice = lt_t_documentos[i].GetString("MONTO").IndexOf(',');
                                //    Monto = lt_t_documentos[i].GetString("MONTO").Substring(0, indice - 1);
                                //    ANTICIPOS_resp.MONTOF = Monto;
                                //}
                                //else
                                //{
                                //    ANTICIPOS_resp.MONTOF = lt_t_documentos[i].GetString("MONTOF");
                                //}
                                ANTICIPOS_resp.MONEDA = lt_t_documentos[i].GetString("MONEDA");
                                if (lt_t_documentos[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_t_documentos[i].GetString("MONTO").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux        = Convert.ToDecimal(Valor);
                                    string  Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                    ANTICIPOS_resp.MONTO = Cualquiernombre;
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_t_documentos[i].GetString("MONTO"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    ANTICIPOS_resp.MONTO = string.Format("{0:0,0.##}", ValorAux);
                                }

                                //if (lt_t_documentos[i].GetString("MONTO") == "")
                                //{
                                //    indice = lt_t_documentos[i].GetString("MONTO").IndexOf(',');
                                //    Monto = lt_t_documentos[i].GetString("MONTO").Substring(0, indice - 1);
                                //    ANTICIPOS_resp.MONTO = Monto;
                                //}
                                //else
                                //{
                                //    ANTICIPOS_resp.MONTO = lt_t_documentos[i].GetString("MONTO");
                                //}
                                ANTICIPOS_resp.MONEDA          = lt_t_documentos[i].GetString("MONEDA");
                                ANTICIPOS_resp.FECVENCI        = lt_t_documentos[i].GetString("FECVENCI");
                                ANTICIPOS_resp.CONTROL_CREDITO = lt_t_documentos[i].GetString("CONTROL_CREDITO");
                                ANTICIPOS_resp.CEBE            = lt_t_documentos[i].GetString("CEBE");
                                ANTICIPOS_resp.COND_PAGO       = lt_t_documentos[i].GetString("COND_PAGO");
                                ANTICIPOS_resp.RUTCLI          = lt_t_documentos[i].GetString("RUTCLI");
                                ANTICIPOS_resp.NOMCLI          = lt_t_documentos[i].GetString("NOMCLI");
                                ANTICIPOS_resp.ESTADO          = lt_t_documentos[i].GetString("ESTADO");
                                ANTICIPOS_resp.ICONO           = lt_t_documentos[i].GetString("ICONO");
                                ANTICIPOS_resp.DIAS_ATRASO     = lt_t_documentos[i].GetString("DIAS_ATRASO");
                                //if (lt_t_documentos[i].GetString("MONTOF_ABON") == "")
                                //{
                                //    indice = lt_t_documentos[i].GetString("MONTO_ABONADO").IndexOf(',');
                                //    Monto = lt_t_documentos[i].GetString("MONTO_ABONADO").Substring(0, indice - 1);
                                //    ANTICIPOS_resp.MONTOF = Monto;
                                //}
                                //else
                                //{
                                //    ANTICIPOS_resp.MONTOF_ABON = lt_t_documentos[i].GetString("MONTOF_ABON");
                                //}
                                if (lt_t_documentos[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_t_documentos[i].GetString("MONTOF_ABON").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux        = Convert.ToDecimal(Valor);
                                    string  Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                    ANTICIPOS_resp.MONTOF_ABON = Cualquiernombre;
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_t_documentos[i].GetString("MONTOF_ABON"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    ANTICIPOS_resp.MONTOF_ABON = string.Format("{0:0,0.##}", ValorAux);
                                }

                                //if (lt_t_documentos[i].GetString("MONTOF_PAGAR") == "")
                                //{
                                //    indice = lt_t_documentos[i].GetString("MONTO_PAGAR").IndexOf(',');
                                //    Monto = lt_t_documentos[i].GetString("MONTO_PAGAR").Substring(0, indice - 1);
                                //    ANTICIPOS_resp.MONTOF = Monto;
                                //}
                                //else
                                //{
                                //    ANTICIPOS_resp.MONTOF_PAGAR = lt_t_documentos[i].GetString("MONTOF_PAGAR");
                                //}
                                if (lt_t_documentos[i].GetString("MONEDA") == "CLP")
                                {
                                    string Valor = lt_t_documentos[i].GetString("MONTOF_PAGAR").Trim();
                                    if (Valor.Contains("-"))
                                    {
                                        Valor = "-" + Valor.Replace("-", "");
                                    }
                                    Valor = Valor.Replace(".", "");
                                    Valor = Valor.Replace(",", "");
                                    decimal ValorAux        = Convert.ToDecimal(Valor);
                                    string  Cualquiernombre = string.Format("{0:0,0}", ValorAux);
                                    ANTICIPOS_resp.MONTOF_PAGAR = Cualquiernombre;
                                }
                                else
                                {
                                    string  moneda   = Convert.ToString(lt_t_documentos[i].GetString("MONTOF_PAGAR"));
                                    decimal ValorAux = Convert.ToDecimal(moneda);
                                    ANTICIPOS_resp.MONTOF_PAGAR = string.Format("{0:0,0.##}", ValorAux);
                                }
                                ANTICIPOS_resp.NREF         = lt_t_documentos[i].GetString("NREF");
                                ANTICIPOS_resp.FECHA_DOC    = lt_t_documentos[i].GetString("FECHA_DOC");
                                ANTICIPOS_resp.COD_CLIENTE  = lt_t_documentos[i].GetString("COD_CLIENTE");
                                ANTICIPOS_resp.SOCIEDAD     = lt_t_documentos[i].GetString("SOCIEDAD");
                                ANTICIPOS_resp.CLASE_DOC    = lt_t_documentos[i].GetString("CLASE_DOC");
                                ANTICIPOS_resp.CLASE_CUENTA = lt_t_documentos[i].GetString("CLASE_CUENTA");
                                ANTICIPOS_resp.CME          = lt_t_documentos[i].GetString("CME");
                                ANTICIPOS_resp.ACC          = lt_t_documentos[i].GetString("ACC");
                                ObjDatosAnticipos.Add(ANTICIPOS_resp);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message + ex.StackTrace);
                                System.Windows.MessageBox.Show(ex.Message + ex.StackTrace);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("No existe(n) registro(s)");
                    }

                    String Mensaje = "";
                    if (lt_retorno.Count > 0)
                    {
                        retorno_resp = new ESTADO();
                        for (int i = 0; i < lt_retorno.Count(); i++)
                        {
                            // lt_retorno.CurrentIndex = i;

                            retorno_resp.TYPE       = lt_retorno.GetString("TYPE");
                            retorno_resp.ID         = lt_retorno.GetString("ID");
                            retorno_resp.NUMBER     = lt_retorno.GetString("NUMBER");
                            retorno_resp.MESSAGE    = lt_retorno.GetString("MESSAGE");
                            retorno_resp.LOG_NO     = lt_retorno.GetString("LOG_NO");
                            retorno_resp.LOG_MSG_NO = lt_retorno.GetString("LOG_MSG_NO");
                            retorno_resp.MESSAGE    = lt_retorno.GetString("MESSAGE");
                            retorno_resp.MESSAGE_V1 = lt_retorno.GetString("MESSAGE_V1");
                            if (lt_retorno.GetString("TYPE") == "S")
                            {
                                Mensaje = Mensaje + " - " + lt_retorno.GetString("MESSAGE") + " - " + lt_retorno.GetString("MESSAGE_V1");
                            }
                            retorno_resp.MESSAGE_V2 = lt_retorno.GetString("MESSAGE_V2");
                            retorno_resp.MESSAGE_V3 = lt_retorno.GetString("MESSAGE_V3");
                            retorno_resp.MESSAGE_V4 = lt_retorno.GetString("MESSAGE_V4");
                            retorno_resp.PARAMETER  = lt_retorno.GetString("PARAMETER");
                            retorno_resp.ROW        = lt_retorno.GetString("ROW");
                            retorno_resp.FIELD      = lt_retorno.GetString("FIELD");
                            retorno_resp.SYSTEM     = lt_retorno.GetString("SYSTEM");
                            Retorno.Add(retorno_resp);
                        }
                        //System.Windows.MessageBox.Show(Mensaje);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message + ex.StackTrace);
                    System.Windows.MessageBox.Show(ex.Message + ex.StackTrace);
                }
            }
            else
            {
                errormessage = retval;
            }
            GC.Collect();
        }
Exemplo n.º 6
0
        public void pagosmasivos(string P_UNAME, string P_PASSWORD, string P_IDSISTEMA, string P_INSTANCIA, string P_MANDANTE, string P_SAPROUTER, string P_SERVER, string P_IDIOMA, string P_RUT, string P_SOCIEDAD, List <PagosMasivos> ListaExc)
        {
            ObjDatosPartidasOpen.Clear();
            Retorno.Clear();
            errormessage = "";
            protesto     = "";
            IRfcTable     lt_PAGOS_MASIVOS;
            IRfcStructure lt_retorno;

            ESTADO       retorno_resp;
            T_DOCUMENTOS PAGOS_MASIVOS_resp;

            //Conexion a SAP
            connectorSap.idioma    = P_IDIOMA;
            connectorSap.idSistema = P_IDSISTEMA;
            connectorSap.instancia = P_INSTANCIA;
            connectorSap.mandante  = P_MANDANTE;
            connectorSap.paswr     = P_PASSWORD;
            connectorSap.sapRouter = P_SAPROUTER;
            connectorSap.user      = P_UNAME;
            connectorSap.server    = P_SERVER;

            string retval = connectorSap.connectionsSAP();

            //Si el valor de retorno es nulo o vacio, hay conexion a SAP y la RFC trae datos
            if (string.IsNullOrEmpty(retval))
            {
                RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination(connectorSap.connectorConfig);
                RfcRepository  SapRfcRepository  = SapRfcDestination.Repository;

                IRfcFunction BapiGetUser = SapRfcRepository.CreateFunction("ZSCP_RFC_GET_DOC_MASI");
                BapiGetUser.SetValue("STCD1", P_RUT);
                BapiGetUser.SetValue("BUKRS", P_SOCIEDAD);



                IRfcTable GralDat = BapiGetUser.GetTable("T_GET_DOC");

                for (var i = 0; i < ListaExc.Count; i++)
                {
                    GralDat.Append();
                    GralDat.SetValue("XBLNR", ListaExc[i].Referencia);
                    GralDat.SetValue("MONTO", ListaExc[i].Monto);
                    GralDat.SetValue("WAERS", ListaExc[i].Moneda);
                }

                BapiGetUser.SetValue("T_GET_DOC", GralDat);


                BapiGetUser.Invoke(SapRfcDestination);


                protesto         = BapiGetUser.GetString("PE_PROTESTADO");
                lt_PAGOS_MASIVOS = BapiGetUser.GetTable("T_DOCUMENTOS");
                lt_retorno       = BapiGetUser.GetStructure("SE_ESTATUS");
                //lt_PART_ABIERTAS = BapiGetUser.GetTable("ZCLSP_TT_LISTA_DOCUMENTOS");
                if (lt_PAGOS_MASIVOS.Count > 0)
                {
                    //LLenamos la tabla de salida lt_DatGen
                    for (int i = 0; i < lt_PAGOS_MASIVOS.RowCount; i++)
                    {
                        lt_PAGOS_MASIVOS.CurrentIndex = i;
                        PAGOS_MASIVOS_resp            = new T_DOCUMENTOS();

                        PAGOS_MASIVOS_resp.SOCIEDAD        = lt_PAGOS_MASIVOS[i].GetString("SOCIEDAD");
                        PAGOS_MASIVOS_resp.NDOCTO          = lt_PAGOS_MASIVOS[i].GetString("NDOCTO");
                        PAGOS_MASIVOS_resp.NREF            = lt_PAGOS_MASIVOS[i].GetString("NREF");
                        PAGOS_MASIVOS_resp.CLASE_CUENTA    = lt_PAGOS_MASIVOS[i].GetString("CLASE_CUENTA");
                        PAGOS_MASIVOS_resp.CLASE_DOC       = lt_PAGOS_MASIVOS[i].GetString("CLASE_DOC");
                        PAGOS_MASIVOS_resp.COD_CLIENTE     = lt_PAGOS_MASIVOS[i].GetString("COD_CLIENTE");
                        PAGOS_MASIVOS_resp.RUTCLI          = lt_PAGOS_MASIVOS[i].GetString("RUTCLI");
                        PAGOS_MASIVOS_resp.NOMCLI          = lt_PAGOS_MASIVOS[i].GetString("NOMCLI");
                        PAGOS_MASIVOS_resp.CEBE            = lt_PAGOS_MASIVOS[i].GetString("CEBE");
                        PAGOS_MASIVOS_resp.FECHA_DOC       = lt_PAGOS_MASIVOS[i].GetString("FECHA_DOC");
                        PAGOS_MASIVOS_resp.FECVENCI        = lt_PAGOS_MASIVOS[i].GetString("FECVENCI");
                        PAGOS_MASIVOS_resp.DIAS_ATRASO     = lt_PAGOS_MASIVOS[i].GetString("DIAS_ATRASO");
                        PAGOS_MASIVOS_resp.ESTADO          = lt_PAGOS_MASIVOS[i].GetString("ESTADO");
                        PAGOS_MASIVOS_resp.ICONO           = lt_PAGOS_MASIVOS[i].GetString("ICONO");
                        PAGOS_MASIVOS_resp.MONEDA          = lt_PAGOS_MASIVOS[i].GetString("MONEDA");
                        PAGOS_MASIVOS_resp.ACC             = lt_PAGOS_MASIVOS[i].GetString("ACC");
                        PAGOS_MASIVOS_resp.CLASE_CUENTA    = lt_PAGOS_MASIVOS[i].GetString("CLASE_CUENTA");
                        PAGOS_MASIVOS_resp.CLASE_DOC       = lt_PAGOS_MASIVOS[i].GetString("CLASE_DOC");
                        PAGOS_MASIVOS_resp.CME             = lt_PAGOS_MASIVOS[i].GetString("CME");
                        PAGOS_MASIVOS_resp.CONTROL_CREDITO = lt_PAGOS_MASIVOS[i].GetString("CONTROL_CREDITO");
                        //string.Format("{0:0.##}", lvatend)
                        //decimal lvNetoAbo2 = Convert.ToDecimal(t_REPORTE_CONTACTOS[i].GetString("NETO_ABONO2"));
                        //REPORTE_CONTACTOS_resp.NETO_ABONO2 = string.Format("{0:#,0}", lvNetoAbo2);
                        if (lt_PAGOS_MASIVOS[i].GetString("MONTOF") == "")
                        {
                            PAGOS_MASIVOS_resp.MONTOF = "0";
                        }
                        else
                        {
                            decimal Cualquiernombre = Convert.ToDecimal(lt_PAGOS_MASIVOS[i].GetString("MONTOF"));
                            // PAGOS_MASIVOS_resp.MONTOF = lt_PAGOS_MASIVOS[i].GetString("MONTOF");
                            PAGOS_MASIVOS_resp.MONTOF = string.Format("{0:0.##}", Cualquiernombre);
                        }
                        if (lt_PAGOS_MASIVOS[i].GetString("MONTO") == "")
                        {
                            PAGOS_MASIVOS_resp.MONTO = "0";
                        }
                        else
                        {
                            decimal Cualquiernombre = Convert.ToDecimal(lt_PAGOS_MASIVOS[i].GetString("MONTO"));
                            // PAGOS_MASIVOS_resp.MONTOF = lt_PAGOS_MASIVOS[i].GetString("MONTOF");
                            PAGOS_MASIVOS_resp.MONTO = string.Format("{0:0.##}", Cualquiernombre);
                        }
                        if (lt_PAGOS_MASIVOS[i].GetString("MONTOF_ABON") == "")
                        {
                            PAGOS_MASIVOS_resp.MONTOF_ABON = "0";
                        }
                        else
                        {
                            decimal Cualquiernombre = Convert.ToDecimal(lt_PAGOS_MASIVOS[i].GetString("MONTOF_ABON"));
                            PAGOS_MASIVOS_resp.MONTOF_ABON = string.Format("{0:0.##}", Cualquiernombre);
                        }
                        if (lt_PAGOS_MASIVOS[i].GetString("MONTOF_PAGAR") == "")
                        {
                            PAGOS_MASIVOS_resp.MONTOF_PAGAR = "0";
                        }
                        else
                        {
                            // PAGOS_MASIVOS_resp.MONTOF_ABON = lt_PAGOS_MASIVOS[i].GetString("MONTOF_ABON");
                            decimal Cualquiernombre = Convert.ToDecimal(lt_PAGOS_MASIVOS[i].GetString("MONTOF_PAGAR"));
                            PAGOS_MASIVOS_resp.MONTOF_PAGAR = string.Format("{0:0.##}", Cualquiernombre);
                        }
                        // PAGOS_MASIVOS_resp.MONTOF_PAGAR = lt_PAGOS_MASIVOS[i].GetString("MONTOF_PAGAR");


                        ObjDatosPartidasOpen.Add(PAGOS_MASIVOS_resp);
                    }
                }
                else
                {
                    MessageBox.Show("No existen registros para este número de RUT");
                }

                String Mensaje = "";
                if (lt_retorno.Count > 0)
                {
                    retorno_resp = new ESTADO();
                    for (int i = 0; i < lt_retorno.Count(); i++)
                    {
                        // lt_retorno.CurrentIndex = i;

                        retorno_resp.TYPE       = lt_retorno.GetString("TYPE");
                        retorno_resp.ID         = lt_retorno.GetString("ID");
                        retorno_resp.NUMBER     = lt_retorno.GetString("NUMBER");
                        retorno_resp.MESSAGE    = lt_retorno.GetString("MESSAGE");
                        retorno_resp.LOG_NO     = lt_retorno.GetString("LOG_NO");
                        retorno_resp.LOG_MSG_NO = lt_retorno.GetString("LOG_MSG_NO");
                        retorno_resp.MESSAGE    = lt_retorno.GetString("MESSAGE");
                        retorno_resp.MESSAGE_V1 = lt_retorno.GetString("MESSAGE_V1");
                        if (i == 0)
                        {
                            Mensaje = Mensaje + " - " + lt_retorno.GetString("MESSAGE") + " - " + lt_retorno.GetString("MESSAGE_V1");
                        }
                        retorno_resp.MESSAGE_V2 = lt_retorno.GetString("MESSAGE_V2");
                        retorno_resp.MESSAGE_V3 = lt_retorno.GetString("MESSAGE_V3");
                        retorno_resp.MESSAGE_V4 = lt_retorno.GetString("MESSAGE_V4");
                        retorno_resp.PARAMETER  = lt_retorno.GetString("PARAMETER");
                        retorno_resp.ROW        = lt_retorno.GetString("ROW");
                        retorno_resp.FIELD      = lt_retorno.GetString("FIELD");
                        retorno_resp.SYSTEM     = lt_retorno.GetString("SYSTEM");
                        Retorno.Add(retorno_resp);
                    }
                    System.Windows.MessageBox.Show(Mensaje);
                }
                GC.Collect();
            }
            else
            {
                errormessage = retval;
                GC.Collect();
            }
        }
Exemplo n.º 7
0
        public void chequearnotascreditos(string P_UNAME, string P_PASSWORD, string P_IDSISTEMA, string P_INSTANCIA, string P_MANDANTE, string P_SAPROUTER, string P_SERVER, string P_IDIOMA, string P_ID_CAJA, string P_MONEDA, string P_PAIS, List <T_DOCUMENTOS> P_DOCSAPAGAR)
        {
            try
            {
                RETURN2      retorno;
                DET_EFECT    efectivo;
                T_DOCUMENTOS docs;
                VIAS_PAGO2   vp;
                //DETALLE_REND detallerend;
                T_Retorno.Clear();
                documentos.Clear();
                viapago.Clear();
                det_efectivo.Clear();
                errormessage = "";
                message      = "";
                IdCaja       = "";
                Efectivo     = "0";

                IRfcTable ls_RETORNO;
                IRfcTable lt_VP;
                IRfcTable lt_DOCS;
                IRfcTable lt_EFECTIVO;

                connectorSap.idioma    = P_IDIOMA;
                connectorSap.idSistema = P_IDSISTEMA;
                connectorSap.instancia = P_INSTANCIA;
                connectorSap.mandante  = P_MANDANTE;
                connectorSap.paswr     = P_PASSWORD;
                connectorSap.sapRouter = P_SAPROUTER;
                connectorSap.user      = P_UNAME;
                connectorSap.server    = P_SERVER;

                string retval = connectorSap.connectionsSAP();

                //Si el valor de retorno es nulo o vacio, hay conexion a SAP y la RFC trae datos
                if (string.IsNullOrEmpty(retval))
                {
                    RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination(connectorSap.connectorConfig);
                    RfcRepository  SapRfcRepository  = SapRfcDestination.Repository;

                    IRfcFunction BapiGetUser = SapRfcRepository.CreateFunction("ZSCP_RFC_CHECK_NC");

                    BapiGetUser.SetValue("ID_CAJA", P_ID_CAJA);
                    BapiGetUser.SetValue("PAY_CURRENCY", P_MONEDA);
                    BapiGetUser.SetValue("LAND", P_PAIS);
                    IRfcTable GralDat2 = BapiGetUser.GetTable("DOCUMENTOS");
                    try
                    {
                        for (var i = 0; i < P_DOCSAPAGAR.Count; i++)
                        {
                            GralDat2.Append();
                            GralDat2.SetValue("NDOCTO", P_DOCSAPAGAR[i].NDOCTO);
                            GralDat2.SetValue("MONTO", P_DOCSAPAGAR[i].MONTO);
                            GralDat2.SetValue("MONTOF", P_DOCSAPAGAR[i].MONTOF);
                            GralDat2.SetValue("MONEDA", P_DOCSAPAGAR[i].MONEDA);
                            GralDat2.SetValue("LAND", P_DOCSAPAGAR[i].LAND);
                            GralDat2.SetValue("FECVENCI", P_DOCSAPAGAR[i].FECVENCI);
                            GralDat2.SetValue("CONTROL_CREDITO", P_DOCSAPAGAR[i].CONTROL_CREDITO);
                            GralDat2.SetValue("CEBE", P_DOCSAPAGAR[i].CEBE);
                            GralDat2.SetValue("COND_PAGO", P_DOCSAPAGAR[i].COND_PAGO);
                            GralDat2.SetValue("RUTCLI", P_DOCSAPAGAR[i].RUTCLI);
                            GralDat2.SetValue("NOMCLI", P_DOCSAPAGAR[i].NOMCLI);
                            GralDat2.SetValue("ESTADO", P_DOCSAPAGAR[i].ESTADO);
                            GralDat2.SetValue("ICONO", P_DOCSAPAGAR[i].ICONO);
                            GralDat2.SetValue("DIAS_ATRASO", P_DOCSAPAGAR[i].DIAS_ATRASO);
                            GralDat2.SetValue("MONTO_ABONADO", P_DOCSAPAGAR[i].MONTO_ABONADO);
                            GralDat2.SetValue("MONTOF_ABON", P_DOCSAPAGAR[i].MONTOF_ABON);
                            GralDat2.SetValue("MONTO_PAGAR", P_DOCSAPAGAR[i].MONTO_PAGAR);
                            GralDat2.SetValue("MONTOF_PAGAR", P_DOCSAPAGAR[i].MONTOF_PAGAR);
                            GralDat2.SetValue("NREF", P_DOCSAPAGAR[i].NREF);
                            GralDat2.SetValue("FECHA_DOC", P_DOCSAPAGAR[i].FECHA_DOC);
                            GralDat2.SetValue("COD_CLIENTE", P_DOCSAPAGAR[i].COD_CLIENTE);
                            GralDat2.SetValue("SOCIEDAD", P_DOCSAPAGAR[i].SOCIEDAD);
                            GralDat2.SetValue("CLASE_DOC", P_DOCSAPAGAR[i].CLASE_DOC);
                            GralDat2.SetValue("CLASE_CUENTA", P_DOCSAPAGAR[i].CLASE_CUENTA);
                            GralDat2.SetValue("CME", P_DOCSAPAGAR[i].CME);
                            GralDat2.SetValue("ACC", P_DOCSAPAGAR[i].ACC);
                            GralDat2.SetValue("FACT_SD_ORIGEN", P_DOCSAPAGAR[i].FACT_SD_ORIGEN);
                            GralDat2.SetValue("FACT_ELECT", P_DOCSAPAGAR[i].FACT_ELECT);
                            GralDat2.SetValue("ID_COMPROBANTE", P_DOCSAPAGAR[i].ID_COMPROBANTE);
                            GralDat2.SetValue("ID_CAJA", P_DOCSAPAGAR[i].ID_CAJA);
                            GralDat2.SetValue("LAND", P_DOCSAPAGAR[i].LAND);
                            GralDat2.SetValue("BAPI", P_DOCSAPAGAR[i].BAPI);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message + ex.StackTrace);
                        //System.Windows.MessageBox.Show(ex.Message + ex.StackTrace);
                    }
                    BapiGetUser.SetValue("DOCUMENTOS", GralDat2);


                    BapiGetUser.Invoke(SapRfcDestination);
                    //BapiGetUser.SetValue("I_VBELN",P_NUMDOCSD);
                    //IRfcTable GralDat = BapiGetUser.GetTable("VIAS_PAGO");
                    lt_DOCS = BapiGetUser.GetTable("DOCUMENTOS");

                    if (lt_DOCS.Count > 0)
                    {
                        //LLenamos la tabla de salida lt_DatGen
                        for (int i = 0; i < lt_DOCS.RowCount; i++)
                        {
                            try
                            {
                                lt_DOCS.CurrentIndex = i;
                                docs = new T_DOCUMENTOS();

                                docs.NDOCTO = lt_DOCS[i].GetString("NDOCTO");
                                string Monto  = "";
                                int    indice = 0;
                                //*******
                                if (lt_DOCS[i].GetString("MONTOF") == "")
                                {
                                    indice      = lt_DOCS[i].GetString("MONTO").IndexOf(',');
                                    Monto       = lt_DOCS[i].GetString("MONTO").Substring(0, indice - 1);
                                    docs.MONTOF = Monto;
                                }
                                else
                                {
                                    docs.MONTOF = lt_DOCS[i].GetString("MONTOF");
                                }
                                if (lt_DOCS[i].GetString("MONTO") == "")
                                {
                                    indice     = lt_DOCS[i].GetString("MONTO").IndexOf(',');
                                    Monto      = lt_DOCS[i].GetString("MONTO").Substring(0, indice - 1);
                                    docs.MONTO = Monto;
                                }
                                else
                                {
                                    docs.MONTO = lt_DOCS[i].GetString("MONTO");
                                }
                                docs.MONEDA          = lt_DOCS[i].GetString("MONEDA");
                                docs.FECVENCI        = lt_DOCS[i].GetString("FECVENCI");
                                docs.CONTROL_CREDITO = lt_DOCS[i].GetString("CONTROL_CREDITO");
                                docs.CEBE            = lt_DOCS[i].GetString("CEBE");
                                docs.COND_PAGO       = lt_DOCS[i].GetString("COND_PAGO");
                                docs.RUTCLI          = lt_DOCS[i].GetString("RUTCLI");
                                docs.NOMCLI          = lt_DOCS[i].GetString("NOMCLI");
                                docs.ESTADO          = lt_DOCS[i].GetString("ESTADO");
                                docs.ICONO           = lt_DOCS[i].GetString("ICONO");
                                docs.DIAS_ATRASO     = lt_DOCS[i].GetString("DIAS_ATRASO");
                                if (lt_DOCS[i].GetString("MONTOF_ABON") == "")
                                {
                                    indice      = lt_DOCS[i].GetString("MONTO_ABONADO").IndexOf(',');
                                    Monto       = lt_DOCS[i].GetString("MONTO_ABONADO").Substring(0, indice - 1);
                                    docs.MONTOF = Monto;
                                }
                                else
                                {
                                    docs.MONTOF_ABON = lt_DOCS[i].GetString("MONTOF_ABON");
                                }
                                if (lt_DOCS[i].GetString("MONTOF_PAGAR") == "")
                                {
                                    indice      = lt_DOCS[i].GetString("MONTO_PAGAR").IndexOf(',');
                                    Monto       = lt_DOCS[i].GetString("MONTO_PAGAR").Substring(0, indice - 1);
                                    docs.MONTOF = Monto;
                                }
                                else
                                {
                                    docs.MONTOF_PAGAR = lt_DOCS[i].GetString("MONTOF_PAGAR");
                                }
                                docs.NREF           = lt_DOCS[i].GetString("NREF");
                                docs.FECHA_DOC      = lt_DOCS[i].GetString("FECHA_DOC");
                                docs.COD_CLIENTE    = lt_DOCS[i].GetString("COD_CLIENTE");
                                docs.SOCIEDAD       = lt_DOCS[i].GetString("SOCIEDAD");
                                docs.CLASE_DOC      = lt_DOCS[i].GetString("CLASE_DOC");
                                docs.CLASE_CUENTA   = lt_DOCS[i].GetString("CLASE_CUENTA");
                                docs.CME            = lt_DOCS[i].GetString("CME");
                                docs.ACC            = lt_DOCS[i].GetString("ACC");
                                docs.FACT_SD_ORIGEN = lt_DOCS[i].GetString("FACT_SD_ORIGEN");
                                docs.FACT_ELECT     = lt_DOCS[i].GetString("FACT_ELECT");
                                docs.ID_COMPROBANTE = lt_DOCS[i].GetString("ID_COMPROBANTE");
                                docs.ID_CAJA        = lt_DOCS[i].GetString("ID_CAJA");
                                docs.LAND           = lt_DOCS[i].GetString("LAND");
                                documentos.Add(docs);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message + ex.StackTrace);
                                System.Windows.MessageBox.Show(ex.Message + ex.StackTrace);
                            }
                        }
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show("No existe(n) registro(s)");
                    }

                    lt_EFECTIVO = BapiGetUser.GetTable("DET_EFECT");
                    try
                    {
                        for (int i = 0; i < lt_EFECTIVO.Count(); i++)
                        {
                            lt_EFECTIVO.CurrentIndex = i;
                            efectivo              = new DET_EFECT();
                            efectivo.LAND         = lt_EFECTIVO.GetString("LAND");
                            efectivo.ID_CAJA      = lt_EFECTIVO.GetString("ID_CAJA");
                            efectivo.SOCIEDAD     = lt_EFECTIVO.GetString("SOCIEDAD");
                            efectivo.SOCIEDAD_TXT = lt_EFECTIVO.GetString("SOCIEDAD_TXT");
                            efectivo.VIA_PAGO     = lt_EFECTIVO.GetString("VIA_PAGO");
                            efectivo.TEXT1        = lt_EFECTIVO.GetString("TEXT1");
                            efectivo.MONEDA       = lt_EFECTIVO.GetString("MONEDA");
                            efectivo.MONTO        = lt_EFECTIVO.GetString("MONTO");
                            Efectivo              = Convert.ToString(Convert.ToDouble(Efectivo) + Convert.ToDouble(lt_EFECTIVO.GetString("MONTO")));
                            efectivo.CANT_DOCS    = lt_EFECTIVO.GetString("CANT_DOCS");
                            det_efectivo.Add(efectivo);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message, ex.StackTrace);
                        MessageBox.Show(ex.Message + ex.StackTrace);
                    }
                    // PART_ABIERTAS_resp.MONTOF_ABON = string.Format("{0:0.##}", Cualquiernombre);
                    //    Efectivo = string.Format("{0:0,0}", Efectivo);
                    //Efectivo = Efectivo.ToString("0.0", CultureInfo.InvariantCulture);
                    //Efectivo = Efectivo.ToString("0:0,0");
                    //string Efect = string.Format("{0:0,0}", Efectivo);
                    //double value = 1234567890;
                    //Console.WriteLine(value.ToString("#,#", CultureInfo.InvariantCulture));
                    //Console.WriteLine(String.Format(CultureInfo.InvariantCulture,
                    //                                "{0:0,#}", value));
                    Double      Efect = Convert.ToDouble(Efectivo);
                    CultureInfo elGR  = CultureInfo.CreateSpecificCulture("el-GR");
                    Console.WriteLine(Efect.ToString("0,0", elGR));
                    Console.WriteLine(String.Format(elGR, "{0:0,0}", Efect));
                    Efectivo = Efect.ToString("0,0", elGR);
                    Efectivo = String.Format(elGR, "{0:0,0}", Efect);
                    // Efectivo = Convert.ToString(Efect).Replace(",", "");


                    lt_VP = BapiGetUser.GetTable("VIAS_PAGO");
                    if (lt_VP.Count > 0)
                    {
                        //LLenamos la tabla de salida lt_DatGen
                        for (int i = 0; i < lt_VP.RowCount; i++)
                        {
                            try
                            {
                                lt_VP.CurrentIndex = i;
                                vp = new VIAS_PAGO2();

                                vp.MANDT            = lt_VP[i].GetString("MANDT");
                                vp.LAND             = lt_VP[i].GetString("LAND");
                                vp.ID_COMPROBANTE   = lt_VP[i].GetString("ID_COMPROBANTE");
                                vp.ID_DETALLE       = lt_VP[i].GetString("ID_DETALLE");
                                vp.VIA_PAGO         = lt_VP[i].GetString("VIA_PAGO");
                                vp.MONTO            = lt_VP[i].GetString("MONTO");
                                vp.MONEDA           = lt_VP[i].GetString("MONEDA");
                                vp.BANCO            = lt_VP[i].GetString("BANCO");
                                vp.EMISOR           = lt_VP[i].GetString("EMISOR");
                                vp.NUM_CHEQUE       = lt_VP[i].GetString("NUM_CHEQUE");
                                vp.COD_AUTORIZACION = lt_VP[i].GetString("COD_AUTORIZACION");
                                vp.NUM_CUOTAS       = lt_VP[i].GetString("NUM_CUOTAS");
                                vp.FECHA_VENC       = lt_VP[i].GetString("FECHA_VENC");
                                vp.TEXTO_POSICION   = lt_VP[i].GetString("TEXTO_POSICION");
                                vp.ANEXO            = lt_VP[i].GetString("ANEXO");
                                vp.SUCURSAL         = lt_VP[i].GetString("SUCURSAL");
                                vp.NUM_CUENTA       = lt_VP[i].GetString("NUM_CUENTA");
                                vp.NUM_TARJETA      = lt_VP[i].GetString("NUM_TARJETA");
                                vp.NUM_VALE_VISTA   = lt_VP[i].GetString("NUM_VALE_VISTA");
                                vp.PATENTE          = lt_VP[i].GetString("PATENTE");
                                vp.NUM_VENTA        = lt_VP[i].GetString("NUM_VENTA");
                                vp.PAGARE           = lt_VP[i].GetString("PAGARE");
                                vp.FECHA_EMISION    = lt_VP[i].GetString("FECHA_EMISION");
                                vp.NOMBRE_GIRADOR   = lt_VP[i].GetString("NOMBRE_GIRADOR");
                                vp.CARTA_CURSE      = lt_VP[i].GetString("CARTA_CURSE");
                                vp.NUM_TRANSFER     = lt_VP[i].GetString("NUM_TRANSFER");
                                vp.NUM_DEPOSITO     = lt_VP[i].GetString("NUM_DEPOSITO");
                                vp.CTA_BANCO        = lt_VP[i].GetString("CTA_BANCO");
                                vp.IFINAN           = lt_VP[i].GetString("IFINAN");
                                vp.CORRE            = lt_VP[i].GetString("CORRE");
                                vp.ZUONR            = lt_VP[i].GetString("ZUONR");
                                vp.HKONT            = lt_VP[i].GetString("HKONT");
                                vp.PRCTR            = lt_VP[i].GetString("PRCTR");
                                vp.ZNOP             = lt_VP[i].GetString("ZNOP");
                                viapago.Add(vp);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message + ex.StackTrace);
                                System.Windows.MessageBox.Show(ex.Message + ex.StackTrace);
                            }
                        }
                    }


                    ls_RETORNO = BapiGetUser.GetTable("RETURN");
                    try
                    {
                        for (int i = 0; i < ls_RETORNO.Count(); i++)
                        {
                            ls_RETORNO.CurrentIndex = i;
                            retorno = new RETURN2();
                            if (ls_RETORNO.GetString("TYPE") == "S")
                            {
                                message = message + "-" + ls_RETORNO.GetString("MESSAGE") + ":" + ls_RETORNO.GetString("MESSAGE_V1").Trim();;
                            }
                            if (ls_RETORNO.GetString("TYPE") == "E")
                            {
                                errormessage = errormessage + " - " + ls_RETORNO.GetString("MESSAGE");
                            }
                            retorno.TYPE       = ls_RETORNO.GetString("TYPE");
                            retorno.ID         = ls_RETORNO.GetString("ID");
                            retorno.NUMBER     = ls_RETORNO.GetString("NUMBER");
                            retorno.MESSAGE    = ls_RETORNO.GetString("MESSAGE");
                            retorno.LOG_NO     = ls_RETORNO.GetString("LOG_NO");
                            retorno.LOG_MSG_NO = ls_RETORNO.GetString("LOG_MSG_NO");
                            retorno.MESSAGE_V1 = ls_RETORNO.GetString("MESSAGE_V1");
                            retorno.MESSAGE_V2 = ls_RETORNO.GetString("MESSAGE_V2");
                            retorno.MESSAGE_V3 = ls_RETORNO.GetString("MESSAGE_V3");
                            //if (ls_RETORNO.GetString("MESSAGE_V4") != "")
                            //{
                            //    // comprobante = ls_RETORNO.GetString("MESSAGE_V4");
                            ////}
                            retorno.MESSAGE_V4 = ls_RETORNO.GetString("MESSAGE_V4");
                            retorno.PARAMETER  = ls_RETORNO.GetString("PARAMETER");
                            retorno.ROW        = ls_RETORNO.GetString("ROW");
                            retorno.FIELD      = ls_RETORNO.GetString("FIELD");
                            retorno.SYSTEM     = ls_RETORNO.GetString("SYSTEM");
                            T_Retorno.Add(retorno);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message, ex.StackTrace);
                        MessageBox.Show(ex.Message + ex.StackTrace);
                    }
                }
                else
                {
                    // errormessage = retval;
                    MessageBox.Show("No se pudo conectar a la RFC");
                }
                GC.Collect();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message, ex.StackTrace);
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }