Ejemplo n.º 1
0
        /**
         * @desc Default constructor for creating new member from main menu.
         * This is for loading from main menu,
         * @params [none] No input parameter.
         * @return [none] No directly returned data.
         */
        public frm_member()
        {
            clMember = new Member();
            InitializeComponent();
            txt_membernum.Text = Utils.sGenerateNewMemberNumber();
            txt_membernum.ReadOnly = true;
            // Members who don't yet exist can't book equipment
            // This will be available once the "Save and Stay" is executed successfully
            button_equipmentbooking.Hide();
            // Members who don't yet exist can't book equipment
            // This will be available once the "Save and Stay" is executed successfully
            button_payments.Hide();
            // Members who don't yet exist can't be deleted
            button_remove.Hide();
            clMember.Id_file = "";
            cmb_type.SelectedIndex = 0;

            this.pictureBox1.BackgroundImage = global::Gym_administration.Properties.Resources.member_male_128;
            rd_male.Checked = true;
        }
Ejemplo n.º 2
0
 /**
   * @desc Constructor
   * Create a payment for a specific member
   * @params [int] id_member identifies the member who is to pay uniquely
   * @return [none] No directly returned data.
   */
 public frm_add_payment(int id_member)
 {
     InitializeComponent();
     // Create a member object
     clMember = new Member(id_member);
 }
