/**
          * @desc Executes when a grid cell is double clicked on the equipment bookings list
          * It loads in the class belonging to the cell
          * @params [none] No input parameter.
          * @return [none] No directly returned data.
          */
        private void dg_eqbookings_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            // Retrieve equipment booking details from grid row
            int id_eq_booking = int.Parse(dg_eqbookings.Rows[e.RowIndex].Cells[0].Value.ToString());
            string equipmentName = dg_eqbookings.Rows[e.RowIndex].Cells[2].Value.ToString();
            int borrowedAmount = int.Parse(dg_eqbookings.Rows[e.RowIndex].Cells[3].Value.ToString());
            // Show return dialog for confirming amount to be returned
            frm_message_box myMessageBox = new frm_message_box();
            string result = myMessageBox.ShowBox(Utils.MB_CUST4, "", "How many "+equipmentName+" would you like to return?",borrowedAmount.ToString());

            // Reference how to use TryParse
            //ref  http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/84990ad2-5046-472b-b103-f862bfcd5dbc

            // Check the result of user input
             	        double Num;
             	        bool isNum = double.TryParse(result, out Num);
            if (isNum)
            {
                // If there is something to return but not everything
                if ((int.Parse(result) > 0) && (result != "Cancel"))
                {
                    // Save the new amount into eq. booking
                    this.clEquipmentBooked = new EquipmentBooked(id_eq_booking);
                    this.clEquipmentBooked.BorrowedAmount = int.Parse(result);
                    this.clEquipmentBooked.IsReturned = false;
                    this.clEquipmentBooked.SaveEquipmentBooking();
                }
                // If all amount of this booking is to be returned
                else if (result != "Cancel")
                {
                    // Mark the booking as returned
                    this.clEquipmentBooked = new EquipmentBooked(id_eq_booking);
                    this.clEquipmentBooked.BorrowedAmount = 0;
                    this.clEquipmentBooked.IsReturned = true;
                    this.clEquipmentBooked.SaveEquipmentBooking();

                }
                // Refresh eq. booking list
                this.vLoadBookedList();
            }
        }
