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();
        }
예제 #2
0
        private void addDataIntoRegister()
        {
            Club   club   = new Club();
            Member member = new Member();

            // get student id for register table
            member.setName(studentNameTextbox.Text);
            studentID = member.getMemberID(member.getName());

            // get club id for register table
            string clubName = club.getClubNameDisplay(session);
            int    clubID   = club.getClubIDFromPresident(session);

            SqlConn connect = new SqlConn();

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

            command.Connection  = connect.sqlConnection;
            command.CommandText = "insert into dbo.register values(" + studentID + "," + clubID + ",CURRENT_TIMESTAMP, " + club.getClubFeesFromDb(clubID) + ", '0')";
            SqlDataReader reader = command.ExecuteReader();

            reader.Close();
            connect.close();
        }
예제 #3
0
 private void signInButton_Click(object sender, EventArgs e)
 {
     try
     {
         SqlConn connect = new SqlConn();
         connect.open();
         SqlCommand command = new SqlCommand();
         command.Connection  = connect.sqlConnection;
         command.CommandText = "select * from dbo.President where PRESIDENT_NAME = '" + usernameTextbox.Text + "' and PRESIDENT_PASSWORD = '******'";
         SqlDataReader reader = command.ExecuteReader();
         if (reader.Read())
         {
             reader.Close();
             connect.close();
             createDashboard(usernameTextbox.Text); // proceed to dashboard if login criteria is correct
         }
         else
         {
             MessageBox.Show("Incorrect username and password combination.");
             reader.Close();
             connect.close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("error" + ex);
     }
 }
예제 #4
0
        public int getSecureMeetingID()
        {
            Club    club    = new Club();
            SqlConn connect = new SqlConn();

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

            command.Connection  = connect.sqlConnection;
            command.CommandText = "select meeting_id from dbo.Meeting where meeting_name = '"
                                  + getMeetingName()
                                  + "' and meeting_location = '" + getMeetingLocation()
                                  + "' and meeting_description = '" + getMeetingDescription()
                                  + "' and meeting_starttime = '" + getStartTime()
                                  + "' and meeting_endtime = '" + getEndTime()
                                  + "' and club_id = " + club.getClubIDFromPresident(session);

            SqlDataReader reader = command.ExecuteReader();

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

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

            return(meetingID);
        }
        private void createButton_Click(object sender, EventArgs e)
        {
            validateEmptyField();
            if (insertClubData)
            {
                decimal societyFees = Convert.ToDecimal(societyFeesTextbox.Text);
                try
                {
                    SqlConn connect = new SqlConn();
                    connect.open();
                    SqlCommand command = new SqlCommand();
                    command.Connection  = connect.sqlConnection;
                    command.CommandText = "insert into dbo.Club values (NULL, '" + societyNameTextbox.Text + "'," + societyFees + ",'" + societyDescriptionTextbox.Text + "');";

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

                    MessageBox.Show("Your society had created successfully, please click [Refresh] to display your society in the list. ");
                    this.Hide();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("error" + ex);
                }
            }
        }
예제 #6
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            validateEmptyField();
            if (insertStudentData)
            {
                Member member = new Member(studentNameTextbox.Text, Convert.ToInt64(studenthpTextbox.Text), studentEmailTextbox.Text,
                                           studentGenderCombobox.Text, intakeCodeTextbox.Text);

                SqlConn connect = new SqlConn();
                connect.open();
                SqlCommand command = new SqlCommand();
                command.Connection  = connect.sqlConnection;
                command.CommandText = "delete from dbo.Register where student_id = " + studentID;
                SqlDataReader reader = command.ExecuteReader();

                deleteMemberFromStudent();


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

                displayAllField(); // display all the data
                clearField();      // clear text field

                // return success message
                messageText.ForeColor = System.Drawing.Color.Green;
                messageText.Text      = "Member information DELETE successfully ! ";
            }
            else
            {
                // warning message
                messageText.ForeColor = System.Drawing.Color.Red;
                messageText.Text      = "DELETE action is INVALID \n because you haven't select a member! ";
            }
        }
        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();
        }
예제 #8
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();
        }
예제 #9
0
        public int getMemberID()
        {
            SqlConn connect = new SqlConn();

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

            command.Connection  = connect.sqlConnection;
            command.CommandText = "select student_id from dbo.Student where student_name = '" + getName()
                                  + "' and student_handphone = " + getHP()
                                  + " and student_email = '" + getEmail()
                                  + "' and student_gender = '" + getGender()
                                  + "' and student_intakecode = '" + getIntakeCode() + "'";

            SqlDataReader reader = command.ExecuteReader();

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

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

            return(memberID);
        }
