Ejemplo n.º 1
0
        /// <summary>
        /// Verifica se há Estrutura de produto não cadastrada
        /// </summary>
        /// <returns>Boolean</returns>
        public static bool HaveNewWorkTree()
        {
            using (var rs = new MyRecordSet())
            {
                rs.DoQuery("SELECT COUNT(*) FROM [Sage_WorkTree] WITH (NOLOCK) WHERE ReadBySAP <> 'Y' ");
                if (rs.HasNext())
                {
                    if (rs.GetFieldValue(0).ToInt() > 0)
                    {
                        principal.GravaAudit("T08 WorkTree Encontrado {0} transações não processadas " + rs.GetFieldValue(0).ToString());
                    }
                    else
                    {
                        principal.GravaAudit("T08 WorkTree - Nenhuma transação em aberto.");
                    }

                    return(rs.GetFieldValue(0).ToInt() > 0);
                }
                else
                {
                    principal.GravaAudit("WorkTree - Erro a consultar a tabela  Sage_Transacoes.");

                    return(false);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Retorna as entidades de transações não lida pelo SAP.
        /// </summary>
        /// <param name="isnew">Buscar somente novas entradas?</param>
        /// <returns></returns>
        public static List <TWOEntity> GetDados(bool isnew)
        {
            var transacoes = new List <TWOEntity>();

            principal.GravaAudit("MyRecordSet ini");
            using (var conn = new MyRecordSet())
            {
                //if (isnew) // TODO @BFAGUNDES -
                conn.DoQuery("SELECT * FROM [dbo].[Sage_Transaction_WO] WITH (NOLOCK) WHERE [TransactionType] = 40 AND ReadBySAP <> 'Y' AND (OWOR_DocNum IS NULL OR OWOR_DocNum < 1) ORDER BY AddDate");
                //else
                //conn.DoQuery("SELECT TOP 500 * FROM [dbo].[Sage_Transaction_WO] WITH (NOLOCK) WHERE [TransactionType] = 40 AND OWOR_DocNum > 0  ORDER BY ReadBySAP DESC");
                while (conn.HasNext())
                {
                    var trans = new TWOEntity();
                    try
                    {
                        trans.TransType          = conn.GetFieldValue("TransactionType").ToInt();
                        trans.ReadBySAP          = conn.GetFieldValue("ReadBySAP").ToChar();
                        trans.OWOR_U_ORDER_JOMAR = conn.GetFieldValue("OWOR_ORDER_JOMAR").ToString();
                        trans.OWOR_DocNum        = conn.GetFieldValue("OWOR_DocNum").ToInt();
                        trans.OITM_CodeBars      = conn.GetFieldValue("OITM_CodeBars").ToString();
                        trans.OWOR_PlannedQty    = conn.GetFieldValue("OWOR_PlannedQty").ToDouble();
                        trans.OWOR_WareHouse     = conn.GetFieldValue("OWOR_WareHouse").ToString();
                        trans.OWOR_PostDate      = conn.GetFieldValue("OWOR_PostDate").ToDate();
                        trans.OWOR_DueDate       = conn.GetFieldValue("OWOR_DueDate").ToDate();
                        trans.OWOR_Project       = conn.GetFieldValue("OWOR_Project").ToString();
                        trans.OWOR_Remarks       = String.Format("ID {0} - Transação 40. {1}", trans.Id, conn.GetFieldValue("OWOR_Remarks").ToString());

                        if (MyQuery.Exist("OITT", trans.OITM_ItemCode, "Code"))
                        {
                            if ((Program.contador % 2) == 0)
                            {
                                transacoes.Add(trans);
                            }
                            else
                            {
                                transacoes.Add(trans);
                            }
                        }
                        else
                        {
                            principal.GravaAudit("Não existe estrutura de produto cadastrado para ItemCode \"{0}\".", trans.OITM_ItemCode);
                            throw new Exception(String.Format("0 - Não existe estrutura de produto cadastrado para ItemCode \"{0}\".", trans.OITM_ItemCode));
                        }
                    }
                    catch (Exception ex)
                    {
                        trans.ReadBySAP = 'E';
                        trans.MSG_SAP   = ex.Message;

                        UpdateStatus(trans);

                        principal.GravaAudit("Erro empacotar ID " + trans.Id.ToString() + " " + ex.Message.ToString());
                    }
                }
                principal.GravaAudit("Termino While");
            }

            return(transacoes);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Informa se há transação em aberto
        /// </summary>
        /// <param name="type">Tipo de transação</param>
        /// <returns></returns>
        public static bool TransactionOpen()
        {
            try
            {
                using (var rs = new MyRecordSet())
                {
                    rs.DoQuery("SELECT COUNT(*) FROM [Sage_Transaction41] WITH (NOLOCK) WHERE [TransactionType] = 41 AND ReadySAP <> 'Y'");
                    if (rs.HasNext())
                    {
                        if (rs.GetFieldValue(0).ToInt() > 0)
                        {
                            principal.GravaAudit("Achou transação em aberto");
                        }
                        else
                        {
                            principal.GravaAudit("Nenhuma transação em aberto");
                        }

                        return(rs.GetFieldValue(0).ToInt() > 0);
                    }
                    else
                    {
                        principal.GravaAudit("Erro a consultar a tabela  Sage_Transaction41");

                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                principal.GravaAudit(ex.Message.ToString());
                return(false);
            }
        }
        /// <summary>
        /// Cria documento com apenas 1 linha por documento.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static List <ROBO.Transacoes.Entidade.Documents> GetDadosSL(TransEnum type)
        {
            var oDocEntitys = new List <Transacoes.Entidade.Documents>();

            using (var conn = new MyRecordSet())
            {
                principal.GravaAudit(Properties.Querys.Transacoes_1);
                principal.GravaAudit(type.ToString());
                conn.DoQuery(Properties.Querys.Transacoes_1, ((int)type));

                while (conn.HasNext())
                {
                    var oDocEntity = new Transacoes.Entidade.Documents();

                    try
                    {
                        oDocEntity = new Transacoes.Entidade.Documents();
                        oDocEntity.MyValues["Id"]        = conn.GetFieldValue(0);
                        oDocEntity.BplId                 = conn.GetFieldValue("BplId").ToInt();
                        oDocEntity.MyValues["ReadBySAP"] = conn.GetFieldValue("ReadBySAP");
                        oDocEntity.Comments              = conn.GetFieldValue("Comments").ToString();
                        oDocEntity.DocDate               = conn.GetFieldValue("DocDate").ToDate();
                        oDocEntity.GroupNum              = conn.GetFieldValue("GroupNum").ToInt();
                        oDocEntity.TaxDate               = conn.GetFieldValue("TaxDate").ToDate();

                        // Linhas
                        var oDocentryLine = new Transacoes.Entidade.DocumentsEntityLine();
                        oDocentryLine.UserFields["U_Lot"]     = conn.GetFieldValue("U_Lot").ToString();
                        oDocentryLine.UserFields["U_Quality"] = conn.GetFieldValue("U_Quality").ToString();
                        oDocentryLine.WhsCode  = conn.GetFieldValue("WareHouse").ToString();
                        oDocentryLine.Quantity = conn.GetFieldValue("Quantity").ToDouble();
                        oDocentryLine.ItemCode = Functions.Find.Item(conn.GetFieldValue("OITM_CodeBars").ToString());

                        oDocEntity.Lines.Add(oDocentryLine);

                        // Adicionando na lista
                        if ((Program.contador % 2) == 0)
                        {
                            if (oDocEntity.MyValues["ReadBySAP"].ToChar() != 'E')
                            {
                                oDocEntitys.Add(oDocEntity);
                            }
                        }
                        else
                        {
                            oDocEntitys.Add(oDocEntity);
                        }
                    }
                    catch (Exception ex)
                    {
                        UpdateStatus(oDocEntity, 'E', String.Format(Properties.LogMessage.TRANS_0030_2L
                                                                    , oDocEntity.MyValues["Id"]
                                                                    , ex.Message));
                    }
                }
            }

            return(oDocEntitys);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Atualiza o status.
 /// </summary>
 /// <param name="t38"></param>
 public static void UpdateStatus(WorkTreeEntity tentity)
 {
     using (var rs = new MyRecordSet())
     {
         var sql = "UPDATE [Sage_WorkTree] SET ReadBySAP = '{0}', MSG_SAP = '{2}' WHERE ID_CodeBars = '{1}'";
         rs.DoQuery(sql, tentity.ReadBySAP, tentity.ID_CodeBars, tentity.MSG_SAP.Replace("'", "\""));
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Atualiza o Status do pedido na tabela de transações WO
        /// </summary>
        /// <param name="two"></param>
        public static void UpdateStatus(TWOEntity two)
        {
            using (var rs = new MyRecordSet())
            {
                principal.GravaAudit("two.Id " + two.Id.ToString());
                principal.GravaAudit("two.OWOR_U_ORDER_JOMAR " + two.OWOR_U_ORDER_JOMAR.ToString());
                if (two.Id == 0)
                {
                    string sql = "UPDATE   [Sage_Transaction_WO]  SET ReadBySAP = '" + two.ReadBySAP + "' , ";
                    sql += "OWOR_DocNum = '" + two.OWOR_DocNum + "' ";
                    sql += ",[MSG_SBO] = '" + two.MSG_SAP.Replace("'", "''") + "' ";
                    sql += "WHERE OWOR_Order_Jomar =  '" + two.OWOR_U_ORDER_JOMAR + "'";

//                    var sql = @"
//                            UPDATE   [Sage_Transaction_WO]
//                            SET      ReadBySAP = 'Y'
//                                    ,OWOR_DocNum = '{1}'
//                                    ,[MSG_SBO] = '{3}'
//                            WHERE (CAST(TransactionType as nvarchar(100))
//		                            +	CAST(OWOR_ORDER_JOMAR as nvarchar(100))
//		                            +	CAST(OITM_CodeBars AS nvarchar(20))
//		                            +	CAST(OWOR_DocNum AS nvarchar(20))
//		                            +	OWOR_WareHouse) = '{2}'";

                    principal.GravaAudit(sql);
                    principal.GravaAudit("Read " + two.ReadBySAP + " Docnum " + two.OWOR_DocNum + " MSG " + two.MSG_SAP.Replace("'", "''"));
                    rs.DoQuery(sql);
                }
                else
                {
                    principal.GravaAudit("Update Status 5");
                    string sql = "UPDATE   [Sage_Transaction_WO]  SET ReadBySAP = '" + two.ReadBySAP + "', ";
                    sql += "OWOR_DocNum = '" + two.OWOR_DocNum + "' ";
                    sql += ",[MSG_SBO] = '" + two.MSG_SAP.Replace("'", "''") + "' ";
                    sql += "Id = '" + two.Id + "'";

//                    var sql = @"
//                        UPDATE   [Sage_Transaction_WO]
//                        SET      ReadBySAP = '{0}'
//                                ,OWOR_DocNum = '{1}'
//                                ,[MSG_SBO] = '{3}'
//                        WHERE Id = {2}";
                    rs.DoQuery(sql, two.ReadBySAP, two.OWOR_DocNum, two.Id, two.MSG_SAP.Replace("'", "''"));
                }
            }
        }
 public static void UpdateStatus(ProductTreeEntity tentity)
 {
     using (var rs = new MyRecordSet())
     {
         var sql = "UPDATE [ProductTree] SET ReadBySAP = '{0}' WHERE Id = '{1}'";
         rs.DoQuery(sql, tentity.ReadBySAP, tentity.Id);
     }
 }
Ejemplo n.º 8
0
 public static void UpdateStatus(T38Entity t38)
 {
     using (var rs0 = new MyRecordSet())
     {
         var sql = "UPDATE [Sage_Transaction38] SET ReadBySAP = '{0}', [OIGE_DocNum] = '{1}',[MSG_SAP] = '{3}',Update_CodeBars = '{4}',[OIGN_DocNum] = '{5}',OWOR_DocNum = '{6}'  WHERE Id = '{2}'";
         rs0.DoQuery(sql, t38.ReadBySAP, t38.OIGE_DocNum, t38.Id, t38.MSG_SAP, t38.Update_CodeBars, t38.OIGN_DocNum, t38.OWOR_DocNum);                
     }
 }
        /// <summary>
        /// Atualiza o Status da Transação
        /// </summary>
        /// <param name="oPedido"></param>
        public static void UpdateStatus(Transacoes.Entidade.Documents oDocEntity, char readBySAP = 'Y', string msg = "")
        {
            using (var rs = new MyRecordSet())
            {
                var sql = String.Format("UPDATE [Sage_Transacoes] SET ReadBySAP = '{0}', DocNum = '{1}', SAP_MSG = '{2}' WHERE Id = '{3}'"
                                        , readBySAP, oDocEntity.DocNum, msg.Replace("'", "''"), oDocEntity.MyValues["Id"]);
                rs.DoQuery(sql);


                foreach (var linha in oDocEntity.Lines)
                {
                    sql = String.Format("UPDATE [Sage_Transacoes] SET ReadBySAP = '{0}', DocNum = '{1}', SAP_MSG = '{2}' WHERE Id = '{3}'"
                                        , readBySAP, oDocEntity.DocNum, msg.Replace("'", "''"), oDocEntity.MyValues["Id"]);

                    rs.DoQuery(sql);
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Transação 05 - Aumenta do valor de um item
        /// </summary>
        private void Trans05()
        {
            var transacoes = TransGenericDAO.GetDadosSL(transType);

            foreach (var transacao in transacoes)
            {
                var Inventory = SAPConnection.GetDocument(SAPConnection.DocsEnum.OIGN);
                // HEADER
                Inventory.DocDate = transacao.DocDate;
                Inventory.TaxDate = transacao.TaxDate;
                Inventory.BPL_IDAssignedToInvoice = transacao.BplId;

                // LINES
                foreach (var line in transacao.Lines)
                {
                    Inventory.Lines.ItemCode      = line.ItemCode;
                    Inventory.Lines.Quantity      = line.Quantity;
                    Inventory.Lines.WarehouseCode = line.WhsCode;
                    Inventory.Lines.UserFields.Fields.Item("U_Lot").Value     = line.UserFields["U_Lot"];
                    Inventory.Lines.UserFields.Fields.Item("U_Quality").Value = line.UserFields["U_Quality"];

                    using (var rs = new MyRecordSet())
                    {
                        rs.DoQuery(Properties.Querys.CustoItem_2, line.ItemCode, line.WhsCode);
                        if (rs.HasNext())
                        {
                            Inventory.Lines.Price = rs.GetFieldValue(0).ToDouble();
                        }
                        else
                        {
                            Inventory.Lines.Price = 0;
                        }
                    }

                    Inventory.Lines.Add();
                }

                //FOOTER
                Inventory.Comments = String.Format("ID {0} - Transação {1}. {2}", transacao.MyValues["Id"].ToInt(), (int)transType, transacao.Comments);
                int res = Inventory.Add();

                if (res != 0)
                {
                    principal.GravaAudit(this.GetType().Name.ToString() + SAPConnection.DI.GetLastErrorDescription().ToString());
                    TransGenericDAO.UpdateStatus(transacao, 'E', SAPConnection.DI.GetLastErrorDescription());
                }
                else
                {
                    transacao.DocNum = int.Parse(MyLibs.v2.sbo.SAPConnection.DI.GetNewObjectKey());
                    TransGenericDAO.UpdateStatus(transacao);
                }
            }

            transacoes.Clear();
            transacoes = null;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Atualiza o Status do pedido na tabela de transações WO
        /// </summary>
        /// <param name="two"></param>
        public static void UpdateStatus(T41Entity two)
        {
            using (var rs = new MyRecordSet())
            {
                var sql = "UPDATE [Sage_Transaction41] SET ReadySAP = '{0}', OWOR_DocNum = '{1}',[MSG_SBO] = '{3}' WHERE Id = '{2}'";

                principal.GravaAudit(String.Format(sql, two.ReadBySAP, two.OWOR_DocNum, two.Id, two.MSG_SAP.Replace("'", "''")));
                rs.DoQuery(sql, two.ReadBySAP, two.OWOR_DocNum, two.Id, two.MSG_SAP.Replace("'", "''"));
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Informa se há transação em aberto
        /// </summary>
        /// <param name="type">Tipo de transação</param>
        /// <returns></returns>
        public static bool TransactionOpen()
        {
            using (var rs = new MyRecordSet())
            {
                rs.DoQuery("SELECT COUNT(*) FROM [Sage_Transaction38] WITH (NOLOCK) WHERE ReadBySAP <> 'Y' AND TransactionType = -38");

                if (rs.HasNext())
                    return (rs.GetFieldValue(0).ToInt() > 0);
                else
                    return false;
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Informa se há transação em aberto
        /// </summary>
        /// <param name="type">Tipo de transação</param>
        /// <returns></returns>
        public static bool TransactionOpen()
        {
            using (var rs = new MyRecordSet())
            {
                rs.DoQuery("SELECT COUNT(*) FROM [Sage_Transaction08] WITH (NOLOCK) WHERE [TransactionType] = -8 AND ReadBySAP <> 'Y'");

                if (rs.HasNext())
                {
                    return(rs.GetFieldValue(0).ToInt() > 0);
                }

                return(false);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Informa se há transação em aberto
        /// </summary>
        /// <param name="type">Tipo de transação</param>
        /// <returns></returns>
        public static bool TransactionOpen()
        {
            using (var rs = new MyRecordSet())
            {
                rs.DoQuery("SELECT COUNT(*) FROM SAGE_TRANSACOES32L1 WITH (NOLOCK) WHERE ReadBySAP <> 'Y'");

                if (rs.HasNext())
                {
                    return(rs.GetFieldValue(0).ToInt() > 0);
                }

                return(false);
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Atualiza o Status do pedido na tabela de transações 08
 /// </summary>
 /// <param name="t38"></param>
 public static void UpdateStatus(T08Entity t08)
 {
     if (t08.Id == 0)
     {
         T08NegDAO.UpdateStatus(t08);
     }
     else
     {
         using (var rs = new MyRecordSet())
         {
             var sql = "UPDATE [Sage_Transaction08] SET ReadBySAP = '{0}', OWOR_DocNum = '{1}',[MSG_SBO] = '{3}', OIGN_DocNum = '{4}', GroupID = '{5}' WHERE Id = '{2}'";
             rs.DoQuery(sql, t08.ReadBySAP, t08.OWOR_DocNum, t08.Id, t08.MSG_SAP.Replace("'", "''"), t08.OIGN_DocNum, t08.GroupID);
         }
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Atualiza o Status do pedido na tabela de transações 08
        /// </summary>
        /// <param name="t38"></param>
        public static void UpdateStatus(T08Entity t08)
        {
            using (var rs = new MyRecordSet())
            {
                if (t08.Id == 0)
                {
                    var sql = @"
UPDATE   [Sage_Transaction08] 
SET      ReadBySAP = '{0}'
        ,OWOR_DocNum = '{1}'
        ,[MSG_SBO] = '{3}'
        , OIGN_DocNum = '{4}' 
        , GroupID = '{5}'
        , OIGE_DocNum = '{6}' 
WHERE (CAST(TransactionType as nvarchar(100)) 
		+	CAST(OWOR_ORDER_JOMAR as nvarchar(100)) 
		+	CAST(OITM_CodeBars AS nvarchar(20))
		+	CAST(OWOR_DocNum AS nvarchar(20))
		+	OWOR_WareHouse) = '{2}'"            ;
                    rs.DoQuery(sql, t08.ReadBySAP, t08.OWOR_DocNum, t08.GroupUnique, t08.MSG_SAP.Replace("'", "''"), t08.OIGN_DocNum, t08.GroupID, t08.OIGE_DocNum);
                }
                else
                {
                    var sql = @"
UPDATE   [Sage_Transaction08] 
SET      ReadBySAP = '{0}'
        ,OWOR_DocNum = '{1}'
        ,[MSG_SBO] = '{3}'
        , OIGN_DocNum = '{4}' 
        , GroupID = '{5}'
        ,OIGE_DocNum = '{6}' 
WHERE Id = {2}";
                    rs.DoQuery(sql, t08.ReadBySAP, t08.OWOR_DocNum, t08.Id, t08.MSG_SAP.Replace("'", "''"), t08.OIGN_DocNum, t08.GroupID, t08.OIGE_DocNum);
                }
            }
        }
Ejemplo n.º 17
0
        public static void UpdateStatus41(T41Entity two)
        {
            principal.GravaAudit("Inicio 41");
            using (var rs = new MyRecordSet())
            {
                string sql = "UPDATE [Sage_Transaction41] SET ReadySAP = '" + two.ReadBySAP + "' , ";
                sql += "OWOR_DocNum = '" + two.OWOR_DocNum + "' ";
                sql += "WHERE OWOR_Order_Jomar =  '" + two.OWOR_U_ORDER_JOMAR + "'";

                principal.GravaAudit(sql);
                principal.GravaAudit("Read " + two.ReadBySAP + " Docnum " + two.OWOR_DocNum);
                rs.DoQuery(sql);
            }
            principal.GravaAudit("Termino 41");
        }
        /// <summary>
        /// Informa se há transação em aberto
        /// </summary>
        /// <param name="type">Tipo de transação</param>
        /// <returns></returns>
        public static bool TransactionOpen(TransEnum type)
        {
            using (var rs = new MyRecordSet())
            {
                rs.DoQuery("SELECT COUNT(*) FROM sage_TRANSACOES WITH (NOLOCK) WHERE ReadBySAP <> 'Y' AND CAST(TransactionType AS INT) = '{0}'", (int)type);

                if (rs.HasNext())
                {
                    return(rs.GetFieldValue(0).ToInt() > 0);
                }
                else
                {
                    return(false);
                }
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Retorna as entidades de transações não lida pelo SAP.
        /// </summary>
        /// <param name="isnew">Buscar somente novas entradas?</param>
        /// <returns></returns>
        public static List <T41Entity> GetDados(bool isnew)
        {
            var transacoes = new List <T41Entity>();

            principal.GravaAudit("MyRecordSet ini");
            using (var conn = new MyRecordSet())
            {
                //if (isnew) // TODO @BFAGUNDES -

                conn.DoQuery("SELECT distinct (Select Top 1 Docentry from OWOR where U_Order_Jomar = T0.owor_order_jomar and status = 'R') As OWOR_DocNum1, TransactionType, ReadySAP, OWOR_ORDER_JOMAR FROM [dbo].[Sage_Transaction41] T0 WITH (NOLOCK) WHERE [TransactionType] = 41 AND ReadySAP <> 'Y' ");
                //else
                //conn.DoQuery("SELECT TOP 500 * FROM [dbo].[Sage_Transaction_WO] WITH (NOLOCK) WHERE [TransactionType] = 40 AND OWOR_DocNum > 0  ORDER BY ReadBySAP DESC");
                while (conn.HasNext())
                {
                    var trans = new T41Entity();
                    try
                    {
                        trans.TransType          = conn.GetFieldValue("TransactionType").ToInt();
                        trans.ReadBySAP          = conn.GetFieldValue("ReadySAP").ToChar();
                        trans.OWOR_U_ORDER_JOMAR = conn.GetFieldValue("OWOR_ORDER_JOMAR").ToString();
                        trans.OWOR_DocNum        = conn.GetFieldValue("OWOR_DocNum1").ToInt();
                        //trans.OWOR_WareHouse = conn.GetFieldValue("OWOR_WareHouse").ToString();
                        //trans.OWOR_PostDate = conn.GetFieldValue("OWOR_PostDate").ToDate();
                        //trans.OWOR_DueDate = conn.GetFieldValue("OWOR_DueDate").ToDate();
                        //trans.OWOR_Project = conn.GetFieldValue("OWOR_Project").ToString();
                        //trans.OWOR_Remarks = String.Format("ID {0} - Transação 40. {1}", trans.Id, conn.GetFieldValue("OWOR_Remarks").ToString());

                        transacoes.Add(trans);
                    }
                    catch (Exception ex)
                    {
                        trans.ReadBySAP = 'E';
                        trans.MSG_SAP   = ex.Message;

                        UpdateStatus(trans);

                        principal.GravaAudit("Erro empacotar ID " + trans.Id.ToString() + " " + ex.Message.ToString());
                    }
                }
                principal.GravaAudit("Termino While");
            }

            return(transacoes);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Faz uma consulta na tabela RSD_IsItemOrResource
        /// </summary>
        /// <param name="reference">Valor do recurso ou código de barras.</param>
        /// <returns></returns>
        public static string Item(string reference)
        {
            using (var rs = new MyRecordSet())
            {
                rs.DoQuery(String.Format("SELECT Codigo FROM RSD_IsItemOrResource WHERE Referencia = '{0}'", reference));

                if (rs.HasNext())
                {
                    return(rs.GetFieldValue("Codigo").ToString());
                }
                else
                {
                    throw new LogException("RSD_IsItemOrResource"
                                           , System.Diagnostics.EventLogEntryType.Error
                                           , Properties.LogMessage.GLOBAL_0029_1
                                           , reference);
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Informa se há transação em aberto
        /// </summary>
        /// <param name="type">Tipo de transação</param>
        /// <returns></returns>
        public static bool TransactionOpen()
        {
            using (var rs = new MyRecordSet())
            {
                rs.DoQuery("SELECT COUNT(*) FROM [Sage_Transaction38] WITH (NOLOCK) WHERE ReadBySAP <> 'Y' AND TransactionType = '38'");

                if (rs.HasNext())
                {
                    if (rs.GetFieldValue(0).ToInt() > 0)
                    {
                        principal.GravaAudit("Transação 38 - Encontrado {0} transações não processadas " + rs.GetFieldValue(0).ToString());
                    }
                    else
                    {
                        principal.GravaAudit("Transação 38 Nenhuma transação em aberto.");
                    }

                    return(rs.GetFieldValue(0).ToInt() > 0);
                }
                return(false);
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Retorna as entidades de transações não lida pelo SAP.
        /// </summary>
        /// <param name="JOMAR_OrderNum">Número de Ordem Jomar (0 todos)</param>
        /// <returns></returns>
        public static List <T38Entity> GetDados(int JOMAR_OrderNum = 0)
        {
            var transacoes = new List <T38Entity>();

            using (var conn = new MyRecordSet())
            {
                if (JOMAR_OrderNum > 0)
                {
                    conn.DoQuery("SELECT * FROM [Sage_Transaction38] WITH (NOLOCK) WHERE TransactionType = '38' AND [JOMAR_OrderNum] = '{0}' AND (WOR1_DocNum IS NULL OR WOR1_DocNum = 0)", JOMAR_OrderNum);
                }
                else
                {
                    conn.DoQuery("SELECT * FROM [Sage_Transaction38] T0 WITH (NOLOCK) inner join OITM T1 on T1.CodeBars = T0.oitm_Codebars inner join OWOR T3 on T3.U_ORDER_JOMAR = T0.Jomar_OrderNum inner join WOR1 T2 on T2.DocEntry = T3.DocEntry and T2.itemcode = T1.ItemCode WHERE TransactionType = '38' AND [ReadBySAP] <> 'Y' AND (OIGE_DocNum IS NULL OR OIGE_DocNum = 0) order by T0.Jomar_OrderNum "); //(WOR1_DocNum IS NULL OR WOR1_DocNum = 0) AND
                }
                principal.GravaAudit("Inicio While ");
                while (conn.HasNext())
                {
                    var t38 = new T38Entity();
                    try
                    {
                        principal.GravaAudit(conn.GetFieldValue("JOMAR_OrderNum").ToString());
                        t38.Id              = conn.GetFieldValue("Id").ToInt();
                        t38.AddDate         = conn.GetFieldValue("AddDate").ToDate();
                        t38.Update_CodeBars = conn.GetFieldValue("Update_CodeBars").ToChar();
                        t38.TransactionType = conn.GetFieldValue("TransactionType").ToInt();
                        t38.ReadBySAP       = conn.GetFieldValue("ReadBySAP").ToChar();
                        t38.JOMAR_OrderNum  = conn.GetFieldValue("JOMAR_OrderNum").ToString();
                        t38.WOR1_DocNum     = conn.GetFieldValue("WOR1_DocNum").ToInt();
                        t38.To_WareHouse    = "PP";
                        t38.From_WareHouse  = conn.GetFieldValue("WOR1_WareHouse").ToString();
                        t38.OITM_CodeBars   = conn.GetFieldValue("OITM_CodeBars").ToString();
                        t38.JOMAR_LineNum   = conn.GetFieldValue("JOMAR_LineNum").ToInt();
                        t38.WOR1_BaseQty    = conn.GetFieldValue("WOR1_BaseQty").ToDouble();
                        t38.WOR1_PlannedQty = conn.GetFieldValue("WOR1_PlannedQty").ToDouble();
                        t38.IGE1_Quantity   = conn.GetFieldValue("IGE1_Quantity").ToDouble();
                        t38.OWOR_DocNum     = MyQuery.GetValue("OWOR", t38.JOMAR_OrderNum, "U_ORDER_JOMAR", "DocNum").ToInt();

                        principal.GravaAudit("Existe OPs " + t38.OWOR_DocNum);
                        if ((Program.contador % 2) == 0)
                        {
                            //if (t38.ReadBySAP != 'E')
                            transacoes.Add(t38);
                        }
                        else
                        {
                            transacoes.Add(t38);
                        }
                    }
                    catch (Exception ex) {
                        t38.ReadBySAP = 'E';
                        t38.MSG_SAP   = ex.Message;

                        UpdateStatus(t38);

                        principal.GravaAudit("Transação 38 - " + t38.Id.ToString() + " " + ex.Message.ToString());
                    }
                }

                principal.GravaAudit("Termino While");

                return(transacoes);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Atualiza a linha OWOR.U_line_Jomar com ITT1.
        /// </summary>
        /// <param name="t08"></param>
        private void LineJomarOWOR(T38Entity t38)
        {
            try
            {
                bool   lineexist = false;
                bool   itemexist = false;
                string itemcode  = null;

                using (var rs = new MyRecordSet())
                {
                    // Pesquisa a Linha Jomar.
                    rs.DoQuery("SELECT ItemCode,LineNum FROM WOR1 WHERE DocEntry = '{0}' AND U_Line_Jomar = '{1}'", t38.OWOR_DocNum, t38.JOMAR_LineNum);

                    if (rs.HasNext())
                    {
                        lineexist = true;
                        linenum   = rs.GetFieldValue(1).ToInt();
                        itemcode  = rs.GetFieldValue(0).ToString();

                        if (t38.OITM_ItemCode == itemcode)
                        {
                            return;
                        }
                    }
                    else
                    {
                        // Pesquisa por item.
                        rs.DoQuery("SELECT LineNum FROM WOR1 WHERE DocEntry = '{0}' AND ItemCode = '{1}'", t38.OWOR_DocNum, t38.OITM_ItemCode);

                        if (rs.HasNext())
                        {
                            itemexist = true;
                            linenum   = rs.GetFieldValue(0).ToInt();
                        }
                        else
                        {
                            principal.GravaAudit(t38.Id.ToString() + " LineJomar OWOR Não existe a linha Jomar " + t38.JOMAR_LineNum.ToString() + "  nem o itemCode " + t38.OITM_ItemCode.ToString() + " na OWOR " + t38.OWOR_DocNum.ToString());
                            return;
                        }
                    }
                }


                bool newitem = false;

                var oOWOR = (SAPbobsCOM.ProductionOrders)SAPConnection.DI.GetBusinessObject(BoObjectTypes.oProductionOrders);

                if (oOWOR.GetByKey(t38.OWOR_DocNum))
                {
                    if (lineexist)
                    {
                        oOWOR.Lines.SetCurrentLine(linenum);

                        if (itemcode != t38.OITM_ItemCode)
                        {
                            oOWOR.Lines.ItemNo = t38.OITM_ItemCode;
                            newitem            = true;
                        }
                    }
                    else if (itemexist)
                    {
                        oOWOR.Lines.SetCurrentLine(linenum);
                        oOWOR.Lines.UserFields.Fields.Item("U_Line_Jomar").Value = t38.JOMAR_LineNum;
                        t38.Update_CodeBars = 'N';
                    }

                    if (oOWOR.Update() != 0)
                    {
                        t38.ReadBySAP       = 'E';
                        t38.Update_CodeBars = 'N';
                        t38.MSG_SAP         = String.Format(Properties.LogMessage.Trans38_0037_2, t38.Id, SAPConnection.DI.GetLastErrorDescription());
                        T38DAO.UpdateStatus(t38);

                        principal.GravaAudit("LineJomarOWOR " + t38.MSG_SAP.ToString());
                    }
                    else
                    {
                        t38.Update_CodeBars = newitem ? 'Y' : 'N';
                        t38.ReadBySAP       = 'Y';
                        t38.MSG_SAP         = "Linha/Item Jomar atualizado na tela de Ordem de Produção.";
                        T38DAO.UpdateStatus(t38);
                    }
                }
            }
            catch (Exception ex)
            {
                principal.GravaAudit("LineJomarOWOR " + ex.Message.ToString());
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Obtem os dados para criar um novo Pedido de Venda e Nota Fiscal (Rascunho).
        /// </summary>
        /// <returns></returns>
        public static List <T32Entity> GetNewORDR()
        {
            var t32list = new List <T32Entity>();

            using (var rs_lines = new MyRecordSet())
            {
                rs_lines.DoQuery("SELECT * FROM [Sage_Transacoes32L1] WITH (NOLOCK)  WHERE ReadBySAP <> 'Y' AND (ORDR_DocEntry <= 0 OR ORDR_DocEntry IS NULL) ORDER BY JOMAR_OrderNum ASC");

                var t32     = new T32Entity();
                var t32line = new T32EntityLine();

                var control = -1;
                while (rs_lines.HasNext())
                {
                    try
                    {
                        if (control == -1)                                              // Controle Inicial
                        {
                            control = rs_lines.GetFieldValue("JOMAR_OrderNum").ToInt(); // Nº da ordem no controle
                        }
                        else if (control != rs_lines.GetFieldValue("JOMAR_OrderNum").ToInt())
                        {
                            t32list.Add(t32);                                           // Guarda o pacote na lista
                            t32     = new T32Entity();                                  // Cria um novo header
                            control = rs_lines.GetFieldValue("JOMAR_OrderNum").ToInt(); // Nº da ordem no controle
                        }

                        #region Linhas
                        t32line = new T32EntityLine();

                        t32line.Id              = rs_lines.GetFieldValue("JOMAR_OrderNum").ToInt();
                        t32line.JOMAR_OrderNum  = rs_lines.GetFieldValue("JOMAR_OrderNum").ToInt();
                        t32line.ReadBySAP       = rs_lines.GetFieldValue("ReadBySAP").ToChar();
                        t32line.Jomar_LineNum   = rs_lines.GetFieldValue("Jomar_LineNum").ToInt();
                        t32line.ORDR_DocEntry   = rs_lines.GetFieldValue("ORDR_DocEntry").ToInt();
                        t32line.OINV_DocEntry   = rs_lines.GetFieldValue("OINV_DocEntry").ToInt();
                        t32line.OITM_CodeBars   = rs_lines.GetFieldValue("OITM_CodeBars").ToString();
                        t32line.RDR1_Quantity   = rs_lines.GetFieldValue("RDR1_Quantity").ToDouble();
                        t32line.RDR1_WhsCode    = rs_lines.GetFieldValue("RDR1_WhsCode").ToString();
                        t32line.JOMAR_Peso      = rs_lines.GetFieldValue("JOMAR_Peso").ToDouble();
                        t32line.SalesOrderIndex = rs_lines.GetFieldValue("SalesOrderIndex").ToInt();
                        t32line.MSG_SAP         = rs_lines.GetFieldValue("MSG_SAP").ToString();
                        #endregion

                        var rs_header = new MyRecordSet();

                        rs_header.DoQuery("SELECT * FROM [Sage_Transacoes32] WITH (NOLOCK) WHERE JOMAR_OrderNum = '{0}'", rs_lines.GetFieldValue("JOMAR_OrderNum").ToInt());
                        {
                            #region Cabeçalho
                            if (t32line.JOMAR_OrderNum != t32.JOMAR_OrderNum)
                            {
                                t32.Id               = rs_lines.GetFieldValue("JOMAR_OrderNum").ToInt();
                                t32.JOMAR_OrderNum   = rs_header.GetFieldValue("JOMAR_OrderNum").ToInt();
                                t32.ReadBySAP        = rs_header.GetFieldValue("ReadBySAP").ToChar();
                                t32.TransactionType  = rs_header.GetFieldValue("TransactionType").ToInt();
                                t32.JOMAR_OIM        = rs_header.GetFieldValue("JOMAR_OIM").ToInt();
                                t32.ORDR_DocEntry    = rs_header.GetFieldValue("ORDR_DocEntry").ToInt();
                                t32.JOMAR_CardCode   = rs_header.GetFieldValue("JOMAR_CardCode").ToString();
                                t32.ORDR_DocDate     = rs_header.GetFieldValue("ORDR_DocDate").ToDate();
                                t32.ORDR_DocDueDate  = rs_header.GetFieldValue("ORDR_DocDueDate").ToDate();
                                t32.ORDR_TaxDate     = rs_header.GetFieldValue("ORDR_TaxDate").ToDate();
                                t32.ORDR_NumAtCard   = rs_header.GetFieldValue("ORDR_NumAtCard").ToString();
                                t32.ORDR_BplId       = rs_header.GetFieldValue("ORDR_BplId").ToInt();
                                t32.ORDR_Comments    = rs_header.GetFieldValue("ORDR_Comments").ToString();
                                t32.SalesHeaderIndex = rs_header.GetFieldValue("SalesHeaderIndex").ToInt();
                                t32.MSG_SAP          = rs_header.GetFieldValue("MSG_SAP").ToString();
                            }
                            #endregion
                        }

                        t32line.ORDR_DocEntry = t32.ORDR_DocEntry;
                    }
                    catch (Exception ex)
                    {
                        principal.GravaAudit(ex.Message.ToString());
                    }

                    t32.Lines.Add(t32line);
                }

                // Pega o ultimo que sobra
                if (rs_lines.CountLines() > 0)
                {
                    t32list.Add(t32);
                }
            }


            return(t32list);
        }
Ejemplo n.º 25
0
        public static void UpdateLineOP(T41Entity two, ProductionOrders prd)
        {
            try
            {
                using (var rs = new MyRecordSet())
                {
                    try
                    {
                        principal.GravaAudit("Inicio remove linhas OP");
                        string sql1 = "delete from WOR1 where docentry = " + two.OWOR_DocNum + "and ItemType = 4 ";

                        rs.DoQuery(sql1);
                        principal.GravaAudit("Termino remove linhas OP ");
                    }
                    catch (Exception ex)
                    {
                        principal.GravaAudit("EX " + ex.Message.ToString());
                        principal.GravaAudit("Continua");
                    }

                    string sql = "Select distinct T1.DocEntry, T3.ItemCode, 'PP' As 'ProductionWarehouse', ConsumptionQuantity , T0.OItm_CodeBars, T0.OWor_DocNum from [Sage_Transaction41] T0 ";
                    sql += "left join OWOR T1 on T1.U_ORDER_JOMAR = T0.OWOR_Order_Jomar and T1.Type = 'S'";
                    sql += "left join OITM T3 on T3.CodeBars = T0.OITM_CodeBars ";
                    sql += "left join ITT1 T2 on T2.Code = T3.ItemCode and T2.Type = 4 ";
                    sql += "where T0.OWOR_Order_Jomar = '" + two.OWOR_U_ORDER_JOMAR + "' and readySAP <> 'Y' ";

                    principal.GravaAudit("Inicio add linhas OP");
                    principal.GravaAudit(sql);
                    rs.DoQuery(sql);

                    int a  = 0;
                    int ii = 0;
                    while (rs.HasNext())
                    {
                        if (prd.GetByKey(rs.GetFieldValue(0).ToInt()))
                        {
                            principal.GravaAudit("Item " + rs.GetFieldValue(1).ToString());
                            principal.GravaAudit("PlannedQuantity " + rs.GetFieldValue(3).ToDouble().ToString());
                            principal.GravaAudit("Warehouse " + rs.GetFieldValue(2).ToString());
                            principal.GravaAudit("U_Line_Jomar " + two.OWOR_U_ORDER_JOMAR);

                            prd.Lines.Add();
                            prd.Lines.ItemNo          = rs.GetFieldValue(1).ToString();
                            prd.Lines.ItemType        = ProductionItemType.pit_Item;
                            prd.Lines.PlannedQuantity = rs.GetFieldValue(3).ToDouble();
                            //prd.Lines.BaseQuantity = rs.GetFieldValue(0).ToInt();
                            prd.Lines.Warehouse = rs.GetFieldValue(2).ToString();
                            prd.Lines.UserFields.Fields.Item("U_Line_Jomar").Value = two.OWOR_U_ORDER_JOMAR;
                            ii = prd.Update();
                        }
                    }

                    principal.GravaAudit("Termino add linhas OP");


                    if (ii != 0)
                    {
                        principal.GravaAudit("Erro " + MyLibs.v2.sbo.SAPConnection.DI.GetLastErrorDescription());
                    }
                    else
                    {
                        two.ReadBySAP = 'Y';
                        UpdateStatus41(two);
                        principal.GravaAudit("Concluido com sucesso");
                    }
                }
            }
            catch (Exception ex)
            {
                principal.GravaAudit("Erro " + ex.Message.ToString());
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Cria um esboço de Nota Fiscal.
        /// </summary>
        /// <param name="t32"></param>
        private void NewOINV(T32Entity t32)
        {
            var oODRF = SAPConnection.GetDocument(SAPConnection.DocsEnum.ODRF);

            oODRF.DocObjectCode = BoObjectTypes.oInvoices;
            oODRF.CardCode      = t32.JOMAR_CardCode;
            //oODRF.NumAtCard = t32.ORDR_NumAtCard;
            oODRF.HandWritten             = BoYesNoEnum.tNO;
            oODRF.BPL_IDAssignedToInvoice = t32.ORDR_BplId;

            //oODRF.Reference1 = t32.JOMAR_OrderNum.ToString();
            oODRF.DocDate    = DateTime.Now;
            oODRF.DocDueDate = DateTime.Now;
            oODRF.TaxDate    = DateTime.Now;

            foreach (var line in t32.Lines)
            {
                oODRF.Lines.ItemCode      = line.OITM_ItemCode;
                oODRF.Lines.Quantity      = line.RDR1_Quantity;
                oODRF.Lines.WarehouseCode = line.RDR1_WhsCode;
                oODRF.Lines.BaseType      = 17;
                oODRF.Lines.BaseEntry     = t32.ORDR_DocEntry;//rs.GetFieldValue("DocNum").ToInt();
                oODRF.Lines.BaseLine      = line.RDR1_LineNum;
                oODRF.Lines.Add();
            }
            //using (var rs = new MyRecordSet())
            //{
            //    rs.DoQuery(Properties.Querys.ItensAberto_RDR1_1, t32.ORDR_DocEntry);
            //    while (rs.HasNext())
            //    {
            //        ////////////////////////////////////
            //        oODRF.Lines.ItemCode = rs.GetFieldValue("ItemCode").ToString();
            //        oODRF.Lines.Quantity = rs.GetFieldValue("diff").ToDouble() < rs.GetFieldValue("Quantity").ToDouble() ;
            //        //oODRF.Lines.Price = rs.GetFieldValue("Price").ToDouble();
            //        //oODRF.Lines.WarehouseCode = rs.GetFieldValue("WhsCode").ToString();
            //        oODRF.Lines.BaseType = rs.GetFieldValue("ObjType").ToInt();
            //        oODRF.Lines.BaseEntry = t32.ORDR_DocEntry;//rs.GetFieldValue("DocNum").ToInt();
            //        oODRF.Lines.BaseLine = rs.GetFieldValue("LineNum").ToInt();
            //        oODRF.Lines.Add();
            //    }
            //}

            oODRF.SalesPersonCode = t32.JOMAR_OIM;

            if (oODRF.Add() != 0)
            {
                t32.ReadBySAP = 'E';
                t32.MSG_SAP   = SAPConnection.DI.GetLastErrorDescription();

                foreach (var line in t32.Lines)
                {
                    line.ReadBySAP = 'E';

                    using (var rs = new MyRecordSet())
                    {
                        rs.DoQuery("SELECT TrgetEntry FROM RDR1 WHERE TargetType = '13' AND LineNum = '{0}' AND DocEntry = '{1}'", line.Jomar_LineNum, t32.ORDR_DocEntry);
                        if (rs.HasNext())
                        {
                            line.OINV_DocEntry = rs.GetFieldValue("TrgetEntry").ToInt();
                            line.ReadBySAP     = 'Y';
                        }
                        else
                        {
                            line.OINV_DocEntry = 0;
                        }
                    }

                    line.OINV_DocEntry = 0;
                    line.MSG_SAP       = SAPConnection.DI.GetLastErrorDescription();
                }

                T32DAO.UpdateStatus(t32, true);

                if (SAPConnection.DI.InTransaction)
                {
                    SAPConnection.DI.EndTransaction(BoWfTransOpt.wf_RollBack);
                }
            }
            else
            {
                var oinv = SAPConnection.GetNewKey();
                var msg  = "SUCESSO - Nota Fiscal Criada com sucesso.";
                foreach (var line in t32.Lines)
                {
                    line.ReadBySAP     = 'Y';
                    line.OINV_DocEntry = oinv;
                    line.MSG_SAP       = msg;
                }

                T32DAO.UpdateStatus(t32, true);
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Retorna as entidades de transações não lida pelo SAP.
        /// </summary>
        /// <param name="JOMAR_OrderNum">Número de Ordem Jomar (0 todos)</param>
        /// <returns></returns>
        public static List<T38Entity> GetDados(int JOMAR_OrderNum = 0)
        {
            var transacoes = new List<T38Entity>();

            using (var conn = new MyRecordSet())
            {
                if(JOMAR_OrderNum > 0)
                    conn.DoQuery("SELECT * FROM [Sage_Transaction38] WITH (NOLOCK) WHERE TransactionType = '-38' AND [JOMAR_OrderNum] = '{0}' AND (WOR1_DocNum IS NULL OR WOR1_DocNum = 0)", JOMAR_OrderNum);
                else
                    conn.DoQuery("SELECT * FROM [Sage_Transaction38] WITH (NOLOCK) WHERE TransactionType = '-38' AND [ReadBySAP] <> 'Y'");

                principal.GravaAudit("Inicio While - 38");
                while (conn.HasNext())
                {
                    var t38 = new T38Entity();
                    try
                    {
                        t38.Id = conn.GetFieldValue("Id").ToInt();
                        t38.AddDate = conn.GetFieldValue("AddDate").ToDate();
                        t38.TransactionType = conn.GetFieldValue("TransactionType").ToInt();
                        t38.ReadBySAP = conn.GetFieldValue("ReadBySAP").ToChar();
                        t38.JOMAR_OrderNum = conn.GetFieldValue("JOMAR_OrderNum").ToString();
                        t38.WOR1_DocNum = conn.GetFieldValue("WOR1_DocNum").ToInt();
                        t38.To_WareHouse = "PP";
                        t38.From_WareHouse = conn.GetFieldValue("WOR1_WareHouse").ToString();
                        t38.OITM_CodeBars = conn.GetFieldValue("OITM_CodeBars").ToString();
                        t38.JOMAR_LineNum = conn.GetFieldValue("JOMAR_LineNum").ToInt();
                        t38.WOR1_BaseQty = conn.GetFieldValue("WOR1_BaseQty").ToDouble();
                        t38.WOR1_PlannedQty = conn.GetFieldValue("WOR1_PlannedQty").ToDouble();
                        t38.IGE1_Quantity= conn.GetFieldValue("IGE1_Quantity").ToDouble();
                        t38.OWOR_DocNum = MyQuery.GetValue("OWOR", t38.JOMAR_OrderNum, "U_ORDER_JOMAR", "DocNum").ToInt();
                        principal.GravaAudit("- 38 - JOMAR_OrderNum " + t38.JOMAR_OrderNum);

                        if (t38.OWOR_DocNum > 0)
                        {
                            if ((Program.contador % 2) == 0)
                            {
                                if (t38.ReadBySAP != 'E')
                                    transacoes.Add(t38);
                            }
                            else
                            {
                                transacoes.Add(t38);
                            }
                        }  

                    } 
                    catch(Exception ex) {
                        t38.ReadBySAP = 'E';
                        t38.MSG_SAP = ex.Message;

                        UpdateStatus(t38);

                        principal.GravaAudit("Transação 38 Erro empacotar ID " + t38.Id.ToString() + " " + ex.Message.ToString());
                    }    

                }

             return transacoes;
            }
        }