public static void ConfirmRecivedItems(string DI, List <DisbursementDetail> ddlist)
        {
            Staff rep = new Staff();

            using (InventorySysDBEntities cntx = new InventorySysDBEntities())
            {
                //update disbursmentdetail
                foreach (DisbursementDetail dd in ddlist)
                {
                    updateDisbursmentDetail(cntx, dd);
                }

                //update disbursment
                Disbursement disbursment = cntx.Disbursements.Find(DI);
                rep = StaffController.getRepByDepID(disbursment.Dept_ID);

                disbursment.Receive_Date = DateTime.Now;
                disbursment.Status       = "Recieved";

                // update Requisition
                List <Requisition> reqList = getRequisitionsByDI(DI);
                foreach (Requisition req in reqList)
                {
                    Requisition reqData = cntx.Requisitions.Find(req.Requisition_ID);
                    reqData.Status = "Received";
                }

                cntx.SaveChanges();
            }
            SendNotificationController.SendNotificaition(rep, DI);
        }
Пример #2
0
        //delegate
        //create new delegate
        public static void createDelegateHistory(string sfid, string managerId, DateTime startDate, DateTime endDate)
        {
            var   t  = from x in ctx.Staffs where x.Staff_ID == sfid select x;
            Staff sf = t.First();

            sf.Role_ID = "AuthStaff";

            DelegateHistory dh = new DelegateHistory();

            dh.Manager_ID = managerId;
            dh.Staff_ID   = sf.Staff_ID;
            dh.Start_Date = Convert.ToDateTime(startDate);
            dh.End_Date   = Convert.ToDateTime(endDate);
            dh.Status     = "Delegated";
            ctx.DelegateHistories.Add(dh);
            ctx.SaveChanges();
        }
Пример #3
0
        //public static bool ChangeRepToStaff(string deptID)
        //{
        //    using (InventorySysDBEntities cntx = new InventorySysDBEntities())
        //    {

        //        Staff stf = GetRepByDeptID(deptID);
        //        Staff repStaff = cntx.Staffs.Find(stf.Staff_ID);
        //        if (repStaff != null)
        //        {
        //            repStaff.Role_ID = "Staff";
        //            cntx.SaveChanges();
        //            return true;
        //        }
        //        else
        //            return false;
        //    }
        //}

        //public static bool ChangeStaffToRep(string staffID)
        //{
        //    using (InventorySysDBEntities cntx = new InventorySysDBEntities())
        //    {
        //        var q = from x in cntx.Staffs where x.Staff_ID == staffID select x;
        //        if (q.ToList().Count > 0)
        //        {
        //            q.First().Role_ID = "RepStaff";
        //            cntx.SaveChanges();
        //            return true;
        //        }
        //        else
        //            return false;
        //    }
        //}

        public static void UpdateCollectionPoint(string DeptID, string ColID)
        {
            using (InventorySysDBEntities cntx = new InventorySysDBEntities())
            {
                var        q = from x in cntx.Departments where x.Dept_ID == DeptID select x;
                Department d = q.First();

                d.Collection_ID = ColID;
                cntx.SaveChanges();
            }
        }
Пример #4
0
        public static bool UpdateCollectionPoint(string DeptID, string staffID, string ColID)
        {
            using (InventorySysDBEntities cntx = new InventorySysDBEntities())
            {
                using (var dbContextTransaction = cntx.Database.BeginTransaction())
                {
                    try
                    {
                        //make here the changes

                        Staff stf      = GetRepByDeptID(DeptID);
                        Staff repStaff = cntx.Staffs.Find(stf.Staff_ID);
                        repStaff.Role_ID = "Staff";



                        var changeStaffTRep             = from x in cntx.Staffs where x.Staff_ID == staffID select x;
                        changeStaffTRep.First().Role_ID = "RepStaff";


                        var        updateCollectionPoint = from x in cntx.Departments where x.Dept_ID == DeptID select x;
                        Department d = updateCollectionPoint.First();
                        d.Collection_ID = ColID;


                        cntx.SaveChanges();
                        dbContextTransaction.Commit();

                        return(true);
                    }
                    catch (Exception ex)
                    {
                        dbContextTransaction.Rollback();
                        return(false);
                    }
                }
            }
        }