예제 #10
0
        // delete Member from student table
        private void deleteMemberFromStudent()
        {
            SqlConn connect = new SqlConn();

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

            command.Connection  = connect.sqlConnection;
            command.CommandText = "delete from dbo.Student where student_id = " + studentID;
            SqlDataReader reader = command.ExecuteReader();

            reader.Close();
            connect.close();
        }
예제 #11
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            validateEmptyField();
            if (insertMeetingData)
            {
                Meeting m = new Meeting(session);
                m.setName(nameTextbox.Text);
                m.setLocation(locationTextbox.Text);
                m.setStartTime(datePicker.Value, startTimePicker.Value);
                m.setEndTime(datePicker.Value, endTimePicker.Value);
                m.setDescription(descriptionTextbox.Text);
                m.calculateDuration();

                Club club = new Club();

                SqlConn connect = new SqlConn();
                connect.open();
                SqlCommand command = new SqlCommand();
                command.Connection  = connect.sqlConnection;
                command.CommandText = "update dbo.meeting set meeting_name = '" + m.getMeetingName()
                                      + "', meeting_location = '" + m.getMeetingLocation()
                                      + "', meeting_description = '" + m.getMeetingDescription()
                                      + "', meeting_starttime = '" + m.getStartTime()
                                      + "', meeting_endtime = '" + m.getEndTime()
                                      + "', meeting_duration = " + m.getDuration() +
                                      "where meeting_id = " + meetingID + " and club_id = " + club.getClubIDFromPresident(session);

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

                // success message
                messageText.ForeColor = System.Drawing.Color.Green;
                messageText.Text      = "Update meeting details successful. ";

                displayAllField();
                clearField();
            }
            else
            {
                MessageBox.Show("Your UPDATE action is INVALID because some field is empty or wrong");

                // warning message
                messageText.ForeColor = System.Drawing.Color.Red;
                messageText.Text      = "UPDATE action is INVALID \n because some field is empty or wrong ! ";
            }

            addButton.Visible = true;
        }
예제 #12
0
        private void deleteExpiredMeeting()
        {
            string  queryMeeting = identifyExpiredMeetingIDQuery();
            SqlConn connect      = new SqlConn();

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

            command.Connection  = connect.sqlConnection;
            command.CommandText = queryMeeting;

            SqlDataReader reader = command.ExecuteReader();

            reader.Close();
            connect.close();
        }
예제 #13
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            validateEmptyField();
            if (insertStudentData)
            {
                Member member = new Member(studentNameTextbox.Text, Convert.ToInt64(studenthpTextbox.Text), studentEmailTextbox.Text,
                                           studentGenderCombobox.Text, intakeCodeTextbox.Text);

                // get club id for register table
                Club club   = new Club();
                int  clubID = club.getClubIDFromPresident(session);

                SqlConn connect = new SqlConn();
                connect.open();
                SqlCommand command = new SqlCommand();
                command.Connection = connect.sqlConnection;

                command.CommandText = "update s set s.student_name = '" + member.getName() +
                                      "', s.student_handphone = " + member.getHP() +
                                      ", s.student_email = '" + member.getEmail() +
                                      "', s.student_gender = '" + member.getGender() +
                                      "', s.student_intakecode = '" + member.getIntakeCode() +
                                      "' from student as s inner join register as r on s.student_id = r.student_id inner join club as c on r.club_id = c.club_id where r.student_id = " +
                                      studentID + " and r.club_id = " + clubID;

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

                displayAllField(); // display all the data
                clearField();      // clear text field

                // return success message
                messageText.ForeColor = System.Drawing.Color.Green;
                messageText.Text      = "Member information UPDATE successfully ! ";
            }
            else
            {
                // warning message
                messageText.ForeColor = System.Drawing.Color.Red;
                messageText.Text      = "UPDATE action is INVALID \n because some field is empty or wrong ! ";
            }

            addButton.Visible = true;
        }
예제 #14
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);
            }
        }
예제 #15
0
        private void updateButton_Click(object sender, EventArgs e)
        {
            validateEmptyField();
            if (insertStudentData)
            {
                // calculate the fees even though without pressing the button
                calculateFees();

                // determine the paid status if the fees left is zero
                Fee f = new Fee();
                f.setFeesLeft(leftFees);
                int paidStatus = f.calculatePaidStatus();

                // get club id for register table
                Club club   = new Club();
                int  clubID = club.getClubIDFromPresident(session);

                // get student id for register table
                Member member = new Member();
                member.setName(studNameLabel.Text);
                int studentID = member.getMemberID(member.getName());

                SqlConn connect = new SqlConn();
                connect.open();
                SqlCommand command = new SqlCommand();
                command.Connection = connect.sqlConnection;

                command.CommandText = "update r set r.member_fees = " + leftFees + ", member_paid = " + paidStatus + " from student as s inner join register as r on s.student_id = r.student_id inner join club as c on r.club_id = c.club_id where r.student_id = " +
                                      studentID + " and r.club_id = " + clubID;
                SqlDataReader reader = command.ExecuteReader();
                reader.Close();
                connect.close();

                displayFeeSummary(); // display all the fees summary
                clearField();        // clear text field */

                MessageBox.Show("The club fee had UPDATED successfully! ");
            }
            else
            {
                MessageBox.Show("UPDATE action is INVALID \nbecause some field is empty or wrong !");
            }
        }