Exemple #2
0
        /**
         * @desc Constructor for booking an equipment.
         * This can only launch form a member or staff panel as it needs data from them!
         * @params [int] id_equipment: identifies the equipment to book
         * @params [int] id_member: identifies the member who books the equipment
         * @params [int] id_staff: identifies the staff  who books the equipment
         * @params [int] id_class_instance: identifies the class instance to book the equipment for
         * @return [none] No directly returned data.
         */
        public frm_equipment(int id_equipment, int id_member, int id_staff, int id_class_instance)
        {
            frmMessageBox = new frm_message_box();
            // Store the fact on class global level that this is a booking
            IsBooking = true;
            InitializeComponent();
            this.Text = "Borrow Equipment";
            // Set up equipment form for bookings
            label_amounttoborrow.Visible = true;
            counter_amounttoborrow.Visible = true;
            counter_amounttoborrow.Value = 1;
            label_numberofdays.Visible = true;
            counter_numberofdays.Visible = true;
            counter_numberofdays.Value = 7;
            button_save.Text = "Borrow";
            txt_itemname.ReadOnly = true;
            txt_setname.ReadOnly = true;
            txt_equipmentdesc.ReadOnly = true;
            cmb_item1.Enabled = false;
            cmb_item2.Enabled = false;
            cmb_item3.Enabled = false;
            cmb_item4.Enabled = false;
            cmb_item5.Enabled = false;
            counter_item1.Enabled = false;
            counter_item2.Enabled = false;
            counter_item3.Enabled = false;
            counter_item4.Enabled = false;
            counter_item5.Enabled = false;
            // Load in the details of the equipment to book
            clEquipment = new Equipment(id_equipment);
            // Store class global level to whom the equipment is booked for
            Id_member = id_member;
            Id_staff = id_staff;
            Id_class_instance = id_class_instance;

            // If the equipment was not found
            if (clEquipment.Id_equipment < 1)
                MessageBox.Show("The equipment could not be found");
            // If the equipmnet was succesfully loaded in
            else
            {
                // If it is an individual item
                // Display table field contents on form in case of item
                if (clEquipment.Type == "item")
                {
                    rd_item.Checked = true;
                    rd_item_Checked();
                    rd_set.Hide();
                    txt_itemname.Text = clEquipment.Name;
                    txt_equipmentdesc.Text = clEquipment.Description;
                }
                // If it is a set
                // Display table field contents on form in case of set
                else if (clEquipment.Type == "set")
                {
                    rd_set.Checked = true;
                    rd_set_Checked();

                    rd_item.Hide();
                    txt_setname.Text = clEquipment.Name;
                    txt_equipmentdesc.Text = clEquipment.Description;
                }
            }
        }
 /**
   * @desc This method loads in every time the frm_equipment_list is instantiated
   * @params [none] No input parameter.
   * @return [none] No directly returned data.
   */
 private void frm_equipment_list_Load(object sender, EventArgs e)
 {
     frmMessageBox = new frm_message_box();
 }
 /**
   * @desc Dialog invoker with three custom buttons
   * @params [Uint32] Type: Selector of one of the custom dialog layouts
   * @params [string] txtMessage: Dialog message
   * @params [string] txtTitle: Dialog title
   * @params [string] Button1: Button text
   * @params [string] Button2: Button text
   * @params [string] Button3: Button text
   * @return [string] Button_id: Return value of selected button
   */
 public string ShowBox(UInt32 Type, string txtMessage, string txtTitle, string Button1, string Button2, string Button3)
 {
     newMessageBox = new frm_message_box();
     newMessageBox.SetButtonLayout(Type, Button1, Button2, Button3);
     if (txtTitle == "") newMessageBox.Text = "Message";
     else newMessageBox.Text = txtTitle;
     newMessageBox.label_Message.Text = txtMessage;
     newMessageBox.ShowDialog();
     return Button_id;
 }
 /**
   * @desc Default dialog invoker
   * @params [Uint32] Type: Selector of one of the default dialog layouts
   * @params [string] txtMessage: Dialog message
   * @params [string] txtTitle: Dialog title
   * @return [string] Button_id: Return value of selected button
   */
 public string ShowBox(UInt32 Type, string txtMessage, string txtTitle)
 {
     // Create message box
     newMessageBox = new frm_message_box();
     // Set layout
     newMessageBox.SetButtonLayout(Type, "", "", "");
     // Set title
     if (txtTitle == "")
         newMessageBox.Text = "Message";
     else
         newMessageBox.Text = txtTitle;
     // Set message
     newMessageBox.label_Message.Text = txtMessage;
     // Show dialog
     newMessageBox.ShowDialog();
     // Return result
     return Button_id;
 }
        /**
          * @desc Executes when a grid cell is double clicked on the borrowed equipment list
          * It loads in the equipment return dialog belonging to the cell
          * @params [none] No input parameter.
          * @return [none] No directly returned data.
          */
        private void dg_eqbookings_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            // Retrieve equipment booking details from grid row
            string equipmentName = dg_eqbookings.Rows[e.RowIndex].Cells[1].Value.ToString();
            int borrowedAmount = int.Parse(dg_eqbookings.Rows[e.RowIndex].Cells[2].Value.ToString());
            int id_eq_booking = int.Parse(dg_eqbookings.Rows[e.RowIndex].Cells[4].Value.ToString());
            // Show return dialog for confirming amount to be returned
            frm_message_box myMessageBox = new frm_message_box();
            string result = myMessageBox.ShowBox(Utils.MB_CUST4, "", "How many " + equipmentName + " would you like to return?", borrowedAmount.ToString());

            // Reference how to use TryParse
            //reference in Bibliography (Alani, S., 2006)

            // Check the result of user input
            double Num;
            bool isNum = double.TryParse(result, out Num);
            if (isNum)
            {
                // If there is something to return but not everything
                if ((int.Parse(result) > 0) && (result != "Cancel"))
                {
                    // Save the new amount into eq. booking
                    this.clEquipmentBooked = new EquipmentBooked(id_eq_booking);
                    this.clEquipmentBooked.BorrowedAmount = int.Parse(result);
                    this.clEquipmentBooked.IsReturned = false;
                    this.clEquipmentBooked.SaveEquipmentBooking();
                }
                // If all amount of this booking is to be returned
                else
                {
                    // Mark the booking as returned
                    this.clEquipmentBooked = new EquipmentBooked(id_eq_booking);
                    this.clEquipmentBooked.BorrowedAmount = 0;
                    this.clEquipmentBooked.IsReturned = true;
                    this.clEquipmentBooked.SaveEquipmentBooking();

                }
                // Refresh eq. booking list
                this.vLoadBookedList();
            }
        }
Exemple #7
0
 /**
   * @desc Executes mouse hovers over pictureBox1
   * It lets the user remove the association between member and its current picture
   * @params [none] No input parameter.
   * @return [none] No directly returned data.
   */
 private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
 {
     switch (e.Button)
     {
         // In case of right mouse click
         case (MouseButtons.Right):
             {
                 // If there is a picture currently loaded in and there is an association between the picture and the member
                 if ((this.pictureBox1.Image != null) && (clMember.Id_file != null))
                 {
                     // Ask user confirmation
                     frm_message_box frmMessageBox = new frm_message_box();
                     string result = frmMessageBox.ShowBox(Utils.MB_YESNO, "Would you like to delete the picture?", "Delete?");
                     if (result == "YES")
                     {
                         // remove all association between member and current picture
                         this.pictureBox1.Image = null;
                         clMember.Id_file = "";
                         clMember.FileName = "";
                         clMember.FilePath = "";
                         // Warn the user that he has to save the modifications
                         MessageBox.Show("Image has been marked for deletion,\r\nyou must click on save for\r\nthe deletion to take effect!");
                         // Display default images as per genders
                         if (rd_male.Checked)
                             this.pictureBox1.BackgroundImage = global::Gym_administration.Properties.Resources.member_male_128;
                         else
                             this.pictureBox1.BackgroundImage = global::Gym_administration.Properties.Resources.member_female_128;
                     }
                 }
                 break;
             }
     }
 }
 /**
   * @desc Executes when the Copy button is clicked
   * It copies the contents of the currently selected grids onto the clipboard
   * with the optional delimiter
   * @params [none] No input parameter.
   * @return [none] No directly returned data.
   */
 private void button_copy_Click(object sender, EventArgs e)
 {
     // Create a string array of the size (amount) of selected cells
     string[] saSelectedCellValues = new string[dg_members.SelectedCells.Count];
     int counter = 0;
     string cellValue;
     // Fill in all selected cell contents into string array
     for (counter = 0; counter < (dg_members.SelectedCells.Count); counter++)
     {
         cellValue = dg_members.SelectedCells[counter].Value.ToString();
         if (cellValue.Length != 0)
             saSelectedCellValues[counter] = cellValue;
     }
     // Offer choice of delimiter
     frm_message_box frmMessageBox = new frm_message_box();
     string result = frmMessageBox.ShowBox(Utils.MB_CUST2, "Which delimiter would you like to use? \r\n Its normally a comma (,) ARU mail uses semicolon (;)", "Mass e-mail delimiter selection", ",", ";");
     char delimiter = result[0];
     // Copy everything to clipboard
     Clipboard.SetData(DataFormats.Text, string.Join(delimiter+" ", saSelectedCellValues));
     // If let the user know about the result
     if (Clipboard.ContainsData(DataFormats.Text))
         MessageBox.Show(Clipboard.GetData(DataFormats.Text) + "\r\n\r\n is on the Clipboard now!");
     else
         MessageBox.Show("Nothing was selected");
 }