Exemplo n.º 1
0
    public static string updateRow(string id, string columnName, string newValue)
    {
        // Check rules
        var rules = new RulesEngine(newValue, columnName);

        rules.checkColumn("grpsiz") // Qty
        .number()
        .negativeOneOrGreaterThanZero();
        rules.checkColumn("ot") // Overtime %
        .number()
        .greaterThan(-100);
        rules.checkColumn("mtf")
        .number()
        .greaterThan(0);
        rules.checkColumn("mtr")
        .number()
        .greaterThanOrEqual(0);
        rules.checkColumn("varbility")
        .number()
        .greaterThanOrEqual(0);

        if (rules.HasError)
        {
            return(MpxTableUtil.CreateError(rules.Error));
        }

        return(MpxTableUtil.UpdateRow(getSource(), TableName, IdColumn, id, columnName, newValue));
    }
    public static string updateRow(string id, string columnName, string newValue)
    {
        // Check rules
        var rules = new RulesEngine(newValue, columnName);

        rules.checkColumn("labordesc")
        .required();
        rules.checkColumn("grpsiz") // Qty
        .required()
        .number()
        .negativeOneOrGreaterThanZero();
        rules.checkColumn("ot") // Overtime %
        .required()
        .number()
        .greaterThan(-100);
        rules.checkColumn("abst") // Inefficiency
        .required()
        .number()
        .inRange(0, 99.99);

        if (rules.HasError)
        {
            return(MpxTableUtil.CreateError(rules.Error));
        }

        return(MpxTableUtil.UpdateRow(getSource(), TableName, IdColumn, id, columnName, newValue));
    }
    public static string updateRow(string id, string columnName, string newValue)
    {
        // Check rules
        var rules = new RulesEngine(newValue, columnName);

        rules.checkColumn("upa")
        .required()
        .number();

        if (columnName == "compname")
        {
            // TODO: need to do additonal query, probably before running model
            // Check compname's ibom settings, make sure it isn't set to this compname

            //Selected Product cannot nest an upper level
            //This would make infinite loop
            //A needs 2xB
            //B cannot nest A
            //A needs 2xC and 2xB, C needs 4xB, this is OK
        }

        if (rules.HasError)
        {
            return(MpxTableUtil.CreateError(rules.Error));
        }

        return(MpxTableUtil.UpdateRow(getSource(), TableName, IdColumn, id, columnName, newValue));
    }
Exemplo n.º 4
0
    public static string addRow()
    {
        // TODO: add any defaults
        int nextId;
        var defaultValues = new List <Tuple <string, string> >();

        defaultValues.Add(new Tuple <string, string>("equipdesc", "NEW ITEM"));
        return(MpxTableUtil.AddRow(getSource(), TableName, IdColumn, defaultValues, out nextId));
    }
Exemplo n.º 5
0
    public static string updateRow(string id, string columnName, string newValue)
    {
        // Check rules
        var rules = new RulesEngine(newValue, columnName);

        rules.checkColumn("enddemd")
        .number()
        .greaterThanOrEqual(0);
        rules.checkColumn("lotsiz")
        .number()
        .greaterThan(0);
        rules.checkColumn("varbility")
        .number()
        .greaterThanOrEqual(0);

        if (rules.HasError)
        {
            return(MpxTableUtil.CreateError(rules.Error));
        }

        return(MpxTableUtil.UpdateRow(getSource(), TableName, IdColumn, id, columnName, newValue));
    }
Exemplo n.º 6
0
 public static TableResults selectList(string columnName)
 {
     return(MpxTableUtil.SelectList(getSource(), TableName, columnName));
 }
Exemplo n.º 7
0
 public static TableResults selectAll()
 {
     return(MpxTableUtil.SelectAll(getSource(), TableName));
 }
Exemplo n.º 8
0
 public static string deleteRow(string id)
 {
     return(MpxTableUtil.DeleteRow(getSource(), TableName, IdColumn, id));
 }
    public static string updateRow(string id, string columnName, string newValue)
    {
        // Check rules
        var rules = new RulesEngine(newValue, columnName);

        rules.checkColumn("opnam")
        .exclude("DOCK")
        .exclude("SCRAP")
        .exclude("STOCK");

        rules.checkColumn("opnum")
        .exclude("0")
        .exclude("10000")
        .exclude("9999")
        .integer()
        .greaterThan(0);

        rules.checkColumn("percentassign")
        .integer()
        .inRange(1, 100);

        rules.checkColumn("eqsetuptime")
        .isSpecialMpxMath();
        rules.checkColumn("eqruntime")
        .isSpecialMpxMath();
        rules.checkColumn("labsetuptime")
        .isSpecialMpxMath();
        rules.checkColumn("labruntime")
        .isSpecialMpxMath();

        if (rules.HasError)
        {
            return(MpxTableUtil.CreateError(rules.Error));
        }

        //newValue = newValue.Trim();
        //columnName = columnName.ToLower();
        //if (columnName == "opnam")
        //{
        //    newValue.ToUpper();
        //    if (newValue == "DOCK" || newValue == "SCRAP" || newValue == "STOCK")
        //    {
        //        return MpxTableUtil.CreateError("Name cannot be DOCK, SCRAP, or STOCK");
        //    }
        //}
        //if (columnName == "opnum")
        //{
        //    if (newValue == "0" || newValue == "10000" || newValue == "9999")
        //    {
        //        return MpxTableUtil.CreateError("Number cannot be 0, 10000, or 9999");
        //    }
        //    int newValueInt = 0;
        //    if (!int.TryParse(newValue, out newValueInt))
        //    {
        //        return MpxTableUtil.CreateError("Must be an integer");
        //    }
        //    if (!(newValueInt > 0))
        //    {
        //        return MpxTableUtil.CreateError("Must be greater than 0");
        //    }
        //}
        //if (columnName == "percentassign")
        //{
        //    int newValueInt = 0;
        //    if (!int.TryParse(newValue, out newValueInt))
        //    {
        //        return MpxTableUtil.CreateError("Must be an integer");
        //    }
        //    if (!(newValueInt >= 1 && newValueInt <= 100))
        //    {
        //        return MpxTableUtil.CreateError("Must be between 1 and 100");
        //    }
        //}
        //if (columnName == "eqsetuptime")
        //{
        //    // TODO: other mathy columns
        //    // TODO: allow mathy ops
        //    int newValueInt = 0;
        //    if (!int.TryParse(newValue, out newValueInt))
        //    {
        //        return MpxTableUtil.CreateError("Must be an integer");
        //    }
        //    if (!(newValueInt >= 0))
        //    {
        //        return MpxTableUtil.CreateError("Must be 0 or more");
        //    }
        //}

        return(MpxTableUtil.UpdateRow(getSource(), TableName, IdColumn, id, columnName, newValue));
    }
Exemplo n.º 10
0
 public static string updateRow(string id, string columnName, string newValue)
 {
     return(MpxTableUtil.UpdateRow(getSource(), TableName, IdColumn, id, columnName, newValue));
 }