コード例 #1
0
 public void UpdateDepartment(Department item, DepartmentDetail detail, IPersistenceContext context)
 {
     item.Id          = detail.Id;
     item.Name        = detail.Name;
     item.Description = detail.Description;
     item.Facility    = context.Load <Facility>(detail.Facility.FacilityRef, EntityLoadFlags.Proxy);
     item.Deactivated = detail.Deactivated;
 }
コード例 #2
0
        public async Task <bool> CreateDepartmentDetailsAsync(DepartmentDetail departmentDetail)
        {
            _context.Set <DepartmentDetail>().Add(departmentDetail);

            await _context.SaveChangesAsync();

            return(true);
        }
コード例 #3
0
        public void AddNewDepartment(string depid, string depname, int totalemployees, string empid)
        {
            OrganizationEntities NewOE = new OrganizationEntities();
            var newDept = new DepartmentDetail {
                DepartmentID = depid, DepartmentName = depname, TotalEmployee = totalemployees, EmployeeID = empid
            };

            NewOE.DepartmentDetails.Add(newDept);
            NewOE.SaveChanges();
        }
コード例 #4
0
 public bool UpdateDepartment(DepartmentDetail model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity =
             ctx
             .DepartmentDbSet
             .Single(e => e.DepartmentId == model.DepartmentId);
         entity.DepartmentName = model.DepartmentName;
         entity.EmployeeCount  = model.EmployeeCount;
         return(ctx.SaveChanges() == 1);
     }
 }
コード例 #5
0
        public IHttpActionResult Put(DepartmentDetail dept)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateDepartmentService();

            if (!service.UpdateDepartment(dept))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
コード例 #6
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            DepartmentDetail = await _context.DepartmentDetail.FirstOrDefaultAsync(m => m.DDID == id);

            if (DepartmentDetail == null)
            {
                return(NotFound());
            }
            return(Page());
        }
