Ejemplo n.º 1
0
        private void ButtonSave_Click(object sender, EventArgs e)
        {
            // Return error if no valid items in Combo Box Locker Type is selected
            if (comboBoxLockerType.SelectedIndex < 0)
            {
                MessageBox.Show("Input Error: Invalid input detected!" + Environment.NewLine +
                                "Please ensure that field 'Locker Type' was filled with provided items. ",
                                "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Get the Locker Type Id of the cabinet using the value of comboBoxLockerType, and parse to int
            int selectedLockerTypeId = Int32.Parse(comboBoxLockerType.SelectedValue.ToString());

            // Set the Cabinet Data and Save it
            CabinetLockerController cabinetController = new CabinetLockerController();

            cabinetController.SetCabinetData(textBoxCabinetCode.Text, selectedLockerTypeId,
                                             (int)numericUpDownRow.Value, (int)numericUpDownColumn.Value);
            cabinetController.SaveCabinetData();

            // Set the insert complete boolean as true
            _isInsertComplete = true;

            // Exit this form
            this.Close();
        }
Ejemplo n.º 2
0
        // Event Handler
        private void ButtonSelectLocker_Click(object sender, EventArgs e)
        {
            if (listViewLocker.SelectedItems.Count <= 0)
            {
                return;
            }

            ListViewItem lvi = listViewLocker.SelectedItems[0];

            string lockerCodeCondition = String.Format("code = '{0}'", lvi.Text);

            List <Locker> lockers = Locker.Where(lockerCodeCondition, 0, 1);
            var           locker  = lockers[0];

            try
            {
                CabinetLockerController cabinetLockerController = new CabinetLockerController();

                if (_rental.Id > 0)
                {
                    cabinetLockerController.CheckLockerAvailability(locker, _rental);
                }

                _selectedLocker = locker;
                _isSelected     = true;

                this.Close();
            }
            catch (InvalidUserInputException exception)
            {
                exception.ShowErrorMessage();
            }
        }
Ejemplo n.º 3
0
        // Constructor for View Rental
        public SelectLockerForm(int rentalId)
        {
            InitializeComponent();

            // Get all data related to the rental
            _rental     = Rental.Get(rentalId);
            _locker     = Locker.Get(_rental.LockerId);
            _cabinet    = Cabinet.Get(_locker.CabinetId);
            _lockerType = LockerType.Get(_cabinet.LockerTypeId);

            // Set the start date and end date of rental
            _startDate = _rental.StartDate;
            _endDate   = _rental.EndDate;

            // Clear combo box  & locker type dictonary to avoid error
            _lockerTypeDictonary.Clear();

            // Only add the involved locker type into the directonary
            _lockerTypeDictonary.Add(_lockerType.Id, _lockerType.Name);

            // Bind locker type dictonary onto combo box locker type locker cabinet (In Locker Module)
            comboBoxLockerTypeLockerCabinet.DataSource = new BindingSource(_lockerTypeDictonary, null);

            // Display the Locker Type Name and Set the Locker Type Id as ValueMember
            comboBoxLockerTypeLockerCabinet.DisplayMember = "Value";
            comboBoxLockerTypeLockerCabinet.ValueMember   = "Key";

            // Trigger SelectedIndexChanged event
            comboBoxLockerTypeLockerCabinet.SelectedIndex = -1;

            // Select the invloved locker type
            comboBoxLockerTypeLockerCabinet.SelectedIndex = 0;

            // Disable the comboBox
            comboBoxLockerTypeLockerCabinet.Enabled = false;

            // Load all cabinet list
            _lockerCabinetPage.PageNumber = 1;
            LockerCabinetPage();

            //Default select the involved cabinet to load
            textBoxCabinetCode.Text = _cabinet.Code;

            // Get the available lockers for the selected cabinet
            CabinetLockerController cabinetLockerController = new CabinetLockerController();
            List <Locker>           availableLockers        = cabinetLockerController.GetAvailableLockers(_cabinet.Id, _startDate, _endDate);

            textBoxEmptyLockerNo.Text = availableLockers.Count.ToString();

            _lockerPage.PageNumber = 1;
            LockerPage(availableLockers);
        }
Ejemplo n.º 4
0
        private void ButtonSelectCabinet_Click(object sender, EventArgs e)
        {
            if (listViewLockerCabinet.SelectedItems.Count <= 0)
            {
                return;
            }

            ListViewItem lvi = listViewLockerCabinet.SelectedItems[0];

            _cabinet.Id             = Convert.ToInt32(lvi.Text);
            textBoxCabinetCode.Text = lvi.SubItems[1].Text;

            // Get the available lockers
            CabinetLockerController cabinetLockerController = new CabinetLockerController();
            List <Locker>           availableLockers        = cabinetLockerController.GetAvailableLockers(_cabinet.Id, _startDate, _endDate);

            textBoxEmptyLockerNo.Text = availableLockers.Count.ToString();

            _lockerPage.PageNumber = 1;
            LockerPage(availableLockers);
        }
Ejemplo n.º 5
0
        // Constructor for Add Rental
        public SelectLockerForm(DateTime newRentalStartDate, DateTime newRentalEndDate)
        {
            InitializeComponent();

            // Change the label on buttonCancel to Back
            buttonCancel.Text = "Back";

            // Set the startDate and endDate to be checked
            _startDate = newRentalStartDate;
            _endDate   = newRentalEndDate;

            // Clear combo box  & locker type dictonary to avoid error
            _lockerTypeDictonary.Clear();

            // Load Locker Type Name into Combo Box 1
            _lockerTypes = LockerType.Where("status <> 'Disabled'", 0, 2147483467);

            // Add default value (select ALL) into locker type dictonary
            _lockerTypeDictonary.Add(0, "All");

            // Add locker types into locker type dictonary
            foreach (LockerType lockerType in _lockerTypes)
            {
                _lockerTypeDictonary.Add(lockerType.Id, lockerType.Name);
            }

            // Bind locker type dictonary onto combo box locker type locker cabinet (In Locker Module)
            comboBoxLockerTypeLockerCabinet.DataSource = new BindingSource(_lockerTypeDictonary, null);

            // Display the Locker Type Name and Set the Locker Type Id as ValueMember
            comboBoxLockerTypeLockerCabinet.DisplayMember = "Value";
            comboBoxLockerTypeLockerCabinet.ValueMember   = "Key";

            // Trigger SelectedIndexChanged event
            comboBoxLockerTypeLockerCabinet.SelectedIndex = -1;

            // Default Select All Cabinets
            comboBoxLockerTypeLockerCabinet.SelectedIndex = 0;

            // Load all cabinet list
            _lockerCabinetPage.PageNumber = 1;
            LockerCabinetPage();

            //Default select the first cabinet to load
            List <Cabinet> cabinets = Cabinet.Where("status <> 'Disabled'", 0, 1);

            //If no cabinet in list, return
            if (!cabinets.Any())
            {
                return;
            }

            // Get the available lockers
            CabinetLockerController cabinetLockerController = new CabinetLockerController();
            List <Locker>           availableLockers        = cabinetLockerController.GetAvailableLockers(cabinets[0].Id, newRentalStartDate, newRentalEndDate);

            textBoxCabinetCode.Text   = cabinets[0].Code;
            textBoxEmptyLockerNo.Text = availableLockers.Count.ToString();

            _lockerPage.PageNumber = 1;
            LockerPage(availableLockers);
        }