Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // Hide buttons first
                panelApproval.Visible = false;

                string requestedStr = Request.QueryString["id"];
                int    requestId;
                if (requestedStr == null)
                {
                    return;
                }

                int.TryParse(requestedStr, out requestId);

                if (requestId == 0)
                {
                    return;
                }

                RequestModel request;

                using (SSISEntities context = new SSISEntities())
                {
                    request = FacadeFactory.getRequestService(context).findRequestById(requestId);

                    if (request == null)
                    {
                        lblInfo.Text = "Could not find that request";
                        return;
                    }
                }

                Session[SESSION_REQUEST_ID] = requestId;

                lblRequestId.Text    += requestedStr;
                lblEmployeeName.Text += request.Username;
                lblReason.Text       += request.Reason;
                lblInfo.Text          = "Status: " + request.Status;

                Dictionary <string, int> items = request.Items
                                                 .Where(w => w.Value > 0)
                                                 .ToDictionary(k => k.Key.Description, v => v.Value);

                if (request.Status == RequestStatus.PENDING || request.Status == RequestStatus.UPDATED)
                {
                    panelApproval.Visible = true;
                }

                gvItems.DataSource = items;
                gvItems.DataBind();
            }
        }
        //InventoryAdjustmentModel model;
        protected void Page_Load(object sender, EventArgs e)
        {
            context = new SSISEntities();

            if (!IsPostBack)
            {
                List <Inventory_Adjustment>     invAdjList   = context.Inventory_Adjustment.Where(x => x.deleted == "N" & x.status == "Pending").ToList();
                List <InventoryAdjustmentModel> invModelList = new List <InventoryAdjustmentModel>();
                foreach (Inventory_Adjustment i in invAdjList)
                {
                    InventoryAdjustmentModel model = new InventoryAdjustmentModel(i);
                    //model = new InventoryAdjustmentModel(i);
                    if (User.IsInRole("Manager"))
                    {
                        foreach (AdjustmentModel j in model.AdjModel)
                        {
                            if (j.Above250())
                            {
                                invModelList.Add(model);
                                break;
                            }
                        }
                    }
                    else if (User.IsInRole("Supervisor"))
                    {
                        foreach (AdjustmentModel j in model.AdjModel)
                        {
                            if (!j.Above250())
                            {
                                invModelList.Add(model);
                                break;
                            }
                        }
                    }
                }

                Session["ViewAdj"]          = invModelList;
                ViewAdjustmentGV.DataSource = invModelList;
                ViewAdjustmentGV.DataBind();

                //invModelList.Add(model);
                //GridView1.DataSource = invModelList;
                //GridView1.DataBind();
            }
            //List<Adjustment_Details> adjList = context.Adjustment_Details.ToList();
            //List<AdjustmentModel> detailList = new List<AdjustmentModel>();
            //foreach (Adjustment_Details i in adjList)
            //{
            //    AdjustmentModel model = new AdjustmentModel(i);
            //    detailList.Add(model);
            //}
            //Session["ViewAdj"] = detailList;
        }
Example #3
0
        protected void btnReject_Click(object sender, EventArgs e)
        {
            using (SSISEntities context = new SSISEntities())
            {
                RequestModel request = FacadeFactory.getRequestService(context).findRequestById((int)Session[SESSION_REQUEST_ID]);
                FacadeFactory.getRequestService(context).rejectRequest(request, "Low Kway Boo");

                context.SaveChanges();
            }

            Response.Redirect("DEMO_ApproveRequest.aspx?id=" + (int)Session[SESSION_REQUEST_ID]);
        }
        protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            GridViewRow row         = GridView1.Rows[e.RowIndex];
            string      supplier_id = (row.FindControl("TextBox1") as TextBox).Text;

            using (SSISEntities s = new SSISEntities())
            {
                Supplier supplier = s.Suppliers.Where(p => p.supplier_id == supplier_id).First <Supplier>();
                supplier.deleted = "Y";
                s.SaveChanges();
            }
            this.BindGrid();
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            context = new SSISEntities();
            InventoryAdjustmentModel invModel = (InventoryAdjustmentModel)Session["ConfirmAdj"];
            //List<InventoryAdjustmentModel> invModelList = new List<InventoryAdjustmentModel>();
            //invModelList.Add(invModel);
            //GridView2.DataSource = invModelList;
            //GridView2.DataBind();

            List <AdjustmentModel> adjList = invModel.AdjModel;


            GridView1.DataSource = adjList;
            GridView1.DataBind();
        }
