예제 #1
0
        protected void CancelDelegationBtn_Click(object sender, EventArgs e)
        {
            string          currentdep      = DisbursementLogic.GetCurrentDep();
            DDelegateDetail currentdelegate = RequisitionLogic.GetLatestDelegate(currentdep);
            string          fullname        = RequisitionLogic.GetDelegateName(currentdelegate);

            RequisitionLogic.CancelDelegate(currentdelegate);
            MultiView1.ActiveViewIndex = 2;
            BindDdl();
            statusMessage.Text      = fullname + "'s delegation has been cancelled.";
            statusMessage.Visible   = true;
            statusMessage.ForeColor = Color.Green;
        }
예제 #2
0
        protected void ShowCurrentDelegate()
        {
            MultiView1.ActiveViewIndex = 0;
            string          currentdep               = DisbursementLogic.GetCurrentDep();
            DDelegateDetail currentdelegate          = RequisitionLogic.GetLatestDelegate(currentdep);
            string          currentdelegatename      = RequisitionLogic.GetDelegateName(currentdelegate);
            DateTime        currentdelegatestartdate = RequisitionLogic.GetDelegateStartDate(currentdelegate);
            DateTime        currentdelegateenddate   = RequisitionLogic.GetDelegateEndDate(currentdelegate);

            LblCurrentDelegate.Text     = currentdelegatename;
            LblCurrentDelStartDate.Text = currentdelegatestartdate.ToShortDateString();
            LblCurrentDelEndDate.Text   = currentdelegateenddate.ToShortDateString();
        }
예제 #3
0
        protected void RemoveDeptHeadRoleFromUserWithDateCheck(object sender, System.Timers.ElapsedEventArgs e)
        {
            List <Department>      depwithdelegateslist = new List <Department>();
            List <Department>      deplist      = new List <Department>();
            List <DDelegateDetail> delegatelist = new List <DDelegateDetail>();
            List <DateTime>        startdates   = new List <DateTime>();
            List <DateTime>        enddates     = new List <DateTime>();

            using (SA45Team12AD entities = new SA45Team12AD())
            {
                //get list of current delegates
                delegatelist = entities.DDelegateDetails.ToList();
                deplist      = entities.Departments.ToList();
                foreach (Department u in deplist)
                {
                    if (u.HasDelegate == 1)
                    {
                        depwithdelegateslist.Add(u);
                    }
                }

                if (depwithdelegateslist != null)
                {
                    foreach (Department u in depwithdelegateslist)
                    {
                        delegatelist.Add(RequisitionLogic.GetLatestDelegate(u.DeptID));
                    }
                    foreach (DDelegateDetail u in delegatelist)
                    {
                        //get username for delegates
                        string username = DisbursementLogic.GetUserName(u.DepartmentHeadDelegate, u.DepartmentID);
                        //remove depthead role from user after checking period
                        if (DateTime.Today > u.EndDate && Roles.IsUserInRole(username, "HOD"))
                        {
                            RequisitionLogic.RemoveDeptHeadRoleFromUser(u.DepartmentHeadDelegate, u.DepartmentID);
                            Department department = entities.Departments.Where(x => x.DeptID == u.DepartmentID).First();
                            department.HasDelegate = 0;
                            entities.SaveChanges();
                        }
                    }
                }
            }
        }
예제 #4
0
        protected void BtnEdit_Click(object sender, EventArgs e)
        {
            statusMessage.Visible      = false;
            MultiView1.ActiveViewIndex = 1;
            string          currentdep               = DisbursementLogic.GetCurrentDep();
            DDelegateDetail currentdelegate          = RequisitionLogic.GetLatestDelegate(currentdep);
            string          currentdelegatename      = RequisitionLogic.GetDelegateName(currentdelegate);
            DateTime        currentdelegatestartdate = RequisitionLogic.GetDelegateStartDate(currentdelegate);
            DateTime        currentdelegateenddate   = RequisitionLogic.GetDelegateEndDate(currentdelegate);

            CalStartEditDelegate.TodaysDate   = currentdelegatestartdate;
            CalEndEditDelegate.TodaysDate     = currentdelegateenddate;
            CalStartEditDelegate.SelectedDate = CalStartEditDelegate.TodaysDate;
            CalEndEditDelegate.SelectedDate   = CalEndEditDelegate.TodaysDate;
            LblCurrentDelegateView2.Text      = currentdelegatename;
            if (CalStartEditDelegate.SelectedDate < DateTime.Today)
            {
                CalStartEditDelegate.Enabled = false;
            }
        }
예제 #5
0
        //for updating current delegate
        protected void ApplyBtn_Click(object sender, EventArgs e)
        {
            DateTime        newstartdate    = CalStartEditDelegate.SelectedDate;
            DateTime        newenddate      = CalEndEditDelegate.SelectedDate;
            string          currentdep      = DisbursementLogic.GetCurrentDep();
            DDelegateDetail currentdelegate = RequisitionLogic.GetLatestDelegate(currentdep);
            string          fullname        = RequisitionLogic.GetDelegateName(currentdelegate);

            if (newstartdate >= DateTime.Today && newstartdate <= newenddate && newstartdate != null && newenddate != null)
            {
                RequisitionLogic.UpdateDelegate(currentdelegate, newstartdate, newenddate);
                statusMessage.Text      = (fullname + " has been delegated as the department head from " + newstartdate.ToShortDateString() + " to " + newenddate.ToShortDateString());
                statusMessage.Visible   = true;
                statusMessage.ForeColor = Color.Green;
                ShowCurrentDelegate();
            }
            else
            {
                statusMessage.Text      = "Please enter a valid period";
                statusMessage.Visible   = true;
                statusMessage.ForeColor = Color.Red;
            }
        }