Exemplo n.º 1
0
        protected void LogIn(object sender, EventArgs e)
        {
            if (IsValid)
            {
                using (DowntownDeliEntity dd = new DowntownDeliEntity())
                {
                    Employee emp = dd.Employees.Where(t => t.Emp_User_Name.ToUpper().Equals(Username.Text.ToUpper()) && t.Emp_Password.Equals(Password.Text)).FirstOrDefault();
                    if (emp != null)
                    {
                        user = emp;
                        FormsAuthentication.RedirectFromLoginPage(Username.Text, true);
                        return;
                    }
                    Customer cust = dd.Customers.Where(t => t.Email.ToUpper().Equals(Username.Text.ToUpper()) && t.Cust_Password == Password.Text).FirstOrDefault();
                    if (cust != null)
                    {
                        customer = cust;
                        FormsAuthentication.RedirectFromLoginPage(Username.Text, true);
                        Response.Redirect("LoggedIn.aspx");
                        return;
                    }

                    FailureText.Text     = "Username or Password is incorrect.";
                    ErrorMessage.Visible = true;
                }
            }
        }
Exemplo n.º 2
0
 protected void Register_Click(object sender, EventArgs e)
 {
     using (DowntownDeliEntity dd = new DowntownDeliEntity())
     {
         Customer cust = dd.Customers.FirstOrDefault(a => a.Phone == Phone.Text);
         if (cust != null)
         {
             phoneUsed.Style["display"] = "block";
             return;
         }
         cust = dd.Customers.FirstOrDefault(a => a.Email == Username.Text);
         if (cust != null)
         {
             usernameUsed.Style["display"] = "block";
             return;
         }
         cust = new Customer();
         cust.Cust_Password = Password.Text;
         cust.Email         = Username.Text;
         cust.F_Name        = FirstName.Text;
         cust.L_Name        = LastName.Text;
         cust.Phone         = Phone.Text;
         dd.Customers.Add(cust);
         dd.SaveChanges();
         Server.Transfer("RegistrationComplete.aspx");
     }
 }
Exemplo n.º 3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         using (DowntownDeliEntity dd = new DowntownDeliEntity())
         {
             DateTime now = DateTime.Now.Date;
             foreach (Promotion promo in dd.Promotions.Where(a => a.Begin_Date <= now && a.End_Date >= now && (a.Discount_Type == "Cash Off" || a.Discount_Type == "Percent Off")))
             {
                 Promotions.Text = Promotions.Text + "<div class='alert alert-success' role='alert'>" + promo.Promo_Description + "</div>";
                 break;
             }
         }
     }
     if (user != null)
     {
         Page.Title = "Welcome, " + user.F_Name + " " + user.L_Name;
     }
     if (System.Web.HttpContext.Current.User == null || !System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
     {
         Response.Clear();
         FormsAuthentication.SignOut();
         Response.Redirect("~/Login.aspx");
     }
 }
Exemplo n.º 4
0
        protected void lvCurrentOrders_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            using (DowntownDeliEntity dde = new DowntownDeliEntity())
            {
                switch (e.CommandName)
                {
                case "Complete":
                    ListViewDataItem item       = (ListViewDataItem)e.Item;
                    Label            lblOrderID = (Label)item.FindControl("lblOrderID");
                    int   id        = int.Parse(lblOrderID.Text);
                    Order RealOrder = dde.Orders.Find(id);
                    RealOrder.Complete = true;
                    dde.SaveChanges();
                    ListView lvCurrentOrders = (ListView)HeadLoginView.FindControl("lvCurrentOrders");
                    lvCurrentOrders.DataSource = dde.Orders.Include("Customer").Where(t => t.Complete == false || t.Complete == null).ToList();
                    lvCurrentOrders.DataBind();
                    break;

                case "Modify":
                    ListViewDataItem item2       = (ListViewDataItem)e.Item;
                    Label            lblOrderID2 = (Label)item2.FindControl("lblOrderID");
                    int   id2        = int.Parse(lblOrderID2.Text);
                    Order RealOrder2 = dde.Orders.Include("Product_Order").Where(t => t.Order_ID == id2).ToList().Single();
                    order       = RealOrder2;
                    ModifyOrder = true;
                    Response.Redirect("~/Pages/PlaceOrder.aspx", false);
                    break;
                }
            }
        }