예제 #16
0
        private void addButton_Click(object sender, EventArgs e)
        {
            validateEmptyField();
            if (insertMeetingData)
            {
                Meeting m = new Meeting(session);
                m.setName(nameTextbox.Text);
                m.setLocation(locationTextbox.Text);
                m.setStartTime(datePicker.Value, startTimePicker.Value);
                m.setEndTime(datePicker.Value, endTimePicker.Value);
                m.setDescription(descriptionTextbox.Text);
                m.calculateDuration();

                Club club = new Club();

                SqlConn connect = new SqlConn();
                connect.open();
                SqlCommand command = new SqlCommand();
                command.Connection  = connect.sqlConnection;
                command.CommandText = "insert into dbo.meeting values (" + club.getClubIDFromPresident(session) +
                                      ",'" + m.getMeetingName() + "','" + m.getMeetingLocation() + "','" + m.getMeetingDescription() +
                                      "','" + m.getStartTime() + "','" + m.getEndTime() + "'," + m.getDuration() + ")";

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

                // success message
                messageText.ForeColor = System.Drawing.Color.Green;
                messageText.Text      = "Create meeting successful. ";

                displayAllField();
                clearField();
            }
            else
            {
                MessageBox.Show("Your action is INVALID because some field is empty or wrong");

                // warning message
                messageText.ForeColor = System.Drawing.Color.Red;
                messageText.Text      = "INSERT action is INVALID \n because some field is empty or wrong ! ";
            }
        }
예제 #17
0
        // display data in datagridview base on query
        private void displayData(string query)
        {
            try
            {
                SqlConn connect = new SqlConn();
                connect.open();
                SqlCommand command = new SqlCommand();
                command.Connection  = connect.sqlConnection;
                command.CommandText = query;

                SqlDataAdapter storage   = new SqlDataAdapter(command); //store the data get from database
                DataTable      datatable = new DataTable();             //put data into this table
                storage.Fill(datatable);
                attendanceList.DataSource = datatable;                  //datagridtable get data from the data table
                connect.close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex);
            }

            DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();

            if (attendanceList.Columns.Contains("CheckBox"))
            {
                attendanceList.Columns.Remove("CheckBox");
            }

            chk.HeaderText = "Attendance";
            chk.Name       = "CheckBox";
            chk.FalseValue = false;
            attendanceList.Columns.Add(chk);

            foreach (DataGridViewColumn dc in attendanceList.Columns)
            {
                dc.ReadOnly = (dc.Index.Equals(4)) ? false : true;
            }

            foreach (DataGridViewRow row in attendanceList.Rows)
            {
                row.Cells[4].Value = false;
            }
        }
        private void loadDataIntoDetails()
        {
            Meeting m    = new Meeting(session);
            Club    club = new Club();

            m.setName(meetingNameComboBox.Text);
            try
            {
                SqlConn connect = new SqlConn();
                connect.open();
                SqlCommand command = new SqlCommand();
                command.Connection  = connect.sqlConnection;
                command.CommandText = "select * from dbo.Meeting where meeting_name = '" + m.getMeetingName() + "' and club_id = " + club.getClubIDFromPresident(session);
                SqlDataReader reader = command.ExecuteReader();

                if (reader.Read())
                {
                    m.setName(reader.GetString(2));
                    m.setLocation(reader.GetString(3));
                    m.setDescription(reader.GetString(4));
                    m.setStartDate(reader.GetDateTime(5));
                    m.setEndDate(reader.GetDateTime(6));


                    // automate value on textfield
                    nameLabel.Text        = m.getMeetingName();
                    locationLabel.Text    = m.getMeetingLocation();
                    startTimeLabel.Text   = m.getStartDate().ToString();
                    endTimeLabel.Text     = m.getEndDate().ToString();
                    descriptionLabel.Text = m.getMeetingDescription().ToString();
                    durationLabel.Text    = m.getReportDurationText().ToString();

                    // close connection
                    connect.close();
                    reader.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("error " + ex);
            }
        }
예제 #19
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);
            }
        }
