Esempio n. 1
0
        public static DateTime EditTextToDateTime(string value)
        {
            SAPbobsCOM.SBObob objBridge = (SAPbobsCOM.SBObob)SapDiConnection.Instance.GetBusinessObject(BoObjectTypes.BoBridge);
            var result = DateTime.ParseExact(value, "yyyyMMdd", CultureInfo.InvariantCulture);

            return(result);
        }
Esempio n. 2
0
        public static string AddData(SAPbobsCOM.Company oCompany, EXR model)
        {
            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";

            SAPbobsCOM.SBObob    oSBob = null;
            SAPbobsCOM.Recordset rs    = null;
            try
            {
                oCompany.StartTransaction();

                oSBob = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);
                rs    = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                rs    = oSBob.GetLocalCurrency();
                rs    = oSBob.GetSystemCurrency();

                oSBob.SetCurrencyRate(model.Currency, model.DateRate, model.Rate, true);
                oCompany.EndTransaction(BoWfTransOpt.wf_Commit);

                strResult = "OK";
            }
            catch (Exception e)
            {
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(BoWfTransOpt.wf_RollBack);
                }
                ;
                throw;
            }
            return(strResult);
        }
Esempio n. 3
0
        public static DateTime EditTextToDateTime(string value)
        {
            SAPbobsCOM.SBObob objBridge = (SAPbobsCOM.SBObob)DIConnection.company.GetBusinessObject(BoObjectTypes.BoBridge);
            DateTime          date      = Convert.ToDateTime(objBridge.Format_StringToDate(value).Fields.Item(0).Value);

            return(date);

            //DateTime CreatdDate = DateTime.ParseExact(date,
            //"yyyyMMdd",
            //System.Globalization.CultureInfo.InvariantCulture);
            //return CreatdDate;
        }
Esempio n. 4
0
        public static double getSCValue(double LocalAmount, DateTime date, out string Message, RoundingContextEnum B1Context)
        {
            double dbSCAmount = 0;

            SAPbobsCOM.SBObob    objBob            = null;
            SAPbobsCOM.Recordset objRS             = null;
            CompanyService       objCompanyService = null;

            Message = "";
            try
            {
                objBob = MainObject.Instance.B1Company.GetBusinessObject(BoObjectTypes.BoBridge);
                objRS  = objBob.GetCurrencyRate(MainObject.Instance.B1AdminInfo.SystemCurrency, date);
                double dbRate = objRS.Fields.Item(0).Value;

                objCompanyService = MainObject.Instance.B1Company.GetCompanyService();

                DecimalData objDecimalData = objCompanyService.GetDataInterface(CompanyServiceDataInterfaces.csdiDecimalData);
                objDecimalData.Context  = B1Context;
                objDecimalData.Currency = MainObject.Instance.B1AdminInfo.SystemCurrency;
                objDecimalData.Value    = LocalAmount / dbRate;
                RoundedData objResult = objCompanyService.RoundDecimal(objDecimalData);

                dbSCAmount = objResult.Value;
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
                Message = er.Message;
            }
            finally
            {
                if (objCompanyService != null)
                {
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(objCompanyService);
                    objCompanyService = null;
                }
                if (objRS != null)
                {
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(objRS);
                    objRS = null;
                }
                if (objBob != null)
                {
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(objBob);
                    objBob = null;
                }
            }
            return(dbSCAmount);
        }
Esempio n. 5
0
        public static void Conectar_Aplicacion()
        {
            SAPbouiCOM.SboGuiApi SboGuiApi = new SAPbouiCOM.SboGuiApi();
            oCompany = new SAPbobsCOM.Company();
            SboGuiApi.Connect("0030002C0030002C00530041005000420044005F00440061007400650076002C0050004C006F006D0056004900490056");
            oApplication = SboGuiApi.GetApplication();
            oCompany     = (SAPbobsCOM.Company)oApplication.Company.GetDICompany();

            oSBObob = (SAPbobsCOM.SBObob)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);

            sCodUsuActual     = oCompany.UserSignature.ToString();
            sNomUsuActual     = Funciones.Current_User_Name();
            sAliasUsuActual   = oCompany.UserName;
            sCurrentCompanyDB = oCompany.CompanyDB;
        }
 public UpdateDb()
 {
     DbConnection = HanaDbConnection.DbConnection();
     bo           = (SBObob)DbConnection.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);
 }
Esempio n. 7
0
        private void UpdateSBO(ref SAPbobsCOM.Company oCompany, DateTime FecActSBO, Double USDObs, Double EU, Double Uefe, ref SAPbobsCOM.SBObob oSBObob)
        {
            Double MonedaBase      = 0;;
            bool   cambioIndirecto = false;

            try
            {
                if (SBO_VID_Currency.Properties.Settings.Default.TipoCambio == 1)
                {
                    cambioIndirecto = true;
                    if (SBO_VID_Currency.Properties.Settings.Default.MonedaBaseIndirecta == "E")
                    {
                        MonedaBase = EU;
                    }
                    else
                    {
                        MonedaBase = USDObs;
                    }
                }

                string s;

                try
                {
                    s = SBO_VID_Currency.Properties.Settings.Default.Dolar;
                    if ((USDObs >= 0) && (s != "") && (s != null))
                    {
                        oSBObob.SetCurrencyRate(s, FecActSBO, USDObs, false);
                    }
                }
                catch
                {
                }
                try
                {
                    s = SBO_VID_Currency.Properties.Settings.Default.Euro;
                    if ((EU >= 0) && (s != "") && (s != null))
                    {
                        oSBObob.SetCurrencyRate(s, FecActSBO, EU, false);
                    }
                }
                catch
                {
                }
                try
                {
                    s = SBO_VID_Currency.Properties.Settings.Default.UF;
                    if ((Uefe >= 0) && (s != "") && (s != null))
                    {
                        oSBObob.SetCurrencyRate(s, FecActSBO, Uefe, false);
                    }
                }
                catch
                {
                }
                try
                {
                    s = SBO_VID_Currency.Properties.Settings.Default.DolarI;
                    if ((USDObs > 0) && (s != "") && (s != null) && (MonedaBase > 0) && (cambioIndirecto))
                    {
                        oSBObob.SetCurrencyRate(s, FecActSBO, MonedaBase / USDObs, false);
                    }
                }
                catch
                {
                }
                try
                {
                    s = SBO_VID_Currency.Properties.Settings.Default.EuroI;
                    if ((EU > 0) && (s != "") && (s != null) && (MonedaBase > 0) && (cambioIndirecto))
                    {
                        oSBObob.SetCurrencyRate(s, FecActSBO, MonedaBase / EU, false);
                    }
                }
                catch
                {
                }
                try
                {
                    s = SBO_VID_Currency.Properties.Settings.Default.UFI;
                    if ((Uefe > 0) && (s != "") && (s != null) && (MonedaBase > 0) && (cambioIndirecto))
                    {
                        oSBObob.SetCurrencyRate(s, FecActSBO, MonedaBase / Uefe, false);
                    }
                }
                catch
                {
                }
            }
            catch (Exception e)
            {
                oLog.LogMsg("Error al actualizar tasa de cambio en SBO - " + e.Message, "A", "E");
            }
        }
Esempio n. 8
0
        private void UpdateSBOSAP(ref SAPbobsCOM.Company oCompany, DateTime FecActSBO, Double USDObs, ref SAPbobsCOM.SBObob oSBObob, string moneda)
        {
            try
            {
                //if (SBO_VID_Currency.Properties.Settings.Default.TipoCambio == 1)
                //{
                //    cambioIndirecto = true;
                //    if (SBO_VID_Currency.Properties.Settings.Default.MonedaBaseIndirecta == "E")
                //        MonedaBase = EU;
                //    else
                //        MonedaBase = USDObs;
                //}
                //string s;

                try
                {
                    //s = SBO_VID_Currency.Properties.Settings.Default.Dolar;
                    if ((moneda != "") && (moneda != null))
                    {
                        oSBObob.SetCurrencyRate(moneda, FecActSBO, USDObs, false);
                        oLog.LogMsg("Valor a cargar Moneda: " + moneda + " Fecha:" + FecActSBO + " Valor: " + USDObs, "A", "I");
                    }
                }
                catch (Exception e)
                {
                    oLog.LogMsg("Tipo de cambio  " + moneda + " ya se encuentra ingresado en la sociedad " + e.Message, "A", "D");
                }
            }
            catch (Exception e)
            {
                oLog.LogMsg("Error al actualizar tasa de cambio en SBO - " + e.Message, "A", "E");
            }
        }
