コード例 #1
0
        public LeaveApplicationDTOs CreateLeaveApplicationInformation(int empcode, int leaveid, string recommendType)
        {
            LeaveApplicationDTOs Result = new LeaveApplicationDTOs();

            Result.LeaveEmpCode  = empcode;
            Result.LeaveTypeId   = leaveid;
            Result.LeaveTypeName = _unitOfWork.LeaveTypeRepository.All().Where(x => x.LeaveTypeId == leaveid).Select(x => x.LeaveTypeName).FirstOrDefault();

            var leaveTypeData = _unitOfWork.LeaveTypeRepository.All().Where(x => x.LeaveTypeId == leaveid).FirstOrDefault();

            // Result.Leavetypes.HalfdayAllow = leaveTypeData.HalfdayAllow;

            Result.IsHalfDayAllow = leaveTypeData.HalfdayAllow;


            LeaveBalance LeaveBalance = LeavebalanceIndividual(null, empcode, leaveid);

            if (LeaveBalance.Leave_Balance <= 0)
            {
                throw new Exception("This Leave Is not assigned for you .");
            }
            else
            if (LeaveBalance.LeaveTypeAssignment != "General")
            {
                throw new Exception("Special Leave can not be applied from  here..");
            }
            Result.ApproverList    = _DynamicSelectList.GetLeaveApproverSelectList(empcode, recommendType).ToList();
            Result.RecommenderList = _DynamicSelectList.GetLeaveRecommenderSelectList(empcode, recommendType).ToList();
            return(Result);
        }
コード例 #2
0
        public JsonResult LeaveBalance(int?EmployeeID)
        {
            List <LeaveBalance> t = new List <LeaveBalance>();
            string conn           = ConfigurationManager.ConnectionStrings["kalingaPPDO"].ConnectionString;

            using (SqlConnection cn = new SqlConnection(conn))
            {
                string     myQuery = "select * from rep_EmpLeaveBalance where empID = @EmployeeID";
                SqlCommand cmd     = new SqlCommand()
                {
                    CommandText = myQuery,
                    CommandType = CommandType.Text
                };
                cmd.Parameters.AddWithValue("@EmployeeID", EmployeeID);
                cmd.Connection = cn;
                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    int counter = 0;
                    while (dr.Read())
                    {
                        LeaveBalance tsData = new LeaveBalance()
                        {
                            Days      = dr["BalanceDays"].ToString(),
                            Hours     = dr["BalanceHours"].ToString(),
                            LeaveType = dr["LeaveTypeCode"].ToString(),
                        };
                        t.Add(tsData);
                        counter++;
                    }
                }
            }
            return(Json(t, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ComId,EmpId,Cl,Sl,El,Ml,Acl,Bcl,Asl,Bsl,Ael,Bel,Aml,Bml")] LeaveBalance leaveBalance)
        {
            if (id != leaveBalance.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(leaveBalance);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LeaveBalanceExists(leaveBalance.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ComId"] = new SelectList(_context.UserResistration, "ComId", "ComId", leaveBalance.ComId);
            ViewData["EmpId"] = new SelectList(_context.EmployeeInfo, "Id", "Id", leaveBalance.EmpId);
            return(View(leaveBalance));
        }
コード例 #4
0
        public async Task <LeaveBalance> SetLeaveBalance(LeaveBalance leave)
        {
            EmployeeInfo info         = _context.EmployeeInfo.FirstOrDefault(e => e.ComId == comId && e.Id == leave.EmpId);
            LeaveBalance leaveBalance = new LeaveBalance();

            leaveBalance.ComId = leave.ComId;
            leaveBalance.EmpId = leave.EmpId;
            leaveBalance.Cl    = leave.Cl;
            leaveBalance.Acl   = 0;
            leaveBalance.Bcl   = leave.Cl;
            leaveBalance.Sl    = leave.Sl;
            leaveBalance.Asl   = 0;
            leaveBalance.Bsl   = leave.Sl;
            leaveBalance.El    = leave.El;
            leaveBalance.Ael   = 0;
            leaveBalance.Bel   = leave.El;
            if (info.Sex == "Female")
            {
                leaveBalance.Ml  = leave.Ml;
                leaveBalance.Aml = 0;
                leaveBalance.Bml = leave.Ml;
            }
            else
            {
                leaveBalance.Ml  = 0;
                leaveBalance.Aml = 0;
                leaveBalance.Bml = 0;
            }

            return(await Task.FromResult(leaveBalance));
        }
コード例 #5
0
        public ActionResult Create(QuickEntryVM quickEntryVM)
        {
            if (ModelState.IsValid)
            {
                UserInfo userInfo = new UserInfo();
                userInfo.MobileNo = quickEntryVM.MobileNo;

                Employee employee = new Employee();
                employee.FullName = quickEntryVM.EmployeeName;
                employee.UserInfo = userInfo;

                Random random = new Random();
                //int rInt = r.Next(0, 100); //for ints

                LeaveBalance leaveBalance = new LeaveBalance();
                leaveBalance.TotalAnnualLeave   = 20;
                leaveBalance.TotalCasualLeave   = 10;
                leaveBalance.TotalSickLeave     = 13;
                leaveBalance.AvailedAnnualLeave = random.Next(0, 20); //Generate random int value in a range
                leaveBalance.AvailedCasualLeave = random.Next(0, 10);
                leaveBalance.AvailedSickLeave   = random.Next(0, 13);
                leaveBalance.Employee           = employee;

                //db.UserInfos.Add(userInfo);
                db.LeaveBalances.Add(leaveBalance);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(quickEntryVM));
        }
コード例 #6
0
        public void CalculateAndChangeLeaveBalance(ref Leave leave)
        {
            ///////////////
            LeaveBalance leaveBalance = CalculateLeaveBalance(ref leave);

            if (leaveBalance == null)
            {
                //new
                leaveBalance                   = new LeaveBalance(ref leave);
                leaveBalance.Taken             = leave.TotalDays;
                leaveBalance.Balance          -= leave.TotalDays;
                leaveBalance.UserId            = leave.UserId;
                leaveBalance.LeaveTypeId       = leave.LeaveTypeId;
                leaveBalance.UserLeavePolicyId = leave.AspNetUser.UserLeavePolicyId;
                db.LeaveBalances.Add(leaveBalance);
            }
            else
            {
                //old
                leaveBalance.Taken          += leave.TotalDays;
                leaveBalance.Balance        -= leave.TotalDays;
                db.Entry(leaveBalance).State = EntityState.Modified;
            }
            ///////////////
        }
コード例 #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            LeaveBalance leaveBalance = db.LeaveBalances.Find(id);

            db.LeaveBalances.Remove(leaveBalance);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #8
0
        public LeaveBalance LeaveBalanceSearch()
        {
            LeaveBalance Result = new LeaveBalance();

            // Result.EmpCodeList = _DynamicSelectList.GetEmployeeSelectList().ToList();
            Result.LeaveYearList = _DynamicSelectList.LeaveYearList().ToList();
            Result.LeaveYearId   = _LeaveSetUp.LeaveYearList().Where(x => x.YearCurrent == true).Select(x => x.YearId).FirstOrDefault();
            return(Result);
        }
コード例 #9
0
        private void FillReport(bool isInitial = false, bool throwException = true)
        {
            string rep_params        = vals.Text;
            ReportGenericRequest req = new ReportGenericRequest();

            req.paramString = rep_params;

            ListResponse <Model.Reports.RT602> resp = _reportsService.ChildGetAll <Model.Reports.RT602>(req);

            if (!resp.Success)
            {
                Common.ReportErrorMessage(resp, GetGlobalResourceObject("Errors", "Error_1").ToString(), GetGlobalResourceObject("Errors", "ErrorLogId").ToString());
            }

            resp.Items.ForEach(x =>
            {
                if (x.hireDate != null)
                {
                    x.hireDateString = x.hireDate.Value.ToString(_systemService.SessionHelper.GetDateformat());
                }
                else
                {
                    x.hireDateString = string.Empty;
                }
                if (x.lastReturnDate != null)
                {
                    x.lastReturnDateString = x.lastReturnDate.Value.ToString(_systemService.SessionHelper.GetDateformat());
                }
                else
                {
                    x.lastReturnDateString = string.Empty;
                }
            });
            Dictionary <string, string> parameters = Web.UI.Forms.Common.FetchReportParameters(texts.Text);
            LeaveBalance h = new LeaveBalance(parameters);

            h.DataSource = resp.Items;

            h.RightToLeft       = _systemService.SessionHelper.CheckIfArabicSession() ? DevExpress.XtraReports.UI.RightToLeft.Yes : DevExpress.XtraReports.UI.RightToLeft.No;
            h.RightToLeftLayout = _systemService.SessionHelper.CheckIfArabicSession() ? DevExpress.XtraReports.UI.RightToLeftLayout.Yes : DevExpress.XtraReports.UI.RightToLeftLayout.No;


            //string from = DateTime.Parse(req.Parameters["_fromDate"]).ToString(_systemService.SessionHelper.GetDateformat());
            //string to = DateTime.Parse(req.Parameters["_toDate"]).ToString(_systemService.SessionHelper.GetDateformat());
            string user = _systemService.SessionHelper.GetCurrentUser();

            //h.Parameters["From"].Value = from;
            //h.Parameters["To"].Value = to;
            h.Parameters["User"].Value = user;
            //    h.Parameters["Fitlers"].Value = texts.Text;
            h.CreateDocument();


            ASPxWebDocumentViewer1.DataBind();
            ASPxWebDocumentViewer1.OpenReport(h);
        }
コード例 #10
0
        public LeaveBalance CalculateLeaveBalanceQuota(ref Leave leave)
        {
            string UserId      = leave.UserId;
            int    LeaveTypeId = leave.LeaveTypeId;
            //List<int> weeklyOffDays = leave.AspNetUser.UserLeavePolicy.WeeklyOffDays.Split(',').Select(int.Parse).ToList();

            LeaveBalance lb = leave.AspNetUser.LeaveBalances.FirstOrDefault(x => x.UserId == UserId && x.LeaveTypeId == LeaveTypeId);

            return(lb);
        }
コード例 #11
0
        public LeaveBalance CalculateLeaveBalance(ref Leave leave)
        {
            //check there is some weakend


            //check there is some anual leaves/public holidays


            //add sbubtract leave and add or update to leaveBalnce table


            List <int>          weeklyOffDays = leave.AspNetUser.UserLeavePolicy.WeeklyOffDays.Split(',').Select(int.Parse).ToList();
            List <AnnualOffDay> AnnualOffDays = leave.AspNetUser.UserLeavePolicy.AnnualOffDays.ToList <AnnualOffDay>();

            double TotalOffDays   = (leave.EndDate - leave.StartDate).TotalDays + 1;
            double NaturalOffDays = 0;
            bool   found          = false;

            for (DateTime DateIdx = leave.StartDate; DateIdx <= leave.EndDate; DateIdx = DateIdx.AddDays(1))
            {
                foreach (int d in weeklyOffDays)
                {
                    if (d == (int)DateIdx.DayOfWeek)
                    {
                        //weekend off days
                        NaturalOffDays += 1;
                        found           = true;
                        break;
                    }
                }
                //this condition is due to: example: if national holiday comes on sunday. then count it one day of. if this statement is not here it will conunt two days. which is wrong
                if (found == true)
                {
                    found = false; continue;
                }

                for (int i = 0; i < AnnualOffDays.Count; i++)
                {
                    if (DateIdx.Date.CompareTo(AnnualOffDays[i].OffDay) == 0)
                    {
                        //annual off days
                        NaturalOffDays += 1;
                        break;
                    }
                }
            }
            leave.TotalDays = (int)(TotalOffDays - NaturalOffDays);
            string UserId      = leave.UserId;
            int    LeaveTypeId = leave.LeaveTypeId;
            //List<int> weeklyOffDays = leave.AspNetUser.UserLeavePolicy.WeeklyOffDays.Split(',').Select(int.Parse).ToList();

            LeaveBalance lb = leave.AspNetUser.LeaveBalances.FirstOrDefault(x => x.UserId == UserId && x.LeaveTypeId == LeaveTypeId);

            return(lb);
        }
コード例 #12
0
 public ActionResult Edit([Bind(Include = "Id,TotalCasualLeave,TotalSickLeave,TotalAnnualLeave,AvailedCasualLeave,AvailedSickLeave,AvailedAnnualLeave,EmployeeId")] LeaveBalance leaveBalance)
 {
     if (ModelState.IsValid)
     {
         db.Entry(leaveBalance).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EmployeeId = new SelectList(db.Employees, "Id", "FullName", leaveBalance.EmployeeId);
     return(View(leaveBalance));
 }
コード例 #13
0
        /// <summary>
        /// Maps the specified original.
        /// </summary>
        /// <param name="original">The original.</param>
        /// <returns></returns>
        public static LeaveBalanceModel Map(this LeaveBalance original, string name, string surname)
        {
            var mappedOutcome = new LeaveBalanceModel
            {
                EmployeeId = original.EmployeeId.Value,
                Balance    = original.Balance.Value,
                Name       = name,
                Surname    = surname
            };

            return(mappedOutcome);
        }
コード例 #14
0
        public IEnumerable <LeaveBalance> GetLeaveBalance(LeaveBalance leaveBalance)
        {
            var sql         = "[Leaves].[sp_getBalance]";
            var queryParams = new DynamicParameters();

            queryParams.Add("@DistrictId", leaveBalance.DistrictId);
            //queryParams.Add("@OrgId", leaveBalance.OrganizationId);
            //queryParams.Add("@Year", leaveBalance.Year);
            //if (leaveBalance.UserId.Length >= 10)
            queryParams.Add("@UserId", leaveBalance.UserId);
            return(Db.Query <LeaveBalance>(sql, queryParams, commandType: System.Data.CommandType.StoredProcedure).ToList());
        }
コード例 #15
0
        public async Task <IActionResult> Create([Bind("Id,ComId,EmpId,Cl,Sl,El,Ml,Acl,Bcl,Asl,Bsl,Ael,Bel,Aml,Bml")] LeaveBalance leaveBalance)
        {
            if (ModelState.IsValid)
            {
                _context.Add(leaveBalance);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ComId"] = new SelectList(_context.UserResistration, "ComId", "ComId", leaveBalance.ComId);
            ViewData["EmpId"] = new SelectList(_context.EmployeeInfo, "Id", "Id", leaveBalance.EmpId);
            return(View(leaveBalance));
        }
コード例 #16
0
        // GET: LeaveBalances/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LeaveBalance leaveBalance = db.LeaveBalances.Find(id);

            if (leaveBalance == null)
            {
                return(HttpNotFound());
            }
            return(View(leaveBalance));
        }
コード例 #17
0
        // GET: LeaveBalances/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LeaveBalance leaveBalance = db.LeaveBalances.Find(id);

            if (leaveBalance == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EmployeeId = new SelectList(db.Employees, "Id", "FullName", leaveBalance.EmployeeId);
            return(View(leaveBalance));
        }
コード例 #18
0
        public async Task <IActionResult> AdjustLimit([FromBody] LeaveBalance model)
        {
            //long _pageSize = filters.pageSize <= 0 ? DefautltPageSize : filters.pageSize;
            //long _requestPage = filters.requestPage <= 0 ? DefaultRequestPage : filters.requestPage;
            //var _obj = await dal.GetLeaveLimitSummary(_pageSize, _requestPage, filters, "no");
            var _obj = await dal.AdjustLeaveLimit(model);

            //Debug.WriteLine(model.user.userName);
            //_obj.status = "000";
            string[] OkStatusList = { "000" };
            if (!OkStatusList.Contains(_obj.status))
            {
                return(BadRequest(_obj));
            }
            return(Ok(_obj));
        }
コード例 #19
0
        public static LeaveBalance SpLeaveBalanceToLeaveBalance(sp_LeaveApplicationEmployeeBalance_Result Record, int Empcode, int YearId)
        {
            LeaveBalance Result = new LeaveBalance
            {
                LeaveTypeId         = Convert.ToInt32(Record.LeaveTypeId),
                LeaveTypeName       = Record.LeaveTypeName,
                Leave_Balance       = Convert.ToDecimal(Record.BalanceDays),
                LeaveTypeAssignment = Record.LeaveTypeAssignment,
                TotalTaken          = Convert.ToDecimal(Record.TotalTaken),
                TotalLeaveAssigned  = Convert.ToDecimal(Record.TotalLeaveDays),
                EmpCode             = Empcode,
                LeaveYearId         = YearId,
            };

            return(Result);
        }
コード例 #20
0
 public IActionResult GetLeaveBalance([FromBody] LeaveBalance leaveBalance)
 {
     try
     {
         var districtId = base.CurrentUser.DistrictId;
         var response   = _service.GetLeaveBalance(leaveBalance);
         return(Ok(response));
     }
     catch (Exception ex)
     {
     }
     finally
     {
     }
     return(null);
 }
コード例 #21
0
 public void UpdateApprovedLeave(Entity target)
 {
     try
     {
         var entityobj            = organizationService.Retrieve("new_leaverequests", target.Id, new ColumnSet(true));
         var leaverequest         = new LeaveRequests(entityobj);
         EntityCollection results = null;
         if (leaverequest.LeaveStatus == eLeaveRequests_LeaveStatus.Approved)
         {
             QueryExpression _LeaveBalanceQuery = new QueryExpression
             {
                 EntityName = "new_leavebalance",
                 ColumnSet  = new ColumnSet("new_leavebalance"),
                 Criteria   = new FilterExpression
                 {
                     Conditions =
                     {
                         new ConditionExpression
                         {
                             AttributeName = "new_employeeid",
                             Operator      = ConditionOperator.Equal,
                             Values        = { leaverequest.CreatedBy.Id }
                         },
                         new ConditionExpression
                         {
                             AttributeName = "new_leavetype",
                             Operator      = ConditionOperator.Equal,
                             Values        = { leaverequest.LeaveType_OptionSetValue.Value }
                         }
                     }
                 }
             };
             results = organizationService.RetrieveMultiple(_LeaveBalanceQuery);
             if (results.Entities.Count == 1)
             {
                 var leavebalance = new LeaveBalance(results.Entities[0]);
                 leavebalance.LeaveBalanceAttribute = leavebalance.LeaveBalanceAttribute - leaverequest.NumberOfDays;
                 leavebalance.Update(organizationService);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #22
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,UserId,LeaveTypeId,Reason,StartDate,EndDate,TotalDays,EmergencyContact,ResponseDate1,ResponseDate2,IsAccepted1,IsAccepted2,LineManager1Id,LineManager2Id,Remarks1,Remarks2,DateCreated,DateModified,UserLeavePolicyId")] Leave leave, decimal LastLeaveDaysCount)
        {
            return(RedirectToAction("Index"));

            leave.UserId       = User.Identity.GetUserId();
            leave.AspNetUser   = db.AspNetUsers.FirstOrDefault(x => x.Id == leave.UserId);
            leave.DateModified = DateTime.Now;
            if (ModelState.IsValid)
            {
                db.Entry(leave).State = EntityState.Modified;
                ///////////////
                LeaveBalance leaveBalance = CalculateLeaveBalance(ref leave);

                if (leaveBalance == null)
                {
                    //new
                    //leaveBalance = new LeaveBalance(ref leave);
                    //leaveBalance.Taken = leave.TotalDays;
                    //leaveBalance.Balance -= leave.TotalDays;
                    //leaveBalance.UserId = leave.UserId;
                    //leaveBalance.LeaveTypeId = leave.LeaveTypeId;
                    //leaveBalance.UserLeavePolicyId = leave.AspNetUser.UserLeavePolicyId;
                    //db.LeaveBalances.Add(leaveBalance);
                }
                else
                {
                    //first reseting Balance to its correct state
                    leaveBalance.Balance = leaveBalance.Balance + LastLeaveDaysCount;//leave.TotalDays;
                    decimal Allowed = (decimal)leaveBalance.UserLeavePolicy.UserLeavePolicyDetails.FirstOrDefault(x => x.UserLeavePolicyId == leave.AspNetUser.UserLeavePolicyId && x.LeaveTypeId == leave.LeaveTypeId).Allowed;
                    leaveBalance.Taken = Allowed - leaveBalance.Balance;
                    /////////////
                    //old
                    leaveBalance.Taken          += leave.TotalDays;
                    leaveBalance.Balance        -= leave.TotalDays;
                    db.Entry(leaveBalance).State = EntityState.Modified;
                }
                ///////////////
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.LeaveTypeId = new SelectList(db.LeaveTypes, "Id", "Name", leave.LeaveTypeId);
            //ViewBag.UserLeavePolicyId = new SelectList(db.UserLeavePolicies, "Id", "UserId", leave.UserLeavePolicyId);
            return(View(leave));
        }
コード例 #23
0
        public object data()
        {
            LeaveBalance leavespend = new LeaveBalance();

            leavespend.Acl = 0;
            leavespend.Ael = 0;
            leavespend.Aml = 0;
            leavespend.Asl = 0;
            leavespend.Bel = 6;
            leavespend.Bcl = 10;
            leavespend.Bml = 5;
            leavespend.Bsl = 12;

            _context.LeaveBalance.Include(BCl => leavespend.Bcl - leavespend.Acl);
            _context.LeaveBalance.Include(BEl => leavespend.Bel - leavespend.Ael);
            _context.LeaveBalance.Include(BSl => leavespend.Bsl - leavespend.Aml);
            _context.LeaveBalance.Include(BMl => leavespend.Bml - leavespend.Asl);
            return(_context);
        }
コード例 #24
0
        public ActionResult LeaveApproval(int?ap, int?rp)
        {
            var ApprovalList = db.LeaveApplications.Where(a => a.StatusID == 3).ToList();

            if (ap != null)
            {
                var AppRec = db.LeaveApplications.Find(ap);
                AppRec.StatusID        = 1;
                AppRec.StatusDate      = DateTime.Now;
                AppRec.StatusBy        = User.Identity.GetUserId();
                db.Entry(AppRec).State = EntityState.Modified;

                var LeavBal = db.LeaveBalances.Where(a => a.UserID == AppRec.UserID && a.LeaveTypeID == AppRec.LeaveTypeID && a.LeaveYear == AppRec.LeaveStartDate.Value.Year).FirstOrDefault();
                if (LeavBal == null)
                {
                    var item = new LeaveBalance
                    {
                        LeaveDays   = AppRec.NoOfDays,
                        LeaveTypeID = (int)AppRec.LeaveTypeID,
                        LeaveYear   = AppRec.ApplicationDate.Value.Year,
                        UserID      = AppRec.UserID,
                    };
                    db.LeaveBalances.Add(item);
                }
                else
                {
                    LeavBal.LeaveDays += AppRec.NoOfDays;
                }
            }
            if (rp != null)
            {
                var AppRec = db.LeaveApplications.Find(rp);
                AppRec.StatusID        = 2;
                AppRec.StatusDate      = DateTime.Now;
                AppRec.StatusBy        = User.Identity.GetUserId();
                db.Entry(AppRec).State = EntityState.Modified;
            }

            db.SaveChanges();

            return(View(ApprovalList));
        }
コード例 #25
0
        public ActionResult ImportUserLeaves(HttpPostedFileBase file, string button)
        {
            if (button == "Save")
            {
                List <LeaveBalanceViewModel> model = new List <LeaveBalanceViewModel>();
                if (file != null)
                {
                    model = ReadCSV(file);
                }

                foreach (var balanceVM in model)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        if (balanceVM.UserId != string.Empty)
                        {
                            LeaveBalance balance = timesheetDb.LeaveBalances.Find(balanceVM.UserId, (_leaveType)i);
                            if (balance == null)
                            {
                                balance = new LeaveBalance
                                {
                                    UserID              = balanceVM.UserId,
                                    UserName            = balanceVM.UserName,
                                    LeaveType           = (_leaveType)i,
                                    AvailableLeaveHours = balanceVM.Balances[i]
                                };
                                timesheetDb.LeaveBalances.Add(balance);
                            }
                            else
                            {
                                balance.AvailableLeaveHours      = balanceVM.Balances[i];
                                timesheetDb.Entry(balance).State = EntityState.Modified;
                            }
                        }
                    }
                    timesheetDb.SaveChanges();
                }
            }
            return(RedirectToAction("Index"));
        }
コード例 #26
0
        public static List <LeaveBalance> SpLeaveBalanceListToLeaveBalanceList(List <sp_LeaveApplicationEmployeeBalance_Result> Record, int Empcode, int YearId)
        {
            List <LeaveBalance> Result = new List <LeaveBalance>();

            foreach (var item in Record)
            {
                LeaveBalance single = new LeaveBalance
                {
                    LeaveTypeId         = Convert.ToInt32(item.LeaveTypeId),
                    LeaveTypeName       = item.LeaveTypeName,
                    Leave_Balance       = Convert.ToDecimal(item.BalanceDays),
                    LeaveTypeAssignment = item.LeaveTypeAssignment,
                    TotalTaken          = Convert.ToDecimal(item.TotalTaken),
                    TotalLeaveAssigned  = Convert.ToDecimal(item.TotalLeaveDays),
                    EmpCode             = Empcode,
                    LeaveYearId         = YearId,
                    PrevYearBalance     = Convert.ToDecimal(item.PrevYearBalance),
                    ThisYearEarned      = Convert.ToDecimal(item.ThisYearEarned)
                };
                Result.Add(single);
            }
            return(Result);
        }
コード例 #27
0
        public async Task <IActionResult> LeaveBalance(string reportYear)
        {
            var          claims    = HttpContext.User.Claims;
            string       _userName = claims.Single(x => x.Type == ClaimTypes.Name).Value;
            LeaveBalance model     = new LeaveBalance
            {
                user = new User
                {
                    userName = _userName
                },
                reportYear = reportYear
            };

            var _obj = await dal.ShowLeaveBalance(model);

            string[] OkStatusList = { "000" };
            if (!OkStatusList.Contains(_obj.status))
            {
                return(BadRequest(_obj));
            }
            //Debug.WriteLine(JsonConvert.SerializeObject(_obj.leaveTypes));
            return(Ok(_obj));
        }
コード例 #28
0
    private void BindGrid(int Month)
    {
        String ApplierId = Session["UserName"] as String;
        List<LeaveBalance> l = new List<LeaveBalance>();

        LeaveType[] lts = LeaveType.GetAll();
        foreach (LeaveType lt in lts)
        {
            LeaveBalance lb = new LeaveBalance();

            float LeaveCountUptoSelectedMonth = 0;
            for (int i = 1; i < Month; i++)
                LeaveCountUptoSelectedMonth += Leave.LeaveCount(ApplierId, i, lt.Id);

            float SelectedMonthLeaveCount = Leave.LeaveCount(ApplierId, Month, lt.Id);

            lb.LeaveType = lt.Name;
            //if (LeaveCountUptoSelectedMonth + SelectedMonthLeaveCount <= lt.MaxLeavesYear)
            //{
            if (SelectedMonthLeaveCount <= lt.MaxLeavesMonth)
            {
                lb.Applied = SelectedMonthLeaveCount;
                lb.Remaining = lt.MaxLeavesMonth - SelectedMonthLeaveCount;
                lb.LossOfPay = 0;
            }
            else
            {
                lb.Applied = lt.MaxLeavesMonth;
                lb.Remaining = 0;
                lb.LossOfPay = SelectedMonthLeaveCount - lt.MaxLeavesMonth;
            }
            l.Add(lb);
            //    }
        }
        GridView1.DataSource = l;
        GridView1.DataBind();
    }
コード例 #29
0
        public async Task <LeaveBalance> ShowLeaveBalance(LeaveBalance model)
        {
            LeaveBalance _obj = new LeaveBalance();

            _obj.user       = model.user;
            _obj.reportYear = model.reportYear;
            List <LeaveType> list = new List <LeaveType>();

            using (SqlConnection con = SqlCon())
            {
                SqlCommand cmd = SqlCmd(con);
                cmd.CommandText = "ShowLeaveBalance";
                cmd.Parameters.AddWithValue("@userName", model.user.userName);
                cmd.Parameters.AddWithValue("@reportYear", model.reportYear);


                SqlParameter prm1 = new SqlParameter
                {
                    ParameterName = "@status",
                    SqlDbType     = SqlDbType.NVarChar,
                    Size          = 50,
                    Direction     = ParameterDirection.Output
                };
                cmd.Parameters.Add(prm1);

                DataTable      dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                try
                {
                    con.Open();
                    da.Fill(dt);
                    foreach (DataRow dr in dt.Rows)
                    {
                        LeaveType leave = new LeaveType();
                        leave.leaveCode = (dr[nameof(leave.leaveCode)] as string) ?? String.Empty;
                        leave.limit     = dr[nameof(leave.limit)] == DBNull.Value? default(int?) : Convert.ToInt32(dr[nameof(leave.limit)]);
                        leave.used      = dr[nameof(leave.used)] == DBNull.Value ? default(int?) : Convert.ToInt32(dr[nameof(leave.used)]);
                        leave.pending   = dr[nameof(leave.pending)] == DBNull.Value ? default(int?) : Convert.ToInt32(dr[nameof(leave.pending)]);
                        leave.balance   = dr[nameof(leave.balance)] == DBNull.Value ? default(int?) : Convert.ToInt32(dr[nameof(leave.balance)]);
                        list.Add(leave);
                    }
                    _obj.status     = (string)prm1.Value;
                    _obj.leaveTypes = list;
                }
                catch (SqlException ex)
                {
                    _obj.status  = ex.Number.ToString();
                    _obj.message = ex.Message;
                }
                finally
                {
                    dt.Dispose();
                    da.Dispose();
                    if (con.State == System.Data.ConnectionState.Open)
                    {
                        con.Close();
                    }
                    cmd.Dispose();
                }
            }
            return(_obj);
        }
コード例 #30
0
        protected override void Seed(ApplicationDbContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.
            var ratan = context.Employees.FirstOrDefault(p => p.MobileNo.Equals("01771998817"));

            if (ratan == null)
            {
                ratan = new Employee
                {
                    FullName    = "Ratan Sunder Parai",
                    MobileNo    = "01771998817",
                    Address     = "Dhaka, Bangladesh",
                    Email       = "*****@*****.**",
                    Designation = "Software Engineer"
                };

                context.Employees.Add(ratan);
                context.SaveChanges();
            }

            var ratanLeaves = context.LeaveBalances.FirstOrDefault(p => p.Id.Equals(ratan.Id));

            if (ratanLeaves == null)
            {
                ratanLeaves = new LeaveBalance
                {
                    EmployeeId         = ratan.Id,
                    TotalAnnualLeave   = 20,
                    TotalCasualLeave   = 10,
                    TotalSickLeave     = 14,
                    AvailedAnnualLeave = 10,
                    AvailedCasualLeave = 5,
                    AvailedSickLeave   = 6
                };
                context.LeaveBalances.Add(ratanLeaves);
                context.SaveChanges();
            }

            var mahedee = context.Employees.FirstOrDefault(p => p.MobileNo.Equals("01787139383"));

            if (mahedee == null)
            {
                mahedee = new Employee
                {
                    FullName    = "Md. Mahedee Hasan",
                    MobileNo    = "01787139383",
                    Address     = "Dhaka",
                    Designation = "Senior Software Architect"
                };
                context.Employees.Add(mahedee);
                context.SaveChanges();
            }

            var mahedeeLeaves = context.LeaveBalances.FirstOrDefault(p => p.Id == mahedee.Id);

            if (mahedeeLeaves == null)
            {
                mahedeeLeaves = new LeaveBalance
                {
                    EmployeeId         = mahedee.Id,
                    TotalAnnualLeave   = 30,
                    TotalCasualLeave   = 20,
                    TotalSickLeave     = 14,
                    AvailedAnnualLeave = 22,
                    AvailedCasualLeave = 8,
                    AvailedSickLeave   = 12
                };
                context.LeaveBalances.Add(mahedeeLeaves);
                context.SaveChanges();
            }
        }
コード例 #31
0
        public string LeaveAproval(LeaveAvailable leave)
        {
            string         comId          = session.GetString("ComId");
            LeaveAvailable leaveAvailable = new LeaveAvailable();
            LeaveBalance   leaveBalance   = db.LeaveBalance.FirstOrDefault(l => l.ComId == comId && l.EmpId == leave.EmpId);

            if (leaveBalance != null)
            {
                LeaveAvailable lAvail = new LeaveAvailable();
                int            count  = 0;
                switch (leave.LeaveType)
                {
                case "CL":
                    count = Convert.ToInt32(leaveBalance.Bcl);
                    if (count >= leave.LeaveApprove)
                    {
                        leaveBalance.Acl += leave.LeaveApprove;
                        leaveBalance.Bcl -= leave.LeaveApprove;
                        db.Update(leaveBalance);
                        lAvail = SetData(leave);
                        db.LeaveAvailable.Add(lAvail);
                        db.SaveChanges();
                        message = "Leave entry succeed";
                    }
                    else
                    {
                        message = "The employee has leave available" + count + "Day";
                    }
                    break;

                case "SL":
                    count = Convert.ToInt32(leaveBalance.Bsl);
                    if (count >= leave.LeaveApprove)
                    {
                        leaveBalance.Asl += leave.LeaveApprove;
                        leaveBalance.Bsl -= leave.LeaveApprove;
                        lAvail            = SetData(leave);
                        db.LeaveAvailable.Add(lAvail);
                        db.SaveChanges();
                        message = "Leave entry succeed";
                    }
                    else
                    {
                        message = "The employee has leave available" + count + "Day";
                    }
                    break;

                case "EL":
                    count = Convert.ToInt32(leaveBalance.Bel);
                    if (count >= leave.LeaveApprove)
                    {
                        leaveBalance.Ael += leave.LeaveApprove;
                        leaveBalance.Bel -= leave.LeaveApprove;
                        lAvail            = SetData(leave);
                        db.LeaveAvailable.Add(lAvail);
                        db.SaveChanges();
                        message = "Leave entry succeed";
                    }
                    else
                    {
                        message = "The employee has leave available" + count + "Day";
                    }
                    break;

                case "ML":
                    count = Convert.ToInt32(leaveBalance.Bml);
                    if (count >= leave.LeaveApprove)
                    {
                        leaveBalance.Aml += leave.LeaveApprove;
                        leaveBalance.Bml -= leave.LeaveApprove;
                        lAvail            = SetData(leave);
                        db.LeaveAvailable.Add(lAvail);
                        db.SaveChanges();
                        message = "Leave entry succeed";
                    }
                    else
                    {
                        message = "The employee has leave available" + count + "Day";
                    }
                    break;

                default:
                    message = "Leave type is not valid";
                    break;
                }
                //db.LeaveAvailable.Add(lAvail);
                //db.SaveChanges();
            }
            else
            {
                message = "No leave balnce of this employee";
            }

            return(message);
        }