コード例 #7
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            DepartmentDetail = await _context.DepartmentDetail.FindAsync(id);

            if (DepartmentDetail != null)
            {
                _context.DepartmentDetail.Remove(DepartmentDetail);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
コード例 #8
0
        public RedirectToRouteResult UpdateCollectionPoint(string[] collectionPointIds, string[] collectionPointDefault)
        {
            using (SSISdbEntities e = new SSISdbEntities())
            {
                //update dept's collection point
                int              index          = collectionPointDefault.ToList <String>().IndexOf("True");
                string           newDefaultCPid = collectionPointIds[index];
                string           deptCode       = Session["DepartmentCode"].ToString();
                DepartmentDetail detail         = e.DepartmentDetails.Where(x => x.DepartmentCode == deptCode).FirstOrDefault();
                detail.CollectionPointID = newDefaultCPid;

                DAL.DepartmentDetailsRepositoryImpl dal = new DAL.DepartmentDetailsRepositoryImpl(e);
                dal.UpdateDepartmentDetail(detail);

                e.SaveChanges();

                return(RedirectToAction("CollectionPoint", "Dept"));
            }
        }
コード例 #9
0
        // GET: Admin/Department/Details/5
        public ActionResult Details(int id)
        {
            DepartmentService       departRepo   = new DepartmentService();
            Department              department   = departRepo.Get(id);
            AdminService            adminRepo    = new AdminService();
            EmployeeService         employeeRepo = new EmployeeService();
            DocumentService         repoDoc      = new DocumentService();
            IEnumerable <Employee>  employees    = employeeRepo.GetByDepartment(id);
            List <EmployeeListItem> finalList    = new List <EmployeeListItem>();

            foreach (Employee employee in employees)
            {
                finalList.Add(new EmployeeListItem(employee));
            }
            IEnumerable <DocumentList> docs         = repoDoc.GetByDepartment(id).Select(d => new DocumentList(d));
            DepartmentDetail           departDetail = new DepartmentDetail(department, adminRepo.Get(department.AdminId), finalList, docs);

            return(View(departDetail));
        }
コード例 #10
0
        /// <summary>
        /// Called by the host to initialize the application component.
        /// </summary>
        public override void Start()
        {
            Platform.GetService <IDepartmentAdminService>(
                service =>
            {
                var formDataResponse = service.LoadDepartmentEditorFormData(
                    new LoadDepartmentEditorFormDataRequest());
                _facilityChoices = formDataResponse.FacilityChoices;

                if (_isNew)
                {
                    _detail = new DepartmentDetail();
                }
                else
                {
                    var response = service.LoadDepartmentForEdit(new LoadDepartmentForEditRequest(_itemRef));
                    _itemRef     = response.Department.DepartmentRef;
                    _detail      = response.Department;
                }
            });

            base.Start();
        }
        public RedirectToRouteResult SubmitNewDelegation(ApprovalDelegation item1, Employee item2)
        {
            using (SSISdbEntities e = new SSISdbEntities())
            {
                DAL.DepartmentDetailsRepositoryImpl dal2 = new DAL.DepartmentDetailsRepositoryImpl(e);
                string           deptCode    = Session["DepartmentCode"].ToString();
                DepartmentDetail deptDetails = e.DepartmentDetails.Where(x => x.DepartmentCode == deptCode && x.Active == 1).FirstOrDefault();

                DAL.EmployeeRepositoryImpl dal3 = new DAL.EmployeeRepositoryImpl(e);

                Employee emp = new Employee();
                emp = e.Employees.Where(x => x.EmployeeName == item2.EmployeeName).FirstOrDefault();
                string   role   = Request.Form["SelectNewEmpRole"].ToString();
                Employee HODemp = e.Employees.Where(x => x.DepartmentCode == deptCode && x.Designation == "Department Head" && x.Active == 1).FirstOrDefault();

                if (emp != null)
                {
                    if (role == "Approver")
                    {
                        //1. If delegated approver,
                        //Insert New Approval Delegation (and inactivate others of same department)
                        DAL.ApprovalDelegationRepositoryImpl dal1 = new DAL.ApprovalDelegationRepositoryImpl(e);
                        item1.EmployeeID   = emp.EmployeeID;
                        item1.Active       = 1;
                        item1.DateAssigned = System.DateTime.Now;
                        item1.Id           = e.ApprovalDelegations.ToList().Count() + 1;


                        //(1.1 loop Approval Delegation - same dept)
                        List <string> employeeList =
                            e.Employees.Where(x => x.DepartmentCode == deptCode && x.Active == 1).Select(x => x.EmployeeID).ToList();

                        List <ApprovalDelegation> pastActiveApprovalsOfDept =
                            e.ApprovalDelegations.Where(x => employeeList.Contains(x.EmployeeID)).ToList();

                        if (pastActiveApprovalsOfDept != null)
                        {
                            foreach (ApprovalDelegation ad in pastActiveApprovalsOfDept)
                            {
                                ad.Active = 0;
                                dal1.UpdateApprovalDelegation(ad);
                            }
                        }

                        if (emp.Designation == "Employee Representative")
                        {
                            deptDetails.RepresentativeID = HODemp.EmployeeID;
                            //assuming only HOD (not just any approver) can delegate roles
                        }

                        if (emp.Designation != "Department Head")
                        {
                            //(1.2 loop employee - same dept)
                            Employee prevApprover = e.Employees.Where(x => x.DepartmentCode == deptCode && x.Approver == 1).FirstOrDefault();
                            if (prevApprover != null)
                            {
                                prevApprover.Approver = 0;
                            }

                            emp.Designation = "Employee";
                            dal1.InsertApprovalDelegation(item1);
                        }


                        //2. Update Employee role and approver flag
                        //3. Update department details (rep and approver id)
                        emp.Approver           = 1;
                        deptDetails.ApproverID = emp.EmployeeID;
                    }

                    if (role == "Representative")
                    {
                        Employee prevRep = e.Employees.Where(x => x.DepartmentCode == deptCode &&
                                                             x.EmployeeID == deptDetails.RepresentativeID).FirstOrDefault();

                        if (prevRep != null && prevRep.Designation != "Department Head")
                        {
                            prevRep.Designation = "Employee";
                        }

                        //inactivate any prev approver del
                        ApprovalDelegation ad = e.ApprovalDelegations.Where(x => x.EmployeeID == emp.EmployeeID && x.Active == 1).FirstOrDefault();
                        if (ad != null)
                        {
                            ad.Active = 0;
                        }

                        //check if dept has no approver, default to dept's HOD
                        if (emp.Approver == 1)
                        {
                            deptDetails.ApproverID = HODemp.EmployeeID;
                        }

                        if (emp.Designation != "Department Head")
                        {
                            emp.Designation = "Employee Representative";
                            emp.Approver    = 0;
                        }

                        deptDetails.RepresentativeID = emp.EmployeeID;

                        //4. Update rep in Disbursement Header (with status 'Open')
                        List <DisbursementHeader> openDisbursements = e.DisbursementHeaders.Where(x => x.DepartmentCode == deptCode && x.Status == "Open").ToList();
                        foreach (DisbursementHeader d in openDisbursements)
                        {
                            d.RepresentativeID = emp.EmployeeID;
                        }
                    }

                    dal3.UpdateEmployee(emp);
                    dal2.UpdateDepartmentDetail(deptDetails);
                }

                e.SaveChanges();
            }

            return(RedirectToAction("Authorisation", "Dept"));
        }
コード例 #12
0
		public UpdateDepartmentRequest(DepartmentDetail detail)
		{
			this.Department = detail;
		}
 public void InsertDepartmentDetail(DepartmentDetail departmentDetail)
 {
     context.DepartmentDetails.Add(departmentDetail);
 }
 public void UpdateDepartmentDetail(DepartmentDetail departmentDetail)
 {
     context.Entry(departmentDetail).State = EntityState.Modified;
 }
コード例 #15
0
 public AddDepartmentRequest(DepartmentDetail detail)
 {
     this.Department = detail;
 }
        public void DeleteDepartmentDetail(string code)
        {
            DepartmentDetail departmentDetail = context.DepartmentDetails.Find(code);

            context.DepartmentDetails.Remove(departmentDetail);
        }
コード例 #17
0
		public LoadDepartmentForEditResponse(DepartmentDetail detail)
		{
			this.Department = detail;
		}
        public Task Execute(IJobExecutionContext context)
        {
            using (SSISdbEntities m = new SSISdbEntities())
            {
                #region Variables
                // List of StaffReq with Open & Approved
                List <StaffRequisitionHeader> staffReqHeadList = m.StaffRequisitionHeaders
                                                                 .Where(x => x.Status == "Open" && x.ApprovalStatus == "Approved").ToList();
                // List of StaffReq with Outstanding
                List <StaffRequisitionHeader> srhWithBO = m.StaffRequisitionHeaders.Where(x => x.Status == "Outstanding").ToList();

                Dictionary <Item, int>            itemAndQty             = new Dictionary <Item, int>();
                List <StaffRequisitionDetail>     srdList                = new List <StaffRequisitionDetail>();
                List <StaffRequisitionDetail>     srdWithBackOrders      = new List <StaffRequisitionDetail>();
                Dictionary <Item, List <string> > listOfItemsAndColAdded = new Dictionary <Item, List <string> >();
                List <string> colpt = new List <string>();
                List <StaffRequisitionDetail> allsrd = new List <StaffRequisitionDetail>();
                #endregion

                #region Prepare new StaffRequisitionDetails to add
                // Search for all Outstanding StaffReqDetails
                foreach (StaffRequisitionHeader srhBO in srhWithBO)
                {
                    List <StaffRequisitionDetail> SRD = m.StaffRequisitionDetails
                                                        .Where(x => x.FormID == srhBO.FormID && x.QuantityBackOrdered > 0).ToList();
                    if (SRD != null)
                    {
                        foreach (StaffRequisitionDetail sr in SRD)
                        {
                            srdWithBackOrders.Add(sr);
                        }
                    }
                }

                // Search for all Open && Approved StaffReqDetails
                foreach (StaffRequisitionHeader srhInWeek in staffReqHeadList)
                {
                    srhInWeek.Status = "Outstanding";
                    m.SaveChanges();

                    // Find List of StaffReqDetails based on Header ID
                    List <StaffRequisitionDetail> SRD = m.StaffRequisitionDetails
                                                        .Where(x => x.FormID == srhInWeek.FormID).ToList();
                    if (SRD != null)
                    {
                        foreach (StaffRequisitionDetail sr in SRD)
                        {
                            srdList.Add(sr);
                        }
                    }
                }
                #endregion

                // Check if there's any entries to collate
                if (srdList.Count() > 0 || srdWithBackOrders.Count() > 0)
                {
                    #region Create StockRetrievalHeader
                    // Create StockRetrievalHeader
                    StockRetrievalHeader newsrh = new StockRetrievalHeader();
                    int    newSRH = m.StockRetrievalHeaders.Count() + 1;
                    string srhId  = CommonLogic.SerialNo(newSRH, "StoR");
                    newsrh.ID                = srhId;
                    newsrh.Date              = DateTime.Now;
                    newsrh.Disbursed         = 0;
                    newsrh.AllItemsRetrieved = 0;
                    m.StockRetrievalHeaders.Add(newsrh);
                    //m.SaveChanges();
                    #endregion

                    #region Confirming how many Items & quantity to collate
                    // Collate items based on Backorder SRDs (Total up items and its quantity to collect)
                    if (srdWithBackOrders.Count() > 0)
                    {
                        foreach (StaffRequisitionDetail srdlist in srdWithBackOrders)
                        {
                            Item item = m.Items.Where(x => x.ItemCode == srdlist.ItemCode).FirstOrDefault();
                            if (!itemAndQty.ContainsKey(item))
                            {
                                itemAndQty.Add(item, srdlist.QuantityBackOrdered);
                            }
                            else
                            {
                                itemAndQty[item] += srdlist.QuantityBackOrdered;
                            }
                        }
                    }

                    // Collate items based on new SRD (Total up items and its quantity to collect)
                    if (srdList.Count() > 0)
                    {
                        foreach (StaffRequisitionDetail srdlist in srdList)
                        {
                            Item item = m.Items.Where(x => x.ItemCode == srdlist.ItemCode).FirstOrDefault();
                            if (!itemAndQty.ContainsKey(item))
                            {
                                itemAndQty.Add(item, srdlist.QuantityOrdered);
                            }
                            else
                            {
                                itemAndQty[item] += srdlist.QuantityOrdered;
                            }
                        }
                    }

                    // Check if quantity is sufficient (If insufficient, can only collect based on Quantity on Hand)
                    foreach (Item itemToCollate in itemAndQty.Keys.ToList())
                    {
                        if (itemToCollate.Quantity < itemAndQty[itemToCollate])
                        {
                            itemAndQty[itemToCollate] = itemToCollate.Quantity;
                        }
                    }
                    #endregion

                    #region Fulfill Backorders
                    // Fulfill all backorders first
                    if (srdWithBackOrders.Count() > 0)
                    {
                        foreach (StaffRequisitionDetail retrievalListWithBO in srdWithBackOrders)
                        {
                            Item itemRetrieved = m.Items.Where(x => x.ItemCode == retrievalListWithBO.ItemCode).FirstOrDefault();
                            Bin  bin           = m.Bins.Where(x => x.ItemCode == retrievalListWithBO.ItemCode).FirstOrDefault();
                            StaffRequisitionHeader srhDeptCode = m.StaffRequisitionHeaders.Where(x => x.FormID == retrievalListWithBO.FormID).FirstOrDefault();
                            DepartmentDetail       dd          = m.DepartmentDetails.Where(x => x.DepartmentCode == srhDeptCode.DepartmentCode).FirstOrDefault();
                            StockRetrievalDetail   newsrd      = new StockRetrievalDetail();
                            int qtyAvailable = itemAndQty[itemRetrieved];

                            // Only create entries with qty available
                            if (qtyAvailable > 0)
                            {
                                // Create quantity requested that is really available for that item
                                int qtyToAdd = 0;
                                if (qtyAvailable > retrievalListWithBO.QuantityBackOrdered)
                                {
                                    qtyToAdd = retrievalListWithBO.QuantityBackOrdered;
                                }
                                else
                                {
                                    qtyToAdd = qtyAvailable;
                                }

                                if (listOfItemsAndColAdded.ContainsKey(itemRetrieved))
                                {
                                    if (!listOfItemsAndColAdded[itemRetrieved].Contains(dd.CollectionPointID))
                                    {
                                        // If its an entirely new Item for the collection point of the SRD, create a new entry
                                        newsrd.Id                = srhId;
                                        newsrd.Bin               = bin.Number;
                                        newsrd.ItemCode          = retrievalListWithBO.ItemCode;
                                        newsrd.QuantityRetrieved = qtyToAdd;
                                        newsrd.CollectionPointID = dd.CollectionPointID;
                                        newsrd.QuantityAdjusted  = 0;
                                        newsrd.Remarks           = "";
                                        newsrd.Collected         = 0;
                                        m.StockRetrievalDetails.Add(newsrd);
                                        allsrd.Add(retrievalListWithBO);

                                        // Prepare list for iteration of repeated entries (Indicate that there's exisiting record of Item & Collection point)
                                        List <string> existingColpt = listOfItemsAndColAdded[itemRetrieved];
                                        existingColpt.Add(dd.CollectionPointID);
                                        listOfItemsAndColAdded[itemRetrieved] = existingColpt;
                                    }
                                    else
                                    {
                                        // If there's existing entry (Based on previous collection point / back orders created), add to entry
                                        StockRetrievalDetail existingSRD = m.StockRetrievalDetails
                                                                           .Where(x => x.Id == srhId && x.ItemCode == itemRetrieved.ItemCode &&
                                                                                  x.CollectionPointID == dd.CollectionPointID).FirstOrDefault();
                                        existingSRD.QuantityRetrieved += qtyToAdd;
                                        allsrd.Add(retrievalListWithBO);
                                    }
                                }
                                else
                                {
                                    // If its an entirely new Item for the collection point of the SRD, create a new entry
                                    newsrd.Id                = srhId;
                                    newsrd.Bin               = bin.Number;
                                    newsrd.ItemCode          = retrievalListWithBO.ItemCode;
                                    newsrd.QuantityRetrieved = qtyToAdd;
                                    newsrd.CollectionPointID = dd.CollectionPointID;
                                    newsrd.QuantityAdjusted  = 0;
                                    newsrd.Remarks           = "";
                                    newsrd.Collected         = 0;
                                    m.StockRetrievalDetails.Add(newsrd);
                                    allsrd.Add(retrievalListWithBO);
                                    colpt = new List <string>();
                                    colpt.Add(dd.CollectionPointID);
                                    listOfItemsAndColAdded.Add(itemRetrieved, colpt);
                                }

                                //Remove quantity added from dictionary
                                itemAndQty[itemRetrieved] -= qtyToAdd;
                                m.SaveChanges();
                            }
                        }
                    }
                    #endregion

                    #region Fulfill new entries
                    // Create StockRetrievalDetails
                    if (srdList.Count() > 0)
                    {
                        foreach (StaffRequisitionDetail retrievalList in srdList)
                        {
                            Item itemRetrieved = m.Items.Where(x => x.ItemCode == retrievalList.ItemCode).FirstOrDefault();
                            Bin  bin           = m.Bins.Where(x => x.ItemCode == retrievalList.ItemCode).FirstOrDefault();
                            StaffRequisitionHeader srhDeptCode = m.StaffRequisitionHeaders
                                                                 .Where(x => x.FormID == retrievalList.FormID).FirstOrDefault();
                            DepartmentDetail dd = m.DepartmentDetails
                                                  .Where(x => x.DepartmentCode == srhDeptCode.DepartmentCode).FirstOrDefault();
                            StockRetrievalDetail newsrd = new StockRetrievalDetail();
                            int qtyAvailable            = itemAndQty[itemRetrieved];

                            // Only create entries with qty available
                            if (qtyAvailable > 0)
                            {
                                // Create quantity requested that is really available for that item
                                int qtyToAdd = 0;
                                if (qtyAvailable > retrievalList.QuantityOrdered)
                                {
                                    qtyToAdd = retrievalList.QuantityOrdered;
                                }
                                else
                                {
                                    qtyToAdd = qtyAvailable;
                                }

                                if (listOfItemsAndColAdded.ContainsKey(itemRetrieved))
                                {
                                    if (!listOfItemsAndColAdded[itemRetrieved].Contains(dd.CollectionPointID))
                                    {
                                        // If its an entirely new Item for the collection point of the SRD, create a new entry
                                        newsrd.Id                = srhId;
                                        newsrd.Bin               = bin.Number;
                                        newsrd.ItemCode          = retrievalList.ItemCode;
                                        newsrd.QuantityRetrieved = qtyToAdd;
                                        newsrd.CollectionPointID = dd.CollectionPointID;
                                        newsrd.QuantityAdjusted  = 0;
                                        newsrd.Remarks           = "";
                                        newsrd.Collected         = 0;
                                        m.StockRetrievalDetails.Add(newsrd);
                                        allsrd.Add(retrievalList);

                                        // Prepare list for iteration of repeated entries (Indicate that there's exisiting record of Item & Collection point)
                                        List <string> existingColpt = listOfItemsAndColAdded[itemRetrieved];
                                        existingColpt.Add(dd.CollectionPointID);
                                        listOfItemsAndColAdded[itemRetrieved] = existingColpt;
                                    }
                                    else
                                    {
                                        // If there's existing entry (Based on previous collection point / back orders created), add to entry
                                        StockRetrievalDetail existingSRD = m.StockRetrievalDetails
                                                                           .Where(x => x.Id == srhId && x.ItemCode == itemRetrieved.ItemCode &&
                                                                                  x.CollectionPointID == dd.CollectionPointID).FirstOrDefault();
                                        existingSRD.QuantityRetrieved += qtyToAdd;
                                        allsrd.Add(retrievalList);
                                    }
                                }
                                else
                                {
                                    // If its an entirely new Item for the collection point of the SRD, create a new entry
                                    newsrd.Id                = srhId;
                                    newsrd.Bin               = bin.Number;
                                    newsrd.ItemCode          = retrievalList.ItemCode;
                                    newsrd.QuantityRetrieved = qtyToAdd;
                                    newsrd.CollectionPointID = dd.CollectionPointID;
                                    newsrd.QuantityAdjusted  = 0;
                                    newsrd.Remarks           = "";
                                    newsrd.Collected         = 0;
                                    m.StockRetrievalDetails.Add(newsrd);
                                    allsrd.Add(retrievalList);

                                    colpt = new List <string>();
                                    colpt.Add(dd.CollectionPointID);
                                    listOfItemsAndColAdded.Add(itemRetrieved, colpt);
                                }

                                // Remove qty that is added
                                itemAndQty[itemRetrieved] -= qtyToAdd;
                                m.SaveChanges();
                            }
                        }
                    }
                    #endregion

                    #region Create StockRetrievalReqForm
                    List <String> allNewlyCreatedReqFormId = new List <String>();

                    foreach (StaffRequisitionDetail allNewlyCreated in allsrd)
                    {
                        allNewlyCreatedReqFormId.Add(allNewlyCreated.FormID);
                    }

                    //To remove duplicate req form id
                    allNewlyCreatedReqFormId = allNewlyCreatedReqFormId.Distinct().ToList();

                    foreach (String newReqFormId in allNewlyCreatedReqFormId)
                    {
                        // New StockRetrievalReqForm
                        StockRetrievalReqForm srrf = new StockRetrievalReqForm();
                        //srrf.ReqFormID = allNewlyCreated.FormID;
                        srrf.ReqFormID        = newReqFormId;
                        srrf.StockRetrievalID = srhId;
                        m.StockRetrievalReqForms.Add(srrf);
                        m.SaveChanges();
                    }
                    #endregion
                }
            }
            return(null);
        }
コード例 #19
0
 public LoadDepartmentForEditResponse(DepartmentDetail detail)
 {
     this.Department = detail;
 }
コード例 #20
0
 public UpdateDepartmentRequest(DepartmentDetail detail)
 {
     this.Department = detail;
 }
コード例 #21
0
		public AddDepartmentRequest(DepartmentDetail detail)
		{
			this.Department = detail;
		}