Esempio n. 9
0
        /// <summary>
        /// carga los valores que se encuentra en el Webservice
        /// </summary>
        /// <param name="oCompany"></param>
        private void deployCurrency(SAPbobsCOM.Company oCompany)
        {
            SAPbobsCOM.Recordset oRS     = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
            SAPbobsCOM.SBObob    pSBObob = (SAPbobsCOM.SBObob)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);

            TasaCambioSBO                  oTasaCambioSBO = new TasaCambioSBO();
            List <TasaCambioSBO>           oTasasCambio   = new List <TasaCambioSBO>();
            DateTime                       Fecha          = DateTime.Now;
            Dictionary <DateTime, Decimal> AuxDict        = new Dictionary <DateTime, decimal>();

            String oSql;
            int    diasAProcesar;

            // Validar definicion de monedas
            if (oCompany.DbServerType == SAPbobsCOM.BoDataServerTypes.dst_HANADB)
            {
                oSql = @"SELECT ""CurrCode"", ""CurrName"" , ""ISOCurrCod"" , ""DocCurrCod""  
                        FROM ""OCRN"" 
                        WHERE ""Locked"" = 'N' ";
            }
            else
            {
                oSql = "SELECT CurrCode, CurrName , ISOCurrCod , DocCurrCod " +
                       "FROM OCRN            " +
                       "WHERE Locked = 'N' ";
            }

            oRS.DoQuery(oSql);
            if (oRS.RecordCount > 0)
            {
                if (SBO_VID_Currency.Properties.Settings.Default.DiasAnterioresAProcesar > 0)
                {
                    diasAProcesar = 0;
                }
                else
                {
                    diasAProcesar = SBO_VID_Currency.Properties.Settings.Default.DiasAnterioresAProcesar;
                }

                oLog.LogMsg("Dias a procesar : " + diasAProcesar, "F", "D");

                for (int x = diasAProcesar; x <= 1; x++)
                {
                    Fecha = Fecha.AddDays(x);
                    string dateFormat = Fecha.ToString("yyyy-MM-dd");
                    oLog.LogMsg("Dia: " + dateFormat, "F", "D");
                    string url          = SBO_VID_Currency.Properties.Settings.Default.WEBPage;
                    string responseRest = restGETWhitParameter(url, dateFormat);
                    if (responseRest != "[]")
                    {
                        var listTC = JsonConvert.DeserializeObject <List <TC> >(responseRest);
                        for (int i = 0; i < oRS.RecordCount; i++)  //Monedas en SAP
                        {
                            string moneda              = ((System.String)oRS.Fields.Item("CurrCode").Value).Trim();
                            string monedaISO           = ((System.String)oRS.Fields.Item("ISOCurrCod").Value).Trim();
                            string monedaInternacional = ((System.String)oRS.Fields.Item("DocCurrCod").Value).Trim();
                            for (int y = 0; y < listTC.Count; y++)
                            {
                                if (moneda == listTC[y].codigo)
                                {
                                    oLog.LogMsg("procesado por CurrCode: " + Fecha + " Currency: " + moneda, "F", "D");
                                    UpdateSBOSAP(ref oCompany, Fecha, (Double)listTC[y].valor, ref pSBObob, moneda);
                                    y = listTC.Count;
                                }
                                else
                                {
                                    if (monedaISO == listTC[y].codigo)
                                    {
                                        oLog.LogMsg("procesado por ISOCurrCod: " + Fecha + " Currency: " + monedaISO, "F", "D");
                                        UpdateSBOSAP(ref oCompany, Fecha, (Double)listTC[y].valor, ref pSBObob, moneda);
                                        y = listTC.Count;
                                    }
                                    else
                                    {
                                        if (monedaInternacional == listTC[y].codigo)
                                        {
                                            oLog.LogMsg("procesado por DocCurrCod: " + Fecha + " Currency: " + monedaInternacional, "F", "D");
                                            UpdateSBOSAP(ref oCompany, Fecha, (Double)listTC[y].valor, ref pSBObob, moneda);
                                            y = listTC.Count;
                                        }
                                    }
                                }
                            }
                            oRS.MoveNext();
                        }
                        oRS.MoveFirst();
                    }
                    Fecha = DateTime.Now;
                }
            }
        }