public string ValidateBLId(string blId)
        {
            string _query = string.Empty;

            try
            {
                oRecordSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                _query = string.Format("SELECT [CctName] FROM [dbo].[OCCT] WHERE CctCode = '{0}'", blId);

                oRecordSet.DoQuery(_query);
                LogDAL _log = new LogDAL();
                _log.WriteEntry(_query);
                if (oRecordSet.RecordCount == 1)
                {
                    return(oRecordSet.Fields.Item("CctName").Value.ToString());
                }
            }
            catch (Exception)
            {
                return("false");
            }

            return("false");
        }
Exemplo n.º 2
0
        public string InsertSplitedDraft(DraftDocumentEntity draft, List <DraftLineEntity> draftLines)
        {
            int addDraftNumber = 0;

            try
            {
                SAPbobsCOM.Documents oDocDraft = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);

                oDocDraft.CardCode                = draft.CardCode;
                oDocDraft.DocObjectCode           = (SAPbobsCOM.BoObjectTypes) 13;
                oDocDraft.BPL_IDAssignedToInvoice = Convert.ToInt16(draft.BPLId);

                oDocDraft.OpeningRemarks = draft.OpeningRemarks;
                oDocDraft.ClosingRemarks = draft.ClosingRemarks;
                oDocDraft.Comments       = draft.Comments;

                oDocDraft.DocDate = DateTime.ParseExact(draft.DocDate.ToString(), "yyyyMMdd", CultureInfo.InvariantCulture);

                if (!string.IsNullOrEmpty(draft.DocDueDate))
                {
                    oDocDraft.DocDueDate = DateTime.ParseExact(draft.DocDueDate.ToString(), "yyyyMMdd", CultureInfo.InvariantCulture);
                }

                oDocDraft.DocCurrency = draft.DocCurrency;
                oDocDraft.DocRate     = draft.DocRate;

                oDocDraft.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items;

                oDocDraft.UserFields.Fields.Item("U_UPP_N_OS").Value      = draft.N_Os;
                oDocDraft.UserFields.Fields.Item("U_Identificacao").Value = draft.DocCode;
                oDocDraft.UserFields.Fields.Item("U_UPBL").Value          = draft.U_UPBL;
                oDocDraft.UserFields.Fields.Item("U_UPAticDraft").Value   = draft.U_UPAticDraft;

                int _first = 0;

                foreach (DraftLineEntity _line in draftLines)
                {
                    oDocDraft.Lines.ItemCode        = _line.ItemCode;
                    oDocDraft.Lines.CostingCode     = _line.CostingCode;
                    oDocDraft.Lines.Currency        = _line.Currency;
                    oDocDraft.Lines.Quantity        = _line.Quantity;
                    oDocDraft.Lines.UnitPrice       = _line.UnitPrice;
                    oDocDraft.Lines.DiscountPercent = _line.DiscountPercent;
                    oDocDraft.Lines.Usage           = _line.Usage;
                    oDocDraft.Lines.WarehouseCode   = _line.WharehouseCode;
                    oDocDraft.Lines.Add();
                    oDocDraft.Lines.SetCurrentLine(oDocDraft.Lines.Count - 1);

                    _first++;
                }

                addDraftNumber = oDocDraft.Add();
            }
            catch (Exception ex)
            {
                throw;
            }

            if (addDraftNumber != 0)
            {
                var erro = oCompany.GetLastErrorDescription();

                LogDAL _log = new LogDAL();
                _log.WriteEntry("InsertDraft error SAP: " + erro);

                return("-3");
            }
            else
            {
                draft.Sketch_Invoice = oCompany.GetNewObjectKey();
                return("0");
            }
        }
        public bool InsertMonitoring(MonitoringEntity monitoring)
        {
            bool success = false;

            try
            {
                oCompService = oCompany.GetCompanyService();
                oCompany.StartTransaction();
                oGeneralService = oCompService.GetGeneralService("UD_INT_MONITORING");

                oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);

                oGeneralData.SetProperty("Code", monitoring.DocCode);

                oGeneralData.SetProperty("U_SketchInv", monitoring.Sketch_Invoice);

                oGeneralData.SetProperty("U_DocDate", DateTime.Now.ToString("yyyyMMdd"));

                oGeneralData.SetProperty("U_DocTotal", monitoring.DocTot);

                if (monitoring.BL != null)
                {
                    oGeneralData.SetProperty("U_Bl", monitoring.BL);
                }

                if (monitoring.BLId != null)
                {
                    oGeneralData.SetProperty("U_BlId", monitoring.BLId);
                }

                if (monitoring.Draft != null)
                {
                    oGeneralData.SetProperty("U_Draft", monitoring.Draft);
                }

                if (monitoring.Branch != null)
                {
                    oGeneralData.SetProperty("U_Branch", monitoring.Branch);
                }

                if (monitoring.BranchId != null)
                {
                    oGeneralData.SetProperty("U_BranchId", monitoring.BranchId);
                }

                oGeneralData.SetProperty("U_StatusId", monitoring.StatusId);
                oGeneralData.SetProperty("U_Status", monitoring.Status);

                oGeneralData.SetProperty("U_XMLPath", monitoring.XMLPath);
                oGeneralData.SetProperty("U_Message", monitoring.Message);

                oGeneralService.Add(oGeneralData);
            }
            catch (Exception e)
            {
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                }

                LogDAL _log = new LogDAL();
                _log.WriteEntry("InsertMonitoring error: " + e.Message);

                throw e;
            }
            if (oCompany.InTransaction)
            {
                oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
            }
            return(success);
        }