Example #6
0
        protected void OnRowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row      = GridView1.Rows[e.RowIndex];
            int         cat_id   = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]);
            string      cat_name = (row.FindControl("TextBox2") as TextBox).Text;


            using (SSISEntities entities = new SSISEntities())
            {
                Category category = entities.Categories.Where(p => p.cat_id == cat_id).First <Category>();
                //SSISEntities.cat_id = cat_id;
                category.cat_name = cat_name;
                entities.SaveChanges();
            }
            GridView1.EditIndex = -1;
            this.BindGrid();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            context = new SSISEntities();

            if (!IsPostBack)
            {
                checkDone = CheckIfMonthlyDone();
                List <MonthlyCheckModel> itemList = (List <MonthlyCheckModel>)Session["Monthly"];

                if (itemList == null)
                {
                    itemList = new List <MonthlyCheckModel>();

                    List <Stock_Inventory> stockList = context.Stock_Inventory.Where(x => x.deleted == "N").ToList();
                    foreach (Stock_Inventory i in stockList)
                    {
                        MonthlyCheckModel item = new MonthlyCheckModel(i);
                        itemList.Add(item);
                    }

                    Session["Monthly"] = itemList;
                }


                MonthlyCheckGV.DataSource = itemList;
                MonthlyCheckGV.DataBind();

                UserModel user     = new UserModel(HttpContext.Current.User.Identity.Name);
                UserModel depthead = user.FindDelegateOrDeptHead();
                //CheckLabel.Text = depthead.Username;


                //today = DateTime.Today;
                //DateTB.Text = today.Date.ToString("dd/MM/yyyy");

                itemList = (List <MonthlyCheckModel>)Session["Monthly"];
                //Session["Monthly"] = itemList;
                MonthlyCheckGV.DataSource = itemList;
                MonthlyCheckGV.DataBind();
            }
        }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            context = new SSISEntities();

            List <MonthlyCheckModel> modelList;
            Dictionary <string, int> SessionInfo;

            if (!IsPostBack)
            {
                modelList   = new List <MonthlyCheckModel>();
                SessionInfo = (Dictionary <string, int>)Session[PUBLIC_SESSION_DISCREPANCY_DICT];

                // Early quit if no session
                if (SessionInfo == null)
                {
                    lblWarning.Text    = "No discrepancies to be filed.";
                    ConfirmBtn.Visible = false;
                    return;
                }

                lblWarning.Visible = false;

                foreach (KeyValuePair <string, int> pair in SessionInfo)
                {
                    string itemCode    = pair.Key;
                    int    qtyAdjusted = pair.Value;

                    Stock_Inventory inventory = context.Stock_Inventory.Where(x => x.item_code == itemCode).ToList().First();

                    MonthlyCheckModel model = new MonthlyCheckModel(inventory);
                    model.ActualQuantity = model.CurrentQuantity - qtyAdjusted;
                    modelList.Add(model);
                }

                Session["DisDetail"] = modelList;

                FileDiscrepencyGV.DataSource = modelList;
                FileDiscrepencyGV.DataBind();
            }
        }
Example #9
0
        protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int cat_id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]);

            using (SSISEntities entities = new SSISEntities())
            {
                Category category = entities.Categories.Where(p => p.cat_id == cat_id).First <Category>();
                //check if there are any items under this cat
                int checkcatid             = category.cat_id;
                List <Stock_Inventory> lsi = entities.Stock_Inventory.Where(x => x.cat_id == checkcatid).ToList();
                if (lsi.Count == 0)
                {
                    category.deleted = "Y";
                    entities.SaveChanges();
                    Message.Text = "";
                }
                else
                {
                    Message.Text = "You cannot delete a category that has items within it.";
                }
            }
            this.BindGrid();
        }
