Пример #1
0
        private void btnLogOut_Click(object sender, EventArgs e)
        {
            this.Hide();
            Login1 login1 = new Login1();

            login1.Show();
        }
        private void btnRegister_Click(object sender, EventArgs e)
        {
            if (txtFNm.Text == "")
            {
                MessageBox.Show("Required !!! Please Enter Name");
            }
            else if (txtLNm.Text == "")
            {
                MessageBox.Show("Required !!! Please Enter Last Name");
            }
            else if (dateTimePicker1.Text == "")
            {
                MessageBox.Show("Required !!! Please Enter Date of Birth ");
            }
            else if (txtPwd.Text == "")
            {
                MessageBox.Show("Required !!! Please Enter Password");
            }
            else if (txtConfirmPwd.Text == "")
            {
                MessageBox.Show("Required !!! Please Enter Confirm Password");
            }
            else if (txtPwdHint.Text == "")
            {
                MessageBox.Show("Required !!! Please Enter Password");
            }
            else if (txtSecurityQue1.Text == "")
            {
                MessageBox.Show("Required !!! Please Enter Birth place");
            }
            else if (txtSecurityQue2.Text == "")
            {
                MessageBox.Show("Required !!! Please Enter your nick name");
            }
            else if (txtSecurityQue3.Text == "")
            {
                MessageBox.Show("Required !!! Please Enter your mother's name");
            }
            else
            {
                using (SqlConnection sqlCon = new SqlConnection(ConnectionString))
                {
                    sqlCon.Open();
                    SqlCommand sqlCmd = new SqlCommand("RegisterAdmin", sqlCon);
                    sqlCmd.CommandType = CommandType.StoredProcedure;

                    sqlCmd.Parameters.AddWithValue("@UserName", txtUNm.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@FirstName", txtFNm.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@LastName", txtLNm.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@DateOfBirth ", dateTimePicker1.Value);
                    sqlCmd.Parameters.AddWithValue("@ContactInfo", txtContact.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@Password", txtPwd.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@ConfirmPassword", txtConfirmPwd.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@PasswordHint", txtPwdHint.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@SecurityQue1", txtSecurityQue1.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@SecurityQue2", txtSecurityQue2.Text.Trim());
                    sqlCmd.Parameters.AddWithValue("@SecurityQue3", txtSecurityQue3.Text.Trim());
                    sqlCmd.ExecuteNonQuery();
                    sqlCon.Close();
                    MessageBox.Show("Registered successfully");
                    Clear();
                    this.Hide();
                    Login1 login = new Login1();
                    login.Show();
                }
            }
        }
Пример #3
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            if (txtPwd.Text == "")
            {
                MessageBox.Show("Required !!! Please Enter Password");
            }
            else if (txtConfirmPwd.Text == "")
            {
                MessageBox.Show("Required !!! Please Enter Confirm Password");
            }

            else if (txtSecurityQue1.Text == "")
            {
                MessageBox.Show("Required !!! Please Enter Birth place");
            }
            else if (txtSecurityQue2.Text == "")
            {
                MessageBox.Show("Required !!! Please Enter your nick name");
            }
            else if (txtSecurityQue3.Text == "")
            {
                MessageBox.Show("Required !!! Please Enter your mother's name");
            }
            else
            {
                using (SqlConnection sqlCon = new SqlConnection(ConnectionString))
                {
                    SqlDataAdapter sqlAdpt = new SqlDataAdapter("select UserName,SecurityQue1,SecurityQue2,SecurityQue3 from tbl_RegisterAdmin where UserName='******'", sqlCon);
                    DataTable      dt      = new System.Data.DataTable();
                    sqlAdpt.Fill(dt);
                    string unm = txtUNm.Text.ToString(), sq1 = txtSecurityQue1.Text.ToString(), sq2 = txtSecurityQue2.Text.ToString(),
                           sq3 = txtSecurityQue3.Text.ToString();
                    {
                        try
                        {
                            if (dt.Rows.Count > 0)
                            {
                                if (dt.Rows[0][0].ToString() == unm & dt.Rows[0][1].ToString() == sq1 & dt.Rows[0][2].ToString() == sq2 & dt.Rows[0][3].ToString() == sq3)
                                {
                                    sqlCon.Open();
                                    SqlCommand sqlCmd = new SqlCommand("ResetPassword", sqlCon);
                                    sqlCmd.CommandType = CommandType.StoredProcedure;
                                    sqlCmd.Parameters.AddWithValue("@UserName", txtUNm.Text.Trim());
                                    sqlCmd.Parameters.AddWithValue("@Password", txtPwd.Text.Trim());
                                    sqlCmd.Parameters.AddWithValue("@ConfirmPassword", txtConfirmPwd.Text.Trim());
                                    sqlCmd.ExecuteNonQuery();
                                    sqlCon.Close();
                                    MessageBox.Show("Password reset successfully");
                                    this.Hide();
                                    Login1 login = new Login1();
                                    login.Show();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Please enter correct Answer");
                            }
                        }

                        catch (Exception ex)
                        {
                            MessageBox.Show("Error", ex.Message);
                        }
                    }
                }
            }
        }