Esempio n. 1
0
        public static FormulaField ExecuteFormula(string formula, decimal omset, decimal tarif)
        {
            DataTable table = new DataTable();
            // Create the first column.
            DataColumn omsetColumn = new DataColumn();
            omsetColumn.DataType = System.Type.GetType("System.Decimal");
            omsetColumn.ColumnName = "Omset";
            omsetColumn.DefaultValue = omset;

            // Create the first column.
            DataColumn tarifColumn = new DataColumn();
            tarifColumn.DataType = System.Type.GetType("System.Decimal");
            tarifColumn.ColumnName = "Tarif";
            tarifColumn.DefaultValue = tarif;

            // Create the second, calculated, column.
            DataColumn bagiHasilColumn = new DataColumn();
            bagiHasilColumn.DataType = System.Type.GetType("System.Decimal");
            bagiHasilColumn.ColumnName = "BagiHasil";
            bagiHasilColumn.Expression = formula;

            // Add columns to DataTable.
            table.Columns.Add(omsetColumn);
            table.Columns.Add(tarifColumn);
            table.Columns.Add(bagiHasilColumn);

            DataRow row = table.NewRow();
            table.Rows.Add(row);
             string _Omset=omset.ToString("N2");
             string _Tarif = tarif.ToString("N2");
            string replaceFormula = FormulaReplace(formula,_Omset,_Tarif);
            FormulaField _formula = new FormulaField()
            {
                Tarif = (decimal)row["Tarif"],
                Omset = (decimal)row["Omset"],
                BagiHasil = (decimal)row["BagiHasil"],
                FormulaName = formula,
                FormulaProcess = replaceFormula
            };

            //DataView view = new DataView(table);
            // dataGrid1.DataSource = view;
            //Assert.AreEqual(909.09,row["BagiHasil"])

            return _formula;
        }
Esempio n. 2
0
 private void SetViewBagFormula(FormulaField formula)
 {
     ViewBag.FormulaKonsesi = formula.FormulaName;
     ViewBag.FormulaProcess = formula.FormulaProcess;
 }