Beispiel #1
0
 private void LookupBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (cboShippers.SelectedIndex <= 0)
         {
             MessageBox.Show("Please select a shipper before clicking [Lookup Shipper]");
         }
         else
         {
             int shipperId        = Convert.ToInt32(cboShippers.SelectedValue);
             NorthwindManager mgr = new NorthwindManager();
             var shipper          = mgr.GetShipper(shipperId);
             if (shipper != null)
             {
                 lblShipperID.Text   = shipper.ShipperID.ToString();
                 txtCompanyName.Text = shipper.CompanyName;
                 txtPhone.Text       = shipper.Phone;
             }
         }
     }
     catch (Exception ex)
     {
         //TODO: Log the exception
         MessageBox.Show("Error: " + ex.Message);
     }
 }
Beispiel #2
0
        private void btnLookupShippers_Click(object sender, EventArgs e)
        {
            try
            {
                if (cboShippers.SelectedIndex <= 0)
                {
                    MessageBox.Show("Please select a shipper before clicking [Lookup]");
                }
                else
                {
                    int shipperId          = Convert.ToInt32(cboShippers.SelectedValue);
                    NorthwindManager nwm   = new NorthwindManager();
                    Shipper          shipr = nwm.GetShipper(shipperId);

                    ShipperID.Text      = shipr.ShipperID.ToString();
                    txtCompanyName.Text = shipr.CompanyName;
                    txtPhone.Text       = shipr.Phone;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw;
            }
        }
Beispiel #3
0
        private void btnUpdateShipper_Click(object sender, EventArgs e)
        {
            try
            {
                int shipperId;
                if (int.TryParse(tboShipperID.Text, out shipperId))
                {
                    //Do the update
                    var info = new Shipper()
                    {
                        ShipperID   = shipperId,
                        CompanyName = tboCompanyName.Text,
                        Phone       = tboPhone.Text
                    };

                    var mgr = new NorthwindManager();
                    mgr.UpdateShipper(info);
                    PopulateShippersComboBox();
                    cboShippers.SelectedValue = info.ShipperID;
                }

                else
                {
                    MessageBox.Show("Please lookup a shipper before trying to update.");
                }
            }
            catch (Exception ex)
            {
                //TODO: Log the exception
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #4
0
        private void btnAdShipper_Click(object sender, EventArgs e)
        {
            try
            {
                Shipper elem = new Shipper()
                {
                    CompanyName = txtCompanyName.Text,
                    Phone       = txtPhone.Text
                };

                var mgr = new NorthwindManager();
                elem.ShipperID = mgr.AddShipper(elem);

                //give feed back to user
                // updater shipper combobox and select right shipper
                //display id of added shipper
                PopulateShippersComboBox();
                cboShippers.SelectedValue = elem.ShipperID;
                ShipperID.Text            = elem.ShipperID.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw;
            }
        }
Beispiel #5
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                NorthwindManager mgr = new NorthwindManager();

                int shipperId = mgr.AddShipper(new Shipper()
                {
                    CompanyName = txtCompanyName.Text,
                    Phone       = txtPhone.Text
                });

                //update the combobox
                PopulateShippersComboBox();
                //has right shipper selected
                cboShippers.SelectedValue = shipperId;
                //display id of added shipper
                lblShipperID.Text = shipperId.ToString();
            }
            catch (Exception ex)
            {
                //TODO: Log the exception
                MessageBox.Show("Error: " + ex.Message);
            }
        }
Beispiel #6
0
        public ActionResult Categories()
        {
            NorthwindManager       mgr        = new NorthwindManager(Properties.Settings.Default.ConStr);
            IEnumerable <Category> categories = mgr.GetCategories();

            return(View(categories));
        }
Beispiel #7
0
        public ActionResult OrderDetails()
        {
            NorthwindManager          mgr          = new NorthwindManager(Properties.Settings.Default.ConStr);
            IEnumerable <OrderDetail> orderDetails = mgr.GetOrderDetailsFor1997();

            return(View(orderDetails));
        }
Beispiel #8
0
 private void btnDeleteShipper_Click(object sender, EventArgs e)
 {
     try
     {
         int temp;
         if (int.TryParse(ShipperID.Text, out temp))
         {
             var elem = new Shipper()
             {
                 ShipperID = temp
             };
             var mgr = new NorthwindManager();
             mgr.DeleteShipper(elem);
             PopulateShippersComboBox();
             ShipperID.Text      = "";
             txtCompanyName.Text = "";
             txtPhone.Text       = "";
         }
         else
         {
             MessageBox.Show("Please look up a shipper before trying delete.");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         throw;
     }
 }
Beispiel #9
0
 private void btnDeleteShipper_Click(object sender, EventArgs e)
 {
     try
     {
         int temp;
         if (int.TryParse(tboShipperID.Text, out temp))
         {
             var data = new Shipper()
             {
                 ShipperID = temp
             };
             var mgr = new NorthwindManager();
             mgr.DeleteShipper(data);
             //feedback to user
             PopulateShippersComboBox();
             //clear the form textboxes
             tboShipperID.Text   = "";
             tboCompanyName.Text = "";
             tboPhone.Text       = "";
         }
         else
         {
             MessageBox.Show("Please lookup a shipper before trying to delete.");
         }
     }
     catch (Exception ex)
     {
         //TODO: Log the exception
         Program.LogMessage(ex.Message);
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #10
0
 private void btnDeleteShipper_Click(object sender, EventArgs e)
 {
     try
     {
         int temp;
         if (int.TryParse(lblShipperID.Text, out temp))
         {
             var info = new Shipper()
             {
                 ShipperID = temp
             };
             var mgr = new NorthwindManager();
             mgr.DeleteShipper(info);
             // Feedback to user
             PopulateShippersComboBox();
             // clear the form textboxes
             Clear();
         }
         else
         {
             MessageBox.Show("Please lookup a shipper before trying to delete.");
         }
     }
     catch (Exception ex)
     {
         // TODO: log exception
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #11
0
 private void UpdateShipper_Click(object sender, EventArgs e)
 {
     try
     {
         int tempShipper;
         if (int.TryParse(ShipperId.Text, out tempShipper))
         {
             // do the update...this is an initializer list, constructor runs, properties of the Shipper Object get values
             var info = new Shipper()
             {
                 ShipperID   = tempShipper,
                 CompanyName = CompanyName.Text,
                 Phone       = Phone.Text
             };
             var mgr = new NorthwindManager();
             mgr.UpdateShipper(info);
             PopulateShippersComboBox();
             cboShippers.SelectedValue = info.ShipperID;
         }
         else
         {
             MessageBox.Show("Please look up a shipper before trying to update.");
         }
     }
     catch (Exception ex)
     {
         // TODO:  Update logging
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #12
0
        private void btnLookupShipper_Click(object sender, EventArgs e)
        {
            try
            {   // get data from form
                if (cboShippers.SelectedIndex <= 0)
                {
                    MessageBox.Show("Please select a shipper before clicking [lookup]");
                }
                else
                {
                    int shipperId = Convert.ToInt32(cboShippers.SelectedValue);

                    NorthwindManager mgr  = new NorthwindManager();
                    Shipper          data = mgr.GetShipper(shipperId);

                    // unpack the data
                    ShipperId.Text   = data.ShipperID.ToString();
                    CompanyName.Text = data.CompanyName;
                    Phone.Text       = data.Phone;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #13
0
        private void btnLookupShipper_Click(object sender, EventArgs e)
        {
            try
            {
                if (cboShippers.SelectedIndex <= 0)
                {
                    MessageBox.Show("Please select a shipper before clicking [Lookup]");
                }
                else
                {
                    int shipperId         = Convert.ToInt32(cboShippers.SelectedValue);
                    NorthwindManager mgr  = new NorthwindManager();
                    Shipper          data = mgr.GetShipper(shipperId);

                    // Unpack the data
                    lblShipperID.Text   = data.ShipperID.ToString();
                    txtCompanyName.Text = data.CompanyName;
                    txtPhone.Text       = data.Phone;
                }
            }
            catch (Exception ex)
            {
                // TODO: log exception
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #14
0
 private void btnUpdateShipper_Click(object sender, EventArgs e)
 {
     try
     {
         int shipperId;
         if (int.TryParse(lblShipperID.Text, out shipperId))
         {
             var info = new Shipper()
             {
                 ShipperID   = shipperId,
                 CompanyName = txtCompanyName.Text,
                 Phone       = txtPhone.Text
             };
             var mgr = new NorthwindManager();
             mgr.UpdateShipper(info);
             PopulateShippersComboBox();
             cboShippers.SelectedValue = info.ShipperID;
             // Maybe there should be some indication to the user that the update was successful. MessageBox? Label?
         }
         else
         {
             MessageBox.Show("Please lookup a shipper before trying to update.");
         }
     }
     catch (Exception ex)
     {
         // TODO: log exception
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #15
0
        private void btnLookupShipper_Click(object sender, EventArgs e)
        {
            try
            {
                //Get data from form
                if (cboShippers.SelectedIndex <= 0)
                {
                    MessageBox.Show("Please select a shipper.");
                }
                else
                {
                    int shipperId = Convert.ToInt32(cboShippers.SelectedValue);

                    NorthwindManager mgr  = new NorthwindManager();
                    Shipper          data = mgr.GetShipper(shipperId);

                    //Unpack the data
                    tboShipperID.Text   = data.ShipperID.ToString();
                    tboCompanyName.Text = data.CompanyName;
                    tboPhone.Text       = data.Phone;
                }
            }
            catch (Exception ex)
            {
                //TODO: Log the exception
                MessageBox.Show("Error: " + ex.Message, "Error Loading Form", MessageBoxButtons.OK);
            }
        }
Beispiel #16
0
        private void btnAddShipper_Click(object sender, EventArgs e)
        {
            try
            {
                Shipper item = new Shipper()
                {
                    CompanyName = tboCompanyName.Text,
                    Phone       = tboPhone.Text
                };

                var mgr = new NorthwindManager();
                item.ShipperID = mgr.AddShipper(item);
                //Give some feedback to the user...
                // - Update my combo-box
                PopulateShippersComboBox();
                // - My combo-box has the right shipper selected
                cboShippers.SelectedValue = item.ShipperID;
                // - Display the id fo the addd shipper
                tboShipperID.Text = item.ShipperID.ToString();
            }
            catch (Exception ex)
            {
                //TODO: Log the exception
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #17
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                int shipperId;
                if (int.TryParse(lblShipperID.Text, out shipperId))
                {
                    //do the delete...
                    var info = new Shipper()
                    {
                        ShipperID = shipperId
                    };

                    NorthwindManager mgr = new NorthwindManager();
                    mgr.DeleteShipper(info);
                    PopulateShippersComboBox();
                    cboShippers.SelectedItem = 0;
                }
                else
                {
                    MessageBox.Show("Please select a shipper before clicking [Lookup Shipper]");
                }
            }
            catch (Exception ex)
            {
                //TODO: Log the exception
                MessageBox.Show("Error: " + ex.Message);
            }
        }
Beispiel #18
0
        public ActionResult DetailsForOrder(int orderId)
        {
            NorthwindManager          manager = new NorthwindManager(Settings.Default.ConStr);
            IEnumerable <OrderDetail> details = manager.GetDetailsForOrder(orderId);

            return(View(details));
        }
Beispiel #19
0
        public ActionResult SearchProducts(string searchText, int minPrice)
        {
            NorthwindManager      mgr      = new NorthwindManager(Properties.Settings.Default.ConStr);
            IEnumerable <Product> products = mgr.SearchProducts(searchText, minPrice);

            return(View(products));
        }
Beispiel #20
0
        public ActionResult OrdersForEmployee(int employeeId)
        {
            NorthwindManager    mgr    = new NorthwindManager(Properties.Settings.Default.ConStr);
            IEnumerable <Order> orders = mgr.GetOrdersForEmployee(employeeId);
            OrdersViewModel     vm     = new OrdersViewModel();

            vm.Orders = orders;
            vm.Date   = DateTime.Now;
            return(View(vm));
        }
Beispiel #21
0
        private void ViewRegions_Load(object sender, EventArgs e)
        {
            // Populate the comboBox
            NorthwindManager manager = new NorthwindManager();
            var data = manager.GetRegions();

            cboRegions.DataSource    = data;
            cboRegions.DisplayMember = "RegionDescription";
            cboRegions.ValueMember   = "RegionID";
        }
Beispiel #22
0
        public ActionResult Orders()
        {
            NorthwindManager manager        = new NorthwindManager(Settings.Default.ConStr);
            OrdersWithDate   ordersWithDate = new OrdersWithDate
            {
                Orders      = manager.GetOrders(),
                CurrentDate = DateTime.Now
            };

            return(View(ordersWithDate));
        }
Beispiel #23
0
        public ActionResult Products(int categoryId)
        {
            NorthwindManager      mgr      = new NorthwindManager(Properties.Settings.Default.ConStr);
            IEnumerable <Product> products = mgr.GetProducts(categoryId);
            ProductsViewModel     vm       = new ProductsViewModel();

            vm.Products     = products;
            vm.CategoryName = mgr.GetCategoryName(categoryId);

            return(View(vm));
        }
Beispiel #24
0
        public ActionResult Products(int catId)
        {
            NorthwindManager   mgr = new NorthwindManager(Settings.Default.ConStr);
            ProductsAndCatName obj = new ProductsAndCatName
            {
                Products     = mgr.GetProductsForCategory(catId),
                CategoryName = mgr.GetCategoryName(catId)
            };

            return(View(obj));
        }
        public ActionResult Search(string searchText)
        {
            NorthwindManager      manager  = new NorthwindManager(Settings.Default.ConStr);
            IEnumerable <Product> products = manager.SearchProducts(searchText);
            SearchResults         results  = new SearchResults
            {
                SearchText = searchText,
                Products   = products
            };

            return(View(results));
        }
Beispiel #26
0
        public ActionResult Products(int catId)
        {
            NorthwindManager        manager  = new NorthwindManager(Settings.Default.ConStr);
            IEnumerable <Product>   products = manager.GetProducts(catId);
            ProductsAndCategoryName data     = new ProductsAndCategoryName
            {
                Products            = products,
                CurrentCategoryName = manager.GetCategoryName(catId)
            };

            return(View(data));
        }
Beispiel #27
0
        public ActionResult Orders()
        {
            NorthwindManager    mgr    = new NorthwindManager(Settings.Default.ConStr);
            IEnumerable <Order> orders = mgr.GetOrders();
            OrdersAndDate       obj    = new OrdersAndDate
            {
                Orders      = orders,
                CurrentDate = DateTime.Now
            };

            return(View(obj));
        }
Beispiel #28
0
        private void ProductSalesForm_Load(object sender, EventArgs e)
        {
            List <ProductSaleSummary> list = new NorthwindManager().GetProductSalesSummeries();

            reportViewer1.LocalReport.DataSources.Clear();

            reportViewer1.LocalReport.ReportEmbeddedResource = "DesktopApp.Reports.ProductSalesReport.rdlc";
            Microsoft.Reporting.WinForms.ReportDataSource dataset = new Microsoft.Reporting.WinForms.ReportDataSource("ProductSalesDataSet", list);
            reportViewer1.LocalReport.DataSources.Add(dataset);
            dataset.Value = list;

            reportViewer1.LocalReport.Refresh();
            this.reportViewer1.RefreshReport();
        }
Beispiel #29
0
 private void PopulateRegions()
 {
     try
     {
         var controller = new NorthwindManager();
         var data       = controller.GetRegions();
         RegionListView.DataSource = data;
         RegionListView.DataBind();
     }
     catch (Exception ex)
     {
         MessageLabel.Text = ex.Message;
     }
 }
Beispiel #30
0
        public void Should_Update_Shipper(Shipper existing)
        {
            //arrange
            existing.Phone = "780.999.9999";
            var sut = new NorthwindManager();

            //act
            sut.UpdateShipper(existing);

            //assert
            var actual = sut.GetShipper(existing.ShipperID);

            Assert.NotNull(actual);
            Assert.Equal(existing.Phone, actual.Phone);
        }