private void btnLogin_Click(object sender, EventArgs e) { if (txtUsername.Text.Length > 0 && txtPassword.Text.Length > 0) { bool check = userInforDB.CheckAccountLogin(txtUsername.Text, txtPassword.Text); if (!check) { MessageBox.Show("Bạn đã đăng nhập sai tên hoặc password!"); return; } ISOK = true; NguoiSuDung nsd = userInforDB.GetUserInfor(txtUsername.Text); HisLogInfor logInfor = new HisLogInfor(); logInfor.NoiDung = nsd.FullName + " đã đăng nhập"; logInfor.ThoiGian = DateTime.Now; logInfor.UserName = nsd.FullName; string mes = ""; log.AddLog(logInfor, ref mes); this.Close(); } else { MessageBox.Show("Bạn chưa điền tên hoặc password!"); } }
public void SetHisOperate(string noidung) { NguoiSuDung nsd = userDB.GetUserInfor(UserNameLogIn); HisLogInfor logInfor = new HisLogInfor(); logInfor.NoiDung = noidung; logInfor.ThoiGian = DateTime.Now; logInfor.UserName = nsd.FullName; string mes = ""; hislogDB.AddLog(logInfor, ref mes); }
public List <HisLogInfor> GetListLog() { List <HisLogInfor> hisLogs = new List <HisLogInfor>(); var lists = (from s in db.dtb_logs select s).ToList(); foreach (var h in lists) { HisLogInfor x = new HisLogInfor(); x.Id = h.id; x.ThoiGian = Convert.ToDateTime(h.create_date); x.NoiDung = h.action; x.UserName = h.username; hisLogs.Add(x); } return(hisLogs); }
public bool AddLog(HisLogInfor log, ref string mes) { try { dtb_log _log = new dtb_log(); _log.username = log.UserName; _log.action = log.NoiDung; _log.create_date = log.ThoiGian; db.dtb_logs.InsertOnSubmit(_log); db.SubmitChanges(); return(true); } catch (Exception ex) { mes = ex.Message; return(false); } }