Example #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                string currentUser = Page.User.Identity.Name;

                string fullName = "";
                using (SSISEntities context = new SSISEntities())
                {
                    try
                    {
                        fullName = context.Dept_Registry.Find(currentUser).fullname;
                    } catch (Exception)
                    {
                        FormsAuthentication.SignOut();
                        Response.Redirect("~/login.aspx");
                    }

                    // Check if user is department rep
                    //int count = ctx.Departments.Where(d => d.rep_user == currentUser).Count();
                    //if (count > 0)
                    //{
                    //    // is a dept rep
                    //    linkBtnDepRepView.Visible = true;
                    //    //btnDepRepViewDisbursements.Visible = true;
                    //} else
                    //{
                    //    linkBtnDepRepView.Visible = false;
                    //    //btnDepRepViewDisbursements.Visible = false;
                    //}
                }

                lblFullName.Text = "Welcome, " + fullName;

                userModel = new UserModel(Page.User.Identity.Name);
            }
        }
Example #11
0
        protected void Page_Init(object sender, EventArgs e)
        {
            bool isPersistent = false;

            if (Page.User.Identity.IsAuthenticated && Page.User.Identity.Name != null && Page.User.Identity.Name != "")
            {
                //var formsAuthCookie = Response.Cookies[FormsAuthentication.FormsCookieName];
                //if (formsAuthCookie != null)
                //{
                //    var existingTicket = FormsAuthentication.Decrypt(formsAuthCookie.Value);

                //    if (existingTicket != null)
                //    {
                //        isPersistent = existingTicket.IsPersistent;
                //    }
                //}

                // Somebody is signed in
                string normalisedUserName = Page.User.Identity.Name.ToLower();
                string storedUserName     = normalisedUserName;
                using (SSISEntities context = new SSISEntities())
                {
                    var users = context.Dept_Registry.Where(w => w.username.ToLower() == normalisedUserName);
                    if (users.Count() > 0)
                    {
                        var user = users.First();
                        storedUserName = user.username;
                    }
                }

                if (Page.User.Identity.Name != storedUserName)
                {
                    FormsAuthentication.SetAuthCookie(storedUserName, isPersistent);
                }
            }
        }
