private void deleteListenerLocal(int walletNumber) { string dataString = null; dataString = Listener.FormatListenerData(serviceLayer.GetListenerById(walletNumber)); // Show prompt. DialogResult result = MessageBox.Show("Are you sure you wish to delete the following listener?" + Environment.NewLine + Environment.NewLine + dataString + Environment.NewLine + "Press [Y] to confirm or [N] to cancel.", ModuleGeneric.getAppShortName(), MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } else if (result == DialogResult.Yes) { string myReason = Interaction.InputBox("Please enter a reason for deletion", "S.B.T.N.A.", ""); bool resultofdelete = false; // Check if the delete was a success. resultofdelete = serviceLayer.SoftDeleteListener(serviceLayer.GetListenerById(walletNumber), myReason); if (resultofdelete) { Interaction.MsgBox("Listener deleted successfully."); MessageBox.Show("You should remove all wallets including the magazine wallet" + Environment.NewLine + "from stock for Wallet number " + txtWallet.Text + ".", ModuleGeneric.getAppShortName(), MessageBoxButtons.OK); // Check if the player / memory stick has been returned. var tempListener = serviceLayer.GetListenerById(walletNumber); if ((tempListener.MemStickPlayer)) { DialogResult walletReturned = MessageBox.Show("Did the listener return the memory stick player?", ModuleGeneric.getAppShortName(), MessageBoxButtons.YesNo); if (walletReturned == DialogResult.Yes) { tempListener.MemStickPlayer = false; if (!serviceLayer.UpdateListener(tempListener)) { Interaction.MsgBox("Error deleting listener."); } } else { // Else print deleted listener form. My.MyProject.Forms.formPrintCollectionForm.Show(); My.MyProject.Forms.formPrintCollectionForm.setupForm(tempListener, true); } } } else { Interaction.MsgBox("Error deleting listener."); } } }
public void addListItem(int walletId) { // If there is no duplicate, just add the item. string[] arr = new string[3]; ListViewItem itm = null; //Add first item arr[0] = walletId.ToString(); arr[1] = "1"; itm = new ListViewItem(arr); lstScanned.Items.Add(itm); txtScannerInput.Text = ""; scannedOut = scannedOut + 1; // Focus list item properly. lstScanned.Focus(); lstScanned.Items[lstScanned.Items.Count - 1].Selected = true; lstScanned.Items[lstScanned.Items.Count - 1].Focused = true; lstScanned.Items[lstScanned.Items.Count - 1].EnsureVisible(); txtScannerInput.Focus(); // Process and play a second beep. ModuleGeneric.Sleep(100); Listener theListener = default(Listener); theListener = serviceLayer.GetListenerById(walletId); if (((theListener == null))) { ModuleSounds.PlayNotInUse(); } else { if (theListener.Status == ListenerStates.ACTIVE & (theListener.Joined > DateTime.Now.AddDays(-6) & theListener.Stock == 3)) { ModuleSounds.PlayNew(); } else if (theListener.Status == ListenerStates.PAUSED) { ModuleSounds.PlayStopped(); } else { ModuleSounds.PlaySecondBeep(); } } }
private void Button2_Click(object sender, EventArgs e) { string myWallet = Interaction.InputBox("Please enter a wallet number!"); var myWalletInt = int.Parse(myWallet); My.MyProject.Forms.formPrintCollectionForm.Show(); My.MyProject.Forms.formPrintCollectionForm.setupForm(serviceLayer.GetListenerById(myWalletInt), true); }
public void setupForm(int walletId) { Listener theListener = default(Listener); theListener = serviceLayer.GetListenerById(walletId); lblWallet.Text = "" + walletId; lblName.Text = theListener.Title + " " + theListener.Forename + " " + theListener.Surname; }
private void btnCancelStop_Click(object sender, EventArgs e) { int theIndex = 0; if (lstBrowse.FocusedItem != null) { theIndex = lstBrowse.FocusedItem.Index; // First sub item is wallet number. int walletNumb = 0; walletNumb = int.Parse(lstBrowse.Items[theIndex].SubItems[0].Text); Listener theListener = serviceLayer.GetListenerById(walletNumb); try { theListener.Resume(); if (!serviceLayer.UpdateListener(theListener)) { log.Error("Failed to update and resume listener! WalletId: " + walletNumb); Interaction.MsgBox("Error: Failed to update listener"); } else { Interaction.MsgBox("Succesfully updated listener."); log.Info("Resumed and updated listener with WalletId: " + walletNumb); refreshList(); } } catch (ListenerStateChangeException ex) { log.Error(ex, "Attempt to resume non paused listener! WalletId: " + walletNumb); Interaction.MsgBox("This listener is not Paused."); } } }
public void addListItem(int walletId) { for (int i = 0; i <= (lstScanned.Items.Count - 1); i++) { ListViewItem item = lstScanned.Items[i]; // If the item exists, just update the quantity. if (item.SubItems[0].Text == walletId.ToString()) { var currentQuantity = int.Parse(item.SubItems[1].Text); currentQuantity = currentQuantity + 1; if (currentQuantity == 2) { ModuleSounds.PlayTwoIn(); } else if (currentQuantity == 3) { ModuleSounds.PlayThreeIn(); } else if (currentQuantity == 3) { // 3 is the max.. currentQuantity = 3; } else { ModuleSounds.PlaySecondBeep(); } item.SubItems[1].Text = currentQuantity.ToString(); // Clear text and play duplicate sound. txtScannerInput.Text = string.Empty; scannedIn = scannedIn + 1; // Focus list item properly. lstScanned.Focus(); lstScanned.Items[i].Selected = true; lstScanned.Items[i].Focused = true; lstScanned.Items[i].EnsureVisible(); txtScannerInput.Focus(); // Check they exist again! if (serviceLayer.GetListenerById(walletId) == null) { ModuleSounds.PlayNotInUse(); } return; } } // If there is no duplicate, just add the item. string[] arr = new string[3]; ListViewItem itm = null; //Add first item arr[0] = walletId.ToString(); arr[1] = "1"; itm = new ListViewItem(arr); lstScanned.Items.Add(itm); txtScannerInput.Text = ""; scannedIn = scannedIn + 1; // Focus list item properly. lstScanned.Focus(); lstScanned.Items[lstScanned.Items.Count - 1].Selected = true; lstScanned.Items[lstScanned.Items.Count - 1].Focused = true; lstScanned.Items[lstScanned.Items.Count - 1].EnsureVisible(); txtScannerInput.Focus(); // Process and play a second beep. ModuleGeneric.Sleep(100); Listener theListener = default(Listener); theListener = serviceLayer.GetListenerById(walletId); if (theListener == null) { ModuleSounds.PlayNotInUse(); } else { if (theListener.Status == ListenerStates.PAUSED) { ModuleSounds.PlayStopped(); } else if (theListener.Status == ListenerStates.DELETED) { ModuleSounds.PlayNotInUse(); Interaction.MsgBox("This listener has been deleted. Please remove the label and place wallet into the stock of unused wallets."); } else { ModuleSounds.PlaySecondBeep(); // Asynchronous //synthesizer.Volume = 100; //synthesizer.Rate = -2; //synthesizer.SpeakAsync(new Prompt("" + walletId)); } } }
private void btnFinished_Click(object sender, EventArgs e) { bool addrChanged = HasAddressChanged(); bool nameChanged = HasNameChanged(); bool updated = HasUpdated(); if (comboTitle.SelectedItem == null) { Interaction.MsgBox("Invalid title entered, please use an item in the drop down list."); return; } // Only if they are updated... if (updated) { myListener.Title = comboTitle.SelectedItem.ToString(); myListener.Forename = txtForename.Text; myListener.Surname = txtSurname.Text; myListener.Addr1 = txtAddr1.Text; myListener.Addr2 = txtAddr2.Text; myListener.Town = txtTown.Text; myListener.County = txtCounty.Text; myListener.Postcode = txtPostcode.Text; myListener.MemStickPlayer = chkMemStickPlayer.Checked; myListener.Magazine = chkMagazine.Checked; myListener.Info = txtInformation.Text; if ((!string.IsNullOrEmpty(txtTelephone.Text))) { myListener.Telephone = (txtTelephone.Text); } else { myListener.Telephone = "0"; } if ((!string.IsNullOrEmpty(txtStock.Text))) { myListener.Stock = int.Parse(txtStock.Text); } if (chkNoBirthday.Checked) { myListener.Birthday = null; } else { myListener.Birthday = birthdayDate.Value; } if (serviceLayer.UpdateListener(myListener)) { Interaction.MsgBox("The listener has successfully been updated."); if (addrChanged || nameChanged) { // Show prompt. DialogResult result = MessageBox.Show("Would you like to print new address labels for the updated address?", ModuleGeneric.getAppShortName(), MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { My.MyProject.Forms.formChoosePrintPoint.Show(); My.MyProject.Forms.formChoosePrintPoint.SetupForm(serviceLayer.GetListenerById(listenerWalletNo)); } } } } this.Close(); }
// Dynamic button depending on form setup. private void btnDynamic_Click(object sender, EventArgs e) { // Add Form if (theFormType == DuplicateFormType.AddForm) { My.MyProject.Forms.formAddFull.Show(); // Use subitems 1, 2, and 3 as they are Title, Forename and Surname. My.MyProject.Forms.formAddFull.comboTitle.SelectedItem = lstDuplicates.Items[0].SubItems[1].Text; My.MyProject.Forms.formAddFull.txtSurname.Text = lstDuplicates.Items[0].SubItems[2].Text; My.MyProject.Forms.formAddFull.txtForename.Text = lstDuplicates.Items[0].SubItems[3].Text; this.Close(); } // Delete Form if (theFormType == DuplicateFormType.DeleteForm) { // Do we have a selected item? if ((lstDuplicates.FocusedItem != null)) { int theIndex = 0; theIndex = lstDuplicates.FocusedItem.Index; // First sub item is wallet number. int walletNumb = 0; walletNumb = int.Parse(lstDuplicates.Items[theIndex].SubItems[0].Text); string dataString = null; dataString = Listener.FormatListenerData(serviceLayer.GetListenerById(walletNumb)); // Show prompt. DialogResult result = MessageBox.Show("Are you sure you wish to delete the following listener?" + Environment.NewLine + Environment.NewLine + dataString + Environment.NewLine + "Press [Y] to confirm or [N] to cancel.", ModuleGeneric.getAppShortName(), MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { string myReason = Interaction.InputBox("Please enter a reason for deletion", "S.B.T.N.A.", ""); bool resultofdelete = false; // Check if the delete was a success. resultofdelete = serviceLayer.SoftDeleteListener(serviceLayer.GetListenerById(walletNumb), myReason); if (resultofdelete) { Interaction.MsgBox("Listener deleted successfully."); lstDuplicates.Items[theIndex].Remove(); MessageBox.Show("You should remove all wallets including the magazine wallet" + Environment.NewLine + "from stock for Wallet number " + walletNumb + ".", ModuleGeneric.getAppShortName(), MessageBoxButtons.OK); } else { Interaction.MsgBox("Error deleting listener."); } this.Close(); } } } // Edit Form if (theFormType == DuplicateFormType.EditForm) { // Do we have a selected item? if ((lstDuplicates.FocusedItem != null)) { int theIndex = 0; theIndex = lstDuplicates.FocusedItem.Index; // First sub item is wallet number. int walletNumb = 0; walletNumb = int.Parse(lstDuplicates.Items[theIndex].SubItems[0].Text); My.MyProject.Forms.formEdit.Show(); My.MyProject.Forms.formEdit.setupForm(serviceLayer.GetListenerById(walletNumb)); this.Close(); } } // StopSending form if (theFormType == DuplicateFormType.StopSending) { // Do we have a selected item? if ((lstDuplicates.FocusedItem != null)) { int theIndex = 0; theIndex = lstDuplicates.FocusedItem.Index; // First sub item is wallet number. int walletNumb = 0; walletNumb = int.Parse(lstDuplicates.Items[theIndex].SubItems[0].Text); My.MyProject.Forms.formStopSending.Show(); My.MyProject.Forms.formStopSending.setupForm(serviceLayer.GetListenerById(walletNumb)); this.Close(); } } // Print labels form. if (theFormType == DuplicateFormType.PrintLabels) { // Do we have a selected item? if ((lstDuplicates.FocusedItem != null)) { int theIndex = 0; theIndex = lstDuplicates.FocusedItem.Index; // First sub item is wallet number. int walletNumb = 0; walletNumb = int.Parse(lstDuplicates.Items[theIndex].SubItems[0].Text); My.MyProject.Forms.formChoosePrintPoint.Show(); My.MyProject.Forms.formChoosePrintPoint.SetupForm(serviceLayer.GetListenerById(walletNumb)); this.Close(); } } if (theFormType == DuplicateFormType.PrintCollector) { // Do we have a selected item? if ((lstDuplicates.FocusedItem != null)) { int theIndex = 0; theIndex = lstDuplicates.FocusedItem.Index; // First sub item is wallet number. int walletNumb = 0; walletNumb = int.Parse(lstDuplicates.Items[theIndex].SubItems[0].Text); DialogResult result = MessageBox.Show("Are you printing this form for a deleted listener? (Select No if its a new one)", ModuleGeneric.getAppShortName(), MessageBoxButtons.YesNo); bool deleted = (result == DialogResult.Yes); My.MyProject.Forms.formPrintCollectionForm.Show(); My.MyProject.Forms.formPrintCollectionForm.setupForm(serviceLayer.GetListenerById(walletNumb), deleted); this.Close(); } } if (theFormType == DuplicateFormType.AdjustStock) { // Do we have a selected item? if ((lstDuplicates.FocusedItem != null)) { int theIndex = 0; theIndex = lstDuplicates.FocusedItem.Index; // First sub item is wallet number. int walletNumb = 0; walletNumb = int.Parse(lstDuplicates.Items[theIndex].SubItems[0].Text); FormAdjustStockLevels formAdjustStock = new FormAdjustStockLevels(); formAdjustStock.setListener(serviceLayer.GetListenerById(walletNumb)); formAdjustStock.Show(); this.Close(); } } }
// Add the listener to the database. private void btnFinished_Click(object sender, EventArgs e) { Listener newListener = new Listener(); newListener.Wallet = 0; newListener.Title = comboTitle.Text; newListener.Forename = txtForename.Text; newListener.Surname = txtSurname.Text; newListener.Addr1 = txtAddr1.Text; newListener.Addr2 = txtAddr2.Text; newListener.Town = txtTown.Text; newListener.County = txtCounty.Text; newListener.Postcode = txtPostcode.Text; newListener.MemStickPlayer = chkTape.Checked; newListener.Magazine = chkMagazine.Checked; newListener.Info = txtInformation.Text; if ((!string.IsNullOrEmpty(txtTelephone.Text))) { newListener.Telephone = (txtTelephone.Text); } else { newListener.Telephone = "0"; } string theStr = ""; if (chkNoBirthday.Checked) { theStr = "01/01/" + DateTime.Now.Year; } else { theStr = birthdayDate.Value.ToString(ModuleGeneric.DATE_FORMAT); } newListener.Birthday = DateTime.Parse(theStr); newListener.Status = ListenerStates.ACTIVE; newListener.StatusInfo = ""; newListener.DeletedDate = DateTime.Now; newListener.Joined = DateTime.Now; newListener.inOutRecords = new InOutRecords(); int result = 0; result = serviceLayer.AddListener(newListener); if (result > 0) { log.Debug("Listener has been added. ID: " + result + ", Name: " + newListener.GetNiceName()); Interaction.MsgBox("The listener has successfully been added."); Listener newListenerWithWalletNo = serviceLayer.GetListenerById(result); // Do new labels need to be added? DialogResult msgResult = MessageBox.Show("Would you like to print labels for the new listener?", ModuleGeneric.getAppShortName(), MessageBoxButtons.YesNo); if (msgResult == DialogResult.Yes) { My.MyProject.Forms.formChoosePrintPoint.Show(); My.MyProject.Forms.formChoosePrintPoint.SetupForm(newListenerWithWalletNo); } // Will they use a memory stick player? if (newListener.MemStickPlayer) { Interaction.MsgBox("Please print the following form as listener requires a memory stick player."); My.MyProject.Forms.formPrintCollectionForm.Show(); My.MyProject.Forms.formPrintCollectionForm.setupForm(newListenerWithWalletNo, false); } this.Close(); } else { log.Error("Failed to add new listener!"); Interaction.MsgBox("Failed to add new listener!"); this.Close(); } }