예제 #20
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            validateEmptyField();
            if (insertMeetingData)
            {
                Meeting m = new Meeting(session);
                m.setName(nameTextbox.Text);
                m.setLocation(locationTextbox.Text);
                m.setStartTime(datePicker.Value, startTimePicker.Value);
                m.setEndTime(datePicker.Value, endTimePicker.Value);
                m.setDescription(descriptionTextbox.Text);
                m.calculateDuration();

                Club club = new Club();

                SqlConn connect = new SqlConn();
                connect.open();
                SqlCommand command = new SqlCommand();
                command.Connection  = connect.sqlConnection;
                command.CommandText = "delete dbo.meeting where meeting_id = " + meetingID + " and club_id = " + club.getClubIDFromPresident(session);

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

                // success message
                messageText.ForeColor = System.Drawing.Color.Green;
                messageText.Text      = "Delete meeting details successful. ";

                displayAllField();
                clearField();
            }
            else
            {
                MessageBox.Show("Your Delete action is INVALID because you did not specifiy a meeting details");

                // warning message
                messageText.ForeColor = System.Drawing.Color.Red;
                messageText.Text      = "Your Delete action is INVALID because you did not specifiy a meeting details";
            }
        }
예제 #21
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();
            }
        }
예제 #22
0
        private void displayAttendance(string query)
        {
            try
            {
                SqlConn connect = new SqlConn();
                connect.open();
                SqlCommand command = new SqlCommand();
                command.Connection  = connect.sqlConnection;
                command.CommandText = query;

                SqlDataAdapter storage   = new SqlDataAdapter(command); //store the data get from database
                DataTable      datatable = new DataTable();             //put data into this table
                storage.Fill(datatable);
                attendanceList1.DataSource = datatable;                 //datagridtable get data from the data table
                connect.close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("" + ex);
            }
        }
예제 #23
0
        private int getClubID(string clubName)
        {
            SqlConn connect = new SqlConn();

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

            command.Connection  = connect.sqlConnection;
            command.CommandText = "select club_id from dbo.Club where club_name = '" + clubName + "'";

            SqlDataReader reader = command.ExecuteReader();

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

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

            return(clubID);
        }
예제 #24
0
        public int getMeetingID()
        {
            SqlConn connect = new SqlConn();

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

            command.Connection = connect.sqlConnection;
            //command.CommandText = "select meeting_id from dbo.Meeting where club_name = " + clubName;

            SqlDataReader reader = command.ExecuteReader();

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

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

            return(meetingID);
        }
예제 #25
0
        // add button helps insert student data into database.
        private void addButton_Click(object sender, EventArgs e)
        {
            validateEmptyField();
            if (insertStudentData)
            {
                Member member = new Member(studentNameTextbox.Text, Convert.ToInt64(studenthpTextbox.Text), studentEmailTextbox.Text,
                                           studentGenderCombobox.Text, intakeCodeTextbox.Text);


                SqlConn connect = new SqlConn();
                connect.open();
                SqlCommand command = new SqlCommand();
                command.Connection  = connect.sqlConnection;
                command.CommandText = "insert into dbo.Student values ('" + member.getName() + "'," + member.getHP() + ",'"
                                      + member.getEmail() + "','" + member.getGender() + "','" + member.getIntakeCode() + "')";
                SqlDataReader reader = command.ExecuteReader();
                reader.Close();
                connect.close();


                //execute another query insert into register table
                addDataIntoRegister();

                displayAllField(); // display all the data
                clearField();      // clear text field

                // return success message
                messageText.ForeColor = System.Drawing.Color.Green;
                messageText.Text      = "Member information INSERT successfully ! ";
            }
            else
            {
                MessageBox.Show("Your action is INVALID because some field is empty or wrong");

                // warning message
                messageText.ForeColor = System.Drawing.Color.Red;
                messageText.Text      = "INSERT action is INVALID \n because some field is empty or wrong";
            }
        }
예제 #26
0
        public int getPresidentID(string presidentName)
        {
            SqlConn connect = new SqlConn();

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

            command.Connection  = connect.sqlConnection;
            command.CommandText = "select president_id from dbo.President where president_name = '" + presidentName + "'";

            SqlDataReader reader = command.ExecuteReader();

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

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

            return(pred_id);
        }
예제 #27
0
        public decimal getClubFeesFromDb(int clubID)
        {
            SqlConn connect = new SqlConn();

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

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

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                clubFees = Convert.ToDecimal(reader["club_fees"].ToString());
            }

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

            return(clubFees);
        }
예제 #28
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. ");
            }
        }
예제 #29
0
        public int getMemberID(string memberName)
        {
            SqlConn connect = new SqlConn();

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

            command.Connection  = connect.sqlConnection;
            command.CommandText = "select student_id from dbo.Student where student_name = '" + memberName + "'";

            SqlDataReader reader = command.ExecuteReader();

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

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

            return(memberID);
        }
예제 #30
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();
                }
            }
        }