private void log() { try { string a = txUsername.text; if (txtPassword.text == string.Empty || txUsername.text == string.Empty) { MessageBox.Show("Please enter valid data"); return; } string un = txUsername.text; string pw = txtPassword.text; Users_BS us = new Users_BS(); us.password_ = pw; us.user_name_ = un; us = us.GetOneUser(con, un, pw); if (us.user_name_ == un && us.password_ == pw) { //MessageBox.Show(us.password_+ us.user_name_); us.status_ = "active"; us.Update(con); BusinessObjects.InitializeStarter inita = new InitializeStarter(); inita.initializer(con); //MemoryManagement.FlushMemory(); this.Hide(); var form2 = new Dashboard(); form2.Closed += (s, args) => this.Dispose(); form2.Show(); } else { MessageBox.Show("Invalid User name or Password"); } } catch (Exception ex) { MetroMessageBox.Show(this, "System error " + ex.Message, "MetroMessageBox", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); } }
private void btnLogIn_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtRetype.Text) || string.IsNullOrEmpty(txtNewPassword.Text) || string.IsNullOrEmpty(txtPassword.Text) || string.IsNullOrEmpty(txUsername.Text)) { MessageBox.Show("Invalid Data"); return; } string userNae = txUsername.Text; string pasword = txtPassword.Text; string newPaass = txtNewPassword.Text; string rety = txtRetype.Text; if (rety != newPaass) { MessageBox.Show("Password does not matching"); } Users_BS ubs = new Users_BS(); ubs = ubs.GetOneUser(con, userNae, pasword); MessageBox.Show(ubs.password_); if (ubs.password_ == pasword && ubs.user_name_ == userNae) { } else { MessageBox.Show("Invalid username or password"); return; } ubs.user_name_ = userNae; ubs.password_ = newPaass; ubs.status_ = "active"; if (ubs.Update(con)) { MetroMessageBox.Show(this, "Successfully Updated", "System Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MetroMessageBox.Show(this, "! System Error. " + ex.Message, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }