private void button1_Click(object sender, EventArgs e) { panelHint.Visible = false; lblPH.Text = "Password Hint"; TxtPW.Text = ""; TxtPW.Focus(); }
private void TxtUser_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (TxtUser.Text == "") { MessageBox.Show("Please Enter the User ID!", "Invalied Data!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { PasswordHint(); TxtPW.Focus(); } } }
private void CmdLogin_Click(object sender, EventArgs e) { if (TxtUser.Text != "" && TxtPW.Text != "") { con.Open(); OleDbCommand cmd1 = new OleDbCommand("select * from UserDetails where UserID='" + TxtUser.Text.Trim() + "' ", con); cmd1.Connection = con; rdr = cmd1.ExecuteReader(); bool temp = false; while (rdr.Read()) { lblPW.Text = rdr["Password1"].ToString(); lblUser.Text = rdr["UserName"].ToString(); lblULevel.Text = rdr["UserLevel"].ToString(); lblPWHint.Text = rdr["PWHint"].ToString(); lblColor.Text = rdr["BGColor"].ToString(); temp = true; } con.Close(); if (temp == false) { MessageBox.Show("Please Enter the correct User ID, or Sign Up your details!", "MESSAGE BOX", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtUser.Text = ""; TxtPW.Text = ""; TxtUser.Focus(); return; } else { if (TxtPW.Text == lblPW.Text) { FrmLoad FLoad = new FrmLoad(); Control[] ctrlsID = FLoad.Controls.Find("lblUser", false); Label lbl1 = (Label)ctrlsID[0]; lbl1.Text = lblUser.Text; Control[] ctrlsUL = FLoad.Controls.Find("lblULevel", false); Label lbl2 = (Label)ctrlsUL[0]; lbl2.Text = lblULevel.Text; Control[] ctrlsIDD = FLoad.Controls.Find("lblID", false); Label lbl3 = (Label)ctrlsIDD[0]; lbl3.Text = TxtUser.Text; Control[] ctrlsPW = FLoad.Controls.Find("lblPW", false); Label lbl4 = (Label)ctrlsPW[0]; lbl4.Text = TxtPW.Text; Control[] ctrlsPWh = FLoad.Controls.Find("lblPWHint", false); Label lbl5 = (Label)ctrlsPWh[0]; lbl5.Text = lblPWHint.Text; Control[] ctrlsClr = FLoad.Controls.Find("lblColor", false); Label lbl6 = (Label)ctrlsClr[0]; lbl6.Text = lblColor.Text; this.Visible = false; FLoad.Show(); return; } else { MessageBox.Show("Please Enter the Valied Password!", "Invalied Data!", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtPW.Text = ""; TxtPW.Focus(); return; } } } else { MessageBox.Show("Please Enter the Valied User ID and Password!", "Invalied Data!", MessageBoxButtons.OK, MessageBoxIcon.Error); TxtUser.Text = ""; TxtPW.Text = ""; TxtUser.Focus(); return; } }