Esempio n. 1
0
        private void createNewVendor()
        {
            string vendorName    = txtVendorName.Text.Trim();
            string phoneNumber   = txtPhoneNumber.Text.Trim();
            bool   vendorCreated = false;

            //Attempt to add the new Vendor
            try
            {
                vendorCreated = _vendorManager.CreateVendor(vendorName, phoneNumber);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message,
                                "Vendor Creation Failed", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            if (vendorCreated == false) //Vendor not created
            {
                MessageBox.Show("Vendor Could Not Be Created With Supplied Fields", "Vendor Creation Failed",
                                MessageBoxButton.OK, MessageBoxImage.Error);
                this.DialogResult = false;
            }
            else
            {
                MessageBox.Show("Vendor Successfully Created", "Vendor Created",
                                MessageBoxButton.OK, MessageBoxImage.Information);
                this.DialogResult = true;
            }
        }
Esempio n. 2
0
        public ActionResult Create(FormCollection form)
        {
            Vendor vendor = new Vendor();

            vendor.VendorName  = form.Get("VendorName");
            vendor.VendorPhone = form.Get("VendorPhone");

            try
            {
                _vendorManager.CreateVendor(vendor.VendorName, vendor.VendorPhone);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }