Beispiel #1
0
        /// <summary>
        /// Cria saída de Produtos acabados.
        /// </summary>
        /// <param name="t08"></param>
        private void NewOIGE(T08Entity t08)
        {
            try
            {
                var Inventory = SAPConnection.GetDocument(SAPConnection.DocsEnum.OIGE);

                // HEADER
                Inventory.DocDate = t08.OWOR_PostDate;
                //Inventory.TaxDate = tn08.OWOR_PostDate;
                Inventory.BPL_IDAssignedToInvoice = 1;
                //Inventory.Lines.Price = 10;
                Inventory.Lines.ItemCode      = "";// tn08.OITM_ItemCode;
                Inventory.Lines.Quantity      = t08.IGN1_Quantity;
                Inventory.Lines.WarehouseCode = t08.OWOR_WareHouse;
                //Inventory.Lines.UserFields.Fields.Item("U_Lot").Value = t08.IGN1_U_Lot;
                Inventory.Lines.BaseEntry = t08.OWOR_DocNum;
                Inventory.Lines.BaseType  = (int)SAPConnection.DocsEnum.OWOR;
                Inventory.Lines.Add();

                //FOOTER
                Inventory.Comments = t08.OWOR_Remarks;

                int res = Inventory.Add();

                if (res != 0)
                {
                    t08.MSG_SAP   = SAPConnection.DI.GetLastErrorDescription();
                    t08.ReadBySAP = 'E';
                    T08DAO.UpdateStatus(t08);

                    principal.GravaAudit(SAPConnection.DI.GetLastErrorDescription().ToString());
                }
                else
                {
                    var docnum = SAPConnection.DI.GetNewObjectKey();

                    if (int.Parse(docnum) == 0) // Estava dando erro ao recuperar o DocEntry
                    {
                        t08.OIGE_DocNum = int.Parse(docnum);
                    }
                    else
                    {
                        t08.OIGE_DocNum = 999999; // Somente para verificar se houver falha.
                    }
                    t08.ReadBySAP = 'Y';
                    t08.MSG_SAP   = "SUCESSO - Saída do produto efetuada.";
                    T08NegDAO.UpdateStatus(t08);
                }
            }
            catch (Exception ex)
            {
                principal.GravaAudit("Transação " + t08.TransType.ToString() + " " + ex.Message.ToString());
            }
        }
Beispiel #2
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);
         }
     }
 }