Exemplo n.º 1
0
        //Delete record
        public static void DeleteRecord(Customer30022962 thisCustomer)
        {
            // this method deletes the related records in Order_Products it then deletes the Orders records and finally deletes the customer.

            // filter orders by customer id
            Orders30022962 order = BasePage.dbeCineplex.Orders30022962.Find(thisCustomer.CustomerId);

            // filter orders and products by order id
            var orderAndMovies = from eachOP in BasePage.dbeCineplex.MovieOrders30022962
                                 select eachOP;

            // delete each order and products link
            foreach (var theOrder in orderAndMovies)
            {
                if (theOrder.OrderId == order.OrderId)
                {
                    BasePage.dbeCineplex.MovieOrders30022962.Remove(theOrder);
                }
            }

            // delete the order
            BasePage.dbeCineplex.Orders30022962.Remove(order);

            // filter the customers by customer id
            var result = from eachCustomer in BasePage.dbeCineplex.Customer30022962 where eachCustomer.CustomerId == thisCustomer.CustomerId select eachCustomer;

            // delete the customer thisCustomer
            BasePage.dbeCineplex.Customer30022962.Remove(result.FirstOrDefault());
            BasePage.dbeCineplex.SaveChanges();
        }
Exemplo n.º 2
0
        public static void UpdateRecord(Customer30022962 newCustomer)
        {
            // Find the original supplier record to update
            Customer30022962 oldCustomer = BasePage.dbeCineplex.Customer30022962.Find(newCustomer.CustomerId);

            // save to found supplier record
            oldCustomer.Name    = newCustomer.Name;
            oldCustomer.Phone   = newCustomer.Phone;
            oldCustomer.CType   = newCustomer.CType;
            oldCustomer.CardNo  = newCustomer.CardNo;
            oldCustomer.Email   = newCustomer.Email;
            oldCustomer.ExpDate = newCustomer.ExpDate;
            BasePage.dbeCineplex.SaveChangesAsync();
        }
Exemplo n.º 3
0
        protected void btnPurchase_Click(object sender, EventArgs e)
        {
            // Add new customer
            Customer30022962 theCustomer = new Customer30022962();

            theCustomer.Name   = txtFName.Text + " " + txtLName.Text;
            theCustomer.Phone  = txtPhone.Text;
            theCustomer.CType  = ddlCardType.SelectedValue;
            theCustomer.CardNo = txtCreditCardNo.Text;

            theCustomer.ExpDate = Convert.ToDateTime("01/" + ddlExpiryMonth.SelectedValue + "/" + ddlExpiryYear.SelectedValue + " 00:00:00.00");
            theCustomer.Email   = txtEmail.Text;

            CineplexSystem.BasePage.dbeCineplex.Customer30022962.Add(theCustomer);
            CineplexSystem.BasePage.dbeCineplex.SaveChanges();



            // add new order
            Orders30022962 theOrder = new Orders30022962();

            theOrder.Date = DateTime.Today;

            // create delivery date
            DateTime theDeliveryDate;

            theDeliveryDate = theOrder.Date.AddDays(5);


            // store the delivery date in a session variable to show on the next pages
            Session["DeliveryDate"] = theDeliveryDate.ToShortDateString();

            theOrder.Date       = theDeliveryDate;
            theOrder.CustomerId = theCustomer.CustomerId;

            CineplexSystem.BasePage.dbeCineplex.Orders30022962.Add(theOrder);
            CineplexSystem.BasePage.dbeCineplex.SaveChanges();

            // add order transaction information to database
            MovieOrders30022962 theOrderMovies;
            float totalSale;

            // loop through each product in the shopping cart and add to ordered products table

            foreach (var cartMovie in CineplexSystem.BasePage.shoppingCart)
            {
                theOrderMovies         = new MovieOrders30022962();
                theOrderMovies.OrderId = theOrder.OrderId;

                // save the Order number in a session variable for the purchase order display page
                Session["OrderID"] = theOrder.OrderId;

                theOrderMovies.MovieId = cartMovie.MovieId;
                //theOrderMovies. = cartMovie.Quantity;

                totalSale            = cartMovie.Price * cartMovie.Quantity; // Total Sale
                Session["TotalSale"] = totalSale;
                CineplexSystem.BasePage.dbeCineplex.MovieOrders30022962.Add(theOrderMovies);
            }

            // save all database changes
            CineplexSystem.BasePage.dbeCineplex.SaveChanges();

            // Clear shopping cart without returning products because the cart items have been purchased.
            ShoppingCart.Reset();

            Response.Redirect("~/PurchaseOrder.aspx");
        }
Exemplo n.º 4
0
        public static void AddRecord(Customer30022962 newCustomer)
        {
            BasePage.dbeCineplex.Customer30022962.Add(newCustomer);

            BasePage.dbeCineplex.SaveChangesAsync();
        }