예제 #1
0
        protected void Unnamed_Click(object sender, EventArgs e)
        {
            string date = default_datetimepicker.Text;

            if(String.IsNullOrEmpty(date))
            {
                date = "10/10/2010";
            }

            string[] words = date.Split('/');

            DateTime dt = new DateTime(Convert.ToInt32(words[2]), Convert.ToInt32(words[1]), Convert.ToInt32(words[0]));

            string gender = "";
            string address = "";

            if (Password.Text.Equals(ConfirmPassword.Text) && dt < DateTime.Now)
            {
                string firstName = FName.Text;
                string surname = Surname.Text;
                string email = Email.Text;
                string contactNumber = ContactNumber.Text;
                address = PhysicalAddress.Text;
                string password = Password.Text;
                int securityRoleNumber = 1;
                int cityNumber = Convert.ToInt32(CityDDL.SelectedIndex)+1;
                Boolean active = true;

                User newuser = new User(0, firstName, surname, email, contactNumber, address, password, securityRoleNumber, cityNumber, dt, gender, active);
                int newUserNumber = 0;

                string test = newuser.InsertNewUser(newuser);

                foreach (string s in newuser.LastUserNumber())
                {
                    newUserNumber = Convert.ToInt32(s);
                }
                Client newClient = new Client();
                newClient.InsertNewClient(newUserNumber, "Client", true);

                Application.Add("username", firstName);
                Application.Add("UserNumber", newUserNumber);
                Application.Add("UserSecRole", "1");
                Response.Redirect("./default");

            }
            else if ( dt > DateTime.Now)
            {
                errorbirth.Visible = true;
                errorbirth.Text = "Please Select a Valid Birth Date";
            }
            else if (!Password.Text.Equals(ConfirmPassword.Text))
            {
                errorbirth.Visible = true;
                errorbirth.Text = "The password fields did not match";
            }
        }