Beispiel #1
0
        private void PeripheralMgmtForm_Load(object sender, EventArgs e)
        {
            //this.peripheralPropertyGrid.SelectedObject = this.EditPeripheral;
            bool needUpdate = false;

            if (IncomingType != null)
            {
                //Setup add mode
                this.AddPeripheral.PeriphType = this.IncomingType;
                this.mode  = PeripheralMgmtMode.ADD;
                needUpdate = true;
            }
            if (CollectionUtilities.isNotEmpty(storeData.AllPeripherals))
            {
                syncPeripherals();
            }
            if (CollectionUtilities.isNotEmpty(storeData.AllWorkstations))
            {
                syncWorkstations();
            }
            if (needUpdate)
            {
                this.updateButtonState();
                this.updatePropertyViewState();
            }
            else
            {
                this.updateButtonState();
            }
        }
Beispiel #2
0
 private void peripheralListView_SelectedIndexChanged(object sender, EventArgs e)
 {
     checkToEnableMapButton();
     //If we have pending changes to a peripheral and the selection is of
     //a different peripheral altogether, warn of a loss in work
     this.processPendingChange(true);
     if (this.peripheralListView.SelectedIndices != null &&
         this.peripheralListView.SelectedIndices.Count > 0)
     {
         this.mode = PeripheralMgmtMode.VIEW;
         this.peripheralSelectedIndex = this.peripheralListView.SelectedIndices[0];
         this.updateButtonState();
         this.updatePropertyViewState();
     }
 }
Beispiel #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="store"></param>
 public PeripheralMgmtForm(
     ref StoreSetupVO store)
 {
     this.mode             = PeripheralMgmtMode.INITIAL;
     this.AddPeripheral    = new PeripheralVO();
     this.EditPeripheral   = new PeripheralVO();
     this.ViewPeripheral   = new PeripheralVO();
     this.DeletePeripheral = new PeripheralVO();
     this.pendingChanges   = false;
     this.storeData        = null;
     InitializeComponent();
     if (store == null)
     {
         return;
     }
     this.storeData = store;
     this.peripheralSelectedIndex = -1;
 }
Beispiel #4
0
        private void removeButton_Click(object sender, EventArgs e)
        {
            if (removeButton.Text == COMMIT)
            {
                //Remove the peripheral (move it from the all list to the delete list)
                //this.storeData.PeripheralsDeletes.Add(this.DeletePeripheral);
                //Clear selection
                this.storeData.AllPeripherals.RemoveAll(x => x.Id.Equals(this.DeletePeripheral.Id, StringComparison.OrdinalIgnoreCase));
                if (CollectionUtilities.isNotEmpty(this.storeData.PawnWorkstationPeripheralMap))
                {
                    //Remove from any workstation mapped to this peripheral
                    foreach (var wkst in this.storeData.PawnWorkstationPeripheralMap.Keys)
                    {
                        if (wkst == null)
                        {
                            continue;
                        }
                        var perMapList = this.storeData.PawnWorkstationPeripheralMap[wkst];
                        if (CollectionUtilities.isNotEmpty(perMapList))
                        {
                            perMapList.RemoveAll(x => x.Right.Id.Equals(this.DeletePeripheral.Id));
                        }
                    }
                }


                //Reset list
                this.mode = PeripheralMgmtMode.INITIAL;
                this.syncPeripherals();
                this.syncWorkstations();
                this.updateButtonState();
                this.updatePropertyViewState();
                this.pendingChanges = false;
            }
            else
            {
                //Setup for removal
                processPendingChange(false);
                this.mode = PeripheralMgmtMode.DELETE;
                this.updateButtonState();
                this.updatePropertyViewState();
            }
        }
