예제 #1
0
        /**
          * @desc Loads in when the object instance first instantiated
          * @params [none] No input parameter.
          * @return [none] No directly returned data.
          */
        private void frm_add_payment_Load(object sender, EventArgs e)
        {
            // Store todays date
            DateTime today = DateTime.Today;
            // Convert date to display format
            txt_date.Text = String.Format("{0:dd-MM-yyyy}", today);

            // Loading Available Staff
            //TODO: Inform Katie about the Position -> Instructor field
            // Create mysl connection
            mySqlConn conn = new mySqlConn();
            conn.connect();
            // Create query for returning all staff for selection of payment "received by"
            string query = "SELECT id_staff, CONCAT(lastName,', ', firstName) name FROM staff ORDER BY lastName";
            // Load result into an arraylist
            ArrayList myItems = conn.alGetComboFromDB(query, "id_staff", "name");
            // Set combobox to display value
            cmb_staff.DisplayMember = "Value";
            // Set myItems a combobox source
            cmb_staff.DataSource = myItems;
            // Set combobox index to be -1 so it can be checked if the user won't select anything here
            // TODO: SET THIS TO BE A CONSTANT AS THE CURRENTLY LOGGED IN STAFF??
            cmb_staff.SelectedIndex = -1;
        }
예제 #2
0
        /**
          * @desc It sets up the form for displaying details of a set
          * @params [none] No input parameter.
          * @return [none] No directly returned data.
          */
        private void rd_set_Checked()
        {
            // Create mysql connection
            mySqlConn conn = new mySqlConn();
            conn.connect();

            // Loading Available Items
            string query = "SELECT id_equipment, name FROM equipment WHERE type = 'item' ORDER BY id_equipment";
            ArrayList myItems1 = conn.alGetComboFromDB(query, "id_equipment", "name");
            ArrayList myItems2 = conn.alGetComboFromDB(query, "id_equipment", "name");
            ArrayList myItems3 = conn.alGetComboFromDB(query, "id_equipment", "name");
            ArrayList myItems4 = conn.alGetComboFromDB(query, "id_equipment", "name");
            ArrayList myItems5 = conn.alGetComboFromDB(query, "id_equipment", "name");

            // Create an option for "none" in each combobox's first position
            DictionaryEntry dent = (DictionaryEntry)myItems1[0];
            dent.Key = "0";
            dent.Value = "none";
            myItems1.Insert(0, dent);
            myItems2.Insert(0, dent);
            myItems3.Insert(0, dent);
            myItems4.Insert(0, dent);
            myItems5.Insert(0, dent);

            // Assign sources and displaymembers to all comboboxes
            cmb_item1.DisplayMember = "Value";
            cmb_item1.DataSource = myItems1;
            cmb_item2.DisplayMember = "Value";
            cmb_item2.DataSource = myItems2;
            cmb_item3.DisplayMember = "Value";
            cmb_item3.DataSource = myItems3;
            cmb_item4.DisplayMember = "Value";
            cmb_item4.DataSource = myItems4;
            cmb_item5.DisplayMember = "Value";
            cmb_item5.DataSource = myItems5;

            // Find the position of the item in the source and set this to be the selected index
            // in each combobox
            int j = 0;
            foreach (object o in myItems1)
            {

                dent = (DictionaryEntry)myItems1[j];
                if (int.Parse(dent.Key.ToString()) == clEquipment.ItemInSet1)
                    cmb_item1.SelectedIndex = j;
                j++;
            }
            j = 0;
            foreach (object o in myItems1)
            {

                dent = (DictionaryEntry)myItems1[j];
                if (int.Parse(dent.Key.ToString()) == clEquipment.ItemInSet2)
                    cmb_item2.SelectedIndex = j;
                j++;
            }
            j = 0;
            foreach (object o in myItems1)
            {

                dent = (DictionaryEntry)myItems1[j];
                if (int.Parse(dent.Key.ToString()) == clEquipment.ItemInSet3)
                    cmb_item3.SelectedIndex = j;
                j++;
            }
            j = 0;
            foreach (object o in myItems1)
            {

                dent = (DictionaryEntry)myItems1[j];
                if (int.Parse(dent.Key.ToString()) == clEquipment.ItemInSet4)
                    cmb_item4.SelectedIndex = j;
                j++;
            }
            j = 0;
            foreach (object o in myItems1)
            {

                dent = (DictionaryEntry)myItems1[j];
                if (int.Parse(dent.Key.ToString()) == clEquipment.ItemInSet5)
                    cmb_item5.SelectedIndex = j;
                j++;
            }

            // Display counter values on form
            counter_item1.Value = clEquipment.AmountInSet1;
            counter_item2.Value = clEquipment.AmountInSet2;
            counter_item3.Value = clEquipment.AmountInSet3;
            counter_item4.Value = clEquipment.AmountInSet4;
            counter_item5.Value = clEquipment.AmountInSet5;

            // Display remaining set related settings on form

            label_iteminfo.Hide();
            label_itemsetinfo.Show();
            label_itemname.Enabled = false;
            txt_itemname.Enabled = false;
            label_setname.Enabled = true;
            txt_setname.Enabled = true;
            label_itemdesc.Hide();
            label_itemsetdesc.Show();
            label_iteminset.Enabled = true;
            label_itemamount.Enabled = true;

            cmb_item1.Enabled = true;
            if (cmb_item1.SelectedIndex < 1) cmb_item2.Enabled = false;
            if (cmb_item2.SelectedIndex < 1) cmb_item3.Enabled = false;
            if (cmb_item3.SelectedIndex < 1) cmb_item4.Enabled = false;
            if (cmb_item4.SelectedIndex < 1) cmb_item5.Enabled = false;

            if (cmb_item1.SelectedIndex < 1) counter_item2.Enabled = false;
            if (cmb_item2.SelectedIndex < 1) counter_item3.Enabled = false;
            if (cmb_item3.SelectedIndex < 1) counter_item4.Enabled = false;
            if (cmb_item4.SelectedIndex < 1) counter_item5.Enabled = false;
        }
        /**
          * @desc This method loads in every time the frm_class_instance_arrange is instantiated
          * @params [none] No input parameter.
          * @return [none] No directly returned data.
          */
        private void frm_class_instance_arrange_Load(object sender, EventArgs e)
        {
            // Create mysql connection
            mySqlConn conn = new mySqlConn();
            conn.connect();

            // Loading Available Classes
            string query = "SELECT id_class, name FROM classes ORDER BY id_class";
            ArrayList myItems = conn.alGetComboFromDB(query, "id_class","name");
            cmb_classes.DisplayMember = "Value";
            cmb_classes.DataSource = myItems;

            // Loading Available Rooms
            query = "SELECT id_room, name FROM rooms ORDER BY id_room";
            myItems = conn.alGetComboFromDB(query, "id_room", "name");
            cmb_rooms.DisplayMember = "Value";
            cmb_rooms.DataSource = myItems;

            // Loading Available Instructor
            //TODO: Inform Katie about the Position -> Instructor field
            query = "SELECT id_staff, CONCAT(lastName,', ', firstName) name FROM staff WHERE position = 'Instructor' ORDER BY id_staff";
            myItems = conn.alGetComboFromDB(query, "id_staff", "name");
            cmb_instructors.DisplayMember = "Value";
            cmb_instructors.DataSource = myItems;

            // Copy the details of the class instancs to the form
            if (this.clClassInstance.Id_class_instance != -1)
            {
                cmb_classes.SelectedIndex = cmb_classes.FindString(clClassInstance.ClClass.Name);
                cmb_rooms.SelectedIndex = cmb_rooms.FindString(clClassInstance.ClRoom.Name);
                cmb_repeats.SelectedIndex = cmb_repeats.FindString(clClassInstance.Frequency);
                // Display number of members enlisted to this class instance
                query = "SELECT COUNT(*) q FROM gym.class_bookings WHERE id_class_instance = '" + this.clClassInstance.Id_class_instance + "'";
                List<Hashtable> lhRes = conn.lhSqlQuery(query);
                lbl_currentmembers_amount.Text = lhRes[0]["q"].ToString();
                // Display max members allowed in the room allocated to this class
                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);
                label_maxmembers_amount.Text = lhRes[0]["size"].ToString();
            }
            else
            {
                // If the class instance was not found, it is not possible to assign member or equipment to it
                button_equipmentbooking.Enabled = false;
                button_viewattendants.Enabled = false;
                button_enrollmembers.Enabled = false;
                button_remove.Enabled = false;
                button_equipmentbooking.Enabled = false;
            }
        }