Esempio n. 1
0
        private void buttonContinue_Click(object sender, EventArgs e)
        {
            /*if (checkBoxNewUser.CheckedChanged)
            {

            }
            else
            {*/
                try
                {
                    if (!(usernameTextBox.Text == string.Empty))
                    {
                        if (!(passwordTextBox.Text == string.Empty))
                        {
                            this.Close();
                            Welcome formW = new Welcome();
                            formW.Visible = true;

                            string connectionString = (@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\E860536\Source\Group_9\IPIMS_9\IPIMS_9\IPIMS_Group_9\IPIMS_Group_9\IPIMS_9.mdf;Integrated Security=True");
                            using (SqlConnection connection = new SqlConnection(connectionString))
                            {
                                SqlCommand cmdLogin = new SqlCommand("SELECT (Username,Password) FROM user_data where Username = '******' and Password = '******'");
                                connection.Open();
                                cmdLogin.ExecuteNonQuery();

                            }

                            /*con = new SqlConnection(@"data source=(localdb)\v11.0;initial catalog=IPIMS_9;Integrated Security=SSPI");
                            con.Open();*/
                            /*SqlCommand cmd = new SqlCommand("select userid,password from login where userid='" + usernameTextBox.Text + "'and password='******'", con);
                            SqlDataAdapter da = new SqlDataAdapter(cmd);
                            DataTable dt = new DataTable();
                            da.Fill(dt);*/
                            /*if (dt.Rows.Count > 0 && dt.Rows.Count < 2)
                            {
                                this.Close();
                                Welcome formW = new Welcome();
                                formW.Visible = true;
                            }
                            else
                            {
                                MessageBox.Show("Invalid Login please check username and password, and try again.");
                            }*/
                            //con.Close();
                        }
                    }
                }

                catch (Exception ex)
                {
                    //throw ex;
                }
        }
Esempio n. 2
0
        private void buttonRegister_Click(object sender, EventArgs e)
        {
            // Set variables with the values from the textboxes
            classification = classificationComboBox.Text;
            first_name = first_NameTextBox.Text;
            last_name = last_NameTextBox.Text;
            // date_of_birth = date_of_BirthDateTimePicker.Value.Date;
            gender = genderComboBox.Text;
            street_address = street_AddressTextBox.Text;
            city = cityTextBox.Text;
            state = stateTextBox.Text;
            zip_code = zip_CodeTextBox.Text;
            password = passwordTextBox.Text;
            username = usernameTextBox.Text;
            email = emailTextBox.Text;
            phone_number = phone_NumberTextBox.Text;

            if (classification == "Patient")
            {
                social_security_number = social_Security_NumberTextBox.Text;
                age = int.Parse(ageTextBox.Text);
                // need to calculate the age...
                // for testing
                // age = ageTextBox.Text;
                country_of_origin = country_of_OriginTextBox.Text;
                insurance_Provider = health_Insurance_ProviderTextBox.Text;
                insurance_Contact_Number = health_Insurance_Contact_NumberTextBox.Text;
                medical_history = medical_HistoryTextBox.Text;
                doctor = doctor_NameComboBox.Text;
            }
            // After user presses the Register button, they will receive a prompt
            // Do they want to login as the newly registered user? Yes, No, or Cancel
            string message = "Would you like to login as this user now?";
            string title = "Do you want to Login as this newly registered user?";
            MessageBoxButtons buttons = MessageBoxButtons.YesNoCancel;
            DialogResult result = MessageBox.Show(message, title, buttons);
            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                //Register user
                Register();

                //Show the LoggingIn form for user to login
                this.Close();
                LoggingIn formLI = new LoggingIn();
                formLI.Visible = true;
            }
            else if (result == System.Windows.Forms.DialogResult.No)
            {
                //Register user
                Register();

                //Show the Welcome form for current user to continue using IPIMS
                this.Close();
                try
                {
                    Welcome formW = new Welcome();
                    formW.Visible = true;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else if (result == System.Windows.Forms.DialogResult.Cancel)
            {
                // Do Nothing, and return to registration form
            }
        }