Esempio n. 1
0
        public int GetPaymentsDraftKey(string pStrCardCode, string pStrFolio)
        {
            SAPbobsCOM.Recordset lObjRecordSet = null;
            try
            {
                Dictionary <string, string> lLstStrParameters = new Dictionary <string, string>();
                lLstStrParameters.Add("CardCode", pStrCardCode);
                lLstStrParameters.Add("AuctionFolio", pStrFolio);


                lObjRecordSet = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                string lStrQuery = this.GetSQL("GetPaymentDraftKey").Inject(lLstStrParameters);

                lObjRecordSet.DoQuery(lStrQuery);

                if (lObjRecordSet.RecordCount > 0)
                {
                    return((int)lObjRecordSet.Fields.Item("DocEntry").Value);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                UIApplication.ShowError(string.Format("GetPaymentDraftKey: {0}", ex.Message));
                LogService.WriteError("PaymentDAO (ExistConfiguration): " + ex.Message);
                LogService.WriteError(ex);
                return(0);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjRecordSet);
            }
        }
Esempio n. 2
0
        public List <string> GetDateTimeUpdate(string pStrCardCode)
        {
            string        lStrQuery  = "select U_EntryDate, U_EntryTime, U_OutputDate, U_OutputTime from [@UG_PL_TCKD] where code = '{Cardcode}' ";
            List <string> lStrResult = new List <string>();

            SAPbobsCOM.Recordset        lObjRecordSet     = null;
            Dictionary <string, string> lLstStrParameters = null;

            try
            {
                lLstStrParameters = new Dictionary <string, string>();
                lLstStrParameters.Add("Cardcode", pStrCardCode);

                lStrQuery     = lStrQuery.Inject(lLstStrParameters);
                lObjRecordSet = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                lObjRecordSet.DoQuery(lStrQuery);

                if (lObjRecordSet.RecordCount > 0)
                {
                    lStrResult.Add(lObjRecordSet.Fields.Item(0).Value.ToString());
                    lStrResult.Add(lObjRecordSet.Fields.Item(1).Value.ToString());
                    lStrResult.Add(lObjRecordSet.Fields.Item(2).Value.ToString());
                    lStrResult.Add(lObjRecordSet.Fields.Item(3).Value.ToString());
                }
            }
            catch (Exception ex)
            {
                LogService.WriteError("[GetDateTimeUpdate]: " + ex.Message);
                LogService.WriteError(ex);
                UIApplication.ShowMessageBox(string.Format("Error de consulta", ex.Message));
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjRecordSet);
            }
            return(lStrResult);
        }
Esempio n. 3
0
        public List <MessageDTO> GetMessages(string pStrFolio)
        {
            List <MessageDTO> lLstMessages = new List <MessageDTO>();

            SAPbobsCOM.Recordset lObjRecordset = null;
            try
            {
                string lStrQuery = this.GetSQL("GetUsersMessage");

                lObjRecordset = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                lObjRecordset.DoQuery(lStrQuery);

                if (lObjRecordset.RecordCount > 0)
                {
                    for (int i = 0; i < lObjRecordset.RecordCount; i++)
                    {
                        MessageDTO lObjMessageDTO = new MessageDTO();
                        lObjMessageDTO.UserCode = lObjRecordset.Fields.Item("USER_CODE").Value.ToString();
                        lObjMessageDTO.UserId   = lObjRecordset.Fields.Item("USERID").Value.ToString();
                        lObjMessageDTO.Message  = "Ya puede realizar el cobro de crédito y cobranza " + pStrFolio;
                        lLstMessages.Add(lObjMessageDTO);
                        lObjRecordset.MoveNext();
                    }
                }
            }
            catch (Exception ex)
            {
                UIApplication.ShowError(string.Format("GetLastAuction: {0}", ex.Message));
                LogService.WriteError("PaymentDAO (ExistConfiguration): " + ex.Message);
                LogService.WriteError(ex);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjRecordset);
            }
            return(lLstMessages);
        }
