// get a person object based on id public cPerson GetPerson(int id) { cPerson p = new cPerson(); int size = dlist.Count; string sql = string.Format("* FROM {0} WHERE {1}={2}", tbl_name, nlist[0], id); // the select will fill the dlist array Select(sql); // after copying person over, now delete from array if(dlist.Count > size) { p = (cPerson)dlist[size]; dlist.RemoveAt(size); } return p; }
// get a person object based on id public cPerson GetPerson(int id) { cPerson p = new cPerson(); int size = dlist.Count; string sql = string.Format("* FROM {0} WHERE {1}={2}", tbl_name, nlist[0], id); // the select will fill the dlist array Select(sql); // after copying person over, now delete from array if (dlist.Count > size) { p = (cPerson)dlist[size]; dlist.RemoveAt(size); } return(p); }
public void Logout() { CurrentYear = DateTime.Now.Year; CurrentSem = "Fall"; current_view = null; current_id = -1; current_login = null; current_section = null; current_assign = null; sub_state = 0; UpdateSecurityLevel(-1); }
public bool Login(string user, string pass) { if(user.Length < 1) { MessageBox.Show("You need to enter a User ID", "Login Error"); } else if(user.ToLower().CompareTo("admin") == 0) { // trying to login as admin if(pass.Length < 1) { MessageBox.Show("You need to enter in Password", "Login Error"); } else { if(pass.CompareTo("test") == 0) { current_id = -1; UpdateSecurityLevel(2); return true; } else { MessageBox.Show("Incorrect Password", "Login Error"); } } } else { int userid = -1; try { userid = Convert.ToInt32(user); } catch(Exception exp) { string err = exp.Message; // error MessageBox.Show("Invalid User ID, numbers are only allowed", "Login Error"); return false; } if( pass.Length > 0 ) { // trying to login as instructor if (inst_list.Login(userid, pass)) { current_id = userid; current_login = person_list.GetPerson(current_id); UpdateSecurityLevel(1); return true; } else { MessageBox.Show("Incorrect User ID or Password", "Login Error"); } } else { MessageBox.Show("Login as Student feature was not been implimented.", "Login Error"); #if false // trying to login as student if (person_list.Login(userid)) { current_id = userid; current_login = person_list.GetPerson(current_id); UpdateSecurityLevel(0); return true; } else { MessageBox.Show("Incorrect User ID", "Login Error"); } #endif } } return false; }
public bool Login(string user, string pass) { if (user.Length < 1) { MessageBox.Show("You need to enter a User ID", "Login Error"); } else if (user.ToLower().CompareTo("admin") == 0) { // trying to login as admin if (pass.Length < 1) { MessageBox.Show("You need to enter in Password", "Login Error"); } else { if (pass.CompareTo("test") == 0) { current_id = -1; UpdateSecurityLevel(2); return(true); } else { MessageBox.Show("Incorrect Password", "Login Error"); } } } else { int userid = -1; try { userid = Convert.ToInt32(user); } catch (Exception exp) { string err = exp.Message; // error MessageBox.Show("Invalid User ID, numbers are only allowed", "Login Error"); return(false); } if (pass.Length > 0) { // trying to login as instructor if (inst_list.Login(userid, pass)) { current_id = userid; current_login = person_list.GetPerson(current_id); UpdateSecurityLevel(1); return(true); } else { MessageBox.Show("Incorrect User ID or Password", "Login Error"); } } else { MessageBox.Show("Login as Student feature was not been implimented.", "Login Error"); #if false // trying to login as student if (person_list.Login(userid)) { current_id = userid; current_login = person_list.GetPerson(current_id); UpdateSecurityLevel(0); return(true); } else { MessageBox.Show("Incorrect User ID", "Login Error"); } #endif } } return(false); }