public void RestoreCabinetData(int id) { var cabItem = Cabinet.Get(id); //Check if the Locker Type available in the list (Not deleted). If no, show error. var lockerType = new LockerType(); var typeItem = LockerType.Get(cabItem.LockerTypeId); if (typeItem.IsDisabled()) { throw new InvalidUserInputException("Restore Error - Cabinet Locker Type", "", typeItem.Name, ""); } cabItem.Restore(); //Restore the cabinet //Calculate how many lockers in the cabinet int noOfLockers = cabItem.Row * cabItem.Column; //Restore the lockers assoicated to this cabinet List <Locker> lockerList = Locker.Where(String.Format("cabinet_id = {0}", id), 0, noOfLockers); for (int i = 0; i < noOfLockers; i++) { var restoreLocker = new Locker { Id = lockerList[i].Id }; restoreLocker.Reset(); } }
// Constructors // Constructor for Add Cabinet public CabinetForm() { InitializeComponent(); // Remove the Tab Control Controls.Remove(tabControlCabinet); // Add the Add Cabinet Panel Controls.Add(panelAddCabinet); // Get the list of Locker Types in the database _lockerTypes = LockerType.Where("status <> 'Disabled'", 0, 2147483467); // Insert Locker Types into the Locker Type Dictionary foreach (LockerType lockerType in _lockerTypes) { _lockerTypeDictionary.Add(lockerType.Id, lockerType.Name); } // Exit the data binding if no data inside the dictionary if (!_lockerTypeDictionary.Any()) { return; } // Bind Locker Type Dictonary onto Combo Box Locker Type comboBoxLockerType.DataSource = new BindingSource(_lockerTypeDictionary, null); // Display the Locker Type Name and Set the Locker Type Id as Value comboBoxLockerType.DisplayMember = "Value"; comboBoxLockerType.ValueMember = "Key"; // Set the selected index to -1 comboBoxLockerType.SelectedIndex = -1; }
public Locker CreateLocker(LockerType lockerType, Vector3 pos, Quaternion rotation, Vector3 scale, bool removeDefaultItems = false) { var synapselocker = new Locker(CreateNetworkObject(Prefabs[lockerType], pos, rotation, scale)); foreach (var chamber in synapselocker.Chambers) { chamber.lockerChamber._spawnpoint.SetParent(synapselocker.locker.transform); } synapselocker.locker.Start(); foreach (var pickup in synapselocker.locker.GetComponentsInChildren <ItemPickupBase>()) { if (removeDefaultItems) { NetworkServer.Destroy(pickup.gameObject); } else { pickup.Rb.isKinematic = false; pickup.Rb.useGravity = true; } } return(synapselocker); }
// Constructor for View Rental public RentalForm(int id, bool isEndedRental) { InitializeComponent(); // Hide all tabs not related to view rental this.Controls.Remove(tabControlRental); this.Controls.Add(panelViewRental); // If view ended rental, hide the change locker button if (isEndedRental) { buttonChangeLocker.Hide(); } // Get data related to the rental _rental = Rental.Get(id); _customer = Customer.Get(_rental.CustomerId); _employee = Employee.Get(_rental.EmployeeId); _locker = Locker.Get(_rental.LockerId); _cabinet = Cabinet.Get(_locker.CabinetId); _lockerType = LockerType.Get(_cabinet.LockerTypeId); // Insert the data into display fields ViewRentalLoadRentalData(); }
public SynapseLockerObject(LockerType lockerType, Vector3 pos, Quaternion rotation, Vector3 scale, bool removeDefaultItems = false) { Locker = CreateLocker(lockerType, pos, rotation, scale, removeDefaultItems); LockerType = lockerType; Map.Get.SynapseObjects.Add(this); var script = GameObject.AddComponent <SynapseObjectScript>(); script.Object = this; }
// 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); }
public void DeleteLockerTypeData(int id) { // Check if any cabinet exists for this locker type. If yes, show error. if (Cabinet.Count(String.Format("locker_type_id = {0} AND status <> 'Disabled'", id)) > 0) { throw new InvalidUserInputException("Delete Error - Locker Type Cabinet"); } // Delete the locker type LockerType deletedLockerType = LockerType.Get(id); deletedLockerType.TempDelete(); }
public void ExportLockerTypeData(int id) { var delType = LockerType.Where(String.Format("id = {0}", id), 0, 1); string defaultFileName = String.Format("EXPORT_LOCKER_TYPE_{0}_{1}", id, DateTime.Now.ToString("ddMMyyyy_HHmmss")); int noOfCabinet = Cabinet.Count(String.Format("locker_type_id = {0}", id)); if (noOfCabinet > 0) { throw new InvalidUserInputException("Export Fail - Cabinet"); } var workbook = new XLWorkbook(); var ws = workbook.AddWorksheet("DeletedCabinet"); ws.Cell(1, 1).Value = "Locker Type"; ws.Cell(2, 1).InsertTable(delType); SaveFileDialog sf = new SaveFileDialog { FileName = defaultFileName, Filter = "Excel Workbook (.xlsx) |*.xlsx", Title = "Export Locker Type as", FilterIndex = 1 }; if (sf.ShowDialog() == DialogResult.OK) { string savePath = Path.GetDirectoryName(sf.FileName); string fileName = Path.GetFileName(sf.FileName); string saveFile = Path.Combine(savePath, fileName); try { workbook.SaveAs(saveFile); //Save the file delType[0].Delete(); } catch (Exception exception) { MessageBox.Show(exception.Message); throw new InvalidUserInputException("Export Fail", "", "", "locker type"); } } else { throw new InvalidUserInputException("Export Fail", "", "", "locker type"); } }
private void ButtonChangeLocker_Click(object sender, EventArgs e) { var result = MessageBox.Show("Do you want to change the locker for this rental?", "Change Locker", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { //Check if the rental overdue. If yes, show error message and return. TimeSpan timeSpan = _rental.EndDate.Date.Subtract(DateTime.Now.Date); int daysLeft = Convert.ToInt32(timeSpan.Days); if (daysLeft < 0) { MessageBox.Show("Access Error: Rental Overdued." + Environment.NewLine + "You cannot change details for an overdued rental.", "Access Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } SelectLockerForm selectLockerForm = new SelectLockerForm(_rental.Id); selectLockerForm.ShowDialog(); if (selectLockerForm.IsSelected()) { // Assign the original cabinet data into a temporary variable Locker previousLocker = _locker; // Get the new locker type, cabinet and locker data for the selected locker _locker = selectLockerForm.SelectedLocker; _cabinet = Cabinet.Get(_locker.CabinetId); _lockerType = LockerType.Get(_cabinet.LockerTypeId); _rental.LockerId = _locker.Id; // Save the rental RentalController rentalController = new RentalController(); rentalController.ChangeBookedLocker(_rental, previousLocker); _isInsertComplete = true; // Load the new data into locker display ViewRentalLoadRentalData(); } } }
private void ButtonNextAddRental_Click(object sender, EventArgs e) { try { _rentalController.SetAddRentalData(_customer, _employee, dateTimePickerStartDateAddRental.Value, dateTimePickerEndDateAddRental.Value, (int)numericUpDownDurationAddRental.Value); _rentalController.CheckRentalDuration((int)numericUpDownDurationAddRental.Value); DateTime startdate = dateTimePickerStartDateAddRental.Value; DateTime endDate = dateTimePickerEndDateAddRental.Value; SelectLockerForm selectLockerForm = new SelectLockerForm(startdate, endDate); selectLockerForm.ShowDialog(); if (!selectLockerForm.IsSelected()) { return; } _rentalController.SetAddRentalLockerData(selectLockerForm.SelectedLocker); // Get data of the selected locker _locker = selectLockerForm.SelectedLocker; _cabinet = Cabinet.Get(_locker.CabinetId); _lockerType = LockerType.Get(_cabinet.LockerTypeId); PayRentalLoadRentalData(); // Show Pay Rental this.Controls.Remove(panelAddRental); this.Controls.Add(panelPayRental); // Hide OK button and show only Confrim Button buttonOKPayRental.Hide(); } catch (InvalidUserInputException exception) { exception.ShowErrorMessage(); } }
// Constructor for End Rental public RentalForm(Rental rental) { InitializeComponent(); // Hide all tabs not related to End Rental this.Controls.Remove(tabControlRental); this.Controls.Add(panelEndRental); // Set rental data _rental = rental; // Get data related to the rental _customer = Customer.Get(_rental.CustomerId); _locker = Locker.Get(_rental.LockerId); _cabinet = Cabinet.Get(_locker.CabinetId); _lockerType = LockerType.Get(_cabinet.LockerTypeId); // Insert the data into display fields EndRentalLoadRentalData(); }
// Constructor for Edit Locker Type public LockerTypeForm(int id) { InitializeComponent(); // Hide labels not related to Edit Locker Type labelAddLockerType.Hide(); // Lock Name and Code input textBoxName.ReadOnly = true; textBoxCode.ReadOnly = true; // Declare this operation is not insert new locker _isNewInsert = false; // Get the Locker Type Data for this id _lockerType = LockerType.Get(id); // Load data into Input Field textBoxName.Text = _lockerType.Name; textBoxCode.Text = _lockerType.Code; numericUpDownRentalRate.Value = _lockerType.Rate; }
// Constructor for Filter Cabinet / Filter Deleted Cabinet public CabinetForm(bool isDisabled) { InitializeComponent(); // Remove the Tab Control Controls.Remove(tabControlCabinet); // Determine the list to be filtered is cabinet or deleted (disabled) cabinet if (isDisabled) { Controls.Add(panelFilterDeletedCabinet); this.Height = 150; // Get the list of all locker types, including the ones disabled _lockerTypes = LockerType.All(0, 2147483467); // Add default element (Select ALL locker types) into the Locker Type Dictonary _lockerTypeDictionary.Add(0, "All"); // Insert Locker Types into the Locker Type Dictonary foreach (LockerType lockerType in _lockerTypes) { _lockerTypeDictionary.Add(lockerType.Id, lockerType.Name); } // Exit the data binding if no data inside the dictionary if (!_lockerTypeDictionary.Any()) { return; } // Bind Locker Type Dictonary onto Combo Box Locker Type for Filter Cabinet comboBoxLockerTypeDeletedCabinet.DataSource = new BindingSource(_lockerTypeDictionary, null); // Display the Locker Type Name and Set the Locker Type Id as Value comboBoxLockerTypeDeletedCabinet.DisplayMember = "Value"; comboBoxLockerTypeDeletedCabinet.ValueMember = "Key"; // Set the selected index to 0 (Select ALL locker types) comboBoxLockerTypeDeletedCabinet.SelectedIndex = 0; } else { Controls.Add(panelFilterCabinet); this.Height = 260; // Get the list of available locker types _lockerTypes = LockerType.Where("status <> 'Disabled'", 0, 2147483467); // Add default element (Select ALL locker types) into the Locker Type Dictonary _lockerTypeDictionary.Add(0, "All"); // Insert Locker Types into the Locker Type Dictonary foreach (LockerType lockerType in _lockerTypes) { _lockerTypeDictionary.Add(lockerType.Id, lockerType.Name); } // Exit the data binding if no data inside the dictionary if (!_lockerTypeDictionary.Any()) { return; } // Bind Locker Type Dictonary onto Combo Box Locker Type for Filter Cabinet comboBoxLockerTypeFilterCabinet.DataSource = new BindingSource(_lockerTypeDictionary, null); // Display the Locker Type Name and Set the Locker Type Id as Value comboBoxLockerTypeFilterCabinet.DisplayMember = "Value"; comboBoxLockerTypeFilterCabinet.ValueMember = "Key"; // Set the selected index to 0 (Select ALL locker types) comboBoxLockerTypeFilterCabinet.SelectedIndex = 0; // Default select ALL cabinets (Ignore cabinet status) radioButtonAll.Checked = true; } }
public void SetScreenLocker(LockerType type, ScreenLocker screenLockerPrefab) { _screenLockerPrefabs[type] = screenLockerPrefab; }
public void SetLockerTypeData(LockerType lockerType, decimal rate) { _lockerType = lockerType; _lockerType.Rate = rate; }
// 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); }
public void RestoreLockerTypeData(int id) { LockerType lockerType = LockerType.Get(id); lockerType.Restore(); }