Esempio n. 1
0
        public bool CheckLeaveBalance(LvApplication _lvapp)
        {
            bool    balance = false;
            decimal RemainingLeaves;

            using (var ctx = new TAS2013Entities())
            {
                List <LvType> lvTypes = new List <LvType>();
                lvTypes = ctx.LvTypes.Where(aa => aa.LvType1 == _lvapp.LvType).ToList();
                if (lvTypes.First().UpdateBalance == true)
                {
                    List <LvConsumed> _lvConsumed = new List <LvConsumed>();
                    string            empLvType   = _lvapp.EmpID.ToString() + _lvapp.LvType;
                    _lvConsumed     = ctx.LvConsumeds.Where(aa => aa.EmpLvType == empLvType).ToList();
                    RemainingLeaves = (decimal)_lvConsumed.FirstOrDefault().YearRemaining;
                    if ((RemainingLeaves - Convert.ToDecimal(_lvapp.NoOfDays)) >= 0)
                    {
                        balance = true;
                    }
                    else
                    {
                        balance = false;
                    }
                }
                else
                {
                    balance = true;
                }
            }

            return(balance);
        }
Esempio n. 2
0
        internal bool CheckForMaxMonthDays(LvApplication lvapplication, LvType lvType)
        {
            bool check = false;

            if (lvapplication.FromDate.Month == lvapplication.ToDate.Month)
            {
                DateTime dts = new DateTime(lvapplication.FromDate.Year, lvapplication.FromDate.Month, 1);
                DateTime dte = new DateTime(lvapplication.FromDate.Year, lvapplication.FromDate.Month, lvapplication.ToDate.Day);
                float    TotalnumOfDayInMonth = 0;
                using (var ctx = new TAS2013Entities())
                {
                    List <LvApplication> lvapps = new List <LvApplication>();
                    lvapps = ctx.LvApplications.Where(aa => aa.FromDate >= dts && aa.ToDate <= dte && aa.EmpID == lvapplication.EmpID).ToList();
                    foreach (var lv in lvapps)
                    {
                        TotalnumOfDayInMonth = TotalnumOfDayInMonth + lv.NoOfDays;
                    }
                }
                if (lvType.MaxDaysMonth == 0)
                {
                    check = true;
                }
                else if (TotalnumOfDayInMonth <= lvType.MaxDaysMonth)
                {
                    check = true;
                }
            }
            else
            {
                check = true;
            }
            return(check);
        }
