private void btncomfirm_Click(object sender, EventArgs e) { UserLogBUS userLogBus = new UserLogBUS(); TimeSpan t = DateTime.Now - logStatic.LoginTime.Value; double time = Convert.ToDouble(t.TotalHours); Log newLog = new Log() { ID = logStatic.ID, LogOutTime = DateTime.Now, LoginTime = logStatic.LoginTime, IDUser = logStatic.IDUser, LoginReason = txtLoginReason.Text }; userLogBus.updateLog(newLog); frmMainUser mainUser = new frmMainUser(userStatic); this.Hide(); mainUser.Show(); }
private void frmMainUser_FormClosing(object sender, FormClosingEventArgs e) { Log log = userLogBus.getUserLog(userStatic).Last(); TimeSpan t = DateTime.Now - log.LoginTime.Value; double time = Convert.ToDouble(t.TotalHours); Log newLog = new Log() { ID = log.ID, LogOutTime = DateTime.Now, LoginTime = log.LoginTime, IDUser = log.IDUser, }; DialogResult dr = MessageBox.Show("Exit", "Are you exit?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { userLogBus.updateLog(newLog); frmMainUser mainUser = new frmMainUser(); mainUser.Close(); } }