Exemple #1
0
        public Leave AddLeave(LeaveTypeEnum leavesType, DateTimeOffset startDate, DateTimeOffset endDate, string purpose, string delegation, DateTimeOffset createDate)
        {
            TimeSpan span     = endDate.Subtract(startDate);
            double   duration = span.TotalDays + 1;

            double remaining = 12 - duration;

            //if leave not null then remaining equal to latest remaining minus duration
            if (Leaves.Count > 0)
            {
                remaining = Leaves.Select(o => o.Remaining).Max();
                remaining = remaining - duration;
            }

            //no idea
            bool status = false;

            var leave = new Leave(Guid.NewGuid(), this.Identity, leavesType, startDate, endDate, purpose, delegation, duration, remaining, status, createDate);

            if (Leaves == null)
            {
                Leaves = new List <Leave>().AsReadOnly();
            }

            var list = Leaves.ToList();

            list.Add(leave);

            ReadModel.Leaves.Add(new LeaveReadModel(leave));

            Leaves = list.AsReadOnly();

            return(leave);
        }
        private void GetLeaveApplications_ByApproverId(int statusId)
        {
            LeaveTypeEnum leaveType                = LeaveTypeEnum.None;
            DateTime      fromApplicationDate      = DateTime.MinValue;
            DateTime      toApplicationDate        = DateTime.MinValue;
            DataTable     dtLeaveApplicationMaster =
                new Business.LeaveManagement.LeaveApprovalDetails()
                .GetLeaveApplications_ByApproverId(Convert.ToInt32(HttpContext.Current.User.Identity.Name), statusId, leaveType, fromApplicationDate, toApplicationDate);

            gvLeavePending.DataSource = dtLeaveApplicationMaster;
            gvLeavePending.DataBind();
        }
Exemple #3
0
        private void GetLeaveApplications_ByApproverId(int statusId)
        {
            LeaveTypeEnum leaveType                = (LeaveTypeEnum)Enum.Parse(typeof(LeaveTypeEnum), ddlLeaveType.SelectedValue);
            DateTime      fromApplicationDate      = string.IsNullOrEmpty(txtFromLeaveDate.Text.Trim()) ? DateTime.MinValue : Convert.ToDateTime(txtFromLeaveDate.Text.Trim());
            DateTime      toApplicationDate        = string.IsNullOrEmpty(txtToLeaveDate.Text.Trim()) ? DateTime.MinValue : Convert.ToDateTime(txtToLeaveDate.Text.Trim());
            DataTable     dtLeaveApplicationMaster =
                new Business.LeaveManagement.LeaveApprovalDetails()
                .GetLeaveApplications_ByApproverId(Convert.ToInt32(HttpContext.Current.User.Identity.Name), statusId, leaveType, fromApplicationDate, toApplicationDate);

            gvLeaveApprovalList.DataSource = dtLeaveApplicationMaster;
            gvLeaveApprovalList.DataBind();
        }
        public Leave(Guid id, Guid employeeId, LeaveTypeEnum leaveType, DateTimeOffset startDate, DateTimeOffset endDate, string purpose, string delegation, double duration, double remaining, bool status, DateTimeOffset createDate)
        {
            Identity   = id;
            EmployeeId = employeeId;
            LeaveType  = leaveType;
            StartDate  = startDate;
            EndDate    = endDate;
            Purpose    = purpose;
            Delegation = delegation;
            Duration   = duration;
            Remaining  = remaining;
            Status     = status;
            CreateDate = createDate;

            this.AddDomainEvent(new LeaveCreated(this));
        }
 public Leave(DateTime startingDate, int duration, LeaveTypeEnum leaveType)
 {
     this.startingDate = startingDate;
     this.duration     = duration;
     this.leaveType    = leaveType;
 }
 public DataTable GetLeaveApplications_ByApproverId(int approverId, int statusId, LeaveTypeEnum leaveType, DateTime fromApplicationDate, DateTime toApplicationDate)
 {
     return(DataAccess.LeaveManagement.LeaveApprovalDetails.GetLeaveApplications_ByApproverId(approverId, statusId, leaveType, fromApplicationDate, toApplicationDate));
 }
 public static DataTable GetLeaveApplications_ByApproverId(int approverId, int statusId, LeaveTypeEnum leaveType, DateTime fromApplicationDate, DateTime toApplicationDate)
 {
     using (DataTable dt = new DataTable())
     {
         using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString()))
         {
             using (SqlCommand cmd = new SqlCommand())
             {
                 cmd.Connection  = con;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.CommandText = "usp_GetLeaveApplications_ByApproverId";
                 cmd.Parameters.AddWithValue("@ApproverId", approverId);
                 if (statusId == 0)
                 {
                     cmd.Parameters.AddWithValue("@Status", DBNull.Value);
                 }
                 else
                 {
                     cmd.Parameters.AddWithValue("@Status", statusId);
                 }
                 if (leaveType == LeaveTypeEnum.None)
                 {
                     cmd.Parameters.AddWithValue("@LeaveTypeId", DBNull.Value);
                 }
                 else
                 {
                     cmd.Parameters.AddWithValue("@LeaveTypeId", (int)leaveType);
                 }
                 if (fromApplicationDate == DateTime.MinValue)
                 {
                     cmd.Parameters.AddWithValue("@FromLeaveApplicationDate", DBNull.Value);
                 }
                 else
                 {
                     cmd.Parameters.AddWithValue("@FromLeaveApplicationDate", fromApplicationDate);
                 }
                 if (toApplicationDate == DateTime.MinValue)
                 {
                     cmd.Parameters.AddWithValue("@ToLeaveApplicationDate", DBNull.Value);
                 }
                 else
                 {
                     cmd.Parameters.AddWithValue("@ToLeaveApplicationDate", toApplicationDate);
                 }
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(dt);
                 }
                 con.Close();
             }
         }
         return(dt);
     }
 }