Esempio n. 1
0
        // Show restore dialog.
        public void showRestore()
        {
            DialogResult result = MessageBox.Show("You should backup the existing database before restoring as restoring will overwrite the current database." + Environment.NewLine + Environment.NewLine + "Overwriting the current database is irreversible, are you sure you want to continue?", ModuleGeneric.getAppShortName(), MessageBoxButtons.OKCancel);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            restoreDialog.FileName         = ModuleGeneric.DATABASE_NAME;
            restoreDialog.Title            = "Restore Listener Database";
            restoreDialog.Filter           = "SQLite Database Files|*.s3db";
            restoreDialog.CheckPathExists  = true;
            restoreDialog.InitialDirectory = "A:\\";

            // If successful, backup the database.
            if (restoreDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (DBUtils.RestoreDatabase(restoreDialog.FileName, ModuleGeneric.GetDatabasePath()))
                {
                    Interaction.MsgBox("Database restore successful.");
                }
                else
                {
                    Interaction.MsgBox("Error: Database was not restored correctly!");
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// On the form load
 /// </summary>
 /// <param name="sender">ignored</param>
 /// <param name="e">ignored</param>
 private void FormAbout_Load(object sender, EventArgs e)
 {
     log.Trace("Loading form.");
     lblVersion.Text   = ModuleGeneric.getVersionString();
     lblDotNetVer.Text = ".Net " + Environment.Version;
     Label1.Text       = Settings.Default.AssociationName;
 }
Esempio n. 3
0
        /// <summary>
        /// When the form loads.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void formMain_Load(object sender, EventArgs e)
        {
            // Load the logo
            LoadLogo();

            // Initially update the time labels.
            updateTimers();

            // Set an initial hint.
            updateHints();

            // Update week number.
            updateWeekNumber();

            // Show version
            lblVersion.Text = ModuleGeneric.getVersionString();
            log.Info("Loaded " + ModuleGeneric.getVersionString());

            // If its not saturday we shouldnt be scanning in!
            if (!(DateTime.UtcNow.DayOfWeek.Equals(DayOfWeek.Saturday)))
            {
                btnScanIn.Enabled = false;
            }

            // Ensure the scan table exists
            serviceLayer.EnsureScanTableExists();
        }
Esempio n. 4
0
        private void updateHints()
        {
            List <string> hints = new List <string>();

            hints.Add("Log files can be found at: " + ModuleGeneric.GetLogFilePath());
            hints.Add("");

            // Pick a random item from the hints.
            Random randomNumber = new Random();

            lblHints.Text = hints[randomNumber.Next(0, hints.Count)];
        }
Esempio n. 5
0
        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();
                }
            }
        }
Esempio n. 6
0
        // On load.
        private void formFinished_Load(object sender, EventArgs e)
        {
            ModuleGeneric.saveEndTime();

            // Setup labels.
            int weeknumb = serviceLayer.GetCurrentWeekNumber();

            lblStartTime.Text   = ModuleGeneric.getStartTimeString();
            lblFinishTime.Text  = ModuleGeneric.getEndTimeString();
            lblElapsedTime.Text = ModuleGeneric.getElapsedTimeString();
            lblScannedIn.Text   = ModuleScanning.getScannedIn().ToString();
            lblScannedOut.Text  = ModuleScanning.getScannedOut().ToString();

            // Update the stats week
            ModuleGeneric.UpdateStatsWeek(serviceLayer, false);

            readyToExit = true;
        }
Esempio n. 7
0
        /// <summary>
        /// Keep the log file up to date!
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void logUpdater_Tick(object sender, EventArgs e)
        {
            // Get the log
            string logPath = ModuleGeneric.GetLogFilePath();

            if (File.Exists(logPath))
            {
                // Only update if its changed
                string newContent = File.ReadAllText(logPath);
                if (!lastUpdate.Equals(newContent))
                {
                    lastUpdate = newContent;
                    UpdateText(lastUpdate);
                }
            }
            else
            {
                txtLog.Clear();
                txtLog.Text = "Couldn't load log file, does it exist at: '" + logPath + "' ? ";
            }
        }
Esempio n. 8
0
        // Show backup dialog.
        public void showBackup()
        {
            backupDialog.FileName         = ModuleGeneric.DATABASE_NAME;
            backupDialog.Title            = "Backup Listener Database";
            backupDialog.Filter           = "SQLite Database Files|*.s3db";
            backupDialog.CheckPathExists  = true;
            backupDialog.InitialDirectory = "A:\\";
            backupDialog.OverwritePrompt  = Settings.Default.OverwritePrompt;

            // If successful, backup the database.
            if (backupDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (DBUtils.CopyDatabase(ModuleGeneric.GetDatabasePath(), backupDialog.FileName))
                {
                    Interaction.MsgBox("Database backup successful, please restart app!");
                }
                else
                {
                    Interaction.MsgBox("Error: Database was not copied correctly!");
                }
            }
        }
