private void BtnExit_Click(object sender, EventArgs e) { try { if (LoginState.Login == this.LoginState) { DialogResult dialogResult = MessageBox.Show(this, "您确定要退出当前账户 " + this.User.Name + " ?", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (DialogResult.OK == dialogResult) { TableUsersManage.ModifyUserLogoutById(DateTime.Now.ToLocalTime().ToString(), this.LoginLogId); SetLoginState(LoginState.Logout); } else { } } else if (LoginState.Logout == this.LoginState) { Login(); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e) { if (LoginState.Login == this.LoginState) { TableUsersManage.ModifyUserLogoutById(DateTime.Now.ToLocalTime().ToString(), this.LoginLogId); } }
private void BtnAccountManage_Click(object sender, EventArgs e) { FrmAccountManager frmAccountManager = new FrmAccountManager { //UserName = this.UserName User = this.User, }; DialogResult dialogResult = frmAccountManager.ShowDialog(this); if (DialogResult.No == dialogResult) { if (LoginState.Login == this.LoginState) { TableUsersManage.ModifyUserLogoutById(DateTime.Now.ToLocalTime().ToString(), this.LoginLogId); SetLoginState(LoginState.Logout); } } DataTable dataTable = TableUsersManage.QueryUserByUserId(this.User.Id); DataRow dataRow = dataTable.Rows[0]; var item = dataRow.ToExpression <UserInfo>(); this.User = item(dataRow); this.LblUserName.Text = this.User.Nickname; }