Exemplo n.º 5
0
        protected void buildCart(Object sender, EventArgs e)
        {
            if (sender is CheckBox)
            {
                useRewardPoints = ((CheckBox)sender).Checked;
            }
            shoppingCartContents.Controls.Clear();
            int index = 0;

            foreach (Product prod in cart)
            {
                shoppingCartContents.Controls.Add(new LiteralControl("<tr><td>" + prod.Product_Name + "</td><td>" + prod.Price.ToString("C") + "</td><td>"));
                Button remove = new Button();
                remove.ID     = index.ToString();
                remove.Text   = "Remove";
                remove.Click += Remove_Click;
                shoppingCartContents.Controls.Add(remove);
                shoppingCartContents.Controls.Add(new LiteralControl("</td></tr>"));
                index++;
            }
            using (DowntownDeliEntity dd = new DowntownDeliEntity())
            {
                decimal total = cart.Sum(a => a.Price);
                if (useRewardPoints)
                {
                    total = total - cart.OrderBy(a => a.Price).First().Price;
                    shoppingCartContents.Controls.Add(new LiteralControl("<tr><td>Customer Rewards Discount</td><td>(" + ((decimal)cart.OrderBy(a => a.Price).First().Price).ToString("C") + ")</td><td></td></tr>"));
                }
                DateTime  now   = DateTime.Now.Date;
                Promotion promo = dd.Promotions.FirstOrDefault(a => a.Begin_Date <= now && a.End_Date >= now && (a.Discount_Type == "Cash Off" || a.Discount_Type == "Percent Off"));
                if (promo != null)
                {
                    if (promo.Discount_Type == "Cash Off")
                    {
                        shoppingCartContents.Controls.Add(new LiteralControl("<tr><td>Promotion</td><td>" + ((decimal)promo.Discount).ToString("C") + "</td><td></td></tr>"));
                        total = total + (decimal)promo.Discount;
                    }
                    if (promo.Discount_Type == "Percent Off")
                    {
                        shoppingCartContents.Controls.Add(new LiteralControl("<tr><td>Promotion</td><td>" + ((decimal)promo.Discount).ToString() + "% off</td><td></td></tr>"));
                        total = total - (total * ((decimal)promo.Discount / 100));
                    }
                    if (total < 0)
                    {
                        total = 0;
                    }
                    shoppingCartContents.Controls.Add(new LiteralControl("<tfoot><td>Total</td><td>" + total.ToString("C") + "</td><td></td></tfoot>"));
                }
                else
                {
                    if (total < 0)
                    {
                        total = 0;
                    }
                    shoppingCartContents.Controls.Add(new LiteralControl("<tfoot><td>Total</td><td>" + cart.Sum(a => a.Price).ToString("C") + "</td><td></td></tfoot>"));
                }
            }
        }
Exemplo n.º 6
0
 protected void UpdateReward_Click(object sender, EventArgs e)
 {
     using (DowntownDeliEntity dd = new DowntownDeliEntity())
     {
         Customer cust = dd.Customers.First(a => a.Customer_ID == customer.Customer_ID);
         cust.Reward_CardID = reward.Text;
         dd.SaveChanges();
     }
     customer.Reward_CardID = reward.Text;
     Response.Redirect("LoggedIn.aspx");
 }
Exemplo n.º 7
0
 protected void lvCurrentOrders_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
 {
     using (DowntownDeliEntity dde = new DowntownDeliEntity())
     {
         ListView  lvCurrentOrders      = (ListView)HeadLoginView.FindControl("lvCurrentOrders");
         DataPager lvCurrentOrdersPager = lvCurrentOrders.FindControl("lvCurrentOrdersPager") as DataPager;
         int       CurrentPage          = ((lvCurrentOrdersPager.StartRowIndex) / lvCurrentOrdersPager.MaximumRows) + 1;
         lvCurrentOrdersPager.SetPageProperties(lvCurrentOrdersPager.StartRowIndex, lvCurrentOrdersPager.MaximumRows, false);
         lvCurrentOrders.DataSource = dde.Orders.Include("Customer").Where(t => t.Complete == false || t.Complete == null).ToList();
         lvCurrentOrders.DataBind();
     }
 }
