Esempio n. 1
0
        /// <summary>
        /// Will Fritz
        /// Created: 2015/02/06
        /// This will send a supplier object to the business logic layer
        /// </summary>
        /// <remarks>
        /// Will Fritz
        /// Updated:  2015/02/15
        /// Added a confirmation message box
        /// </remarks>
        private async void AddTheSupplier()
        {
            try
            {
                bool validUserName = _loginManager.CheckSupplierUserName(TxtUserName.Text);

                if (validUserName)
                {
                    Supplier tempSupplier = new Supplier
                    {
                        CompanyName  = TxtCompanyName.Text.Trim(),
                        FirstName    = TxtFirstName.Text.Trim(),
                        LastName     = TxtLastName.Text.Trim(),
                        Address1     = TxtAddress1.Text.Trim(),
                        Address2     = TxtAddress2.Text.Trim(),
                        PhoneNumber  = TxtPhoneNumber.Text,
                        Zip          = CboZip.SelectedValue.ToString(),
                        EmailAddress = TxtEmail.Text.Trim(),
                        SupplyCost   = (decimal)NumSupplyCost.Value
                    };

                    if (_manager.AddANewSupplier(tempSupplier, TxtUserName.Text) == SupplierResult.Success)
                    {
                        await this.ShowMessageDialog("Supplier was added to the database.");

                        DialogResult = true;
                        Close();
                    }
                    else
                    {
                        throw new WanderingTurtleException(this, "Supplier wasn't added to the database.");
                    }
                }
                else
                {
                    TxtUserName.Text = "";
                    throw new WanderingTurtleException(this, "UserName already used.  Please choose another one.");
                }
            }
            catch (Exception ex)
            {
                throw new WanderingTurtleException(this, ex);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Miguel Santana
        /// Created:  2015/04/04
        /// Takes user input to send to business logic layer
        /// </summary>
        /// <remarks>
        /// Pat Banks
        /// Added rejected/approved/pending combo box
        /// </remarks>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            //validates data from form
            if (!Validate())
            {
                return;
            }

            try
            {
                if (CboAppStatus.SelectedValue.ToString().Equals(ApplicationStatus.Approved.ToString()))
                {
                    bool validUserName = MyLoginManager.CheckSupplierUserName(TxtUserName.Text);

                    if (validUserName)
                    {
                        //get data from form
                        GetFormData();

                        decimal supplyCost = (decimal)(NumSupplyCost.Value);

                        SupplierResult result = MySupplierManager.ApproveSupplierApplication(CurrentSupplierApplication, UpdatedSupplierApplication, TxtUserName.Text, supplyCost);

                        if (result == SupplierResult.Success)
                        {
                            await this.ShowMessageDialog("Supplier application approved: Supplier added.");

                            DialogResult = true;
                            Close();
                        }
                        else
                        {
                            throw new WanderingTurtleException(this, "DB Error");
                        }
                    }
                    else
                    {
                        TxtUserName.Text = "";
                        throw new WanderingTurtleException(this, "UserName already used.  Please choose another one.");
                    }
                }
                else if (CboAppStatus.SelectedValue.ToString().Equals(ApplicationStatus.Rejected.ToString()) || CboAppStatus.SelectedValue.ToString().Equals(ApplicationStatus.Pending.ToString()))
                {
                    //get data from form
                    GetFormData();

                    SupplierResult result = MySupplierManager.EditSupplierApplication(CurrentSupplierApplication, UpdatedSupplierApplication);

                    if (result == SupplierResult.Success)
                    {
                        await this.ShowMessageDialog("Supplier application updated.");

                        DialogResult = true;
                        Close();
                    }
                    else
                    {
                        throw new WanderingTurtleException(this, "DB Error");
                    }
                }
                else
                {
                    throw new WanderingTurtleException(this, "DB Error.");
                }
            }
            catch (SqlException ex)
            {
                // ShowErrorMessage("UserName already used.  Please choose another one.");

                throw new WanderingTurtleException(this, "UserName already used.  Please choose another one.", ex);
            }
            catch (Exception ex)
            {
                throw new WanderingTurtleException(this, ex);
            }
        }