Пример #1
0
        public static double getExchange(int curr, DateTime date, IEnvironment env)
        {
            IPagedSource s = new PagedSourceDailyExchangesMagic(env);

            s.getBuilder().addParameterValue(TableDAILYEXCHANGES.CRTYPE, curr);
            s.getBuilder().addParameterValue(TableDAILYEXCHANGES.DATE_, ToolGeneral.date2IntDate(date));
            return((double)ToolColumn.getColumnLastValue(s.getAll(), ToolColumn.getColumnFullName(TableDUMMY.TABLE, TableDUMMY.EXCHANGE), (double)0));
        }
Пример #2
0
        public static DataTable getMatUnitPrices(int unit, DateTime date, IEnvironment env, DataTable tablePrices, DataTable tableMatUnits)
        {
            DataTable resPrices = tablePrices.Clone();

            ToolColumn.add(resPrices, TablePRCLIST.E_DUMMY__PRICE, typeof(double));
            for (int i = 0; i < tablePrices.Rows.Count; ++i)
            {
                DataRow row         = tablePrices.Rows[i];
                short   convertable = (short)row[TablePRCLIST.UNITCONVERT];
                int     curUnit     = (int)row[TablePRCLIST.UOMREF];

                if ((convertable == (short)ConstBool.yes) || (curUnit == unit))
                {
                    if (ToolDateTime.isBetween(date, (DateTime)row[TablePRCLIST.BEGDATE], (DateTime)row[TablePRCLIST.ENDDATE]))
                    {
                        DataRow curRow = ToolRow.copyRowToTable(row, resPrices);
                        double  cf     = getMatUnitCF(curUnit, tableMatUnits);
                        double  cf_    = getMatUnitCF(unit, tableMatUnits);
                        double  price  = (double)curRow[TablePRCLIST.PRICE];
                        price = (price / cf) * cf_;
                        curRow[TablePRCLIST.PRICE] = price;
                        double exchange = ToolGeneral.getExchange((short)curRow[TablePRCLIST.CURRENCY], date, env);
                        curRow[TablePRCLIST.CURRENCY] = env.getInfoApplication().periodCurrencyNativeId;
                        if (exchange > ConstValues.minPositive)
                        {
                            price /= exchange;
                        }
                        else
                        {
                            price = 0;
                        }
                        curRow[TablePRCLIST.E_DUMMY__PRICE] = price;
                        curRow[TablePRCLIST.UOMREF]         = unit;
                    }
                }
            }
            return(resPrices);
        }