示例#1
0
        public SpecialsCalculation getSpecialsCalculation(string calculation)
        {
            SpecialsCalculation sc = new SpecialsCalculation();

            string[] parts = calculation.Split(new char[] { '#' });
            string   t1    = parts[0].Split(new char[] { ':' })[1];

            switch (t1.ToUpper())
            {
            case "STOCKITEMS": { sc.tableOne = TableNames.StockTables.StockItems; } break;

            case "STOCKITEMS_SPECIALS": { sc.tableOne = TableNames.StockTables.StockItems_Specials; } break;
            }
            sc.tableOneColumn = parts[1].Split(new char[] { ':' })[1];

            sc.operation = parts[2].Split(new char[] { ':' })[1];

            string t2 = parts[3].Split(new char[] { ':' })[1];

            switch (t2.ToUpper())
            {
            case "STOCKITEMS": { sc.tableTwo = TableNames.StockTables.StockItems; } break;

            case "STOCKITEMS_SPECIALS": { sc.tableTwo = TableNames.StockTables.StockItems_Specials; } break;
            }

            sc.tableTwoColumn = parts[4].Split(new char[] { ':' })[1];

            return(sc);
        }
        private void frmSpecialsCalculationEditor_Load(object sender, EventArgs e)
        {
            loadDBColumns();

            if (string.IsNullOrWhiteSpace(calculation))
            {
                return;
            }

            SpecialsCalculation sc = tempMethods.getSpecialsCalculation(calculation);

            cbTableOne.Text       = sc.tableOne.ToString();
            cbTableOneColumn.Text = sc.tableOneColumn;
            cbOperator.Text       = sc.operation;
            cbTableTwo.Text       = sc.tableTwo.ToString();
            cbTableTwoColumn.Text = sc.tableTwoColumn;
        }
示例#3
0
        public string doSpecialsCalculation(SpecialsCalculation sc, string keyValue)
        {
            string function = "CalculateSpecialsValueNormalSpecials";

            switch (sc.tableOne)
            {
            case TableNames.StockTables.StockItems:
            {
                function = "CalculateSpecialsValueNormalSpecials";
                query    = "EXECUTE " + function + " '" + sc.tableOneColumn + "', '" + sc.tableTwoColumn + "', '" + keyValue + "', '" + sc.operation + "'";
            } break;

            case TableNames.StockTables.StockItems_Specials:
            {
                function = "CalculateSpecialsValueSpecialsNormal";
                query    = "EXECUTE " + function + " '" + sc.tableTwoColumn + "', '" + sc.tableOneColumn + "', '" + keyValue + "', '" + sc.operation + "'";
            } break;
            }

            string returnValue = db.readOne(query);

            return(returnValue);
        }