Esempio n. 4
0
        private bool VerifyDocItem(string pStrCode, string pStrItem, string pStrTable)
        {
            bool lBolVerify = false;
            Dictionary <string, string> lLstStrParameters = null;
            string lStrQuery = "select DocEntry from {Table} where ItemCode = '{ItemCode}' and DocEntry = '{DocEntry}'";

            SAPbobsCOM.Recordset lObjRecordSet = null;
            try
            {
                lObjRecordSet = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                List <string> lStrResult = new List <string>();
                lLstStrParameters = new Dictionary <string, string>();
                lLstStrParameters.Add("ItemCode", pStrItem);
                lLstStrParameters.Add("DocEntry", pStrCode);
                lLstStrParameters.Add("Table", pStrTable);
                lStrQuery = lStrQuery.Inject(lLstStrParameters);
                lObjRecordSet.DoQuery(lStrQuery);
                if (lObjRecordSet.RecordCount > 0)
                {
                    lBolVerify = true;
                    //lStrResult.Add(lObjRecordSet.Fields.Item(0).Value.ToString());
                }
            }
            catch (Exception ex)
            {
                UIApplication.ShowMessageBox(string.Format("Error de consulta", ex.Message));
                LogService.WriteError("[VerifyDocItem]: " + ex.Message);
                LogService.WriteError(ex);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjRecordSet);
            }
            return(lBolVerify);
            // return lStrResult;
        }
Esempio n. 5
0
        public UserDTO GetUser(string pStrUserCode)
        {
            SAPbobsCOM.Recordset lObjRecordset = null;
            UserDTO lObjUser = new UserDTO();

            try
            {
                Dictionary <string, string> lLstStrParameters = new Dictionary <string, string>();
                lLstStrParameters.Add("UserCode", pStrUserCode);
                string lStrQuery = this.GetSQL("GetUser").Inject(lLstStrParameters);
                //this.UIAPIRawForm.DataSources.DataTables.Item("RESULT").ExecuteQuery(lStrQuery);

                lObjRecordset = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                lObjRecordset.DoQuery(lStrQuery);

                if (lObjRecordset.RecordCount > 0)
                {
                    lObjUser.UserId         = lObjRecordset.Fields.Item("USERID").Value.ToString();
                    lObjUser.UserCode       = lObjRecordset.Fields.Item("USER_CODE").Value.ToString();
                    lObjUser.Department     = lObjRecordset.Fields.Item("Department").Value.ToString();
                    lObjUser.DepartmentName = lObjRecordset.Fields.Item("Name").Value.ToString();
                    lObjUser.CostigCode     = lObjRecordset.Fields.Item("U_GLO_CostCenter").Value.ToString();
                    lObjUser.CYC            = Convert.ToChar(lObjRecordset.Fields.Item("CYC").Value);
                }
            }
            catch (Exception ex)
            {
                UIApplication.ShowError(string.Format("GetUser: {0}", ex.Message));
                LogService.WriteError("PaymentDAO (GetUser): " + ex.Message);
                LogService.WriteError(ex);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjRecordset);
            }
            return(lObjUser);
        }
Esempio n. 6
0
        public int AttachFile(string pStrFile)
        {
            int lIntAttEntry = -1;

            SAPbobsCOM.Attachments2 lObjAttachment = (SAPbobsCOM.Attachments2)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2);
            try
            {
                string lStrFileName = pStrFile;
                lObjAttachment.Lines.Add();
                lObjAttachment.Lines.FileName      = System.IO.Path.GetFileNameWithoutExtension(lStrFileName);
                lObjAttachment.Lines.FileExtension = System.IO.Path.GetExtension(lStrFileName).Substring(1);
                lObjAttachment.Lines.SourcePath    = System.IO.Path.GetDirectoryName(lStrFileName);
                lObjAttachment.Lines.Override      = SAPbobsCOM.BoYesNoEnum.tYES;

                if (lObjAttachment.Add() == 0)
                {
                    lIntAttEntry = int.Parse(DIApplication.Company.GetNewObjectKey());
                }
                else
                {
                    LogService.WriteError(string.Format("[AttachmentDI - AttachFile] {0}", DIApplication.Company.GetLastErrorDescription()));
                    throw new Exception(DIApplication.Company.GetLastErrorDescription());
                }
            }
            catch (Exception ex)
            {
                LogService.WriteError(string.Format("[AttachmentDI - AttachFile] {0}", ex.Message));
                LogService.WriteError(ex);
                throw new Exception(string.Format("Error al guardar el archivo adjunto {0}: {1}", pStrFile, ex.Message));
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjAttachment);
            }
            return(lIntAttEntry);
        }
