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

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

                if (reader.Read())
                {
                    Club club = new Club();
                    club.setClubName(reader.GetString(2));
                    club.setClubFees(reader.GetDecimal(3));
                    club.setClubDescription(reader.GetString(4));

                    // show value for edit
                    societyName.Text = club.getClubName();
                    societyFees.Text = club.getClubFees();
                    beautifyDescription();
                    societyDescription.Text = club.getClubDescription();

                    // automate value on textfield
                    societyNameTextbox.Text        = club.getClubName();
                    feesLabel.Text                 = club.getClubFees();
                    societyDescriptionTextbox.Text = club.getClubDescription();

                    // close connection
                    connect.close();
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("error " + ex);
            }
        }
Exemplo n.º 2
0
        private void updateClubDatabase(string session, string clubname)
        {
            if (clubname == "")
            {
                return;
            }
            else
            {
                President p       = new President();
                SqlConn   connect = new SqlConn();
                connect.open();
                SqlCommand command = new SqlCommand();
                command.Connection  = connect.sqlConnection;
                command.CommandText = "update dbo.club set president_id = " + p.getPresidentID(session) +
                                      " where club_name = '" + clubname + "'";

                SqlDataReader reader = command.ExecuteReader();
                reader.Close();
                connect.close();
            }
        }
Exemplo n.º 3
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            validateEmptyField();
            if (insertData)
            {
                President p = new President();
                try
                {
                    SqlConn connect = new SqlConn();
                    connect.open();
                    SqlCommand command = new SqlCommand();
                    command.Connection  = connect.sqlConnection;
                    command.CommandText = "update dbo.President set president_name = '" + updateNameTextbox.Text + "', president_email = '" + updateEmailTextbox.Text +
                                          "', president_gender = '" + genderCombobox.Text + "',  president_password = '******' where president_id = " + p.getPresidentID(session);

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

                    // register updated name for session on data retrieval
                    p.setPresidentName(updateNameTextbox.Text);
                    this.session = p.getPresidentName();

                    MessageBox.Show("Your account details had update successfully! ");
                    openView();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("error" + ex);
                }

                openView();
                loadPresidentData();
            }
            else
            {
                MessageBox.Show("Update action is INVALID \n because some field is empty or wrong. ");
            }
        }
Exemplo n.º 4
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();
                }
            }
        }
Exemplo n.º 5
0
        public int getClubIDFromPresident(string presidentName)
        {
            President pres        = new President();
            int       presidentID = pres.getPresidentID(presidentName);
            SqlConn   connect     = new SqlConn();

            connect.open();
            SqlCommand command = new SqlCommand();

            command.Connection  = connect.sqlConnection;
            command.CommandText = "select club_id from dbo.Club where president_id = " + presidentID;

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                clubID = Convert.ToInt32(reader["club_id"].ToString());
            }

            reader.Close();
            connect.close();

            return(clubID);
        }
Exemplo n.º 6
0
        public string getClubNameDisplay(string presidentName)
        {
            President pres        = new President();
            int       presidentID = pres.getPresidentID(presidentName);
            SqlConn   connect     = new SqlConn();

            connect.open();
            SqlCommand command = new SqlCommand();

            command.Connection  = connect.sqlConnection;
            command.CommandText = "select club_name from dbo.Club where president_id = " + presidentID;

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                clubName_display = reader["club_name"].ToString();
            }

            reader.Close();
            connect.close();

            return(clubName_display);
        }