Exemple #1
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();
                }
            }
        }
Exemple #2
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.");
                }
            }
        }