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);
     }
 }
        /// <summary>
        /// Retorna as entidades de transações não lida pelo SAP.
        /// </summary>
        /// <param name="itemCode">Código do item</param>
        /// <param name="type">Tipo de transação</param>
        /// <returns></returns>
        public static ProductTreeEntity GetDados(string itemCode)
        {
            var prodTree = new ProductTreeEntity();

            using (var conn = new ConnSqlServer())
            {
                var codeBars = MyQuery.GetValue("OITM", itemCode, "ItemCode", "CodeBars");

                conn.DoQuery("SELECT * FROM [Sage_WorkTree] WITH (NOLOCK) WHERE ReadBySAP <> 'Y' AND  OITM_CodeBars = '{0}'", codeBars);

                //if(conn.)


                while (conn.HasNext())
                {
                    prodTree.Id              = conn.GetFieldValue("Id").ToInt();
                    prodTree.AddDate         = conn.GetFieldValue("AddDate").ToDate();
                    prodTree.TransactionType = conn.GetFieldValue("TransactionType").ToInt();
                    prodTree.ReadBySAP       = conn.GetFieldValue("ReadBySAP").ToChar();

                    prodTree.OITM_CodeBars  = conn.GetFieldValue("OITM_CodeBars").ToString();
                    prodTree.OITT_Code      = conn.GetFieldValue("OITT_Code").ToString();
                    prodTree.OITT_Quantity  = conn.GetFieldValue("OITT_Quantity").ToDouble();
                    prodTree.OITT_ToWH      = conn.GetFieldValue("OITT_ToWH").ToString();
                    prodTree.OITT_PriceList = conn.GetFieldValue("OITT_PriceList").ToInt();
                    prodTree.OITT_Project   = conn.GetFieldValue("OITT_Project").ToString();
                    prodTree.OITT_TreeType  = conn.GetFieldValue("OITT_TreeType").ToChar();

                    using (var connLine = new MyLibs.v2.local.DataBase.ConnSqlServer())
                    {
                        var line = new ProductTreeEntityLine();

                        connLine.DoQuery("SELECT * FROM [ProductTreeLine] WHERE ReadBySAP <> 'Y'");

                        line.ITT1_Type       = connLine.GetFieldValue("ITT1_Type").ToInt();
                        line.OITM_CodeBars   = connLine.GetFieldValue("OITM_CodeBars").ToString();
                        line.ITT1_Code       = connLine.GetFieldValue("ITT1_Code").ToString();
                        line.ITT1_Quantity   = connLine.GetFieldValue("ITT1_Quantity").ToDouble();
                        line.ITT1_WareHouse  = connLine.GetFieldValue("ITT1_WareHouse").ToString();
                        line.ITT1_IssuedMthd = connLine.GetFieldValue("ITT1_IssuedMthd").ToChar();
                        line.ITT1_Comment    = connLine.GetFieldValue("ITT1_Comment").ToString();
                        line.ITT1_Price      = connLine.GetFieldValue("ITT1_Price").ToDouble();

                        prodTree.Lines.Add(line);
                    }
                }
            }
            return(prodTree);
        }