示例#1
0
        private void Create_Click(object sender, EventArgs e)
        {
            conn = new OracleConnection(ordb);
            conn.Open();
            OracleCommand cmd = new OracleCommand();

            cmd.Connection  = conn;
            cmd.CommandText = "select username from useraccounts where username=:username";
            cmd.Parameters.Add("username", User_Name.Text);
            OracleDataReader dr = cmd.ExecuteReader();
            int count           = 0;

            while (dr.Read())
            {
                count++;
            }
            dr.Close();
            if (count != 0)
            {
                MessageBox.Show("UserName already taken");
                User_Name.Clear();
                Password.Clear();
                Confirm.Clear();
                conn.Close();
            }
            else if (Password.Text != Confirm.Text)
            {
                MessageBox.Show("Password doesn't match");
                Password.Clear();
                Confirm.Clear();
                conn.Close();
            }
            else
            {
                if (checkBox1.Checked)
                {
                    Global.Admin = 1;
                }

                OracleCommand cmd2 = new OracleCommand();
                cmd2.Connection  = conn;
                cmd2.CommandText = "insert into UserAccounts values (:username,:name,:password,:email,null,:phone,:flat,:building,:city,:street,:admin)";
                cmd2.Parameters.Add("username", User_Name.Text);
                cmd2.Parameters.Add("name", Name.Text);
                cmd2.Parameters.Add("password", Password.Text);
                cmd2.Parameters.Add("email", Email.Text);
                cmd2.Parameters.Add("phone", int.Parse(Phone.Text));
                cmd2.Parameters.Add("flat", int.Parse(Flat.Text));
                cmd2.Parameters.Add("building", int.Parse(building.Text));
                cmd2.Parameters.Add("city", City.Text);
                cmd2.Parameters.Add("street", int.Parse(Street.Text));
                cmd2.Parameters.Add("admin", Global.Admin);
                int r = cmd2.ExecuteNonQuery();
                MessageBox.Show("UserAccount Created");
                conn.Close();
                Global.CurrentUser = Name.Text;
                Search S = new Search();
                S.Show();
            }
        }
示例#2
0
 //重置登录表单
 private void Resetting_Button(object sender, RoutedEventArgs e)
 {
     User_Name.Clear();
     User_Password.Clear();
 }