Beispiel #5
0
        private void editButton_Click(object sender, EventArgs e)
        {
            if (editButton.Text == COMMIT)
            {
                string errMsg;
                if (!this.isPeripheralValid(this.EditPeripheral, out errMsg))
                {
                    MessageBox.Show("Cannot edit the peripheral due to the following errors:" + Environment.NewLine +
                                    errMsg, PawnStoreSetupForm.SETUPALERT_TXT);
                    this.EditPeripheral = null;
                    this.mode           = PeripheralMgmtMode.INITIAL;
                    this.syncPeripherals();
                    this.updateButtonState();
                    this.updatePropertyViewState();
                    this.pendingChanges = false;
                    return;
                }
                //this.EditPeripheral.UpdatePeripheral();
                this.EditPeripheral.CalculatePeripheralTypeFromTypeId(storeData.AllPeripheralTypes);
                bool hasId;
                int  fndIdx = getPeripheralIndex(this.EditPeripheral,
                                                 this.storeData.AllPeripherals,
                                                 out hasId);
                //Update the peripheral in the all peripheral list
                if (fndIdx != -1)
                {
                    this.storeData.AllPeripherals[fndIdx] = this.EditPeripheral;

                    /*int fndUpdIdx = getPeripheralIndex(this.EditPeripheral,
                     *                                 this.storeData.PeripheralsUpdates,
                     *                                 out hasId);
                     * if (fndUpdIdx == -1)
                     * {
                     *  this.storeData.PeripheralsUpdates.Add(this.EditPeripheral);
                     * }
                     * else
                     * {
                     *  MessageBox.Show("You have already made a change to this peripheral.",
                     *                  PawnStoreSetupForm.SETUPALERT_TXT);
                     * }*/
                }
                else
                {
                    MessageBox.Show(
                        "Cannot find the original peripheral that you are editing now.  Please try again.",
                        PawnStoreSetupForm.SETUPALERT_TXT);
                }

                //Clear view
                this.mode = PeripheralMgmtMode.INITIAL;
                this.syncPeripherals();
                this.updateButtonState();
                this.updatePropertyViewState();
                this.pendingChanges = false;
            }
            else
            {
                //Set mode to edit
                processPendingChange(false);
                this.mode = PeripheralMgmtMode.EDIT;
                this.updateButtonState();
                this.updatePropertyViewState();
            }
        }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addButton_Click(object sender, EventArgs e)
        {
            if (addButton.Text == COMMIT)
            {
                //Verify the peripheral being added prior to adding it
                string errMsg;
                if (!this.isPeripheralValid(this.AddPeripheral, out errMsg))
                {
                    MessageBox.Show("Cannot add the peripheral due to the following errors:" + Environment.NewLine +
                                    errMsg, PawnStoreSetupForm.SETUPALERT_TXT);
                    this.AddPeripheral = null;
                    this.mode          = PeripheralMgmtMode.INITIAL;
                    this.syncPeripherals();
                    this.updateButtonState();
                    this.updatePropertyViewState();
                    this.pendingChanges = false;
                    return;
                }
                //this.AddPeripheral.UpdatePeripheral();
                this.AddPeripheral.SetPeripheralTypeNames(this.storeData.AllPeripheralTypes);
                this.AddPeripheral.CalculatePeripheralTypeFromLogicalType(storeData.AllPeripheralTypes);
                bool hasId;
                int  fndIdx = this.getPeripheralIndex(this.AddPeripheral,
                                                      this.storeData.AllPeripherals,
                                                      out hasId);
                if (fndIdx == -1)
                {
                    this.storeData.AllPeripherals.Add(this.AddPeripheral);

                    /*int fndInsIdx = this.getPeripheralIndex(this.AddPeripheral,
                     *                                      this.storeData.PeripheralsInserts,
                     *                                      out hasId);
                     * if (fndInsIdx == -1)
                     * {
                     *  this.storeData.PeripheralsInserts.Add(this.AddPeripheral);
                     * }
                     * else
                     * {
                     *  MessageBox.Show(
                     *          "This peripheral already exists in the add list.  Please try again.",
                     *          PawnStoreSetupForm.SETUPALERT_TXT);
                     * }*/
                }
                else
                {
                    MessageBox.Show("This peripheral has already been added.",
                                    PawnStoreSetupForm.SETUPALERT_TXT);
                }

                //Clear view
                this.mode = PeripheralMgmtMode.INITIAL;
                this.syncPeripherals();
                this.updateButtonState();
                this.updatePropertyViewState();
                this.pendingChanges = false;
            }
            else
            {
                //Set mode to add
                processPendingChange(false);
                this.mode = PeripheralMgmtMode.ADD;
                this.updateButtonState();
                this.updatePropertyViewState();
            }
        }