Esempio n. 3
0
        //Process Contractuals Monthly Attendance
        private void ProcessMonthly(DateTime startDate, DateTime endDate)
        {
            TAS2013Entities ctx = new TAS2013Entities();
            // Pass list of selected emp Attendance data to optimize sql query
            List <AttData> _AttData    = new List <AttData>();
            List <AttData> _EmpAttData = new List <AttData>();

            _AttData = ctx.AttDatas.Where(aa => aa.AttDate >= startDate && aa.AttDate <= endDate).ToList();
            int        count = 0;
            List <Emp> _Emp  = ctx.Emps.Where(em => em.Status == true).ToList();
            List <Emp> _oEmp = ctx.Emps.Where(em => em.Status == true).ToList();

            _Emp.AddRange(_oEmp);
            int _TE = _Emp.Count;

            foreach (Emp emp in _Emp)
            {
                count++;
                try
                {
                    ContractualMonthlyProcessor cmp = new ContractualMonthlyProcessor();
                    _EmpAttData = _AttData.Where(aa => aa.EmpID == emp.EmpID).ToList();
                    if (!cmp.processContractualMonthlyAttSingle(startDate, endDate, emp, _EmpAttData))
                    {
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Esempio n. 4
0
 public void BalanceLeaves(LvApplication lvappl, LvType LeaveType)
 {
     if (LeaveType.UpdateBalance == true)
     {
         using (var ctx = new TAS2013Entities())
         {
             List <LvConsumed> _lvConsumed = new List <LvConsumed>();
             string            empLvType   = lvappl.EmpID.ToString() + lvappl.LeaveTypeID + lvappl.FromDate.Year.ToString("0000");
             _lvConsumed = ctx.LvConsumeds.Where(aa => aa.EmpLvTypeYear == empLvType).ToList();
             float _NoOfDays = lvappl.NoOfDays;
             if (_lvConsumed.Count > 0)
             {
                 _lvConsumed.FirstOrDefault().YearRemaining       = (float)(_lvConsumed.FirstOrDefault().YearRemaining - _NoOfDays);
                 _lvConsumed.FirstOrDefault().GrandTotalRemaining = (float)(_lvConsumed.FirstOrDefault().GrandTotalRemaining - _NoOfDays);
                 if (lvappl.IsHalf == true)
                 {
                     AddHalfLeaveBalancceMonthQuota(_lvConsumed, lvappl);
                 }
                 else
                 {
                     AddBalancceMonthQuota(_lvConsumed, lvappl);
                 }
                 ctx.SaveChanges();
             }
             ctx.Dispose();
         }
     }
 }
Esempio n. 5
0
        public bool CheckHalfLeaveBalance(LvApplication lvapplication, LvType lvType)
        {
            bool              check = false;
            float             RemainingLeaves;
            List <LvConsumed> _lvConsumed = new List <LvConsumed>();

            if (lvType.UpdateBalance == true)
            {
                using (var ctx = new TAS2013Entities())
                {
                    string empLvType = lvapplication.EmpID.ToString() + lvapplication.LeaveTypeID + lvapplication.FromDate.Year.ToString("0000");
                    _lvConsumed = ctx.LvConsumeds.Where(aa => aa.EmpLvTypeYear == empLvType).ToList();
                    if (_lvConsumed.Count > 0)
                    {
                        RemainingLeaves = (float)_lvConsumed.FirstOrDefault().YearRemaining;
                        if ((RemainingLeaves - (float)lvapplication.NoOfDays) >= 0)
                        {
                            check = true;
                        }
                        else
                        {
                            check = false;
                        }
                    }
                }
            }
            else
            {
                check = true;
            }
            return(check);
        }
Esempio n. 6
0
 public int UploadImageInDataBase(HttpPostedFileBase file, string _empNo)
 {
     using (var context = new TAS2013Entities())
     {
         List <EmpPhoto> _empPhotoList = new List <EmpPhoto>();
         EmpPhoto        _EmpPhoto     = new EmpPhoto();
         Emp             _Emp          = new Emp();
         int             empPhotoID    = 0;
         _Emp             = context.Emps.First(aa => aa.EmpNo == _empNo);
         _empPhotoList    = context.EmpPhotoes.Where(aa => aa.EmpID == _Emp.EmpID).ToList();
         _EmpPhoto.EmpPic = ConvertToBytes(file);
         if (_empPhotoList.Count > 0)
         {
             //Update Existing Image
             _EmpPhoto.EmpID   = _empPhotoList.FirstOrDefault().EmpID;
             _EmpPhoto.PhotoID = _empPhotoList.FirstOrDefault().PhotoID;
         }
         else
         {
             //Add New Image
             _EmpPhoto.EmpID = _Emp.EmpID;
             context.EmpPhotoes.Add(_EmpPhoto);
         }
         try
         {
             empPhotoID = _EmpPhoto.PhotoID;
             context.SaveChanges();
             return(empPhotoID);
         }
         catch (Exception ex)
         {
             return(empPhotoID);
         }
     }
 }
Esempio n. 7
0
 public void SaveManualRequest(int empid, DateTime dts, DateTime dte)
 {
     try
     {
         if ((DateTime.Today.Day >= 1 && DateTime.Today.Day <= 4) || (DateTime.Today.Day > 25))
         {
             using (var db = new TAS2013Entities())
             {
                 int          DaysInPreviousMonth = System.DateTime.DaysInMonth(dts.Year, dts.Month);
                 DateTime     dt  = new DateTime(dts.Year, dts.Month, DaysInPreviousMonth);
                 AttProSystem aps = new AttProSystem();
                 aps.EmpID       = empid;
                 aps.StartDate   = dts;
                 aps.EndDate     = dt;
                 aps.CreatedDate = DateTime.Now;
                 aps.Status      = false;
                 db.AttProSystems.Add(aps);
                 db.SaveChanges();
                 db.Dispose();
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 8
0
        internal string MakeCustomizeQueryForEmp(User LoggedInUser)
        {
            string query = " where Deleted='0' ";

            if (LoggedInUser.UserType == "Admin")
            {
            }
            else
            {
                TAS2013Entities    ctx          = new TAS2013Entities();
                List <UserSection> userlocation = new List <UserSection>();
                List <UserSection> userSections = new List <UserSection>();
                userlocation = ctx.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID && aa.LocationOrSection == "Location").ToList();
                if (userlocation.Count == 1)
                {
                    query = query + " and (LocID = " + userlocation.FirstOrDefault().LocationID + ")";
                }
                else
                {
                    List <string> _CriteriaForSection = new List <string>();
                    string        queryloc            = " ";
                    foreach (var usec in userlocation)
                    {
                        _CriteriaForSection.Add(" LocID = " + usec.LocationID + " ");
                    }
                    for (int i = 0; i < _CriteriaForSection.Count - 1; i++)
                    {
                        queryloc = queryloc + _CriteriaForSection[i] + " or ";
                    }
                    queryloc = queryloc + _CriteriaForSection[_CriteriaForSection.Count - 1];
                    queryloc = query + "and ( " + queryloc + " )";
                }
            }
            return(query);
        }
Esempio n. 9
0
        internal string QueryForSectionRptFilters(User LoggedInUser)
        {
            string query = " ";

            if (LoggedInUser.UserType == "Admin")
            {
            }
            else
            {
                TAS2013Entities    ctx         = new TAS2013Entities();
                List <UserSection> userSection = new List <UserSection>();
                userSection = ctx.UserSections.Where(aa => aa.UserID == LoggedInUser.UserID).ToList();
                if (userSection.Count == 1)
                {
                    query = query + " where SectionID = " + userSection.FirstOrDefault().SecID;
                }
                else
                {
                    List <string> _CriteriaForSection = new List <string>();
                    string        querySec            = "";
                    foreach (var usec in userSection)
                    {
                        _CriteriaForSection.Add(" SectionID = " + usec.SecID + " ");
                    }
                    for (int i = 0; i < _CriteriaForSection.Count - 1; i++)
                    {
                        querySec = querySec + _CriteriaForSection[i] + " or ";
                    }
                    querySec = querySec + _CriteriaForSection[_CriteriaForSection.Count - 1];
                    query    = query + "where " + querySec + " ";
                }
            }
            return(query);
        }
Esempio n. 10
0
        private void RandomGenerator(DateTime date)
        {
            TAS2013Entities ctx  = new TAS2013Entities();
            List <Emp>      emps = new List <Emp>();

            emps = ctx.Emps.Where(aa => aa.CrewID == 1 && aa.Status == true).ToList();
            DateTime ds = new DateTime(2015, 08, 09);
            DateTime de = new DateTime(2015, 08, 13);

            while (ds <= de)
            {
                foreach (var emp in emps)
                {
                    AttData attdata = new AttData();
                    if (ctx.AttDatas.Where(aa => aa.AttDate == ds && aa.EmpID == emp.EmpID).Count() > 0)
                    {
                        attdata = ctx.AttDatas.First(aa => aa.AttDate == ds && aa.EmpID == emp.EmpID);
                        if (attdata != null)
                        {
                            ctx.AttDatas.DeleteObject(attdata);
                        }
                        List <PollData> polls = new List <PollData>();
                        polls = ctx.PollDatas.Where(aa => aa.EmpID == emp.EmpID && aa.EntDate >= ds && aa.EntDate <= de).ToList();
                        foreach (var poll in polls)
                        {
                            poll.Process = false;
                            ctx.SaveChanges();
                        }
                        ctx.SaveChanges();
                    }
                }
                ds = ds.AddDays(1);
            }
        }
Esempio n. 11
0
        //private void AdjustDOJUnit()
        //{
        //    using (var ctx = new TAS2013Entities())
        //    {
        //        List<DOJJ> dates = new List<DOJJ>();
        //        List<Emp> emps = new List<Emp>();
        //        emps = ctx.Emps.Where(aa => aa.CompanyID == 13).ToList();
        //        dates = ctx.DOJJs.ToList();
        //        foreach (var emp in emps)
        //        {
        //            if (dates.Where(aa => aa.EmpNo == emp.EmpNo).Count() > 0)
        //            {
        //                emp.JoinDate = dates.First(aa => aa.EmpNo == emp.EmpNo).DateOfJoin;
        //            }
        //        }
        //        ctx.SaveChanges();
        //    }
        //}

        private void CalculateEmpWithWrongSection()
        {
            try
            {
                TAS2013Entities ctx     = new TAS2013Entities();
                List <Emp>      emps    = new List <Emp>();
                List <Section>  secs    = new List <Section>();
                int             count   = 0;
                List <Emp>      temEmps = new List <Emp>();
                emps = ctx.Emps.ToList();
                secs = ctx.Sections.ToList();
                foreach (var emp in emps)
                {
                    if (secs.Where(aa => aa.SectionID == emp.SecID).Count() == 0)
                    {
                        count++;
                        //short sss = secs.Where(aa => aa.SectionName == "To Be Fixed" && aa.CompanyID == emp.CompanyID).First().SectionID;
                        //emp.SecID = sss;
                        temEmps.Add(emp);
                        //ctx.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 12
0
        // GET: /Editor/
        public ActionResult Index()
        {
            TAS2013Entities db = new TAS2013Entities();

            if (Session["EditAttendanceDate"] == null)
            {
                ViewData["datef"] = DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd");
            }
            else
            {
                ViewData["datef"] = Session["EditAttendanceDate"].ToString();
            }
            User LoggedInUser = Session["LoggedUser"] as User;

            ViewData["JobDateFrom"] = DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd");
            ViewData["JobDateTo"]   = DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd");
            ViewBag.JobCardType     = new SelectList(db.JobCards, "WorkCardID", "WorkCardName");
            ViewBag.ShiftList       = new SelectList(db.Shifts, "ShiftID", "ShiftName");

            // string _EmpNo = Request.Form["EmpNo"].ToString();
            ViewBag.CompanyID        = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID);
            ViewBag.CompanyIDJobCard = new SelectList(CustomFunction.GetCompanies(db.Companies.ToList(), LoggedInUser), "CompID", "CompName", LoggedInUser.CompanyID);
            ViewBag.CrewList         = new SelectList(db.Crews, "CrewID", "CrewName");
            ViewBag.SectionList      = new SelectList(db.Sections, "SectionID", "SectionName");
            ViewBag.DesignationID    = new SelectList(db.Designations.Where(aa => aa.CompanyID == LoggedInUser.CompanyID), "DesignationID", "DesignationName");
            ViewBag.Message          = "";
            return(View());
        }
Esempio n. 13
0
        public bool HasLeaveQuota(int empID, string lvType)
        {
            bool check = false;

            using (var ctx = new TAS2013Entities())
            {
                List <LvConsumed> lv      = new List <LvConsumed>();
                List <LvType>     lvTypes = new List <LvType>();
                lvTypes = ctx.LvTypes.Where(aa => aa.LvType1 == lvType).ToList();
                if (lvTypes.Count > 0)
                {
                    if (lvTypes.First().UpdateBalance == true)
                    {
                        lv = ctx.LvConsumeds.Where(aa => aa.EmpID == empID && aa.LeaveType == lvType).ToList();
                        if (lv.Count > 0)
                        {
                            check = true;
                        }
                    }
                    else
                    {
                        check = true;
                    }
                }
            }
            return(check);
        }
Esempio n. 14
0
 public bool AddLeaveToLeaveAttData(LvApplication lvappl)
 {
     try
     {
         DateTime datetime = new DateTime();
         datetime = lvappl.FromDate;
         for (int i = 0; i < lvappl.NoOfDays; i++)
         {
             string _EmpDate = lvappl.EmpID + datetime.Date.ToString("yyMMdd");
             using (var context = new TAS2013Entities())
             {
                 if (context.AttProcesses.Where(aa => aa.ProcessDate == datetime).Count() > 0)
                 {
                     AttData _EmpAttData = new AttData();
                     _EmpAttData             = context.AttDatas.First(aa => aa.EmpDate == _EmpDate);
                     _EmpAttData.TimeIn      = null;
                     _EmpAttData.TimeOut     = null;
                     _EmpAttData.WorkMin     = null;
                     _EmpAttData.LateIn      = null;
                     _EmpAttData.LateOut     = null;
                     _EmpAttData.EarlyIn     = null;
                     _EmpAttData.EarlyOut    = null;
                     _EmpAttData.StatusAB    = false;
                     _EmpAttData.StatusLeave = true;
                     _EmpAttData.StatusEI    = null;
                     _EmpAttData.StatusEO    = null;
                     _EmpAttData.StatusLI    = null;
                     _EmpAttData.StatusLI    = null;
                     _EmpAttData.StatusLO    = null;
                     _EmpAttData.StatusDO    = null;
                     _EmpAttData.StatusGZ    = null;
                     _EmpAttData.StatusGZOT  = null;
                     _EmpAttData.StatusMN    = null;
                     _EmpAttData.StatusOD    = null;
                     if (lvappl.LvType == "A")//Casual Leave
                     {
                         _EmpAttData.Remarks = "[CL]";
                     }
                     if (lvappl.LvType == "B")//Anual Leave
                     {
                         _EmpAttData.Remarks = "[AL]";
                     }
                     if (lvappl.LvType == "C")//Sick Leave
                     {
                         _EmpAttData.Remarks = "[SL]";
                     }
                     _EmpAttData.StatusAB    = false;
                     _EmpAttData.StatusLeave = true;
                     context.SaveChanges();
                 }
             }
             datetime = datetime.AddDays(1);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
     return(true);
 }
        public ActionResult GetBestCriteria(string CriteriaValue)
        {
            List <DailySummary> BestCriteria = new List <DailySummary>();

            using (TAS2013Entities dc = new TAS2013Entities())
            {
                DateTime To                = (DateTime)dc.DailySummaries.Max(x => x.Date);
                DateTime From              = To.AddDays(-20);
                var      GetSummaries      = dc.DailySummaries.Where(aa => aa.Criteria == CriteriaValue && (aa.Date >= From && aa.Date <= To)).ToList();
                var      DistinctCriterias = GetSummaries.Select(aa => new { aa.CriteriaValue }).Distinct().ToList();
                foreach (var distinctcriteria in DistinctCriterias)
                {
                    DailySummary gatherinfo = new DailySummary();

                    List <DailySummary> intermediate = GetSummaries.Where(aa => aa.CriteriaValue == distinctcriteria.CriteriaValue).ToList();
                    gatherinfo = InitializeDailySummaryValues(intermediate);

                    foreach (DailySummary inter in intermediate)
                    {
                        gatherinfo = AddValues(gatherinfo, inter);
                    }
                    BestCriteria.Add(gatherinfo);
                }
            }
            Console.Write(CriteriaValue);
            return(Json(BestCriteria, JsonRequestBehavior.AllowGet));
        }
Esempio n. 16
0
        private bool AddBadliAttData(string _empDate, int _empID, DateTime _Date, int _userID, JobCardApp jcApp)
        {
            bool check = false;

            try
            {
                //Normal Duty
                using (var context = new TAS2013Entities())
                {
                    AttData _attdata = context.AttDatas.FirstOrDefault(aa => aa.EmpDate == _empDate);
                    JobCard _jcCard  = context.JobCards.FirstOrDefault(aa => aa.WorkCardID == jcApp.CardType);
                    if (_attdata != null)
                    {
                        _attdata.DutyCode    = "D";
                        _attdata.StatusAB    = false;
                        _attdata.StatusLeave = false;
                        _attdata.StatusP     = true;
                        _attdata.Remarks     = _attdata.Remarks + "[Badli][Manual]";
                        _attdata.StatusMN    = true;
                    }
                    context.SaveChanges();
                    if (context.SaveChanges() > 0)
                    {
                        check = true;
                    }
                    context.Dispose();
                }
            }
            catch (Exception ex)
            {
            }
            return(check);
        }
Esempio n. 17
0
        internal string QueryForLocationTableSegerationForLinq(User LoggedInUser)
        {
            TAS2013Entities     db                = new TAS2013Entities();
            List <UserLocation> ulocs             = new List <UserLocation>();
            List <string>       _CriteriaForOrLoc = new List <string>();

            ulocs = db.UserLocations.Where(aa => aa.UserID == LoggedInUser.UserID).ToList();
            String query = "";

            foreach (var uloc in ulocs)
            {
                _CriteriaForOrLoc.Add(" LocID = " + uloc.LocationID + " ");
            }
            for (int i = 0; i < _CriteriaForOrLoc.Count - 1; i++)
            {
                query = query + _CriteriaForOrLoc[i] + " or ";
            }
            if (_CriteriaForOrLoc.Count != 0)
            {
                query = query + _CriteriaForOrLoc[_CriteriaForOrLoc.Count - 1];
            }
            else
            {
                query = "LocID > 0";
            }
            return(query);
        }
Esempio n. 18
0
        public string QueryForUserAccess(User _User, string view)
        {
            string role  = "";
            string query = "";

            using (var context = new TAS2013Entities())
            {
                role = context.UserRoles.Where(aa => aa.RoleID == _User.RoleID).FirstOrDefault().RoleName;
            }


            switch (view)
            {
            case "Region":  query = UserAcccessGetRegion(_User, role);
                return(query);

            case "Zone": query = UserAcccessGetZone(_User, role);
                return(query);

            case "Location": query = UserAcccessGetLocation(_User, role);
                return(query);

            case "City": query = UserAccessGetCity(_User, role);
                return(query);

            case "SuperUser": query = "CompanyID >0";
                return(query);
            }
            return(query);
        }
Esempio n. 19
0
        public bool AddLeaveToLeaveData(LvApplication lvappl)
        {
            DateTime datetime = new DateTime();

            datetime = lvappl.FromDate;
            for (int i = 0; i < lvappl.NoOfDays; i++)
            {
                string _EmpDate = lvappl.EmpID + datetime.Date.ToString("yyMMdd");
                LvData _LVData  = new LvData();
                _LVData.EmpID     = lvappl.EmpID;
                _LVData.EmpDate   = _EmpDate;
                _LVData.Remarks   = lvappl.LvReason;
                _LVData.LvID      = lvappl.LvID;
                _LVData.AttDate   = datetime.Date;
                _LVData.LvCode    = lvappl.LvType;
                _LVData.CompanyID = lvappl.CompanyID;
                try
                {
                    using (var context = new TAS2013Entities())
                    {
                        context.LvDatas.Add(_LVData);
                        context.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                }
                datetime = datetime.AddDays(1);
                // Balance Leaves from Emp Table
            }
            BalanceLeaves(lvappl);
            return(true);
        }
Esempio n. 20
0
        private string UserAccessGetCity(User _User, string role)
        {
            string            query = "";
            TAS2013Entities   ctx   = new TAS2013Entities();
            List <UserAccess> uAcc  = new List <UserAccess>();

            uAcc = ctx.UserAccesses.Where(aa => aa.UserID == _User.UserID).ToList();
            switch (role)
            {
            case "Region":
                foreach (var uaccess in uAcc)
                {
                    Region      region = ctx.Regions.Where(aa => aa.RegionID == uaccess.CriteriaData).FirstOrDefault();
                    List <City> cities = ctx.Cities.Where(aa => aa.CityID == region.RegionID).ToList();

                    foreach (var city in cities)
                    {
                        query = query + "CityID=" + city.CityID + " or ";
                    }
                }
                query = query.Substring(0, query.Length - 4);
                return(query);

            case "City": foreach (var uaccess in uAcc)
                {
                    query = query + "CityID=" + uaccess.CriteriaData + " or ";
                }
                query = query.Substring(0, query.Length - 4);
                return(query);

            case "Zone": foreach (var uaccess in uAcc)
                {
                    Zone          zone   = ctx.Zones.Where(aa => aa.ZoneID == uaccess.CriteriaData).FirstOrDefault();
                    List <Region> region = ctx.Regions.Where(aa => aa.ZoneID == zone.ZoneID).ToList();
                    foreach (var re in region)
                    {
                        List <City> cities = ctx.Cities.Where(aa => aa.RegionID == re.RegionID).ToList();
                        foreach (var city in cities)
                        {
                            query = query + "CityID=" + city.CityID + " or ";
                        }
                    }
                }
                query = query.Substring(0, query.Length - 4);
                return(query);

            case "Location": foreach (var uaccess in uAcc)
                {
                    Location loc  = ctx.Locations.Where(aa => aa.LocID == uaccess.CriteriaData).FirstOrDefault();
                    City     city = ctx.Cities.Where(aa => aa.CityID == loc.CityID).FirstOrDefault();
                    query = query + "CityID=" + city.CityID + " or ";
                }
                query = query.Substring(0, query.Length - 4);
                return(query);

            case "SuperUser": query = "CityID>0";
                return(query);
            }
            return(query);
        }
Esempio n. 21
0
        //Check Duplication of Leave for a date
        public bool CheckDuplicateLeave(LvApplication lvappl)
        {
            List <LvApplication> _Lv      = new List <LvApplication>();
            DateTime             _DTime   = new DateTime();
            DateTime             _DTimeLV = new DateTime();

            using (var context = new TAS2013Entities())
            {
                _Lv = context.LvApplications.Where(aa => aa.EmpID == lvappl.EmpID).ToList();
                foreach (var item in _Lv)
                {
                    _DTime   = item.FromDate;
                    _DTimeLV = lvappl.FromDate;
                    while (_DTime <= item.ToDate)
                    {
                        while (_DTimeLV <= lvappl.ToDate)
                        {
                            if (_DTime == _DTimeLV)
                            {
                                return(false);
                            }
                            _DTimeLV = _DTimeLV.AddDays(1);
                        }
                        _DTime = _DTime.AddDays(1);
                    }
                }
            }
            return(true);
        }
Esempio n. 22
0
        public string CheckForUserRole(User user)
        {
            string val = "";

            using (var ctx = new TAS2013Entities())
            {
                string criteria = ctx.UserAccesses.Where(aa => aa.UserID == user.UserID).FirstOrDefault().Criteria;
                switch (criteria.Trim())
                {
                case "Z":
                    val = "Zone";
                    break;

                case "R":
                    val = "Region";
                    break;

                case "C":
                    val = "City";
                    break;

                case "L":
                    val = "Location";
                    break;

                case "S":
                    val = "SuperUser";
                    break;
                }
                ctx.Dispose();
            }
            return(val);
        }
Esempio n. 23
0
        //public void BalanceLeaves(LvApplication lvappl)
        //{
        //    _empQuota.Clear();
        //    using (var context = new TAS2013Entities())
        //    {
        //        _empQuota = context.LvQuotas.Where(aa => aa.EmpID == lvappl.EmpID).ToList();
        //        float _NoOfDays = lvappl.NoOfDays;
        //        if (_empQuota.Count > 0)
        //        {
        //            switch (lvappl.LvType)
        //            {
        //                case "A":
        //                    _empQuota.FirstOrDefault().A = (float)(_empQuota.FirstOrDefault().A - _NoOfDays);
        //                    break;
        //                case "B":
        //                    _empQuota.FirstOrDefault().B = (float)(_empQuota.FirstOrDefault().B - _NoOfDays);
        //                    break;
        //                case "C":
        //                    _empQuota.FirstOrDefault().C = (float)(_empQuota.FirstOrDefault().C - _NoOfDays);
        //                    break;
        //                case "D":
        //                    _empQuota.FirstOrDefault().D = (float)(_empQuota.FirstOrDefault().D - _NoOfDays);
        //                    break;
        //                case "E":
        //                    _empQuota.FirstOrDefault().E = (float)(_empQuota.FirstOrDefault().E - _NoOfDays);
        //                    break;
        //                case "F":
        //                    _empQuota.FirstOrDefault().F = (float)(_empQuota.FirstOrDefault().F - _NoOfDays);
        //                    break;
        //                case "G":
        //                    _empQuota.FirstOrDefault().G = (float)(_empQuota.FirstOrDefault().G - _NoOfDays);
        //                    break;
        //                case "H":
        //                    _empQuota.FirstOrDefault().H = (float)(_empQuota.FirstOrDefault().H - _NoOfDays);
        //                    break;
        //                case "I":
        //                    _empQuota.FirstOrDefault().I = (float)(_empQuota.FirstOrDefault().I - _NoOfDays);
        //                    break;
        //                case "J":
        //                    _empQuota.FirstOrDefault().J = (float)(_empQuota.FirstOrDefault().J - _NoOfDays);
        //                    break;
        //                case "K":
        //                    _empQuota.FirstOrDefault().K = (float)(_empQuota.FirstOrDefault().K - _NoOfDays);
        //                    break;
        //                case "L":
        //                    _empQuota.FirstOrDefault().L = (float)(_empQuota.FirstOrDefault().L - _NoOfDays);
        //                    break;
        //                default:
        //                    break;
        //            }
        //            context.SaveChanges();
        //        }
        //    }
        //}

        #endregion

        #region -- Add Half Leave--

        public void AddHalfLeaveToLeaveData(LvApplication lvappl, LvType lvType)
        {
            DateTime datetime = new DateTime();

            datetime = lvappl.FromDate;
            string _EmpDate = lvappl.EmpID + datetime.Date.ToString("yyMMdd");
            LvData _LVData  = new LvData();

            _LVData.EmpID     = lvappl.EmpID;
            _LVData.EmpDate   = _EmpDate;
            _LVData.Remarks   = lvappl.LvReason;
            _LVData.HalfLeave = true;
            _LVData.LvID      = lvappl.LvID;
            _LVData.AttDate   = datetime.Date;
            _LVData.LvCode    = lvappl.LeaveTypeID;
            _LVData.FirstHalf = lvappl.FirstHalf;
            try
            {
                using (var db = new TAS2013Entities())
                {
                    db.LvDatas.Add(_LVData);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }
            // Balance Leaves from Emp Table
            BalanceLeaves(lvappl, lvType);
        }
Esempio n. 24
0
        private void UpdateEmpLocation(Emp emp, Emp OldEmp)
        {
            TAS2013Entities db = new TAS2013Entities();

            if (emp.Islamabad != OldEmp.Islamabad)
            {
                UpdateEmpLocationChild(emp, (int)db.Locations.First(aa => aa.LocName == "Islamabad").LocID, (bool)emp.Islamabad);
            }
            if (emp.Quetta != OldEmp.Quetta)
            {
                UpdateEmpLocationChild(emp, (int)db.Locations.First(aa => aa.LocName == "Quetta").LocID, (bool)emp.Quetta);
            }
            if (emp.Lahore != OldEmp.Lahore)
            {
                UpdateEmpLocationChild(emp, (int)db.Locations.First(aa => aa.LocName == "Lahore").LocID, (bool)emp.Lahore);
            }
            if (emp.Peshawar != OldEmp.Peshawar)
            {
                UpdateEmpLocationChild(emp, (int)db.Locations.First(aa => aa.LocName == "Peshawar").LocID, (bool)emp.Peshawar);
            }
            if (emp.Karachi != OldEmp.Karachi)
            {
                UpdateEmpLocationChild(emp, (int)db.Locations.First(aa => aa.LocName == "Karachi").LocID, (bool)emp.Karachi);
            }
        }
Esempio n. 25
0
        //public bool CheckHalfLeaveBalance(LvApplication lvapplication)
        //{
        //    _empQuota.Clear();
        //    int _EmpID;
        //    float RemainingLeaves;
        //    _EmpID = lvapplication.EmpID;
        //    using (var context = new TAS2013Entities())
        //    {
        //        _empQuota = context.LvQuotas.Where(aa => aa.EmpID == _EmpID).ToList();
        //        if (_empQuota.Count > 0)
        //        {
        //            switch (lvapplication.LvType)
        //            {
        //                case "A":
        //                    RemainingLeaves = (float)_empQuota.FirstOrDefault().A;
        //                    break;
        //                case "B":
        //                    RemainingLeaves = (float)_empQuota.FirstOrDefault().B;
        //                    break;
        //                case "C":
        //                    RemainingLeaves = (float)_empQuota.FirstOrDefault().C;
        //                    break;
        //                case "D":
        //                    RemainingLeaves = (float)_empQuota.FirstOrDefault().D;
        //                    break;
        //                case "E":
        //                    RemainingLeaves = (float)_empQuota.FirstOrDefault().E;
        //                    break;
        //                case "F":
        //                    RemainingLeaves = (float)_empQuota.FirstOrDefault().F;
        //                    break;
        //                case "G":
        //                    RemainingLeaves = (float)_empQuota.FirstOrDefault().G;
        //                    break;
        //                case "H":
        //                    RemainingLeaves = (float)_empQuota.FirstOrDefault().H;
        //                    break;
        //                case "I":
        //                    RemainingLeaves = (float)_empQuota.FirstOrDefault().I;
        //                    break;
        //                case "J":
        //                    RemainingLeaves = (float)_empQuota.FirstOrDefault().J;
        //                    break;
        //                case "K":
        //                    RemainingLeaves = (float)_empQuota.FirstOrDefault().K;
        //                    break;
        //                default:
        //                    RemainingLeaves = 1;
        //                    break;
        //            }
        //            if ((RemainingLeaves - (float)lvapplication.NoOfDays) >= 0)
        //            {
        //                return true;
        //            }
        //            else
        //                return false;
        //        }
        //        else
        //            return false;

        //    }
        //}

        #endregion

        #region -- Delete Leaves --
        public void DeleteFromLVData(LvApplication lvappl)
        {
            int      _EmpID = lvappl.EmpID;
            DateTime Date   = lvappl.FromDate;

            while (Date <= lvappl.ToDate)
            {
                using (var context = new TAS2013Entities())
                {
                    string EmpDate = _EmpID.ToString() + Date.ToString("yyMMdd");
                    if (context.LvDatas.Where(aa => aa.EmpDate == EmpDate).Count() > 0)
                    {
                        var _id = context.LvDatas.Where(aa => aa.EmpID == _EmpID && aa.AttDate == Date.Date).FirstOrDefault().EmpDate;
                        if (_id != null)
                        {
                            LvData lvvdata = context.LvDatas.Find(_id);
                            //lvvdata.Active = false;
                            context.LvDatas.Remove(lvvdata);
                            context.SaveChanges();
                        }
                    }
                }
                Date = Date.AddDays(1);
            }
        }
Esempio n. 26
0
        internal float CalculateNoOfDays(LvApplication lvapplication, LvType lvType)
        {
            TAS2013Entities db  = new TAS2013Entities();
            float           val = 0;

            if (lvapplication.IsHalf == true)
            {
                val = (float)0.5;
            }
            else
            {
                if (lvType.CountRestDays != true)
                {
                    Shift    ss  = db.Emps.Where(aa => aa.EmpID == lvapplication.EmpID).First().Shift;
                    DateTime dts = lvapplication.FromDate;
                    while (dts <= lvapplication.ToDate)
                    {
                        if (!CurrentDayNotRest(ss, dts))
                        {
                            val = val + 1;
                        }
                        dts = dts.AddDays(1);
                    }
                }
            }
            return(val);
        }
Esempio n. 27
0
        private void AdjustPollData()
        {
            int      currentYear = DateTime.Today.Date.Year;
            int      StartYear   = currentYear - 3;
            DateTime endDate     = DateTime.Today.AddDays(2);
            DateTime startDate   = new DateTime(StartYear, 1, 1);

            using (var ctx = new TAS2013Entities())
            {
                List <PollData> polls = ctx.PollDatas.Where(aa => aa.EntDate <= startDate && aa.Process == false).ToList();
                foreach (var item in polls)
                {
                    item.Process = true;
                }
                ctx.SaveChanges();
                polls.Clear();
                polls = ctx.PollDatas.Where(aa => aa.EntDate >= endDate && aa.Process == false).ToList();
                foreach (var item in polls)
                {
                    item.Process = true;
                }
                ctx.SaveChanges();
                ctx.Dispose();
            }
        }
Esempio n. 28
0
        public ActionResult Create()
        {
            var _wings = new List <Division>();

            using (TAS2013Entities context = new TAS2013Entities())
            {
                _wings = context.Divisions.ToList();
            }
            ViewBag.CompanyID = new SelectList(db.Companies.OrderBy(aa => aa.CompName), "CompID", "CompName");
            ViewBag.CrewID    = new SelectList(db.Crews.OrderBy(aa => aa.CrewName), "CrewID", "CrewName");
            ViewBag.DesigID   = new SelectList(db.Designations.OrderBy(aa => aa.DesignationName), "DesignationID", "DesignationName");
            ViewBag.GradeID   = new SelectList(db.Grades.OrderBy(aa => aa.GradeName), "GradeID", "GradeName");
            ViewBag.JobID     = new SelectList(db.JobTitles.OrderBy(aa => aa.JobTitle1), "JobID", "JobTitle1");
            //ViewBag.LocID = new SelectList(db.Locations, "LocID", "LocName");
            ViewBag.SecID      = new SelectList(db.Sections.OrderBy(aa => aa.SectionName), "SectionID", "SectionName");
            ViewBag.ShiftID    = new SelectList(db.Shifts.OrderBy(aa => aa.ShiftName), "ShiftID", "ShiftName");
            ViewBag.TypeID     = new SelectList(db.EmpTypes.OrderBy(aa => aa.TypeName), "TypeID", "TypeName");
            ViewBag.EmpID      = new SelectList(db.EmpFaces, "EmpID", "Face1");
            ViewBag.EmpID      = new SelectList(db.EmpFps.OrderBy(aa => aa.Fp1), "EmpID", "Fp1");
            ViewBag.CatID      = new SelectList(db.Categories.OrderBy(aa => aa.CatName), "CatID", "CatName");
            ViewBag.DeptID     = new SelectList(db.Departments.OrderBy(aa => aa.DeptName), "DeptID", "DeptName");
            ViewBag.CityID     = new SelectList(db.Cities.OrderBy(aa => aa.CityName), "CityID", "CityName");
            ViewBag.ZoneID     = new SelectList(db.Zones.OrderBy(aa => aa.ZoneName), "ZoneID", "ZoneName");
            ViewBag.RegionID   = new SelectList(db.Regions.OrderBy(aa => aa.RegionName), "RegionID", "RegionName");
            ViewBag.PostedAsID = new SelectList(db.Designations.OrderBy(aa => aa.DesignationName), "DesignationID", "DesignationName");
            return(View());
        }
Esempio n. 29
0
        private bool AddLateInMarginAttData(string _empDate, int _empID, DateTime _Date, int _userID, short _WorkCardID, short _CompID)
        {
            bool check = false;

            try
            {
                //Late In Job Card
                short LateInMins = 0;
                using (var context = new TAS2013Entities())
                {
                    AttData _attdata = context.AttDatas.FirstOrDefault(aa => aa.EmpDate == _empDate);
                    if (_attdata != null)
                    {
                        _attdata.StatusAB = false;
                        _attdata.Remarks.Replace("[LI]", "");
                        _attdata.Remarks  = _attdata.Remarks + "[LI Job Card]";
                        _attdata.LateIn   = 0;
                        _attdata.WorkMin  = (short)(_attdata.WorkMin + (short)LateInMins);
                        _attdata.StatusLI = false;
                    }
                    context.SaveChanges();
                    if (context.SaveChanges() > 0)
                    {
                        check = true;
                    }
                    context.Dispose();
                }
            }
            catch (Exception ex)
            {
            }
            return(check);
        }
Esempio n. 30
0
        private void ProcessMonthlyPermanent(DateTime _startDate, DateTime _endDate)
        {
            TAS2013Entities context = new TAS2013Entities();
            // Pass list of selected emp Attendance data to optimize sql query
            List <AttData> _AttData    = new List <AttData>();
            List <AttData> _EmpAttData = new List <AttData>();

            _AttData = context.AttDatas.Where(aa => aa.AttDate >= _startDate && aa.AttDate <= _endDate).ToList();
            int count = 0;
            //multi company
            //  List<Emp> _Emp = context.Emps.Where(em => (em.EmpType.CatID !=3) && em.CompanyID==1 && em.Status == true).ToList();
            // generic no company
            List <Emp> _Emp  = context.Emps.Where(em => (em.EmpType.CatID != 3) && em.Status == true).ToList();
            List <Emp> _Emps = context.Emps.Where(em => (em.LocID == 4 || em.LocID == 5) && em.Status == true).ToList();

            _Emp.AddRange(_Emps);
            int _TE = context.Emps.Where(em => (em.EmpType.CatID == 4 || em.EmpType.CatID == 2) && em.Status == true).Count();

            foreach (Emp emp in _Emp)
            {
                count++;
                try
                {
                    PermanetMonthlyProcess cmp = new PermanetMonthlyProcess();
                    _EmpAttData = _AttData.Where(aa => aa.EmpID == emp.EmpID).ToList();
                    if (!cmp.processPermanentMonthlyAttSingle(_startDate, _endDate, emp, _EmpAttData))
                    {
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }