Saturday, 30 August 2014

how to create new user account in C#

    if (txtUsername.Text.TrimStart () != "")
            {
                if (txtNewPass.Text.TrimStart () != "")
                {
                    if (txtConPass.Text.TrimStart () != "")
                    {
                        if (txtNewPass.Text.TrimStart () == txtConPass.Text.TrimStart ())
                        {
                            string str = "Insert into T_LoginMain(username,pw,usertype)Values('" + txtUsername.Text.TrimStart () + "','" + txtConPass.Text.TrimStart () + "','" + cbxUserType.Text.TrimStart () + "')";
                            con = new OleDbConnection(dbCon());
                            OleDbCommand cmd = new OleDbCommand(str, con);
                            con.Open();
                            cmd.ExecuteNonQuery();
                            con.Close();
                            MessageBox.Show("User Created", "Created", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            TextClear();
                        }
                        else
                        {
                            MessageBox.Show("New Password and Confirm Password must be same", "Same Password?", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtNewPass.Focus();
                            txtNewPass.SelectAll();
                            return;
                        }

                    }
                    else
                    {
                        MessageBox.Show("Enter Password", "Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtConPass.Focus();
                        txtConPass.SelectAll();
                        return;
                    }

                }
                else
                {
                    MessageBox.Show("Enter Password", "Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtNewPass.Focus();
                    txtNewPass.SelectAll();
                    return;
                }
            }
            else
            {
                MessageBox.Show("Enter Username", "Username", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUsername.Focus();
                txtUsername.SelectAll();
                return;
            }

No comments:

Post a Comment