Esempio n. 7
0
        public int CreateJournalEntry(string pStrFolio, string pStrSellerCardCode, string pStrBuyerCardCode, double pDblAmount)
        {
            SAPbobsCOM.JournalEntries lObjJournalEntry = null;
            int lIntResult = -1;

            try
            {
                //Get Header
                lObjJournalEntry           = (SAPbobsCOM.JournalEntries)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries);
                lObjJournalEntry.DueDate   = DateTime.Today;
                lObjJournalEntry.TaxDate   = DateTime.Today;
                lObjJournalEntry.AutoVAT   = SAPbobsCOM.BoYesNoEnum.tYES;
                lObjJournalEntry.Reference = pStrFolio;
                lObjJournalEntry.Series    = GetSeries();
                lObjJournalEntry.Memo      = "Cierre de subasta " + DateTime.Now.ToShortDateString();

                //Add debit to seller
                lObjJournalEntry = AddDebitToSeller(lObjJournalEntry, pStrFolio, pStrSellerCardCode, pDblAmount);

                //Add credit to the buyer
                lObjJournalEntry = AddCreditToBuyer(lObjJournalEntry, pStrFolio, pStrBuyerCardCode, pDblAmount);

                //Save
                lIntResult = lObjJournalEntry.Add();
            }
            catch (Exception lObjException)
            {
                Console.WriteLine(lObjException.ToString());
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjJournalEntry);
            }

            return(lIntResult);
        }
Esempio n. 8
0
        /// <summary>
        /// Removes the given pStrDocEntry.
        /// </summary>
        /// <remarks>
        /// Ranaya, 26/05/2017.
        /// </remarks>
        /// <exception cref="TableException">
        /// Thrown when a Table error condition occurs.
        /// </exception>
        /// <param name="pStrDocEntry">
        /// The String Document entry to remove.
        /// </param>
        /// <returns>
        /// An int.
        /// </returns>

        public int Remove(string pStrCode)
        {
            SAPbobsCOM.UserTable lObjUserTable = GetUserTable();

            try
            {
                if (lObjUserTable.GetByKey(pStrCode))
                {
                    return(lObjUserTable.Remove());
                }
                else
                {
                    throw new TableException(string.Format("No existe el registro '{0}'.", pStrCode));
                }
            }
            catch (Exception e)
            {
                throw new TableException(e.Message, e);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjUserTable);
            }
        }
Esempio n. 9
0
        private static void LoadGameFromTmpSave(string fileName)
        {
            string str = GenText.ToCommaList(from mod in LoadedModManager.RunningMods
                                             select mod.ToString());

            Log.Message("Loading game with colony " + fileName + " with mods " + str);

            MemoryUtility.ClearAllMapsAndWorld();
            Current.Game = new Game();
            Scribe.loader.InitLoading(FilePathForTmpSave());
            ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, logVersionConflictWarning: true);
            if (Scribe.EnterNode("game"))
            {
                Current.Game = new Game();
                Current.Game.LoadGame();
                PermadeathModeUtility.CheckUpdatePermadeathModeUniqueNameOnGameLoad(fileName);
            }
            else
            {
                Log.Error("Could not find game XML node.");
                Scribe.ForceStop();
            }
            RemoveTmpSave();
        }
Esempio n. 10
0
        public IList <InvoiceRowDTO> GetInvoiceLinesByGroup(int pDocEntry)
        {
            SAPbobsCOM.Recordset  lObjResults        = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
            IList <InvoiceRowDTO> lLstObjInvoiceRows = new List <InvoiceRowDTO>();

            try
            {
                string lStrQuery = this.GetSQL("GetGroupedLines").InjectSingleValue("DocEntry", pDocEntry);
                lObjResults.DoQuery(lStrQuery);
                if (lObjResults.RecordCount > 0)
                {
                    for (int i = 0; i < lObjResults.RecordCount; i++)
                    {
                        InvoiceRowDTO lObjInvoiceRowDTO = new InvoiceRowDTO();
                        lObjInvoiceRowDTO.LineTotal = Convert.ToDouble(lObjResults.Fields.Item("LineTotal").Value.ToString());
                        lObjInvoiceRowDTO.TaxCode   = lObjResults.Fields.Item("TaxCode").Value.ToString();
                        lObjInvoiceRowDTO.OcrCode   = lObjResults.Fields.Item("OcrCode").Value.ToString();
                        lObjInvoiceRowDTO.OcrCode2  = lObjResults.Fields.Item("OcrCode2").Value.ToString();
                        lObjInvoiceRowDTO.OcrCode3  = lObjResults.Fields.Item("OcrCode3").Value.ToString();
                        lObjInvoiceRowDTO.BagsBales = lObjResults.Fields.Item("U_GLO_BagsBales").Value.ToString();
                        lLstObjInvoiceRows.Add(lObjInvoiceRowDTO);
                        lObjResults.MoveNext();
                    }
                }
                return(lLstObjInvoiceRows);
            }
            catch (Exception e)
            {
                LogUtility.WriteError(string.Format("[DocumentDAO - GetInvoiceLinesByGroup] Error al obtener las lineas de la factura con DocEntry {0}: {1}", pDocEntry, e.Message));
                throw new Exception(string.Format("Error al obtener las lineas de la factura con DocEntry {0}: {1}", pDocEntry, e.Message));
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjResults);
            }
        }
