/**
          * @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();
            }
        }
        /**
          * @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 #3
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");
 }