public WCF_AppDuties CheckAppDuties(string deptcode) { try { Approval_Duties c = work.ListAppDuties(deptcode); return(new WCF_AppDuties(c.username, c.start_date.ToString(), c.end_date.ToString(), c.dept_code, c.created_date.ToString(), c.deleted, c.reason)); } catch { return(null); } //return Work.ListAppDuties(deptcode).ToArray<String>(); }
public void Create(WCF_AppDuties dr) { string fullName = dr.username; string usrName = work.GetUserName(fullName); Approval_Duties appduties = new Approval_Duties { username = usrName, start_date = Convert.ToDateTime(dr.StartDate), end_date = Convert.ToDateTime(dr.EndDate), dept_code = dr.DeptCode, created_date = Convert.ToDateTime(dr.CreatedDate), deleted = dr.Deleted, reason = dr.Reason }; work.CreateAppDuties(appduties); }
public UserModel FindDelegateHead() { try { DateTime today = DateTime.Today; SSISEntities context = new SSISEntities(); string dept = this.department.dept_code; List <Approval_Duties> approvedList = context.Approval_Duties.Where(x => x.dept_code == dept && x.deleted == "N").ToList(); List <Approval_Duties> validList = new List <Approval_Duties>(); for (int i = 0; i < approvedList.Count; i++) { if (approvedList[i].start_date.Ticks <= today.Ticks && approvedList[i].end_date.Ticks >= today.Ticks) { validList.Add(approvedList[i]); } } DateTime currentApproved = validList.Max(x => x.created_date); //var listOfApproved = context.Approval_Duties.Where(x => x.created_date == currentApproved); var listOfApproved = validList.Where(x => x.created_date == currentApproved); if (listOfApproved.Count() > 0) { Approval_Duties currentRep = listOfApproved.Last(); UserModel repUser = new UserModel(currentRep.username); repUser.role = "DeptHead"; return(repUser); } else { return(null); } } catch (Exception) { return(null); } }
protected void btnSave_Click(object sender, EventArgs e) { //show FUll Name- save username delegateFullName = ddlEmployee.SelectedItem.ToString(); //Select Dropdown List Validation try { if (delegateFullName.Equals("Select---")) { Label1.Text = "Please Choose One Delegate!"; } else { Label1.Text = ""; } //Date Validation selectStartDate = tbStartDate.Text; selectEndDate = tbEndDate.Text; if (selectStartDate == "" || selectEndDate == "") { lbDateError.Text = "Please choose the Date!"; } else { if (selectStartDate.CompareTo(currentDate) == -1 || selectEndDate.CompareTo(currentDate) == -1) { lbDateError.Text = "cannot choose previous date!"; } else if (selectEndDate.CompareTo(selectStartDate) == -1) { lbDateError.Text = "Start Date should before End Date!"; } else { lbDateError.Text = ""; Dept_Registry depReg = context.Dept_Registry.SingleOrDefault(x => x.fullname == delegateFullName); delegateUserName = depReg.username; Approval_Duties ad = new Approval_Duties { //delegateFullName username = delegateUserName, start_date = Convert.ToDateTime(tbStartDate.Text), end_date = Convert.ToDateTime(tbEndDate.Text), dept_code = currentDeptCode, created_date = Convert.ToDateTime(currentDate), deleted = "N", reason = tbReason.Text }; context.Approval_Duties.Add(ad); context.SaveChanges(); lbDateError.Text = "Successfully Saved!"; } } } catch (Exception ex) { ex.StackTrace.ToString(); } }
public void CreateAppDuties(Approval_Duties ap) { context.Entry(ap).State = System.Data.Entity.EntityState.Added; context.SaveChanges(); }