示例#1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (user != null)
     {
         if (user.Job_ID != 1 && user.Job_ID != 4)
         {
             Response.Redirect("~/Home.aspx");
         }
     }
     if (!Page.IsPostBack)
     {
         using (DowntownDeliEntity dde = new DowntownDeliEntity())
         {
             lvInventoryItems.DataSource = dde.Inventories.OrderBy(t => t.Item_Name).ToList();
             lvInventoryItems.DataBind();
             ddlInventory.DataSource = dde.Inventories.OrderBy(t => t.Item_Name).ToList();
             ddlInventory.DataBind();
             lvOrderInventoryItems.DataSource = dde.Inventories.OrderBy(t => t.Item_Name).Where(t => t.Quantity <= 25).ToList();
             lvOrderInventoryItems.DataBind();
             ddlVendors.DataSource = dde.Vendors.OrderBy(t => t.Vendor_Name).ToList();
             ddlVendors.DataBind();
         }
     }
     if (System.Web.HttpContext.Current.User == null || !System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
     {
         Response.Clear();
         FormsAuthentication.SignOut();
         Response.Redirect("~/Login.aspx");
     }
 }
示例#2
0
 protected void lvMenuItems_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
 {
     using (DowntownDeliEntity dde = new DowntownDeliEntity())
     {
         DataPager lvMenuItemsPager = lvMenuItems.FindControl("lvMenuItemsPager") as DataPager;
         int       CurrentPage      = ((lvMenuItemsPager.StartRowIndex) / lvMenuItemsPager.MaximumRows) + 1;
         lvMenuItemsPager.SetPageProperties(lvMenuItemsPager.StartRowIndex, lvMenuItemsPager.MaximumRows, false);
         lvMenuItems.DataSource = dde.Products.OrderBy(t => t.Product_Name).ToList();
         lvMenuItems.DataBind();
     }
 }
示例#3
0
 protected void lvInventoryItems_ItemDataBound(object sender, ListViewItemEventArgs e)
 {
     if (e.Item is ListViewDataItem)
     {
         using (DowntownDeliEntity dde = new DowntownDeliEntity())
         {
             ListViewDataItem item      = (ListViewDataItem)e.Item;
             Inventory        invItem   = (Inventory)item.DataItem;
             Button           btnDelete = (Button)item.FindControl("btnDelete");
             if (invItem.Product_Inventory.Count > 0)
             {
                 btnDelete.Visible = false;
             }
         }
     }
 }
示例#4
0
 protected void btnOrder_Click(object sender, EventArgs e)
 {
     using (DowntownDeliEntity dde = new DowntownDeliEntity())
     {
         List <Inventory> listofItems = new List <Inventory>();
         foreach (ListViewDataItem item in lvOrderInventoryItems.Items)
         {
             CheckBox cbAddToOrder = (CheckBox)item.FindControl("cbAddToOrder");
             if (cbAddToOrder.Checked)
             {
                 Label     lblItemID = (Label)item.FindControl("lblItemID");
                 int       id        = int.Parse(lblItemID.Text);
                 Inventory invItem   = dde.Inventories.Find(id);
                 if (invItem != null)
                 {
                     listofItems.Add(invItem);
                 }
             }
         }
         if (listofItems.Count > 0)
         {
             foreach (Inventory inv in listofItems)
             {
                 Inventory_Order invOrder = new Inventory_Order();
                 invOrder.Item_ID       = inv.Item_ID;
                 invOrder.Vendor_ID     = int.Parse(ddlVendors.SelectedValue);
                 invOrder.Quantity      = 50;
                 invOrder.Total_Cost    = (inv.Cost * 50) + ((inv.Cost * 50) * .0675M);
                 invOrder.Purchase_Date = DateTime.Now;
                 invOrder.Delivery_Date = DateTime.Now.AddDays(5);
                 dde.Inventory_Order.Add(invOrder);
                 Inventory invItem = dde.Inventories.Find(inv.Item_ID);
                 invItem.Quantity += 50;
                 dde.SaveChanges();
                 lvInventoryItems.DataSource = dde.Inventories.OrderBy(t => t.Item_Name).ToList();
                 lvInventoryItems.DataBind();
                 lvOrderInventoryItems.DataSource = dde.Inventories.OrderBy(t => t.Item_Name).Where(t => t.Quantity <= 25).ToList();
                 lvOrderInventoryItems.DataBind();
             }
             Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "OpenModal('SuccessModal')", true);
         }
         else
         {
             Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "OpenModal('FailureModal')", true);
         }
     }
 }
示例#5
0
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     using (DowntownDeliEntity dde = new DowntownDeliEntity())
     {
         Inventory invItem = new Inventory();
         invItem.Item_Name       = tbItemName.Text;
         invItem.Quantity        = int.Parse(tbNewQuantity.Text);
         invItem.Cost            = decimal.Parse(tbCost.Text);
         invItem.Experation_Date = DateTime.Parse(ExpDateTimePickerInput.Value);
         dde.Inventories.Add(invItem);
         dde.SaveChanges();
         lvInventoryItems.DataSource = dde.Inventories.OrderBy(t => t.Item_Name).ToList();
         lvInventoryItems.DataBind();
         ddlInventory.DataSource = dde.Inventories.OrderBy(t => t.Item_Name).ToList();
         ddlInventory.DataBind();
     }
 }
示例#6
0
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     using (DowntownDeliEntity dde = new DowntownDeliEntity())
     {
         int       item     = int.Parse(ddlInventory.SelectedValue);
         int       quantity = int.Parse(tbQuantity.Text);
         Inventory invItem  = dde.Inventories.FirstOrDefault(a => a.Item_ID == item);
         if (invItem != null)
         {
             invItem.Quantity = quantity;
             dde.SaveChanges();
         }
         lvInventoryItems.DataSource = dde.Inventories.OrderBy(t => t.Item_Name).ToList();
         lvInventoryItems.DataBind();
         ddlInventory.DataSource = dde.Inventories.OrderBy(t => t.Item_Name).ToList();
         ddlInventory.DataBind();
     }
 }
示例#7
0
 protected void lvInventoryItems_ItemCommand(object sender, ListViewCommandEventArgs e)
 {
     switch (e.CommandName)
     {
     case "DeleteCommand":
         using (DowntownDeliEntity dde = new DowntownDeliEntity())
         {
             ListViewDataItem item      = (ListViewDataItem)e.Item;
             Label            lblItemID = (Label)item.FindControl("lblItemID");
             int       id      = int.Parse(lblItemID.Text);
             Inventory invItem = dde.Inventories.Find(id);
             dde.Inventories.Remove(invItem);
             dde.SaveChanges();
             lvInventoryItems.DataSource = dde.Inventories.OrderBy(t => t.Item_Name).ToList();
             lvInventoryItems.DataBind();
         }
         break;
     }
 }
示例#8
0
        protected void Generate_Report(object sender, EventArgs e)
        {
            DateTime start = DateTime.Parse(StartDateDatePickerReportsInput.Value);
            DateTime end   = DateTime.Parse(StopDateDatePickerReportsInput.Value);

            if (ddlProducts.SelectedItem.Text == "Timekeeping")
            {
                Data.Text = "<table class='table'><thead><th>Name</th><th>Date</th><th>Hours</th></thead>";
                using (DowntownDeliEntity dd = new DowntownDeliEntity())
                {
                    foreach (Empworktime work in dd.Empworktimes.Where(a => a.Work_Date >= start && a.Work_Date <= end).OrderBy(a => a.Work_Date))
                    {
                        Data.Text = Data.Text + "<tr><td>" + work.Employee.F_Name + " " + work.Employee.L_Name + "</td><td>" + work.Work_Date + "</td><td>" + (work.Clock_Out - work.Clock_In).TotalHours + " hours</td></tr>";
                    }
                }
                Data.Text = Data.Text + "</table>";
            }
            if (ddlProducts.SelectedItem.Text == "Sales")
            {
                Data.Text = "<table class='table'><thead><th>Date</th><th>Total Sales</th></thead>";
                using (DowntownDeliEntity dd = new DowntownDeliEntity())
                {
                    foreach (DateTime date in dd.Orders.Where(a => a.Ord_Date >= start && a.Ord_Date <= end).Select(a => a.Ord_Date).Distinct())
                    {
                        Decimal profit = dd.Orders.Where(a => a.Ord_Date == date).Sum(a => a.Price);
                        Data.Text = Data.Text + "<tr><td>" + date.ToShortDateString() + "</td><td>" + profit.ToString("C") + "</td></tr>";
                    }
                }
                Data.Text = Data.Text + "</table>";
            }
            if (ddlProducts.SelectedItem.Text == "Top Selling Item")
            {
                Data.Text = "<table class='table'><thead><th>Date</th><th>Total Sales</th></thead>";
                using (DowntownDeliEntity dd = new DowntownDeliEntity())
                {
                    foreach (DateTime date in dd.Orders.Where(a => a.Ord_Date >= start && a.Ord_Date <= end).Select(a => a.Ord_Date).Distinct())
                    {
                        Dictionary <long, int> prod = new Dictionary <long, int>();
                        foreach (Order ord in dd.Orders.Where(a => a.Ord_Date == date))
                        {
                            foreach (Product_Order pord in ord.Product_Order)
                            {
                                if (!prod.ContainsKey((long)pord.Product_ID))
                                {
                                    prod[(long)pord.Product_ID] = 1;
                                }
                                else
                                {
                                    prod[(long)pord.Product_ID]++;
                                }
                            }
                        }
                        if (!prod.Any())
                        {
                            break;
                        }
                        long    id      = prod.OrderByDescending(x => x.Value).ToDictionary(a => a.Key, a => a.Value).First().Key;
                        Product product = dd.Products.FirstOrDefault(a => a.Product_ID == id);
                        Data.Text = Data.Text + "<tr><td>" + date.ToShortDateString() + "</td><td>" + product.Product_Name + "</td></tr>";
                    }
                }
                Data.Text = Data.Text + "</table>";
            }
        }