Example #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }

            string currentUser = User.Identity.Name;

            SSISEntities context = new SSISEntities();

            string fullName = "";

            fullName = context.Dept_Registry.Find(currentUser).fullname;

            lblFullName.Text = "Welcome, " + fullName;

            /* Emp side Dash */
            FillPage();

            /* Items to retrieve */
            #region Items to retrieve
            /* Items for retrieving */
            var allocated = FacadeFactory.getAllocatedService(context).getAllAllocated();

            bool anyAllocated = false;

            if (allocated != null)
            {
                anyAllocated = allocated.Count > 0;

                var allocatedItems = allocated.SelectMany(sm =>
                                                          sm.Items
                                                          .Select(s => new { s.Key.ItemCode, s.Key.Description, Quantity = s.Value
                                                                                                                           //, sm.Department.dept_code, sm.RequestId, sm.Department.name
                                                                  })
                                                          )
                                     .GroupBy(k => k.ItemCode, v => v)
                                     .Select(s => s.Aggregate((a, b) => {
                    int Quantity = a.Quantity + b.Quantity;
                    return(new { a.ItemCode, a.Description, Quantity });
                })
                                             )
                                     .ToList();
                gridViewToRetrieve_FromWarehouse.DataSource = allocatedItems.Take(3);
                gridViewToRetrieve_FromWarehouse.DataBind();

                lblNumToRetrieve.Text = string.Format("({0} in total)", allocatedItems.Count);
            }


            /* Items to confirm */
            var toConfirm = FacadeFactory.getRetrievalService(context).getAllRetrievingByClerk(currentUser);

            bool anyRetrievingToConfirm = toConfirm.Count > 0;

            var toConfirmItems = toConfirm.SelectMany(sm =>
                                                      sm.Items
                                                      .Select(s => new { s.Key.ItemCode, s.Key.Description, Quantity = s.Value })
                                                      )
                                 .GroupBy(k => k.ItemCode, v => v)
                                 .Select(s => s.Aggregate((a, b) => {
                int Quantity = a.Quantity + b.Quantity;
                return(new { a.ItemCode, a.Description, Quantity });
            })
                                         )
                                 .ToList();

            gridViewToRetrieve_ToConfirm.DataSource = toConfirmItems.Take(3);
            gridViewToRetrieve_ToConfirm.DataBind();

            /* Display toggling */
            panelToRetrieve_Empty.Visible         = true;
            panelToRetrieve_FromWarehouse.Visible = true;
            panelToRetrieve_ToConfirm.Visible     = true;

            if (anyAllocated)
            {
                panelToRetrieve.CssClass      = "panel panel-info";
                panelToRetrieve_Empty.Visible = false;
            }
            else
            {
                panelToRetrieve_FromWarehouse.Visible = false;
            }

            if (anyRetrievingToConfirm)
            {
                panelToRetrieve.CssClass      = "panel panel-info";
                panelToRetrieve_Empty.Visible = false;
                lblNumToConfirm.Text          = string.Format("({0} in total)", toConfirmItems.Count);
            }
            else
            {
                panelToRetrieve_ToConfirm.Visible = false;
            }
            #endregion

            /* Disbursements */
            #region Disbursements
            /* To disburse to collection points */
            var toBeDisbursed = FacadeFactory.getDisbursementService(context).getAllPossibleDisbursements();

            bool anyToBeDisbursed = toBeDisbursed.Count > 0;

            var collectionPtIds = toBeDisbursed.SelectMany(sm =>
                                                           sm.Items
                                                           .Select(s => new { s.Key.ItemCode, s.Key.Description, s.Value, sm.Department.dept_code, sm.RequestId, sm.Department.name, sm.CollectionPtId })
                                                           )
                                  .GroupBy(k => k.CollectionPtId)
                                  .Select(s => s.Key)
                                  .ToList();

            List <Collection_Point> collectionPts = context.Collection_Point.Where(w => w.deleted != "Y" && collectionPtIds.Contains(w.collection_pt_id)).ToList();

            gridViewToDisburse_ToCollectionPt.DataSource = collectionPts.Take(3);
            gridViewToDisburse_ToCollectionPt.DataBind();

            /* To sign-off */
            DisbursementModelCollection disbursingList = FacadeFactory.getDisbursementService(context).getAllThatCanBeSignedOff(currentUser);

            bool anyToBeSignedOff = disbursingList.Count > 0;

            var toBeSignedOff = disbursingList
                                .Select(sm => sm.Department.name)
                                .Distinct()
                                .Select(s => new { DepartmentName = s })
                                .ToList();

            gridViewToDisburse_ToConfirm.DataSource = toBeSignedOff.Take(3);
            gridViewToDisburse_ToConfirm.DataBind();

            /* Display toggling */
            panelToDisburse_Empty.Visible          = true;
            panelToDisburse_ToCollectionPt.Visible = true;
            panelToDisburse_ToConfirm.Visible      = true;

            if (anyToBeDisbursed)
            {
                panelToDisburse.CssClass      = "panel panel-success";
                panelToDisburse_Empty.Visible = false;
                lblNumToDisburse.Text         = string.Format("({0} in total)", collectionPts.Count);
            }
            else
            {
                panelToDisburse_ToCollectionPt.Visible = false;
            }

            if (anyToBeSignedOff)
            {
                panelToDisburse.CssClass      = "panel panel-success";
                panelToDisburse_Empty.Visible = false;
                lblNumToSignOff.Text          = string.Format("({0} in total)", toBeSignedOff.Count);
            }
            else
            {
                panelToDisburse_ToConfirm.Visible = false;
            }
            #endregion

            /* Low Stocks */
            #region Low Stocks
            List <Stock_Inventory> stocks    = context.Stock_Inventory.ToList();
            List <ItemModel>       lowStocks = new List <ItemModel>();

            foreach (var stock in stocks)
            {
                ItemModel im = new ItemModel(stock);
                if (im.AvailableQuantity < im.ReorderLevel)
                {
                    lowStocks.Add(im);
                }
            }

            gridViewLowStocks.DataSource = lowStocks.OrderBy(o => o.AvailableQuantity).Take(5);
            gridViewLowStocks.DataBind();

            if (lowStocks.Count > 0)
            {
                panelLowStocksEmpty.Visible          = false;
                panelLowStocksNormal.Visible         = true;
                panelLowStocksBtn.Visible            = true;
                panelLowStocks.CssClass              = "panel panel-warning";
                gridViewLowStocks.HeaderRow.CssClass = "warning";
                lblNumLowStock.Text = string.Format("({0} in total)", lowStocks.Count);
            }
            else
            {
                panelLowStocksEmpty.Visible  = true;
                panelLowStocksNormal.Visible = false;
                panelLowStocksBtn.Visible    = false;
            }
            #endregion

            context.Dispose();
        }