//----------------------------- Pradeep Elango's Code Starts Here--------------------// public static void AddDelegate(String fullname, DateTime startdate, DateTime enddate, string depid) { if (startdate >= DateTime.Today && enddate >= startdate) { using (SA45Team12AD entities = new SA45Team12AD()) { DDelegateDetail delegateDetail = new DDelegateDetail { DepartmentID = depid, DepartmentHeadDelegate = fullname, StartDate = startdate, EndDate = enddate }; entities.DDelegateDetails.Add(delegateDetail); Department department = entities.Departments.Where(x => x.DeptID == depid).First(); department.HasDelegate = 1; entities.SaveChanges(); } if (startdate == DateTime.Today) { AddDeptHeadRoleToUser(fullname, depid); } } }
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; }
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(); }
public static void UpdateDelegate(DDelegateDetail dDelegateinput, DateTime newstartdate, DateTime newenddate) { //if (Roles.IsUserInRole(DisbursementLogic.GetUserName(dDelegateinput.DepartmentHeadDelegate, dDelegateinput.DepartmentID), "HOD")) { using (SA45Team12AD entities = new SA45Team12AD()) { DDelegateDetail dDelegate = entities.DDelegateDetails.Where(p => p.DepartmentHeadDelegate == dDelegateinput.DepartmentHeadDelegate).Where(x => x.DepartmentID == dDelegateinput.DepartmentID).Where(x => x.StartDate == dDelegateinput.StartDate).Where(x => x.EndDate == dDelegateinput.EndDate).First(); dDelegate.StartDate = newstartdate; dDelegate.EndDate = newenddate; entities.SaveChanges(); } using (EmailControl em = new EmailControl()) { List <string> depuseremails = new List <string>(); depuseremails = Utility.Utility.GetAllUserEmailAddressListForDept(dDelegateinput.DepartmentID); } } }
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; } }
public static void CancelDelegate(DDelegateDetail dDelegateinput) { using (SA45Team12AD entities = new SA45Team12AD()) { DDelegateDetail dDelegate = entities.DDelegateDetails.Where(p => p.DepartmentHeadDelegate == dDelegateinput.DepartmentHeadDelegate).Where(x => x.DepartmentID == dDelegateinput.DepartmentID).Where(x => x.StartDate == dDelegateinput.StartDate).Where(x => x.EndDate == dDelegateinput.EndDate).First(); if (dDelegateinput.StartDate >= DateTime.Today) { dDelegate.StartDate = DateTime.Today.AddDays(-1); } dDelegate.EndDate = DateTime.Today.AddDays(-1); Department department = entities.Departments.Where(x => x.DeptID == dDelegateinput.DepartmentID).First(); department.HasDelegate = 0; entities.SaveChanges(); if (Roles.IsUserInRole(DisbursementLogic.GetUserName(dDelegateinput.DepartmentHeadDelegate, dDelegateinput.DepartmentID), "HOD")) { RemoveDeptHeadRoleFromUser(dDelegate.DepartmentHeadDelegate, dDelegate.DepartmentID); } } }
//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; } }
public static string GetDelegateName(DDelegateDetail dDelegateDetail) { return(dDelegateDetail.DepartmentHeadDelegate.ToString()); }
public static DateTime GetDelegateEndDate(DDelegateDetail dDelegateDetail) { return((DateTime)dDelegateDetail.EndDate); }
public static DateTime GetDelegateStartDate(DDelegateDetail dDelegateDetail) { return((DateTime)dDelegateDetail.StartDate); }