Esempio n. 9
0
        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();
        }
Esempio n. 10
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            // Confirm we really want to cancel.
            DialogResult result = MessageBox.Show("Are you sure you wish to cancel?" + Environment.NewLine + Environment.NewLine + "Press [y] to confirm, [n] to cancel.", ModuleGeneric.getAppShortName(), MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                this.Close();
            }
        }
Esempio n. 11
0
 private void InitializeComponent()
 {
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormTest));
     this.btnAddListener      = new System.Windows.Forms.Button();
     this.btnCleanDatabase    = new System.Windows.Forms.Button();
     this.tabControl          = new System.Windows.Forms.TabControl();
     this.tabDefault          = new System.Windows.Forms.TabPage();
     this.btnClose            = new System.Windows.Forms.Button();
     this.Label1              = new System.Windows.Forms.Label();
     this.tabListeners        = new System.Windows.Forms.TabPage();
     this.DateTimePicker1     = new System.Windows.Forms.DateTimePicker();
     this.Button4             = new System.Windows.Forms.Button();
     this.Button2             = new System.Windows.Forms.Button();
     this.btnGetFreeIndex     = new System.Windows.Forms.Button();
     this.tabWeeklyStats      = new System.Windows.Forms.TabPage();
     this.Button3             = new System.Windows.Forms.Button();
     this.btnClearWeekStats   = new System.Windows.Forms.Button();
     this.tabYearlyStats      = new System.Windows.Forms.TabPage();
     this.Button1             = new System.Windows.Forms.Button();
     this.btnClearYearlyStats = new System.Windows.Forms.Button();
     this.tabGeneric          = new System.Windows.Forms.TabPage();
     this.btnDevTest          = new System.Windows.Forms.Button();
     this.btnThrowException   = new System.Windows.Forms.Button();
     this.tabPage1            = new System.Windows.Forms.TabPage();
     this.label2              = new System.Windows.Forms.Label();
     this.txtConvertLog       = new System.Windows.Forms.TextBox();
     this.label3              = new System.Windows.Forms.Label();
     this.btnRunCommands      = new System.Windows.Forms.Button();
     this.lblLinesRead        = new System.Windows.Forms.Label();
     this.tabControl.SuspendLayout();
     this.tabDefault.SuspendLayout();
     this.tabListeners.SuspendLayout();
     this.tabWeeklyStats.SuspendLayout();
     this.tabYearlyStats.SuspendLayout();
     this.tabGeneric.SuspendLayout();
     this.tabPage1.SuspendLayout();
     this.SuspendLayout();
     //
     // btnAddListener
     //
     this.btnAddListener.Location = new System.Drawing.Point(6, 41);
     this.btnAddListener.Name     = "btnAddListener";
     this.btnAddListener.Size     = new System.Drawing.Size(155, 29);
     this.btnAddListener.TabIndex = 1;
     this.btnAddListener.Text     = "Add New Listener";
     this.btnAddListener.UseVisualStyleBackColor = true;
     this.btnAddListener.Click += new System.EventHandler(this.btnAddListener_Click);
     //
     // btnCleanDatabase
     //
     this.btnCleanDatabase.Location = new System.Drawing.Point(6, 6);
     this.btnCleanDatabase.Name     = "btnCleanDatabase";
     this.btnCleanDatabase.Size     = new System.Drawing.Size(155, 29);
     this.btnCleanDatabase.TabIndex = 2;
     this.btnCleanDatabase.Text     = "Clean Database";
     this.btnCleanDatabase.UseVisualStyleBackColor = true;
     this.btnCleanDatabase.Click += new System.EventHandler(this.btnCleanDatabase_Click);
     //
     // tabControl
     //
     this.tabControl.Controls.Add(this.tabDefault);
     this.tabControl.Controls.Add(this.tabListeners);
     this.tabControl.Controls.Add(this.tabWeeklyStats);
     this.tabControl.Controls.Add(this.tabYearlyStats);
     this.tabControl.Controls.Add(this.tabGeneric);
     this.tabControl.Controls.Add(this.tabPage1);
     this.tabControl.Location      = new System.Drawing.Point(12, 12);
     this.tabControl.Name          = "tabControl";
     this.tabControl.SelectedIndex = 0;
     this.tabControl.Size          = new System.Drawing.Size(528, 370);
     this.tabControl.TabIndex      = 0;
     //
     // tabDefault
     //
     this.tabDefault.Controls.Add(this.btnClose);
     this.tabDefault.Controls.Add(this.Label1);
     this.tabDefault.Location = new System.Drawing.Point(4, 22);
     this.tabDefault.Name     = "tabDefault";
     this.tabDefault.Padding  = new System.Windows.Forms.Padding(3);
     this.tabDefault.Size     = new System.Drawing.Size(520, 218);
     this.tabDefault.TabIndex = 3;
     this.tabDefault.Text     = "Test Controls";
     this.tabDefault.UseVisualStyleBackColor = true;
     //
     // btnClose
     //
     this.btnClose.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(128)))));
     this.btnClose.Location  = new System.Drawing.Point(199, 138);
     this.btnClose.Name      = "btnClose";
     this.btnClose.Size      = new System.Drawing.Size(115, 50);
     this.btnClose.TabIndex  = 1;
     this.btnClose.Text      = "Close";
     this.btnClose.UseVisualStyleBackColor = false;
     this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
     //
     // Label1
     //
     this.Label1.AutoSize = true;
     this.Label1.Font     = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
     this.Label1.Location = new System.Drawing.Point(36, 57);
     this.Label1.Name     = "Label1";
     this.Label1.Size     = new System.Drawing.Size(450, 25);
     this.Label1.TabIndex = 0;
     this.Label1.Text     = "Welcome to the " + ModuleGeneric.getAppShortName() + " Application test page.";
     //
     // tabListeners
     //
     this.tabListeners.Controls.Add(this.DateTimePicker1);
     this.tabListeners.Controls.Add(this.Button4);
     this.tabListeners.Controls.Add(this.Button2);
     this.tabListeners.Controls.Add(this.btnGetFreeIndex);
     this.tabListeners.Controls.Add(this.btnAddListener);
     this.tabListeners.Controls.Add(this.btnCleanDatabase);
     this.tabListeners.Location = new System.Drawing.Point(4, 22);
     this.tabListeners.Name     = "tabListeners";
     this.tabListeners.Padding  = new System.Windows.Forms.Padding(3);
     this.tabListeners.Size     = new System.Drawing.Size(520, 218);
     this.tabListeners.TabIndex = 0;
     this.tabListeners.Text     = "Listener Database";
     this.tabListeners.UseVisualStyleBackColor = true;
     //
     // DateTimePicker1
     //
     this.DateTimePicker1.CustomFormat = "ddddMMMMyyyy";
     this.DateTimePicker1.Location     = new System.Drawing.Point(344, 15);
     this.DateTimePicker1.Name         = "DateTimePicker1";
     this.DateTimePicker1.Size         = new System.Drawing.Size(152, 20);
     this.DateTimePicker1.TabIndex     = 6;
     //
     // Button4
     //
     this.Button4.Location = new System.Drawing.Point(344, 44);
     this.Button4.Name     = "Button4";
     this.Button4.Size     = new System.Drawing.Size(152, 26);
     this.Button4.TabIndex = 5;
     this.Button4.Text     = "Print Birthdays for Week";
     this.Button4.UseVisualStyleBackColor = true;
     this.Button4.Click += new System.EventHandler(this.Button4_Click);
     //
     // Button2
     //
     this.Button2.Location = new System.Drawing.Point(6, 110);
     this.Button2.Name     = "Button2";
     this.Button2.Size     = new System.Drawing.Size(155, 28);
     this.Button2.TabIndex = 4;
     this.Button2.Text     = "Print deleted form for Listener";
     this.Button2.UseVisualStyleBackColor = true;
     this.Button2.Click += new System.EventHandler(this.Button2_Click);
     //
     // btnGetFreeIndex
     //
     this.btnGetFreeIndex.Location = new System.Drawing.Point(6, 76);
     this.btnGetFreeIndex.Name     = "btnGetFreeIndex";
     this.btnGetFreeIndex.Size     = new System.Drawing.Size(155, 28);
     this.btnGetFreeIndex.TabIndex = 3;
     this.btnGetFreeIndex.Text     = "Get Next Free Index";
     this.btnGetFreeIndex.UseVisualStyleBackColor = true;
     this.btnGetFreeIndex.Click += new System.EventHandler(this.btnGetFreeIndex_Click);
     //
     // tabWeeklyStats
     //
     this.tabWeeklyStats.Controls.Add(this.Button3);
     this.tabWeeklyStats.Controls.Add(this.btnClearWeekStats);
     this.tabWeeklyStats.Location = new System.Drawing.Point(4, 22);
     this.tabWeeklyStats.Name     = "tabWeeklyStats";
     this.tabWeeklyStats.Padding  = new System.Windows.Forms.Padding(3);
     this.tabWeeklyStats.Size     = new System.Drawing.Size(520, 218);
     this.tabWeeklyStats.TabIndex = 1;
     this.tabWeeklyStats.Text     = "Weekly Stats";
     this.tabWeeklyStats.UseVisualStyleBackColor = true;
     //
     // Button3
     //
     this.Button3.Location = new System.Drawing.Point(6, 41);
     this.Button3.Name     = "Button3";
     this.Button3.Size     = new System.Drawing.Size(155, 29);
     this.Button3.TabIndex = 5;
     this.Button3.Text     = "Get Week Number";
     this.Button3.UseVisualStyleBackColor = true;
     this.Button3.Click += new System.EventHandler(this.Button3_Click);
     //
     // btnClearWeekStats
     //
     this.btnClearWeekStats.Location = new System.Drawing.Point(6, 6);
     this.btnClearWeekStats.Name     = "btnClearWeekStats";
     this.btnClearWeekStats.Size     = new System.Drawing.Size(155, 29);
     this.btnClearWeekStats.TabIndex = 4;
     this.btnClearWeekStats.Text     = "Clean Database";
     this.btnClearWeekStats.UseVisualStyleBackColor = true;
     this.btnClearWeekStats.Click += new System.EventHandler(this.btnClearWeekStats_Click);
     //
     // tabYearlyStats
     //
     this.tabYearlyStats.Controls.Add(this.Button1);
     this.tabYearlyStats.Controls.Add(this.btnClearYearlyStats);
     this.tabYearlyStats.Location = new System.Drawing.Point(4, 22);
     this.tabYearlyStats.Name     = "tabYearlyStats";
     this.tabYearlyStats.Size     = new System.Drawing.Size(520, 218);
     this.tabYearlyStats.TabIndex = 2;
     this.tabYearlyStats.Text     = "Yearly Stats";
     this.tabYearlyStats.UseVisualStyleBackColor = true;
     //
     // Button1
     //
     this.Button1.Location = new System.Drawing.Point(3, 38);
     this.Button1.Name     = "Button1";
     this.Button1.Size     = new System.Drawing.Size(155, 29);
     this.Button1.TabIndex = 6;
     this.Button1.Text     = "Check Last Years Listeners";
     this.Button1.UseVisualStyleBackColor = true;
     this.Button1.Click += new System.EventHandler(this.Button1_Click);
     //
     // btnClearYearlyStats
     //
     this.btnClearYearlyStats.Location = new System.Drawing.Point(3, 3);
     this.btnClearYearlyStats.Name     = "btnClearYearlyStats";
     this.btnClearYearlyStats.Size     = new System.Drawing.Size(155, 29);
     this.btnClearYearlyStats.TabIndex = 5;
     this.btnClearYearlyStats.Text     = "Clean Database";
     this.btnClearYearlyStats.UseVisualStyleBackColor = true;
     this.btnClearYearlyStats.Click += new System.EventHandler(this.btnClearYearlyStats_Click);
     //
     // tabGeneric
     //
     this.tabGeneric.Controls.Add(this.btnDevTest);
     this.tabGeneric.Controls.Add(this.btnThrowException);
     this.tabGeneric.Location = new System.Drawing.Point(4, 22);
     this.tabGeneric.Name     = "tabGeneric";
     this.tabGeneric.Padding  = new System.Windows.Forms.Padding(3);
     this.tabGeneric.Size     = new System.Drawing.Size(520, 218);
     this.tabGeneric.TabIndex = 4;
     this.tabGeneric.Text     = "Other";
     this.tabGeneric.UseVisualStyleBackColor = true;
     //
     // btnDevTest
     //
     this.btnDevTest.Location = new System.Drawing.Point(6, 41);
     this.btnDevTest.Name     = "btnDevTest";
     this.btnDevTest.Size     = new System.Drawing.Size(155, 29);
     this.btnDevTest.TabIndex = 4;
     this.btnDevTest.Text     = "Latest Dev Test";
     this.btnDevTest.UseVisualStyleBackColor = true;
     this.btnDevTest.Click += new System.EventHandler(this.btnDevTest_Click);
     //
     // btnThrowException
     //
     this.btnThrowException.Location = new System.Drawing.Point(6, 6);
     this.btnThrowException.Name     = "btnThrowException";
     this.btnThrowException.Size     = new System.Drawing.Size(155, 29);
     this.btnThrowException.TabIndex = 3;
     this.btnThrowException.Text     = "Throw Exception";
     this.btnThrowException.UseVisualStyleBackColor = true;
     this.btnThrowException.Click += new System.EventHandler(this.btnThrowException_Click);
     //
     // tabPage1
     //
     this.tabPage1.Controls.Add(this.lblLinesRead);
     this.tabPage1.Controls.Add(this.btnRunCommands);
     this.tabPage1.Controls.Add(this.label3);
     this.tabPage1.Controls.Add(this.txtConvertLog);
     this.tabPage1.Controls.Add(this.label2);
     this.tabPage1.Location = new System.Drawing.Point(4, 22);
     this.tabPage1.Name     = "tabPage1";
     this.tabPage1.Padding  = new System.Windows.Forms.Padding(3);
     this.tabPage1.Size     = new System.Drawing.Size(520, 344);
     this.tabPage1.TabIndex = 5;
     this.tabPage1.Text     = "Log to SQL";
     this.tabPage1.UseVisualStyleBackColor = true;
     //
     // label2
     //
     this.label2.AutoSize = true;
     this.label2.Location = new System.Drawing.Point(18, 14);
     this.label2.Name     = "label2";
     this.label2.Size     = new System.Drawing.Size(493, 13);
     this.label2.TabIndex = 0;
     this.label2.Text     = "Attempts to convert a log file into SQL statements - use only as a last resort! D" +
                            "rag the file on to convert..";
     //
     // txtConvertLog
     //
     this.txtConvertLog.AllowDrop  = true;
     this.txtConvertLog.Location   = new System.Drawing.Point(6, 42);
     this.txtConvertLog.Multiline  = true;
     this.txtConvertLog.Name       = "txtConvertLog";
     this.txtConvertLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
     this.txtConvertLog.Size       = new System.Drawing.Size(505, 235);
     this.txtConvertLog.TabIndex   = 1;
     this.txtConvertLog.DragDrop  += new System.Windows.Forms.DragEventHandler(this.txtConvertLog_DragDrop);
     this.txtConvertLog.DragEnter += new System.Windows.Forms.DragEventHandler(this.txtConvertLog_DragEnter);
     //
     // label3
     //
     this.label3.AutoSize = true;
     this.label3.Location = new System.Drawing.Point(411, 280);
     this.label3.Name     = "label3";
     this.label3.Size     = new System.Drawing.Size(103, 13);
     this.label3.TabIndex = 2;
     this.label3.Text     = "Warning: this is slow";
     //
     // btnRunCommands
     //
     this.btnRunCommands.BackColor = System.Drawing.Color.Maroon;
     this.btnRunCommands.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
     this.btnRunCommands.Location  = new System.Drawing.Point(200, 283);
     this.btnRunCommands.Name      = "btnRunCommands";
     this.btnRunCommands.Size      = new System.Drawing.Size(124, 55);
     this.btnRunCommands.TabIndex  = 3;
     this.btnRunCommands.Text      = "Run on DB";
     this.btnRunCommands.UseVisualStyleBackColor = false;
     this.btnRunCommands.Click += new System.EventHandler(this.btnRunCommands_Click);
     //
     // lblLinesRead
     //
     this.lblLinesRead.AutoSize = true;
     this.lblLinesRead.Location = new System.Drawing.Point(6, 280);
     this.lblLinesRead.Name     = "lblLinesRead";
     this.lblLinesRead.Size     = new System.Drawing.Size(13, 13);
     this.lblLinesRead.TabIndex = 4;
     this.lblLinesRead.Text     = "0";
     //
     // formTest
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize          = new System.Drawing.Size(552, 394);
     this.Controls.Add(this.tabControl);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
     this.Icon            = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.MaximizeBox     = false;
     this.MinimizeBox     = false;
     this.Name            = "formTest";
     this.StartPosition   = System.Windows.Forms.FormStartPosition.CenterScreen;
     this.Text            = "Testing Form";
     this.tabControl.ResumeLayout(false);
     this.tabDefault.ResumeLayout(false);
     this.tabDefault.PerformLayout();
     this.tabListeners.ResumeLayout(false);
     this.tabWeeklyStats.ResumeLayout(false);
     this.tabYearlyStats.ResumeLayout(false);
     this.tabGeneric.ResumeLayout(false);
     this.tabPage1.ResumeLayout(false);
     this.tabPage1.PerformLayout();
     this.ResumeLayout(false);
 }