Esempio n. 11
0
 protected override bool CanDoNext()
 {
     if (!base.CanDoNext())
     {
         return(false);
     }
     LongEventHandler.QueueLongEvent(delegate
     {
         Find.GameInitData.ResetWorldRelatedMapInitData();
         Current.Game.World =
             WorldGenerator.GenerateWorld(_planetCoverage, _seedString, _rainfall, _temperature);
         LongEventHandler.ExecuteWhenFinished(delegate
         {
             if (next != null)
             {
                 Find.WindowStack.Add(next);
             }
             MemoryUtility.UnloadUnusedUnityAssets();
             Find.World.renderer.RegenerateAllLayersNow();
             Close();
         });
     }, "GeneratingWorld", true, null);
     return(false);
 }
Esempio n. 12
0
        public string GetInternalStatus(string pStrFolio)
        {
            SAPbobsCOM.Recordset lObjResults = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
            try
            {
                string lStrQuery = this.GetSQL("GetInternalStatus").InjectSingleValue("Folio", pStrFolio);

                lObjResults.DoQuery(lStrQuery);

                string lStr = lObjResults.Fields.Item("Stat").Value.ToString();
                return(lObjResults.RecordCount > 0 ? lObjResults.Fields.Item("Stat").Value.ToString() : string.Empty);;
            }
            catch (Exception ex)
            {
                UIApplication.ShowError(string.Format("GetInternalStatus: {0}", ex.Message));
                LogService.WriteError("RouteListDAO (GetInternalStatus): " + ex.Message);
                LogService.WriteError(ex);
                return(string.Empty);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjResults);
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Get Lines for Delivery Document that will be added to Invoice Document
        /// </summary>
        /// <returns></returns>
        public List <DeliveryLine> GetDeliveryLines(string cardCode, string whsCode)
        {
            Recordset lObjRecordset     = null;
            var       parameters        = new Dictionary <string, string>();
            var       lLstdeliveryLines = new List <DeliveryLine>();

            try {
                string query = this.GetSQL("GetDeliveryLines");
                parameters.Add("CardCode", cardCode);
                parameters.Add("WhsCode", whsCode);

                lObjRecordset = (Recordset)DIApplication.Company.GetBusinessObject(BoObjectTypes.BoRecordset);
                lObjRecordset.DoQuery(query.Inject(parameters));

                if (lObjRecordset.RecordCount > 0)
                {
                    for (int i = 0; i < lObjRecordset.RecordCount; i++)
                    {
                        var deliveryLine = new DeliveryLine();
                        Parallel.ForEach(lObjRecordset.Fields.OfType <SAPbobsCOM.Field>(), field => {
                            deliveryLine.GetType().GetProperty(field.Name).SetValue(deliveryLine, field.Value);
                        });
                        lLstdeliveryLines.Add(deliveryLine);
                        lObjRecordset.MoveNext();
                    }
                }
            }
            catch (Exception ex) {
                HandleException(ex, "GetDeliveryLines");
            }
            finally {
                MemoryUtility.ReleaseComObject(lObjRecordset);
            }

            return(lLstdeliveryLines);
        }
Esempio n. 14
0
        public PendingOrderDTO[] GetPendingSalesOrders()
        {
            var recordset = (Recordset)DIApplication.Company.GetBusinessObject(BoObjectTypes.BoRecordset);

            PendingOrderDTO[] pendingOrders = null;

            try {
                var query = this.GetSQL("GetPendingSalesOrders");
                recordset.DoQuery(query);

                if (recordset.RecordCount > 0)
                {
                    pendingOrders = new PendingOrderDTO[recordset.RecordCount];
                    for (int i = 0; i < recordset.RecordCount; i++)
                    {
                        var pendingOrder = new PendingOrderDTO();
                        foreach (Field field in recordset.Fields)
                        {
                            pendingOrder.GetType().GetProperty(field.Name).SetValue(pendingOrder, field.Value);
                        }

                        pendingOrders[i] = pendingOrder;
                        recordset.MoveNext();
                    }
                }
            }
            catch (Exception ex) {
                HandleException(ex, "GetPendingSalesOrders");
            }
            finally {
                MemoryUtility.ReleaseComObject(recordset);
            }


            return(pendingOrders);
        }
Esempio n. 15
0
        public int GetNextUgrsFolio(string pStrPrefix)
        {
            SAPbobsCOM.Recordset        lObjRecordSet     = null;
            Dictionary <string, string> lLstStrParameters = null;
            string lStrQuery = "";

            try {
                lObjRecordSet = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                lLstStrParameters = new Dictionary <string, string>();
                lLstStrParameters.Add("Prefix", pStrPrefix);

                lStrQuery = this.GetSQL("GetNextUgrsFolio").Inject(lLstStrParameters);
                lObjRecordSet.DoQuery(lStrQuery);

                return(lObjRecordSet.RecordCount > 0 ? (int)lObjRecordSet.Fields.Item("UgrsFolio").Value : 0);
            }
            catch (Exception lObjException) {
                throw new QueryException(lObjException.Message, lObjException);
            }
            finally {
                MemoryUtility.ReleaseComObject(lObjRecordSet);
            }
        }
Esempio n. 16
0
        public static void DIReconnect()
        {
            try
            {
                if (Company != null)
                {
                    Company.Disconnect();
                    MemoryUtility.ReleaseComObject(Company);
                }
            }
            catch (Exception lObjException)
            {
                LogUtility.WriteException(lObjException);
            }

            DIConnection lObjDIConnection = new DIConnection();

            lObjDIConnection.ConnectToDI(GetCredentials());

            if (lObjDIConnection.Company != null && lObjDIConnection.Company.Connected)
            {
                DIApplication.DIConnect(lObjDIConnection.Company);
            }
        }
Esempio n. 17
0
        public IList <AccountDTO> GetClientBankAccounts(string pCardCode, string pBankCode)
        {
            SAPbobsCOM.Recordset lObjResults  = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
            IList <AccountDTO>   lLstObjBanks = new List <AccountDTO>();

            try
            {
                string lStrQuery = this.GetSQL("GetClientBankAccounts");
                Dictionary <string, string> lObjParameters = new Dictionary <string, string>();
                lObjParameters.Add("CardCode", pCardCode);
                lObjParameters.Add("BankCode", pBankCode);
                lObjResults.DoQuery(lStrQuery.Inject(lObjParameters));
                if (lObjResults.RecordCount > 0)
                {
                    for (int i = 0; i < lObjResults.RecordCount; i++)
                    {
                        AccountDTO lObjAccount = new AccountDTO();
                        lObjAccount.BankCode = lObjResults.GetColumnValue <string>("BankCode");
                        lObjAccount.Account  = lObjResults.GetColumnValue <string>("Account");
                        lObjAccount.Branch   = lObjResults.GetColumnValue <string>("Branch");
                        lLstObjBanks.Add(lObjAccount);
                        lObjResults.MoveNext();
                    }
                }
                return(lLstObjBanks);
            }
            catch (Exception e)
            {
                LogUtility.WriteError(string.Format("[BankDAO - GetClientBankAccounts] Error al obtener las cuentas para el cliente {0} con el banco {1}: {2}", pCardCode, pBankCode, e.Message));
                throw new Exception(string.Format("Error al obtener las cuentas para el cliente {0} con el banco {1}: {2}", pCardCode, pBankCode, e.Message));
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjResults);
            }
        }
Esempio n. 18
0
        public float GetTaxWT(string pStrItemCode)
        {
            string pStrWT = mObjQueryManager.GetValue("WtLiable", "ItemCode", pStrItemCode, "OITM");

            if (pStrWT == "Y")
            {
                SAPbobsCOM.Recordset lObjRecordSet = null;
                string lStrQuery = "";
                try
                {
                    lObjRecordSet = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                    Dictionary <string, string> lLstParams = new Dictionary <string, string>();

                    lLstParams.Add("ItemCode", pStrItemCode);
                    lStrQuery = this.GetSQL("GetTaxWT").Inject(lLstParams);

                    lObjRecordSet.DoQuery(lStrQuery);
                    return(float.Parse(lObjRecordSet.Fields.Item("Rate").Value.ToString()));
                }
                catch (Exception ex)
                {
                    UIApplication.ShowError(string.Format("GetJournalId: {0}", ex.Message));
                    LogService.WriteError("RouteListDAO (GetJournalId): " + ex.Message);
                    LogService.WriteError(ex);
                    return(0);
                }
                finally
                {
                    MemoryUtility.ReleaseComObject(lObjRecordSet);
                }
            }
            else
            {
                return(0);
            }
        }
Esempio n. 19
0
        public string GetTaxCode(string pStrRate)
        {
            SAPbobsCOM.Recordset lObjRecordset = null;
            string lStrVoucherCode             = "C0";

            try
            {
                Dictionary <string, string> lLstStrParameters = new Dictionary <string, string>();
                lLstStrParameters.Add("Rate", pStrRate);
                string lStrQuery = this.GetSQL("GetTaxCodeAP").Inject(lLstStrParameters);
                //this.UIAPIRawForm.DataSources.DataTables.Item("RESULT").ExecuteQuery(lStrQuery);

                lObjRecordset = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                lObjRecordset.DoQuery(lStrQuery);

                if (lObjRecordset.RecordCount > 0)
                {
                    lStrVoucherCode = lObjRecordset.Fields.Item("Code").Value.ToString();
                }
                else
                {
                    LogService.WriteError("No se encontro impuesto con  tasa o cuota de: " + pStrRate);
                }
            }
            catch (Exception ex)
            {
                UIApplication.ShowMessageBox(string.Format("InitDataSourcesException: {0}", ex.Message));
                LogService.WriteError("PurchasesDAO (GetVoucherCode): " + ex.Message);
                LogService.WriteError(ex);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjRecordset);
            }
            return(lStrVoucherCode);
        }
Esempio n. 20
0
        public PendingTransfer[] GetPendingTransfers()
        {
            Recordset recordset = (Recordset)DIApplication.Company.GetBusinessObject(BoObjectTypes.BoRecordset);;

            PendingTransfer[] pendingTransfers = null;

            try {
                recordset.DoQuery(this.GetSQL("GetPendingTransfers").Inject(new Dictionary <string, string>()
                {
                    { "Whs", GetUserDefaultWarehouse() }
                }));

                if (recordset.RecordCount > 0)
                {
                    pendingTransfers = new PendingTransfer[recordset.RecordCount];
                    for (int i = 0; i < recordset.RecordCount; i++)
                    {
                        var pendingTransfer = new PendingTransfer();
                        Parallel.ForEach(recordset.Fields.OfType <Field>(), field => {
                            pendingTransfer.GetType().GetProperty(field.Name).SetValue(pendingTransfer, field.Value);
                        });
                        pendingTransfers[i] = pendingTransfer;
                        recordset.MoveNext();
                    }
                }
            }
            catch (Exception ex) {
                HandleException(ex, "GetPendingTransfers");
            }
            finally {
                MemoryUtility.ReleaseComObject(recordset);
            }


            return(pendingTransfers);
        }
Esempio n. 21
0
        public List <CommissionDriverDTO> GetListDrivers()
        {
            List <CommissionDriverDTO> lLstDrivers = new List <CommissionDriverDTO>();

            SAPbobsCOM.Recordset lObjResults = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
            try
            {
                Dictionary <string, string> lLstParams = new Dictionary <string, string>();
                string lStrQuery = this.GetSQL("GetCmsnDrivers").Inject(lLstParams);
                lObjResults.DoQuery(lStrQuery);
                if (lObjResults.RecordCount > 0)
                {
                    for (int i = 0; i < lObjResults.RecordCount; i++)
                    {
                        lLstDrivers.Add(new CommissionDriverDTO()
                        {
                            DriverId = lObjResults.Fields.Item("empID").Value.ToString(),
                            Driver   = lObjResults.Fields.Item("SlpName").Value.ToString(),
                            WkDisc   = Convert.ToDouble(lObjResults.Fields.Item("WkDisc").Value.ToString()),
                        });
                        lObjResults.MoveNext();
                    }
                }
            }
            catch (Exception ex)
            {
                LogService.WriteError("CommissionDAO (GetComission): " + ex.Message);
                LogService.WriteError(ex);
                UIApplication.ShowError(string.Format("GetComission: {0}", ex.Message));
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjResults);
            }
            return(lLstDrivers);
        }
Esempio n. 22
0
        public double GetProdItemBags(int docEntry)
        {
            Recordset lObjRecordset = (Recordset)DIApplication.Company.GetBusinessObject(BoObjectTypes.BoRecordset);;
            Dictionary <string, string> lLstParams = new Dictionary <string, string>();
            dynamic result = 0;

            try {
                lObjRecordset.DoQuery(this.GetSQL("GetProdItemBags").Inject(new Dictionary <string, string>()
                {
                    { "DocEntry", docEntry.ToString() }
                }));
                if (lObjRecordset.RecordCount > 0)
                {
                    result = lObjRecordset.Fields.Item(0).Value;
                }
            }
            catch (Exception e) {
                HandleException(e, "GetPlannedQty");
            }
            finally {
                MemoryUtility.ReleaseComObject(lObjRecordset);
            }
            return(result);
        }
Esempio n. 23
0
        /// <summary>
        /// Obtener cuenta afectable.
        /// </summary>
        public IList <string> GetAffectable()
        {
            SAPbobsCOM.Recordset lObjRecordset  = null;
            IList <string>       lLstAffectable = new List <string>();

            try
            {
                //Dictionary<string, string> lLstStrParameters = new Dictionary<string, string>();
                //lLstStrParameters.Add("WareHouse", "");
                string lStrQuery = this.GetSQL("GetAffectable");
                //this.UIAPIRawForm.DataSources.DataTables.Item("RESULT").ExecuteQuery(lStrQuery);

                lObjRecordset = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                lObjRecordset.DoQuery(lStrQuery);

                if (lObjRecordset.RecordCount > 0)
                {
                    for (int i = 0; i < lObjRecordset.RecordCount; i++)
                    {
                        lLstAffectable.Add(lObjRecordset.Fields.Item("AcctCode").Value.ToString());
                        lObjRecordset.MoveNext();
                    }
                }
            }
            catch (Exception ex)
            {
                UIApplication.ShowMessageBox(string.Format("InitDataSourcesException: {0}", ex.Message));
                LogService.WriteError("PurchasesDAO (GetAffectable): " + ex.Message);
                LogService.WriteError(ex);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjRecordset);
            }
            return(lLstAffectable);
        }
Esempio n. 24
0
        public int GetIsBagRequired(string itemCode)
        {
            Recordset recordset = (Recordset)DIApplication.Company.GetBusinessObject(BoObjectTypes.BoRecordset);
            int       result    = 0;

            try {
                recordset.DoQuery(this.GetSQL("GetIsBagRequired").Inject(new Dictionary <string, string>()
                {
                    { "ItemCode", itemCode }
                }));

                if (recordset.RecordCount > 0)
                {
                    result = recordset.Fields.Item(0).Value.ToString() == "Y" ? 1 : 0;
                }
            }
            catch (Exception e) {
                HandleException(e, "GetIsBagRequired");
            }
            finally {
                MemoryUtility.ReleaseComObject(recordset);
            }
            return(result);
        }
Esempio n. 25
0
        private bool GetHoliday(DateTime pDtmDateTime)
        {
            bool lBolIsHoliday = false;
            Dictionary <string, string> lLstStrParameters = null;
            string lStrDelivery = "";

            SAPbobsCOM.Recordset lObjRecordsetCT = null;
            try
            {
                lObjRecordsetCT = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                string lStrQuery = ("select StrDate from HLD1 where HldCode = '{HldCode}' and StrDate = CAST('{Date}' AS DATE)");
                lLstStrParameters = new Dictionary <string, string>();
                lLstStrParameters.Add("Date", pDtmDateTime.ToString("yyyyMMdd"));
                lLstStrParameters.Add("HldCode", GetHldCode());

                lStrQuery = lStrQuery.Inject(lLstStrParameters);
                lObjRecordsetCT.DoQuery(lStrQuery);

                if (lObjRecordsetCT.RecordCount > 0)
                {
                    lStrDelivery = lObjRecordsetCT.Fields.Item(0).Value.ToString();
                }
            }
            catch (Exception ex)
            {
                LogService.WriteError("[RemoveTicketDetail]: " + ex.Message);
                LogService.WriteError(ex);
                UIApplication.ShowError("Consultar días" + ex.Message);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjRecordsetCT);
            }

            return(lBolIsHoliday);
        }
Esempio n. 26
0
        public double GetItemStock(string itemCode, string whsCode)
        {
            Recordset recordset = (Recordset)DIApplication.Company.GetBusinessObject(BoObjectTypes.BoRecordset);
            double    result    = 0;

            try {
                recordset.DoQuery(this.GetSQL("GetItemStock").Inject(new Dictionary <string, string>()
                {
                    { "ItemCode", itemCode }, { "WhsCode", whsCode }
                }));

                if (recordset.RecordCount > 0)
                {
                    result = (double)recordset.Fields.Item(0).Value;
                }
            }
            catch (Exception e) {
                HandleException(e, "GetItemStock");
            }
            finally {
                MemoryUtility.ReleaseComObject(recordset);
            }
            return(result);
        }
Esempio n. 27
0
        public IList <DeliveryFoodDTO> GetUpdatedDeliveriesFoodList(string pStrWhsCode)
        {
            Recordset lObjRecordset = null;
            IList <DeliveryFoodDTO> lLstObjDeliveriesFood = new List <DeliveryFoodDTO>();

            try
            {
                lObjRecordset = (Recordset)DIApplication.Company.GetBusinessObject(BoObjectTypes.BoRecordset);

                Dictionary <string, string> lLstStrParameters = new Dictionary <string, string>();
                lLstStrParameters.Add("WhsCode", pStrWhsCode);
                string pstr = this.GetSQL("GetUpdatedDeliveriesFoodList").Inject(lLstStrParameters);

                lObjRecordset.DoQuery(this.GetSQL("GetUpdatedDeliveriesFoodList").Inject(lLstStrParameters));

                if (lObjRecordset.RecordCount > 0)
                {
                    for (int i = 0; i < lObjRecordset.RecordCount; i++)
                    {
                        lLstObjDeliveriesFood.Add(GetDelivery(lObjRecordset));
                        lObjRecordset.MoveNext();
                    }
                }
            }
            catch (Exception lObjException)
            {
                LogService.WriteError(lObjException.Message);
                throw new DAOException(lObjException.Message, lObjException);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjRecordset);
            }

            return(lLstObjDeliveriesFood);
        }
Esempio n. 28
0
        public TransferItem[] GetTransferItems(string DocEntry)
        {
            Recordset recordset = (Recordset)DIApplication.Company.GetBusinessObject(BoObjectTypes.BoRecordset);;

            TransferItem[] transferItems = null;

            try {
                string query = this.GetSQL("GetTransferItems").Inject(new Dictionary <string, string>()
                {
                    { "DocEntry", DocEntry }
                });
                recordset.DoQuery(query);

                if (recordset.RecordCount > 0)
                {
                    transferItems = new TransferItem[recordset.RecordCount];
                    for (int i = 0; i < recordset.RecordCount; i++)
                    {
                        var transferItem = new TransferItem();
                        Parallel.ForEach(recordset.Fields.OfType <Field>(), field => {
                            transferItem.GetType().GetProperty(field.Name).SetValue(transferItem, field.Value);
                        });
                        transferItems[i] = transferItem;
                        recordset.MoveNext();
                    }
                }
            }
            catch (Exception ex) {
                HandleException(ex, "GetTransferItems");
            }
            finally {
                MemoryUtility.ReleaseComObject(recordset);
            }

            return(transferItems);
        }
Esempio n. 29
0
        public string GetPrice(string pStrItemCode)
        {
            SAPbobsCOM.Recordset lObjRecordset = null;
            string lStrPrice = "";

            try
            {
                TicketDAO mObjTicketDAO = new TicketDAO();
                Dictionary <string, string> lLstStrParameters = new Dictionary <string, string>();
                lLstStrParameters.Add("ItemCode", pStrItemCode);
                lLstStrParameters.Add("WhsCode", "PLHE");
                string lStrQuery = this.GetSQL("GetPrice").Inject(lLstStrParameters);
                //this.UIAPIRawForm.DataSources.DataTables.Item("RESULT").ExecuteQuery(lStrQuery);

                lObjRecordset = (SAPbobsCOM.Recordset)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                lObjRecordset.DoQuery(lStrQuery);

                if (lObjRecordset.RecordCount > 0)
                {
                    lStrPrice = lObjRecordset.Fields.Item(1).Value.ToString();
                }
            }
            catch (Exception ex)
            {
                LogService.WriteError(string.Format("[GetPrice]: {0} ", ex.Message));
                LogService.WriteError(ex);
                UIApplication.ShowError(string.Format("[GetPrice]: {0}", ex.Message));
                // UIApplication.ShowMessageBox(string.Format("InitDataSourcesException: {0}", ex.Message));
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjRecordset);
            }

            return(lStrPrice);
        }
Esempio n. 30
0
        public int GetInventoryExitByDocNum(string docNum)
        {
            var recordset = (Recordset)DIApplication.Company.GetBusinessObject(BoObjectTypes.BoRecordset);
            int result    = 0;

            try {
                recordset.DoQuery(this.GetSQL("GetInventoryExitByDocNum").Inject(new Dictionary <string, string>()
                {
                    { "DocNum", docNum }
                }));
                if (recordset.RecordCount > 0)
                {
                    result = int.Parse(recordset.Fields.Item(0).Value.ToString());
                }
            }
            catch (Exception ex) {
                HandleException(ex, "GetInventoryExitByDocNum");
            }
            finally {
                MemoryUtility.ReleaseComObject(recordset);
            }

            return(result);
        }