public AdminUser_Model getAdminUser_ModelbyUser(string username) { //Control control = this.Parent; //while (!(control is ScrumBoardView)) //{ // control = control.Parent; //} //AdminUser_Model model = ((ScrumBoardView)control).lstUser.Where(p => p.username == username).FirstOrDefault(); //return model; AdminUser_Model model = new AdminUser_Model(); Control control = GetParentForm(); if (control is ScrumBoardView) { model = ((ScrumBoardView)control).lstUser.Where(p => p.username == username).FirstOrDefault(); } else if (control is ScrumBoardReviewDone) { model = ((ScrumBoardReviewDone)control).lstUser.Where(p => p.username == username).FirstOrDefault(); } return(model); }
public List <AdminUser_Model> getAllUser() { List <AdminUser_Model> result = new List <AdminUser_Model>(); try { DataTable dt = DBHandler.selectDataBase(ref conn, "`order_admin_user`", "*", string.Empty); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { AdminUser_Model item = new AdminUser_Model() { username = (string)dt.Rows[i]["username"], password = (string)dt.Rows[i]["password"], firstname = (string)dt.Rows[i]["firstname"], lastname = (string)dt.Rows[i]["lastname"], permission = (PermissionUser)((int)(short)dt.Rows[i]["permission_id"]) }; result.Add(item); } } } catch (Exception ex) { result = null; LogFile.writeLog(LogFile.DIR, "Exception" + LogFile.getTimeStringNow() + ".txt", LogFile.Filemode.GHIDE, ex.Message); } return(result); }
private bool CheckLogin() { bool result = false; string passmd5 = Functions.GetMD5(tb_pass.Text); AdminUser_Model adminCheck = lstUser.Where(u => u.username == tb_user.Text && u.password == passmd5).FirstOrDefault(); if (adminCheck != null) { UserName = adminCheck.username; Password = adminCheck.password; SetPermission(adminCheck.permission); result = true; } else { Functions.ShowMessgeError("Tài khoản hoặc mật khẩu không đúng!"); } return(result); }