Resolved
gracias
i dont know how projects like. mean how depot class made.
but suggest include number property (like accesslevel), used access of options.
here, took time make console application how checking after login, , how use data based on login:
using system; using system.collections.generic; using system.linq; using system.text; using system.data.sqlclient; using system.io; namespace mar20_1c { class program { static void main(string[] args) { list<user> users = new list<user>(); users.add(new user { accesslevel = 1, name = "name 1" }); users.add(new user { accesslevel = 2, name = "name 2" }); users.add(new user { accesslevel = 1, name = "name 3" }); //i create simple login: user user = login(users); //your checking: console.writeline("options: 1 - locate cargo 2 - locate worker 3 - create schedule 4 - exit"); string input = string.empty; while (true) { input = console.readline(); if (input.equals("1") || input.equals("2") || input.equals("3") || input.equals("4")) { //example option no. 3: if (input.equals("3")) { if (user.accesslevel == 2) { //all fine in here //user manager, , selected 3rd optin console.writeline("access granted!"); break; } else { console.writeline("you not have permision access option \"create schedule\"!"); console.writeline("re-enter option:"); //not ok!! //user not have permition access level } } else { //if user enter 1,2 or 4: console.writeline("access granted!"); if (input.equals("4")) { //close application! console.writeline("close application..."); } else break; } } else console.writeline("this command not in use. re-type option..."); } console.writeline("now can continue working..."); console.readline(); } static user login(list<user> list) { user newuser = new user(); bool buserok = false; string typeduser = string.empty; console.writeline("plese enter username:"); while (true) { typeduser = console.readline(); var checkingexistance = list.where(w => w.name == typeduser).select(s=>s.name).tolist(); if (checkingexistance.count > 0) { console.writeline("login succeeded!"); buserok = true; break; } else console.writeline("this name not exist. re-enter username..."); } if (buserok) { var query = list.where(w => w.name == typeduser).select(s => new user() { accesslevel = s.accesslevel, name = s.name }).tolist(); newuser.accesslevel = query[0].accesslevel; newuser.name = query[0].name; } return newuser; } } class user { //access level: //1 ordinary user //2 manager public int accesslevel { get; set; } public string name { get; set; } } }
please take time study code, there need.
hope helps.
bye
mitja
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment