private void btnSubmit_Click(object sender, EventArgs e) { MongoClient client = new MongoClient("mongodb://localhost"); MongoServer server = client.GetServer(); MongoDatabase db = server.GetDatabase("NBA"); MongoCursor <User> put = db.GetCollection <User>("Users").FindAll(); bool f = false; foreach (User i in put) { //checks entered username with username in database if (txtusername.Text.Trim() == i.username) { f = true; //take all this following values on 2nd form of forgot password frmForgot_Pass2 obj = new frmForgot_Pass2(); obj.username = i.username; obj.security = i.security; obj.answer = i.answer; this.Hide(); obj.Show(); break; } } //if username not matches with username in database then gives error if (!f) { MessageBox.Show("Invalid Username!"); } txtusername.Focus(); }
private void picBack_Click(object sender, EventArgs e) { frmForgot_Pass2 obj = new frmForgot_Pass2(); obj.username = username; obj.security = security; obj.answer = answer; this.Hide(); obj.Show(); }