Пример #1
0
        public static DataTable getMainUnit(DataTable tableMatUnits)
        {
            DataRow uRow = null;

            for (int i = 0; i < tableMatUnits.Rows.Count; ++i)
            {
                DataRow row = tableMatUnits.Rows[i];
                if ((short)row[TableITMUNITA.LINENR] == (short)1)
                {
                    uRow = row;
                    break;
                }
            }
            DataTable tab = tableMatUnits.Clone();

            ToolRow.copyRowToTable(uRow, tab);
            return(tab);
        }
Пример #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);
        }
Пример #3
0
        public static DataTable getSmallUnit(DataTable tableMatUnits)
        {
            DataRow uRow   = null;
            double  cfLast = double.MaxValue;
            short   nrLast = short.MaxValue;

            for (int i = 0; i < tableMatUnits.Rows.Count; ++i)
            {
                DataRow row   = tableMatUnits.Rows[i];
                double  cfCur = (double)row[TableITMUNITA.CONVFACT2] / (double)row[TableITMUNITA.CONVFACT1];
                short   nrCur = (short)row[TableITMUNITA.LINENR];
                if ((cfLast > cfCur) || ((cfLast == cfCur) && (nrCur < nrLast)))
                {
                    uRow   = row;
                    cfLast = cfCur;
                    nrLast = nrCur;
                }
            }
            DataTable tab = tableMatUnits.Clone();

            ToolRow.copyRowToTable(uRow, tab);
            return(tab);
        }