Exemplo n.º 1
0
        private void loadPresidentData()
        {
            President p = new President();

            try
            {
                SqlConn connect = new SqlConn();
                connect.open();
                SqlCommand command = new SqlCommand();
                command.Connection  = connect.sqlConnection;
                command.CommandText = "select * from dbo.President where president_id = " + p.getPresidentID(session);
                SqlDataReader reader = command.ExecuteReader();

                if (reader.Read())
                {
                    President pred = new President();
                    pred.setPresidentName(reader.GetString(2));
                    pred.setPresidentEmail(reader.GetString(3));
                    pred.setPresidentGender(reader.GetString(4));
                    pred.setPresidentPassword(reader.GetString(5), reader.GetString(5));

                    // show value for edit
                    name.Text   = pred.getPresidentName();
                    email.Text  = pred.getPresidentEmail();
                    gender.Text = pred.getPresidentGender();
                    pw.Text     = pred.getPresidentPassword();

                    // automate value on textfield
                    updateNameTextbox.Text  = pred.getPresidentName();
                    pwTextbox.Text          = pred.getPresidentPassword();
                    genderCombobox.Text     = pred.getPresidentGender();
                    updateEmailTextbox.Text = pred.getPresidentEmail();


                    // close connection
                    connect.close();
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("error " + ex);
            }
        }
Exemplo n.º 2
0
        private void registerButton_Click(object sender, EventArgs e)
        {
            validateEmptyField();

            if (insertPresidentData)
            {
                President pred = new President();
                pred.setPresidentName(nameTextbox.Text);
                pred.setPresidentEmail(emailTextbox.Text);
                pred.setPresidentGender(genderCombobox.Text);
                pred.setPresidentPassword(pwTextbox.Text, retypepwTextbox.Text);

                if (pred.getPasswordBoolean() == false)
                {
                    MessageBox.Show("Your password does not match, please retype again.");
                }
                else
                {
                    SqlConn connect = new SqlConn();
                    connect.open();
                    SqlCommand command = new SqlCommand();
                    command.Connection  = connect.sqlConnection;
                    command.CommandText = "insert into dbo.President values ('" + getClubID(posCombobox.Text) +
                                          "','" + pred.getPresidentName() + "','" + pred.getPresidentEmail() + "','"
                                          + pred.getPresidentGender() + "','" + pred.getPresidentPassword() + "');";

                    SqlDataReader reader = command.ExecuteReader();
                    reader.Close();
                    connect.close();

                    MessageBox.Show("Your account had been created successfully! ");

                    Dashboard dashboard = new Dashboard(pred.getPresidentName(), posCombobox.Text);
                    this.Hide();
                    dashboard.ShowDialog();
                }
            }
        }