Esempio n. 12
0
        private void progressForm()
        {
            // Check all fields have data.
            if ((string.IsNullOrEmpty(txtForename.Text) | string.IsNullOrEmpty(txtSurname.Text) | string.IsNullOrEmpty(comboTitle.Text)))
            {
                log.Warn("User attempted to submit empty form.");
                Interaction.MsgBox("You must complete the form first.");
            }
            else
            {
                // Check Name exists
                List <Listener> theListeners = new List <Listener>();
                log.Trace("Looking up listeners by name and surname.");
                theListeners = serviceLayer.GetListenersByName(txtForename.Text, txtSurname.Text, comboTitle.Text);

                // Check for results.
                if ((theListeners != null) & theListeners.Count > 0)
                {
                    // If its just one form.
                    string dataString = null;
                    if (theListeners.Count == 1)
                    {
                        // Look up data.
                        Listener theListener = theListeners[0];
                        dataString = Listener.FormatListenerData(theListener);

                        // Show prompt.
                        DialogResult result = MessageBox.Show("There would appear to be another listener with the same name. Is this a duplicate?" + Environment.NewLine + Environment.NewLine + dataString + Environment.NewLine + "Press [Y] if this is a duplicate or [N] otherwise.", ModuleGeneric.getAppShortName(), MessageBoxButtons.YesNo);
                        if (result == DialogResult.No)
                        {
                            // Show the form.
                            showFullForm();
                        }
                        else if (result == DialogResult.Yes)
                        {
                            log.Trace("Not adding new user as a duplicate exists!");
                            Interaction.MsgBox("Addition cancelled - duplicate listener." + Environment.NewLine + Environment.NewLine + "Press [enter] to continue.");
                            this.Close();
                        }
                    }
                    else
                    {
                        log.Trace("Multiple duplicates, displaying choice form.");
                        Interaction.MsgBox("Multiple Listeners with this Forename and Surname have been found. Please review the Listeners and cancel if a duplicate exists.");

                        showDuplicateForm(theListeners);
                    }
                }
                else
                {
                    showFullForm();
                }
            }
        }
