private bool CheckForLQuota(LvShort lvshort)
        {
            string EmpLvType = lvshort.EmpID + "A";

            List<LvConsumed> consumed = db.LvConsumeds.Where(aa => aa.EmpLvType == EmpLvType).ToList();
            if (consumed.Count() > 0)
                return true;
            else
                return false;
        }
示例#2
0
 public void AddShortLeaveToAttData(LvShort lvshort)
 {
     DateTime datetime = new DateTime();
     using (var db = new TAS2013Entities())
     {
         if (db.AttProcesses.Where(aa => aa.ProcessDate == datetime).Count() > 0)
         {
             AttData _EmpAttData = new AttData();
             _EmpAttData = db.AttDatas.First(aa => aa.EmpDate == lvshort.EmpDate);
             _EmpAttData.StatusAB = false;
             _EmpAttData.StatusSL = true;
             _EmpAttData.Remarks = _EmpAttData.Remarks + "[Short Leave]";
             db.SaveChanges();
         }
     }
 }
        private int AddCausalLeave(LvShort lvshort)
        {
            //find that bastard through the causal leave field in EmpLvType
            string EmpLvType= lvshort.EmpID+"A";
            //if there is some freak accident and now he has two or more records
            //cater for that by going through a list
            List<LvConsumed> consumed = db.LvConsumeds.Where(aa => aa.EmpLvType == EmpLvType).ToList();
            if (consumed.Count() > 0)
            {
                foreach (LvConsumed consume in consumed)
                {
                    consume.GrandTotalRemaining = consume.GrandTotalRemaining - 1;
                    consume.YearRemaining = consume.YearRemaining - 1;
                    LvConsumed refresh = new LvConsumed();
                    refresh = CheckMonthAndAddOneLeave(consume);
                    if (db.LvApplications.Where(aa => aa.LvDate == lvshort.DutyDate && aa.EmpID == lvshort.EmpID && aa.LvType == "A").Count() > 0)
                    {
                        return 1;

                    }
                    else
                    {
                        LvApplication lvapplication = new LvApplication();
                        lvapplication.EmpID = (int)lvshort.EmpID;
                        lvapplication.LvDate = (DateTime)lvshort.DutyDate;
                        lvapplication.LvType = "A";
                        lvapplication.FromDate = (DateTime)lvshort.DutyDate;
                        lvapplication.ToDate = (DateTime)lvshort.DutyDate;
                        lvapplication.NoOfDays = 1;
                        lvapplication.IsHalf = false;
                        lvapplication.HalfAbsent = false;
                        lvapplication.LvReason = lvshort.Remarks;
                        lvapplication.CreatedBy = lvshort.CreatedBy;
                        lvapplication.LvStatus = "P";
                        lvapplication.CompanyID = lvshort.CompanyID;
                        lvapplication.Active = true;
                        LeaveController LvProcessController = new LeaveController();
                        if (LvProcessController.HasLeaveQuota(lvapplication.EmpID, lvapplication.LvType))
                        {
                            if (lvapplication.IsHalf != true)
                            {

                                if (LvProcessController.CheckDuplicateLeave(lvapplication))
                                {
                                    //Check leave Balance
                                    if (LvProcessController.CheckLeaveBalance(lvapplication))
                                    {
                                        lvapplication.LvDate = DateTime.Today;
                                        int _userID = Convert.ToInt32(Session["LogedUserID"].ToString());
                                        lvapplication.CreatedBy = _userID;
                                db.LvApplications.Add(lvapplication);
                                        if (db.SaveChanges() > 0)
                                        {
                                            HelperClass.MyHelper.SaveAuditLog(_userID, (byte)MyEnums.FormName.Leave, (byte)MyEnums.Operation.Add, DateTime.Now);
                                            LvProcessController.AddLeaveToLeaveData(lvapplication);
                                            LvProcessController.AddLeaveToLeaveAttData(lvapplication);
                                             return 2;
                                        }
                                        else
                                        {
                                            ModelState.AddModelError("Remarks", "There is an error while creating leave.");
                                        }

                                    }
                                    else
                                        ModelState.AddModelError("Remarks", "Leave Balance Exceeds, Please check the balance");
                                }
                                else
                                    ModelState.AddModelError("Remarks", "This Employee already has leave of this date ");
                            }
                      }
                        else
                            ModelState.AddModelError("Remarks", "Leave Quota does not exist");

                    }

                }
                return 2;
            }
            else
                return 3;
        }
示例#4
0
 public void AddShortLeaveToAttData(LvShort lvshort)
 {
     DateTime datetime = new DateTime();
     using (var db = new TAS2013Entities())
     {
         if (db.AttDatas.Where(aa => aa.EmpDate== lvshort.EmpDate).Count() > 0)
         {
             AttData _EmpAttData = new AttData();
             _EmpAttData = db.AttDatas.First(aa => aa.EmpDate == lvshort.EmpDate);
             _EmpAttData.StatusAB = false;
             _EmpAttData.StatusSL = true;
             _EmpAttData.ShifMin = (short)(_EmpAttData.ShifMin - lvshort.THour.Value.TotalMinutes);
             if (_EmpAttData.WorkMin !=null)
             {
                 if (_EmpAttData.WorkMin >0)
                 {
                     if ((_EmpAttData.WorkMin + lvshort.THour.Value.TotalMinutes) >=
                         ProcessSupportFunc.CalculateShiftMinutes(_EmpAttData.Emp.Shift, lvshort.DutyDate.Value.DayOfWeek))
                     {
                         _EmpAttData.StatusLI = false;
                         _EmpAttData.StatusEO = false;
                         _EmpAttData.Remarks= _EmpAttData.Remarks.Replace("[LI]", "");
                         _EmpAttData.Remarks = _EmpAttData.Remarks.Replace("[EO]", "");
                         _EmpAttData.LateIn = 0;
                         _EmpAttData.EarlyOut = 0;
                     }
                 }
             }
             _EmpAttData.Remarks = _EmpAttData.Remarks + "[Short Leave]";
             db.SaveChanges();
         }
     }
 }