Ejemplo n.º 3
0
        /**
         * @desc Constructor.
         * Loads in various info from tables CLASSES, CLASS_INSTANCE and STAFF for this class instance.
         * Loads in all atendants for this class instance.
         * @params [int]  id_class_instance identifies the class instance uniquely.
         * @return [none] No directly returned data.
         */
        public ClassInstance(int id_class_instance)
        {
            // Create mysql connection.
            mySqlConn conn = new mySqlConn();
            conn.connect();
            // Launch the query to return all all fields from a single class instance row of the CLASS_INSTANCE table.
            List<Hashtable> lhResultSet = conn.lhSqlQuery("SELECT ci.id_class_instance, c.name, c.type, c.description, s.firstName, s.id_staff, DATE_FORMAT(ci.date, '%d/%m/%Y') date, ci.start_time, ci.end_time, ci.id_room, c.id_class, ci.frequency FROM classes c, class_instance ci, staff s WHERE ci.id_class = c.id_class AND ci.id_staff = s.id_staff AND ci.id_class_instance = '" + id_class_instance + "'");

            // Check if we found the row
            if ((int)lhResultSet.Count > 0)
            {
                // Fill in all class instance fields with table data
                this.Id_class_instance = int.Parse(lhResultSet[0]["id_class_instance"].ToString());
                this.Id_staff = int.Parse(lhResultSet[0]["id_staff"].ToString());
                this.ClRoom = new Room(int.Parse(lhResultSet[0]["id_room"].ToString()));
                this.ClClass = new Class(int.Parse(lhResultSet[0]["id_class"].ToString()));
                this.DateStart = lhResultSet[0]["date"].ToString();
                this.EndTime = lhResultSet[0]["end_time"].ToString();
                this.StartTime = lhResultSet[0]["start_time"].ToString();
                this.Frequency = lhResultSet[0]["frequency"].ToString();

                // Create a list for storing member objects
                // Load in all records for the same class instance from CLASS_BOOKINGS table (each contains a different member ID)
                List<Hashtable> lhResultSetBookings = conn.lhSqlQuery("SELECT * FROM `gym`.`class_bookings` WHERE id_class_instance = '" + id_class_instance + "'");
                // If there is any class booking (any member enrolled) exist with the class instance id
                if ((int)lhResultSetBookings.Count > 0)
                {
                    // Create a list of attending members
                    foreach (Hashtable hClassBooking in lhResultSetBookings)
                    {
                        // Retrieve the member number from the current class booking
                        int id_member = int.Parse(hClassBooking["id_member"].ToString());
                        // Create a corresponding member object with all the particular member info loaded into it
                        Member clMember = new Member(id_member);
                        // If a member with this id_member actually exist, then add the member object to the list
                        if(clMember.Id_member != -1)
                            this.lclAttendants.Add(clMember);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 /**
   * @desc Constructor for creating new member, that was opened from member list.
   * (To be able to refresh member list after saving the new member)
   * @params [frm_member_list] frmMemberList: by taking this parameter there will be a reference
   * to the member list so it can be refreshed after saving the new member
   * @return [none] No directly returned data.
   */
 public frm_member(frm_member_list frmMemberList)
 {
     // Create reference to the parent form
     this.frmMemberList = frmMemberList;
     // create new member object
     clMember = new Member();
     InitializeComponent();
     txt_membernum.Text = Utils.sGenerateNewMemberNumber();
     txt_membernum.ReadOnly = true;
     // equipmentbooking, add payments and remove member buttons are hidden until saving (creating) the member
     button_equipmentbooking.Hide();
     button_payments.Hide();
     button_remove.Hide();
     // As this was opened from a member list there is no need to open a new one after closing
     button_saveOpen.Hide();
     clMember.Id_file = "";
     // Set a default type (Full time student)
     cmb_type.SelectedIndex = 0;
     // Set default gender and image
     rd_male.Checked = true;
     this.pictureBox1.BackgroundImage = global::Gym_administration.Properties.Resources.member_male_128;
 }
Ejemplo n.º 5
0
        /**
          * @desc Constructor for editing an existing member.
          * (To be able to refresh member list after saving the edited member)
          * @params [int] id_member: identifies the member to modify
          * @params [frm_member_list] frmMemberList: by taking this parameter there will be a reference
          * to the member list so it can be refreshed after saving the edited member
          * @return [none] No directly returned data.
          */
        public frm_member(int id_member, frm_member_list frmMemberList)
        {
            InitializeComponent();
            // Create reference to the parent form
            this.frmMemberList = frmMemberList;
            // Load in member details for specified member
            clMember = new Member(id_member);

            button_equipmentbooking.Show();
            button_payments.Show();
            button_remove.Show();
            button_saveOpen.Hide();

            if (clMember.Id_member < 1)
                MessageBox.Show("The member could not be found");
            else
            {
                // If the member was found, load in all member details into member object from database
                vLoadBookedList();
                 txt_firstName.Text = clMember.FirstName;
                 txt_lastName.Text = clMember.LastName;
                 chk_active.Checked = clMember.IsActive;
                 txt_dob.Text = Utils.sGetCsharpDateFromMysqlDate(clMember.Birthdate);
                 txt_address1.Text = clMember.Address_1;
                 txt_address2.Text = clMember.Address_2;
                 txt_city.Text = clMember.City;
                 txt_county.Text = clMember.County;
                 txt_emerg_mobile.Text = clMember.EmergContactMobile;
                 txt_emerg_name.Text = clMember.EmergContactName;
                 txt_emerg_telephone.Text = clMember.EmergContactPhone;
                 txt_emerg_relation.Text = clMember.EmergContactRelation;
                 txt_allergies.Text = clMember.MedicalAllergies;
                 txt_doctor_name.Text = clMember.MedicalDoctorName;
                 txt_medical_notes.Text = clMember.MedicalNotes;
                 txt_doctor_phone.Text = clMember.MedicalPhone;
                 txt_membernum.Text = clMember.Id_member.ToString();
                 txt_pc.Text = clMember.PostalCode;
                 cmb_type.Text = clMember.Type;
                 txt_email.Text = clMember.Email;
                 txt_mobile.Text = clMember.Mobile;
                 txt_telephone.Text = clMember.Phone;
                 txt_sid.Text = clMember.Sid;
                 txt_stcardnumber.Text = clMember.StudCardNumber;

                 // Create mysql connection
                mySqlConn conn = new mySqlConn();
                 conn.connect();
                // If there is a corresponing picture for this member, then load it in,
                // else show default image, depending on gender
                 if (clMember.Gender == "male")
                 {
                     rd_male.Checked = true;
                     if (clMember.Id_file == "")
                     {
                         this.pictureBox1.BackgroundImage = global::Gym_administration.Properties.Resources.member_male_128;
                     }
                     else
                     {

                         pictureBox1.Image = conn.loadImageFromDB(clMember.Id_file);
                     }
                 }
                 else
                 {
                     rd_female.Checked = true;
                     if (clMember.Id_file == "")
                     {
                         this.pictureBox1.BackgroundImage = global::Gym_administration.Properties.Resources.member_female_128;
                     }
                     else
                     {
                         pictureBox1.Image = conn.loadImageFromDB(clMember.Id_file);
                     }
                 }

            }
        }
Ejemplo n.º 6
0
        /**
          * @desc Executes when a grid cell is double clicked on the member list
          * It loads in the member belonging to the cell for editing
          * @params [none] No input parameter.
          * @return [none] No directly returned data.
          */
        private void dg_members_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                // Get the member id at current cell
                int id_member = int.Parse(dg_members.Rows[e.RowIndex].Cells[0].Value.ToString());
                // Create mysql connection
                mySqlConn conn = new mySqlConn();
                conn.connect();
                // If this member list was launched from the payment list panel
                if (this.frmPayments != null)
                {
                    // Launch Add Payment panel for the selected member
                    frm_add_payment frmAddPayment = new frm_add_payment(id_member);
                    frmAddPayment.ShowDialog();
                    // As this member list was launched from the payment list, refresh the payment list when this finishes
                    this.frmPayments.vloadDgPayments();
                    this.Close();
                    return;
                }
                // If this member list was launched from class instance list for adding new members
                if (this.clClassInstance.Id_class_instance != -1 && this.viewAttendants == false)
                {
                    // Confirm enrollment
                    DialogResult dialogResult = MessageBox.Show("Enroll this member to the class?", "Enroll member?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dialogResult == DialogResult.Yes)
                    {
                        // Check the room size
                        string query = "SELECT COUNT(*) q FROM gym.class_bookings WHERE id_class_instance = '" + this.clClassInstance.Id_class_instance + "'";
                        List<Hashtable> lhRes = conn.lhSqlQuery(query);
                        int currMembers = int.Parse(lhRes[0]["q"].ToString());
                        query = "SELECT r.size FROM gym.class_instance ci, gym.rooms r WHERE ci.id_room = r.id_room AND ci.id_class_instance = '" + this.clClassInstance.Id_class_instance + "'";
                        lhRes = conn.lhSqlQuery(query);
                        int maxMembers = int.Parse(lhRes[0]["size"].ToString());
                        if (maxMembers < currMembers + 1)
                        {
                            MessageBox.Show("Sorry! This room does not allow more bookings!");
                            return;
                        }

                        Member clMember = new Member(id_member);
                        this.clClassInstance.LclAttendants.Add(clMember);
                        this.clClassInstance.SaveClassInstance();
                    }
                }
                // If this member list was launched from class instance list for viewing attending members
                if (this.clClassInstance.Id_class_instance != -1 && this.viewAttendants == true)
                {
                    // Confirm removal
                    DialogResult dialogResult = MessageBox.Show("Remove this member from the class?", "Delete entry?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dialogResult == DialogResult.Yes)
                    {
                        // Create delete query
                        string deleteClassBookingQuery = "delete from class_bookings WHERE id_member = '" + id_member + "'" + " AND id_class_instance = '" + this.clClassInstance.Id_class_instance + "'";
                        // Launch delete query
                        int result = conn.DeleteOrUpdate(deleteClassBookingQuery);
                        // Check delete result
                        if (result > 0)
                        {
                            MessageBox.Show("The attendant has been removed from this class instance!");
                            vLoadMemberList();
                        }
                        else
                        {
                            MessageBox.Show("There was a problem updating the class booking information, please check your data!");
                            return;
                        }
                    }
                }
                // If this member list was launched from main menu just create an edit member form
                else
                {
                    frm_member frmMember = new frm_member(id_member, this);
                    frmMember.ShowDialog();
                }
            }catch(Exception)
            {
                return;
            }
        }