Esempio n. 13
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            // Search for the wallet id.
            if (!string.IsNullOrEmpty(txtWallet.Text))
            {
                if ((serviceLayer.GetListenerById(int.Parse(txtWallet.Text)) != null))
                {
                    // Are we in delete mode?
                    if (theType == FindListenerFormType.DeleteForm)
                    {
                        deleteListenerLocal(int.Parse(txtWallet.Text));
                        this.Close();
                    }

                    // Are we in delete mode?
                    if (theType == FindListenerFormType.EditForm)
                    {
                        My.MyProject.Forms.formEdit.Show();
                        My.MyProject.Forms.formEdit.setupForm(serviceLayer.GetListenerById(int.Parse(txtWallet.Text)));
                        this.Close();
                    }

                    if (theType == FindListenerFormType.StopSending)
                    {
                        My.MyProject.Forms.formStopSending.Show();
                        My.MyProject.Forms.formStopSending.setupForm(serviceLayer.GetListenerById(int.Parse(txtWallet.Text)));
                        this.Close();
                    }

                    if (theType == FindListenerFormType.PrintLabels)
                    {
                        My.MyProject.Forms.formChoosePrintPoint.Show();
                        My.MyProject.Forms.formChoosePrintPoint.SetupForm(serviceLayer.GetListenerById(int.Parse(txtWallet.Text)));
                        this.Close();
                    }

                    if (theType == FindListenerFormType.AdjustStock)
                    {
                        FormAdjustStockLevels formAdjustStock = new FormAdjustStockLevels();
                        formAdjustStock.setListener(serviceLayer.GetListenerById(int.Parse(txtWallet.Text)));
                        formAdjustStock.Show();
                        this.Close();
                    }

                    if (theType == FindListenerFormType.PrintCollector)
                    {
                        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(int.Parse(txtWallet.Text)), deleted);
                        this.Close();
                    }
                }
                else
                {
                    Interaction.MsgBox("Could not find a listener with the following Wallet number: " + txtWallet.Text);
                }
            }

            // Search for the name / surname.
            if (!(string.IsNullOrEmpty(txtForename.Text) & string.IsNullOrEmpty(txtSurname.Text)))
            {
                List <Listener> theListeners = new List <Listener>();
                theListeners = serviceLayer.GetListenersByName(txtForename.Text, txtSurname.Text);

                if ((theListeners.Count > 0))
                {
                    // If there is just one duplicate.
                    if (theListeners.Count == 1)
                    {
                        // Look up data.
                        Listener theListener = theListeners[0];

                        // Delete form.
                        if (theType == FindListenerFormType.DeleteForm)
                        {
                            string dataString = null;
                            dataString = Listener.FormatListenerData(theListener);
                            deleteListenerLocal(theListener.Wallet);
                            this.Close();
                        }

                        // Edit form.
                        if (theType == FindListenerFormType.EditForm)
                        {
                            My.MyProject.Forms.formEdit.Show();
                            My.MyProject.Forms.formEdit.setupForm(theListener);
                            this.Close();
                        }
                        if (theType == FindListenerFormType.StopSending)
                        {
                            My.MyProject.Forms.formStopSending.Show();
                            My.MyProject.Forms.formStopSending.setupForm(theListener);
                            this.Close();
                        }
                        if (theType == FindListenerFormType.PrintLabels)
                        {
                            My.MyProject.Forms.formChoosePrintPoint.Show();
                            My.MyProject.Forms.formChoosePrintPoint.SetupForm(theListener);
                            this.Close();
                        }
                        if (theType == FindListenerFormType.AdjustStock)
                        {
                            FormAdjustStockLevels formAdjustStock = new FormAdjustStockLevels();
                            formAdjustStock.setListener(serviceLayer.GetListenerById(int.Parse(txtWallet.Text)));
                            formAdjustStock.Show();
                            this.Close();
                        }
                        if (theType == FindListenerFormType.PrintCollector)
                        {
                            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(theListener, deleted);
                            this.Close();
                        }
                    }
                    else
                    {
                        // If there are more than 1 duplicate.
                        My.MyProject.Forms.formDuplicates.Show();
                        if (theType == FindListenerFormType.DeleteForm)
                        {
                            My.MyProject.Forms.formDuplicates.setupForm(FormDuplicates.DuplicateFormType.DeleteForm);
                        }
                        if (theType == FindListenerFormType.EditForm)
                        {
                            My.MyProject.Forms.formDuplicates.setupForm(FormDuplicates.DuplicateFormType.EditForm);
                        }
                        if (theType == FindListenerFormType.StopSending)
                        {
                            My.MyProject.Forms.formDuplicates.setupForm(FormDuplicates.DuplicateFormType.StopSending);
                        }
                        if (theType == FindListenerFormType.PrintLabels)
                        {
                            My.MyProject.Forms.formDuplicates.setupForm(FormDuplicates.DuplicateFormType.PrintLabels);
                        }
                        if (theType == FindListenerFormType.PrintCollector)
                        {
                            My.MyProject.Forms.formDuplicates.setupForm(FormDuplicates.DuplicateFormType.PrintCollector);
                        }
                        if (theType == FindListenerFormType.AdjustStock)
                        {
                            My.MyProject.Forms.formDuplicates.setupForm(FormDuplicates.DuplicateFormType.AdjustStock);
                        }
                        foreach (Listener tListener in theListeners)
                        {
                            My.MyProject.Forms.formDuplicates.addDuplicate(tListener);
                        }
                        this.Close();
                    }
                }
                else
                {
                    Interaction.MsgBox("Could not find any listeners with the Forename and Surname provided.");
                }
            }
        }
