示例#1
0
        private string identifyExpiredAttendanceQuery()
        {
            President p = new President();
            Meeting   m = new Meeting(session);

            expiredMeetingID = m.getExpiredMeetingID();

            if (expiredMeetingID.Count.Equals(0))
            {
                string query = "delete from attendance where meeting_id in (0)";
                return(query);
            }
            else
            {
                string queryAttendance = "delete from attendance where meeting_id in (";

                for (int i = 0; i < expiredMeetingID.Count; i++)
                {
                    if (i.Equals(expiredMeetingID.Count - 1))
                    {
                        queryAttendance += expiredMeetingID[i];
                    }
                    else
                    {
                        queryAttendance += expiredMeetingID[i] + ",";
                    }
                }
                queryAttendance += ") and president_id = " + p.getPresidentID(session);

                return(queryAttendance);
            }
        }
示例#2
0
        private void submitButton_Click(object sender, EventArgs e)
        {
            for (int i = attendanceList.Rows.Count - 1; i >= 0; i--)
            {
                bool attend = (bool)attendanceList.Rows[i].Cells[4].Value;

                if (attend)
                {
                    Member  m  = new Member();
                    Meeting mt = new Meeting(session);
                    mt.setName(meetingCombobox.Text);
                    President p = new President();

                    string name = attendanceList.Rows[i].Cells[0].Value.ToString();

                    SqlConn connect = new SqlConn();
                    connect.open();
                    SqlCommand command = new SqlCommand();
                    command.Connection  = connect.sqlConnection;
                    command.CommandText = "insert into dbo.Attendance values (" + m.getMemberID(name) + ","
                                          + mt.getMeetingID() + "," + p.getPresidentID(session) + ",'1')";

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

            MessageBox.Show("Your attendance had updated! ");
            navigation();
        }
示例#3
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();
            }
        }
示例#4
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);
        }
示例#5
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);
        }
示例#6
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. ");
            }
        }
示例#7
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);
            }
        }
        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();
                    societyDescription.Text = club.getClubDescription();

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

                    // close connection
                    connect.close();
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("error " + ex);
            }
        }
        private void updateSocietyButton_Click(object sender, EventArgs e)
        {
            President p           = new President();
            decimal   societyFees = Convert.ToDecimal(societyFeesTextbox.Text);

            try
            {
                SqlConn connect = new SqlConn();
                connect.open();
                SqlCommand command = new SqlCommand();
                command.Connection  = connect.sqlConnection;
                command.CommandText = "update dbo.Club set club_name = '" + societyNameTextbox.Text + "', club_fees = " + societyFees +
                                      ", club_description = '" + societyDescriptionTextbox.Text + "' where president_id = " + p.getPresidentID(session);

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

                MessageBox.Show("Your society had update successfully! ");
                showView();
            }
            catch (Exception ex)
            {
                MessageBox.Show("error" + ex);
            }
            loadClubData();
            showView();
        }
        private void updateButton_Click(object sender, EventArgs e)
        {
            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();

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