Exemplo n.º 8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         using (DowntownDeliEntity dd = new DowntownDeliEntity())
         {
             DateTime now = DateTime.Now.Date;
             foreach (Promotion promo in dd.Promotions.Where(a => a.Begin_Date <= now && a.End_Date >= now && (a.Discount_Type == "Cash Off" || a.Discount_Type == "Percent Off")))
             {
                 Promotions.Text = Promotions.Text + "<div class='alert alert-success' role='alert'>" + promo.Promo_Description + "</div>";
                 return;
             }
         }
     }
 }
Exemplo n.º 9
0
 protected void Add_Click(object sender, EventArgs e)
 {
     using (DowntownDeliEntity dd = new DowntownDeliEntity())
     {
         foreach (Control c in Menu.Controls)
         {
             if (c is CheckBox && ((CheckBox)c).Checked)
             {
                 long id = long.Parse(c.ID);
                 cart.Add(dd.Products.First(a => a.Product_ID == id));
             }
         }
     }
     shoppingCart.Text = "<b>" + cart.Count + "</b> items in your cart";
     buildCart();
 }
Exemplo n.º 10
0
        protected void Page_Init(Object sender, EventArgs e)
        {
            if (cart == null)
            {
                cart = new List <Product>();
            }

            using (DowntownDeliEntity dd = new DowntownDeliEntity())
            {
                foreach (Product prod in dd.Products)
                {
                    Menu.Controls.Add(new LiteralControl("<tr><td>"));
                    CheckBox menucheck = new CheckBox();
                    menucheck.ID = prod.Product_ID.ToString();
                    Menu.Controls.Add(menucheck);
                    Menu.Controls.Add(new LiteralControl("</td><td>" + prod.Product_Name + "</td><td>" + prod.Price.ToString("C") + "</td ></tr>"));
                }
            }

            buildCart();
        }
Exemplo n.º 11
0
 protected void Username_TextChanged(object sender, EventArgs e)
 {
     if (Username.Text != "")
     {
         using (DowntownDeliEntity dd = new DowntownDeliEntity())
         {
             Customer cust = dd.Customers.FirstOrDefault(a => a.Email == Username.Text);
             if (cust != null)
             {
                 usernameUsed.Style["display"] = "block";
             }
             else
             {
                 usernameUsed.Style["display"] = "none";
             }
         }
     }
     else
     {
         usernameUsed.Style["display"] = "none";
     }
 }
Exemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (System.Web.HttpContext.Current.User != null && System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
            {
                if (user != null)
                {
                    Button btnAdmin       = (Button)HeadLoginView.FindControl("btnAdmin");
                    Button btnOrder       = (Button)HeadLoginView.FindControl("btnOrder");
                    Button btnReports     = (Button)HeadLoginView.FindControl("btnReports");
                    Button btnInventory   = (Button)HeadLoginView.FindControl("btnInventory");
                    Button btnTimeKeeping = (Button)HeadLoginView.FindControl("btnTimeKeeping");
                    if (user.Job_ID == 2)//cook
                    {
                        btnAdmin.Visible       = false;
                        btnOrder.Visible       = false;
                        btnReports.Visible     = false;
                        btnInventory.Visible   = false;
                        btnTimeKeeping.Visible = true;
                    }
                    else if (user.Job_ID == 3)
                    {//cashier
                        btnAdmin.Visible       = false;
                        btnOrder.Visible       = true;
                        btnReports.Visible     = false;
                        btnInventory.Visible   = false;
                        btnTimeKeeping.Visible = true;
                    }
                    else if (user.Job_ID == 4)//manager
                    {
                        btnAdmin.Visible       = false;
                        btnOrder.Visible       = true;
                        btnReports.Visible     = true;
                        btnInventory.Visible   = true;
                        btnTimeKeeping.Visible = true;
                    }
                    else if (user.Job_ID == 5)// customer.. should never happen but just in case.
                    {
                        btnAdmin.Visible       = false;
                        btnOrder.Visible       = false;
                        btnReports.Visible     = false;
                        btnInventory.Visible   = false;
                        btnTimeKeeping.Visible = false;
                    }
                    else
                    {
                        btnAdmin.Visible       = true;
                        btnOrder.Visible       = true;
                        btnReports.Visible     = true;
                        btnInventory.Visible   = true;
                        btnTimeKeeping.Visible = true;
                    }
                }


                using (DowntownDeliEntity dde = new DowntownDeliEntity())
                {
                    ListView lvCurrentOrders = (ListView)HeadLoginView.FindControl("lvCurrentOrders");
                    lvCurrentOrders.DataSource = dde.Orders.Include("Customer").Where(t => t.Complete == false || t.Complete == null).ToList();
                    lvCurrentOrders.DataBind();
                }
            }
            else
            {
                FormsAuthentication.SignOut();
            }
        }
Exemplo n.º 13
0
        protected void CheckOut_Click(object sender, EventArgs e)
        {
            using (DowntownDeliEntity dd = new DowntownDeliEntity())
            {
                decimal total = cart.Sum(a => a.Price);
                if (useRewardPoints)
                {
                    total = total - cart.OrderBy(a => a.Price).First().Price;
                    shoppingCartContents.Controls.Add(new LiteralControl("<tr><td>Customer Rewards Discount</td><td>(" + ((decimal)cart.OrderBy(a => a.Price).First().Price).ToString("C") + ")</td><td></td></tr>"));
                    dd.Customers.First(a => a.Customer_ID == customer.Customer_ID).TotalPoints = dd.Customers.First(a => a.Customer_ID == customer.Customer_ID).TotalPoints - 10;
                    customer = dd.Customers.First(a => a.Customer_ID == customer.Customer_ID);
                    dd.SaveChanges();
                }
                else
                {
                    dd.Customers.First(a => a.Customer_ID == customer.Customer_ID).TotalPoints = dd.Customers.First(a => a.Customer_ID == customer.Customer_ID).TotalPoints + 1;
                    dd.SaveChanges();
                    customer.TotalPoints++;
                }
                DateTime  now   = DateTime.Now.Date;
                Promotion promo = dd.Promotions.FirstOrDefault(a => a.Begin_Date <= now && a.End_Date >= now && (a.Discount_Type == "Cash Off" || a.Discount_Type == "Percent Off"));
                if (promo != null)
                {
                    if (promo.Discount_Type == "Cash Off")
                    {
                        total = total + (decimal)promo.Discount;
                    }
                    if (promo.Discount_Type == "Percent Off")
                    {
                        total = total - (total * ((decimal)promo.Discount / 100));
                    }
                }
                Order Order = new Order();
                Order.Customer_ID = customer.Customer_ID;
                if (promo != null)
                {
                    Order.Promotion = promo;
                }
                Order.Price    = cart.Sum(a => a.Price);
                Order.Ord_Date = DateTime.Now;
                Order.Points   = 0;
                dd.Orders.Add(Order);
                dd.SaveChanges();

                foreach (Product item in cart)
                {
                    Product_Order newitem = new Product_Order();
                    newitem.Order_ID   = Order.Order_ID;
                    newitem.Product_ID = item.Product_ID;
                    dd.Product_Order.Add(newitem);
                    Product prods = dd.Products.Find(item.Product_ID);
                    foreach (Product_Inventory prodInv in prods.Product_Inventory)
                    {
                        Inventory inv = dd.Inventories.Find(prodInv.Item_ID);
                        inv.Quantity -= 1;
                    }
                }
                dd.SaveChanges();
            }
            Server.Transfer("CheckoutComplete.aspx");
        }