Esempio n. 14
0
        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.");
                }
            }
        }
Esempio n. 15
0
        // Close the form and process the wallets.
        public void doClose()
        {
            ModuleScanning.setScannedIn(scannedIn);

            // Actually process the scanned items!
            for (int i = 0; i <= (lstScanned.Items.Count - 1); i++)
            {
                ListViewItem item = lstScanned.Items[i];

                // If the item exists, just update the quantity.
                Listener theListener = serviceLayer.GetListenerById(int.Parse(item.SubItems[0].Text));
                if ((theListener != null))
                {
                    theListener.inOutRecords.In8 = int.Parse(item.SubItems[1].Text);

                    // Also adjust stock.
                    theListener.Stock = theListener.Stock + int.Parse(item.SubItems[1].Text);

                    // Are there more than 3 stock items?
                    if (theListener.Stock > Listener.DEFAULT_STOCK)
                    {
                        int overStock = theListener.Stock;
                        theListener.Stock = 3;
                        MessageBox.Show("Listener with Wallet: " + theListener.Wallet + ", Name: " + theListener.GetNiceName() + " would have " + overStock + " stock after scanning in these wallets. " + Environment.NewLine + Environment.NewLine +
                                        "Please look for any old wallets and remove the labels before clicking OK to continue.");
                        log.Warn("Listner " + theListener.GetNiceName() + " would have " + overStock + " stock after the scanning in. Limiting to " + Listener.DEFAULT_STOCK + " and displaying warning.");
                    }

                    // If the listener is active, we will be also sending it out
                    if (theListener.Status.Equals(ListenerStates.ACTIVE))
                    {
                        theListener.Stock = theListener.Stock - 1;

                        // Increment scanned out count
                        ModuleScanning.setScannedOut(ModuleScanning.getScannedOut() + 1);

                        // Also update the last out time (as we will be updating this listener in a minute with out8 = 1).
                        theListener.LastOut = DateTime.Now;
                    }

                    theListener.LastIn = DateTime.Now;

                    if (!serviceLayer.UpdateListener(theListener))
                    {
                        Interaction.MsgBox("Error: Failed to update scan information on listener.");
                        log.Error("Error: Failed to update scan information on listener.");
                        this.Close();
                    }
                    else
                    {
                        log.Debug("Updated listener information.");
                    }

                    serviceLayer.RecordScan(theListener.Wallet, ScanTypes.IN);
                }
            }

            // Show message and close.
            MessageBox.Show("The " + scannedIn + " wallets you have scanned have been successfully processed." + Environment.NewLine + Environment.NewLine + "You can now load them with memory sticks and place them in GPO mailbags.", ModuleGeneric.getAppShortName(), MessageBoxButtons.OK);
            exitMe = true;

            // Update the new week stats
            ModuleGeneric.UpdateStatsWeek(serviceLayer, true);

            this.Close();
        }
