Exemple #1
0
        //
        // GET: /DCRCalendar/

        public JsonResult GetCalendarDetails(string startDate, string endDate)
        {
            List <JsonResult> dcrJSON = new List <JsonResult>();

            _objcurrentInfo = new CurrentInfo();
            MasterController masterController        = new MasterController();
            DataSet          dsParentRegions         = new DataSet();
            string           companyCode             = _objcurrentInfo.GetCompanyCode();
            string           regionCode              = _objcurrentInfo.GetRegionCode();
            string           userCode                = _objcurrentInfo.GetUserCode();
            string           GreytipLeaveConfigValue = "";

            dsParentRegions = masterController.GetParentRegionsDataSet(regionCode);

            bool      payRollIntegratedStatus = _objcurrentInfo.GetPayRollIntegratedStatus();
            DataTable dtRegion = dsParentRegions.Tables[0];

            GreytipLeaveConfigValue = GetGreyTipPayRollShortNameConfigValue();;

            string parentRegions = string.Empty;

            for (int i = 0; i < dtRegion.Rows.Count; i++)
            {
                if (dtRegion.Rows[i]["Region_Code"].ToString() != regionCode)
                {
                    parentRegions += dtRegion.Rows[i]["Region_Code"] + "^";
                }
            }

            DataSet   dsMasterDetails = _objSPData.GetCalendarDetails(startDate, endDate, userCode, regionCode, parentRegions);
            DataTable dtHeaderDetails = dsMasterDetails.Tables[0];
            DataTable dtLockDetails   = dsMasterDetails.Tables[1];
            DataTable dtLockhelpInfo  = dsMasterDetails.Tables[2];
            DataTable dtTPInfo        = dsMasterDetails.Tables[3];
            DataTable dtActivityLock  = dsMasterDetails.Tables[4];
            DataTable dtWAData        = dsMasterDetails.Tables[5];
            DataTable dtSSData        = dsMasterDetails.Tables[6];

            List <DCRCalendarModel> lstDCRHeaderDetails = (from Master_Data in dtHeaderDetails.AsEnumerable()
                                                           select new DCRCalendarModel
            {
                year = Master_Data["Year"].ToString(),
                month = Master_Data["Month"].ToString(),
                day = Master_Data["Day"].ToString(),
                start = Master_Data["Month"].ToString() + "/" + Master_Data["Day"].ToString() + "/" + Master_Data["Year"].ToString(),
                title = Convert.ToInt32(Master_Data["Status"]) == -1 ?
                        "WA-" + masterController.GetFlagFullName(Master_Data["Flag"].ToString()) :
                        Convert.ToInt32(Master_Data["Status"]) == -2 ? "Off-" + masterController.GetFlagFullName(Master_Data["Flag"].ToString()) :
                        Master_Data["Flag"].ToString() == "L" ?
                        Master_Data["Source_Of_Entry"].ToString() == "PAY_WS" ?
                        masterController.GetFlagFullName(Master_Data["Flag"].ToString()) + " " + Enum.GetName(typeof(DCRStatus), Convert.ToInt32(Master_Data["Status"])) + " (" + GreytipLeaveConfigValue + ")"
                                                                            : masterController.GetFlagFullName(Master_Data["Flag"].ToString()) + " " + Enum.GetName(typeof(DCRStatus), Convert.ToInt32(Master_Data["Status"]))
                                                                    : masterController.GetFlagFullName(Master_Data["Flag"].ToString()) + " " + Enum.GetName(typeof(DCRStatus), Convert.ToInt32(Master_Data["Status"])),

                isTP = "",
                url = "#",
                className = "DCR" + "-" + Enum.GetName(typeof(DCRStatus), Convert.ToInt32(Master_Data["Status"])) + "-" + Master_Data["Flag"].ToString(),
                Activity_Count = Master_Data["Activity_Count"] == null ? "0" : Master_Data["Activity_Count"].ToString(),
                // DCR_Lock_Status = Master_Data["DCR_Lock_Status"].ToString(),
                Record_Status = Master_Data["Record_Status"] == null ? "0" : Master_Data["Record_Status"].ToString()
            }).ToList <DCRCalendarModel>();

            List <DCRLockModel> lstDCRLockDetails = (from Master_Data in dtLockDetails.AsEnumerable()
                                                     select new DCRLockModel
            {
                Locked_Date = Master_Data["Locked_Date"].ToString(),
                LockType = Master_Data["Lock_Type"].ToString(),
                TP_Define_Month = Master_Data["TP_Define_Month"].ToString(),
                TP_Define_Year = Master_Data["TP_Define_Year"].ToString(),
                TP_Approval_Month = Master_Data["TP_Approval_Month"].ToString(),
                TP_Approval_Year = Master_Data["TP_Approval_Year"].ToString(),
                Lock_Reason = Master_Data["Lock_Reason"].ToString(),
                Reason = Master_Data["Reason"].ToString(),
                DCR_Actual_Date = Master_Data["DCR_Actual_Date"].ToString()
            }).ToList <DCRLockModel>();

            List <DCRLockModel> lstDCRLockHelpInfo = (from Master_Data in dtLockhelpInfo.AsEnumerable()
                                                      select new DCRLockModel
            {
                // IsTPDefineNextMonth = Master_Data["IsTPDefineNextMonth"].ToString(),
                MissedDCRDate = Master_Data["MissedDCRDate"].ToString(),
                //IsRegionLock = Master_Data["RegionLock"].ToString(),
                HidoctorStartDate = Master_Data["JoinDate"].ToString(),
                Leave_Entry_Mode = Master_Data["Leave_Entry_Mode"].ToString(),
                // TP_Approval_Lock = Convert.ToInt32(Master_Data["TP_Approval_Lock"]),
                Is_WA_User = Master_Data["Is_WA_User"].ToString(),
                Is_WA_TABLET_USER = Convert.ToBoolean(Master_Data["Is_WA_TABLET_USER"]),
                WA_REGIS_DATE = Master_Data["WA_REGIS_DATE"].ToString()
            }).ToList <DCRLockModel>();


            dcrJSON.Add(Json(lstDCRLockDetails));
            dcrJSON.Add(Json(lstDCRLockHelpInfo));
            dcrJSON.Add(Json(lstDCRHeaderDetails));


            DataSet   dsLockLevaeDetails = _objSPData.GetLockLeaveDetails(startDate, endDate);
            DataTable dtLockLevaeDetails = dsLockLevaeDetails.Tables[0];
            List <DCRCalendarModel> lstDCRLockLeaveDetails = (from lock_leaveData in dtLockLevaeDetails.AsEnumerable()
                                                              select new DCRCalendarModel
            {
                year = lock_leaveData["Year"].ToString(),
                month = lock_leaveData["Month"].ToString(),
                day = lock_leaveData["Day"].ToString(),
                LeaveType = lock_leaveData["Leave_Type"].ToString(),
                start = lock_leaveData["Month"].ToString() + "/" + lock_leaveData["Day"].ToString() + "/" + lock_leaveData["Year"].ToString(),
                title = lock_leaveData["Flag"].ToString() + "-" + lock_leaveData["Status"].ToString(),
                DCR_Lock_Status = lock_leaveData["Status"].ToString(),
                isTP = "",
                url = "#",
                className = lock_leaveData["ClassName"].ToString(),
                Record_Status = lock_leaveData["Record_Status"].ToString(),
                Released_Date = lock_leaveData["Released_Date"].ToString()
            }).ToList <DCRCalendarModel>();

            dcrJSON.Add(Json(lstDCRLockLeaveDetails));


            DataSet   dsHolidays = masterController.GetHolidays(companyCode, startDate, endDate, parentRegions, regionCode);
            DataTable dtHoliday  = dsHolidays.Tables[0];
            List <DCRCalendarModel> lstDCRHolidayDetails = (from hoilday_data in dtHoliday.AsEnumerable()
                                                            select new DCRCalendarModel
            {
                year = hoilday_data["Year"].ToString(),
                month = hoilday_data["Month"].ToString(),
                day = hoilday_data["Day"].ToString(),
                start = hoilday_data["Month"].ToString() + "/" + hoilday_data["Day"].ToString() + "/" + hoilday_data["Year"].ToString(),
                title = hoilday_data["Flag"].ToString() + " " + hoilday_data["Status"].ToString(),
                isTP = "",
                url = "#",
                className = hoilday_data["ClassName"].ToString()
            }).ToList <DCRCalendarModel>();

            dcrJSON.Add(Json(lstDCRHolidayDetails));
            List <DCRCalendarModel> lstTPInfo = (from tp_data in dtTPInfo.AsEnumerable()
                                                 select new DCRCalendarModel
            {
                year = tp_data["Year"].ToString(),
                month = tp_data["Month"].ToString(),
                day = tp_data["Day"].ToString(),
                start = tp_data["Month"].ToString() + "/" + tp_data["Day"].ToString() + "/" + tp_data["Year"].ToString(),
                title = tp_data["Flag"].ToString() + "-" + tp_data["Status"].ToString(),
                isTP = "",
                url = "#",
                className = tp_data["Status"].ToString()
            }).ToList <DCRCalendarModel>();


            dcrJSON.Add(Json(lstTPInfo));

            List <DCRActivityLock> lstActivityLock = (from activity_lock_data in dtActivityLock.AsEnumerable()
                                                      select new DCRActivityLock
            {
                User_Code = activity_lock_data["User_Code"].ToString(),
                Lock_Status = activity_lock_data["Lock_Status"].ToString(),
                DCR_Actual_Date = activity_lock_data["DCR_Actual_Date"].ToString(),
                Flag = activity_lock_data["Activity_Flag"].ToString(),
                UnapproveReason = activity_lock_data["Unapproval_Reason"].ToString(),
            }).ToList <DCRActivityLock>();

            dcrJSON.Add(Json(lstActivityLock));

            List <DCRCalendarModel> lstWAData = (from wa_data in dtWAData.AsEnumerable()
                                                 select new DCRCalendarModel
            {
                year = wa_data["Year"].ToString(),
                month = wa_data["Month"].ToString(),
                day = wa_data["Day"].ToString(),
                start = wa_data["Month"].ToString() + "/" + wa_data["Day"].ToString() + "/" + wa_data["Year"].ToString(),
                title = Convert.ToInt32(wa_data["Status"]) == -1 ? "WA-" + masterController.GetFlagFullName(wa_data["Flag"].ToString())

                                                        : Convert.ToInt32(wa_data["Status"]) == -2 ? "Off-" + masterController.GetFlagFullName(wa_data["Flag"].ToString()) : masterController.GetFlagFullName(wa_data["Flag"].ToString()) + " " + Enum.GetName(typeof(DCRStatus), Convert.ToInt32(wa_data["Status"])),
                isTP = "",
                url = "#",
                className = wa_data["Status"].ToString()
            }).ToList <DCRCalendarModel>();

            dcrJSON.Add(Json(lstWAData));
            BLRegion objBLRegion = new BLRegion();
            List <WeekendDaysForARegion> lstWeekEnd = objBLRegion.GetWeekendDaysForARegion(companyCode, regionCode, startDate, endDate);

            dcrJSON.Add(Json(lstWeekEnd));

            if (dtSSData.Rows.Count > 0)
            {
                List <DCRLockModel> lstSSDCRLock = (from Master_Data in dtSSData.AsEnumerable()
                                                    select new DCRLockModel
                {
                    SS_Applied_Lock = Master_Data["Lock_Status"].ToString(),
                    Previous_Month_Year = Convert.ToDateTime(Master_Data["Previous_Month_Year"]).ToString("dd-MM-yyyy"),
                    SS_Id = Convert.ToInt32(Master_Data["SS_Id"])
                }).ToList <DCRLockModel>();


                dcrJSON.Add(Json(lstSSDCRLock));
            }

            return(Json(dcrJSON));
        }