/// <summary> /// Add 1 to the Reserve value of the part with code /// </summary> /// <param name="code"></param> /// <returns></returns> public static string DbBook(string code) { BDD database = new BDD("kitbox"); string selection = "Enstock, Reserve, Id, DelaiFourn1, CommandeFourn1, DelaiFourn2, CommandeFourn2"; string table_name = "catalog"; string condition = "WHERE (Code = '" + code + "');"; List <List <object> > result = database.readElement(selection, table_name, condition); string delayed = "0"; if (result.Count > 0) { string modification = "Reserve = '" + Convert.ToString(Convert.ToInt32(result[0][1]) + 1) + "'"; database.modifyElement(table_name, modification, Convert.ToString(result[0][2])); if (Convert.ToInt32(result[0][0]) < Convert.ToInt32(result[0][1])) { if (Convert.ToInt32(result[0][4]) > 0) { delayed = Convert.ToString(result[0][3]); } else if (Convert.ToInt32(result[0][6]) > 0) { delayed = Convert.ToString(result[0][5]); } else { delayed = "-1"; } } } return(delayed); }
// args is a string collection, example : "1", "PrixClient=4" // The first element of the collection is always the Id number of the item. // In case of the example above, we're changing the values of the first item. public static void DbModifyStock(params string[] args) { BDD database = new BDD("kitbox"); int size = args.Count(); string number_Id = args[0]; // Skip the first element of the string var array = args.Skip(1).ToArray(); string data = string.Join(",", array); database.modifyElement("catalog", data, number_Id); }
/// <summary> /// remove 1 from the Reserve value of the part with code /// </summary> /// <param name="code"></param> public static void DbUnBook(string code) { BDD database = new BDD("kitbox"); string selection = "Reserve, Id"; string table_name = "catalog"; string condition = "WHERE (Code = '" + code + "');"; List <List <object> > result = database.readElement(selection, table_name, condition); if (result.Count > 0) { if (Convert.ToInt32(result[0][0]) > 0) { string modification = "Reserve = '" + Convert.ToString(Convert.ToInt32(result[0][0]) - 1) + "'"; database.modifyElement(table_name, modification, Convert.ToString(result[0][1])); } } }