Esempio n. 16
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            int theIndex = 0;

            theIndex = lstBrowse.FocusedItem.Index;

            // First sub item is wallet number.
            int Id = 0;

            Id = int.Parse(lstBrowse.Items[theIndex].SubItems[0].Text);

            DialogResult result = MessageBox.Show("Are you sure you wish to delete the selected collector?", ModuleGeneric.getAppShortName(), MessageBoxButtons.YesNo);

            if (result == DialogResult.No)
            {
                return;
            }
            else if (result == DialogResult.Yes)
            {
                if (!serviceLayer.DeleteCollector(serviceLayer.GetCollector(Id)))
                {
                    Interaction.MsgBox("Error: Failed to delete collector!");
                }
                else
                {
                    Interaction.MsgBox("Successfully deleted collector.");
                }
            }

            refreshList();
        }
Esempio n. 17
0
 private void openLogDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Process.Start("explorer.exe", ModuleGeneric.GetLogFilePath().Replace("Debug.log", ""));
 }
Esempio n. 18
0
        private void PrintAllListenerLabelsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Show prompt.
            DialogResult result = MessageBox.Show("Are you sure you wish to print 4 labels for every listener? This will require multiple label sheets.", ModuleGeneric.getAppShortName(), MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                My.MyProject.Forms.formPrintAllLabels.Show();
            }
        }
