Пример #1
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         string username = txtAccount.Text;
         string password = txtPassword.Text;
         if (Login(username, password))
         {
             AccountBusiness   accountBusiness = new AccountBusiness();
             Account           logInAccount    = accountBusiness.GetAccountByUsername(username);
             frmChooseDocument f = new frmChooseDocument(username);
             f.Show();
             this.Hide();
             //Luu password va username tam thoi vao app.Config
             //ConfigurationManager.AppSettings.Set("usernameTemp", txtAccount.Text);
             //ConfigurationManager.AppSettings.Set("passwordTemp", txtPassword.Text);
             Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
             configuration.AppSettings.Settings["usernameTemp"].Value = txtAccount.Text;
             configuration.AppSettings.Settings["passwordTemp"].Value = txtPassword.Text;
             configuration.Save();
             ConfigurationManager.RefreshSection("appSettings");
         }
         else
         {
             MessageBox.Show("Sai ten tai khoan hoac mat khau!", "Thong bao!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Thông báo!");
     }
 }
Пример #2
0
 private void FrmChooseDocument_FormClosed_1(object sender, FormClosedEventArgs e)
 {
     if (MessageBox.Show("Ban co thuc su muon thoat chuong trinh?", "Thong bao!", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.No)
     {
         System.Windows.Forms.Application.Exit();
     }
     else
     {
         frmChooseDocument f = new frmChooseDocument(lblAccount.Text);
         f.ShowDialog();
     }
 }