Esempio n. 19
0
        private void btnScanIn_Click(object sender, EventArgs e)
        {
            // Check if alterations have been completed.
            DialogResult result = MessageBox.Show("Have you completed all the alterations and additions from the pending tray?" + Environment.NewLine + Environment.NewLine + "If you still have alterations or additions press Cancel and scan in after.", ModuleGeneric.getAppShortName(), MessageBoxButtons.OKCancel);

            if (result == DialogResult.OK)
            {
                // Is it not a new stats week?
                if (!(serviceLayer.IsNewStatsWeek()) &&
                    serviceLayer.GetCurrentWeekStats().hasScanningResults())
                {
                    // Check before we create a new stats bit then!
                    DialogResult newWeekCheck = MessageBox.Show("Scanning has already been done this week. Are you sure you want to continue, a new stats week will be created.", ModuleGeneric.getAppShortName());
                    if (result == DialogResult.OK)
                    {
                        My.MyProject.Forms.formScanIn.Show();
                    }
                }
                else
                {
                    My.MyProject.Forms.formScanIn.Show();
                }
            }
        }
Esempio n. 20
0
        // 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();
                }
            }
        }
Esempio n. 21
0
        private void btnRemove_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);

                if (deletedMode)
                {
                    if (serviceLayer.RestoreListener(serviceLayer.GetListenerById(walletNumb)))
                    {
                        Interaction.MsgBox("Successfully restored listener.");
                        log.Info("Listener resumed: " + walletNumb);
                        refreshList();
                    }
                    else
                    {
                        log.Error("Failed to restore listener. Id: " + walletNumb);
                        Interaction.MsgBox("ERROR: Failed to restore listener");
                    }
                }
                else
                {
                    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.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(walletNumb), myReason);
                        if (resultofdelete)
                        {
                            Interaction.MsgBox("Listener deleted successfully. ");
                            log.Info("Listener deleted: " + walletNumb);
                            MessageBox.Show("You should remove all wallets including the magazine wallet" + Environment.NewLine + "from stock for Wallet number " + walletNumb + ".", ModuleGeneric.getAppShortName(), MessageBoxButtons.OK);

                            // Check if the player / memory stick has been returned.
                            var tempListener = serviceLayer.GetListenerById(walletNumb);
                            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.");
                            log.Error("Error deleting listener: " + walletNumb);
                        }
                        refreshList();
                    }
                }
            }
        }
Esempio n. 22
0
 private void formPrintAllLabels_Load(object sender, EventArgs e)
 {
     MessageBox.Show("Ensure you insert labels into the printer tray before printing.", ModuleGeneric.getAppShortName(), MessageBoxButtons.OK);
     printLabels();
     MessageBox.Show("Make sure you replace the labels in the printer tray with plain paper.", ModuleGeneric.getAppShortName(), MessageBoxButtons.OK);
     this.Close();
 }
Esempio n. 23
0
        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));
                }
            }
        }
Esempio n. 24
0
        // 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();
            }
        }