コード例 #1
0
        public ActionResult ViewChart()
        {
            initEmpDDL();
            initDateDDL();
            string[] TimeRangeArr=new string[48];
            TimeSheetBusinessLayer timesheetbusinesslayer = new TimeSheetBusinessLayer();
            List<tsChartData> cdList = new List<tsChartData>();

            for (int i = 0; i <= 23; i++) {
                TimeRangeArr[i * 2] = i.ToString() + ":00~" + i.ToString() + ":30";
                TimeRangeArr[i * 2 + 1] = i.ToString() + ":30~"+(i+1).ToString() + ":00";
            }

            foreach (string TimeRangeItem in TimeRangeArr)
            {
                char[] delimiterChars = {':', '~' };
                string[] timeElmt = TimeRangeItem.Split(delimiterChars);
                int CourtInTime = timesheetbusinesslayer.CountInTime(null, false, System.DateTime.Now.Year, System.DateTime.Now.Month, Int32.Parse(timeElmt[0]), Int32.Parse(timeElmt[1]), Int32.Parse(timeElmt[2]), Int32.Parse(timeElmt[3]));
                //int CourtInTime = timesheetbusinesslayer.CountInTime(2015, 7, 11,0,11,30);

                int CourtOutTime = timesheetbusinesslayer.CountOutTime(null, false, System.DateTime.Now.Year, System.DateTime.Now.Month, Int32.Parse(timeElmt[0]), Int32.Parse(timeElmt[1]), Int32.Parse(timeElmt[2]), Int32.Parse(timeElmt[3]));
                tsChartData cdItem = new tsChartData { TimeRange = TimeRangeItem, IntimeCount = CourtInTime, OuttimeCount = CourtOutTime };
                cdList.Add(cdItem);
            }
            return View(cdList);
        }
コード例 #2
0
        public ActionResult ViewChart(String ddlAllEmployees, String ddlActiveEmployees, String ddlInactiveEmployees,
            String rdbEmployee, string ddlYear, string ddlMonth)
        {
            initEmpDDL();
            initDateDDL();

            Guid? GuidEmpID = new Guid();
            Boolean? del = new Boolean();
            switch (rdbEmployee)
            {
                case "All":
                    del = null;
                    if (ddlAllEmployees.Length > 0)
                        GuidEmpID = Guid.Parse(ddlAllEmployees);
                    else
                        GuidEmpID = null;
                    break;
                case "Active":
                    del = false;
                    if (ddlActiveEmployees.Length > 0)
                        GuidEmpID = Guid.Parse(ddlActiveEmployees);
                    else
                        GuidEmpID = null;
                    break;
                case "Inactive":
                    del = true;
                    if (ddlInactiveEmployees.Length > 0)
                        GuidEmpID = Guid.Parse(ddlInactiveEmployees);
                    else
                        GuidEmpID = null;
                    break;
            }

            string[] TimeRangeArr = new string[48];
            TimeSheetBusinessLayer timesheetbusinesslayer = new TimeSheetBusinessLayer();
            List<tsChartData> cdList = new List<tsChartData>();

            for (int i = 0; i <= 23; i++)
            {
                TimeRangeArr[i * 2] = i.ToString() + ":00~" + i.ToString() + ":30";
                TimeRangeArr[i * 2 + 1] = i.ToString() + ":30~" + (i + 1).ToString() + ":00";
            }

            int year = int.Parse(ddlYear);
            int? month;
            if (ddlMonth.Length > 0)
                month = int.Parse(ddlMonth);
            else
                month = null;

            foreach (string TimeRangeItem in TimeRangeArr)
            {
                char[] delimiterChars = { ':', '~' };
                string[] timeElmt = TimeRangeItem.Split(delimiterChars);
                int CourtInTime = timesheetbusinesslayer.CountInTime(GuidEmpID, del, year, month, Int32.Parse(timeElmt[0]), Int32.Parse(timeElmt[1]), Int32.Parse(timeElmt[2]), Int32.Parse(timeElmt[3]));
                int CourtOutTime = timesheetbusinesslayer.CountOutTime(GuidEmpID, del, year, month, Int32.Parse(timeElmt[0]), Int32.Parse(timeElmt[1]), Int32.Parse(timeElmt[2]), Int32.Parse(timeElmt[3]));
                tsChartData cdItem = new tsChartData { TimeRange = TimeRangeItem, IntimeCount = CourtInTime, OuttimeCount = CourtOutTime };
                cdList.Add(cdItem);
            }
            return View(cdList);
        }
コード例 #3
0
        public JsonResult makechartdata()
        {
            string[] TimeRangeArr = new string[48];
            TimeSheetBusinessLayer timesheetbusinesslayer = new TimeSheetBusinessLayer();
            List<tsChartData> cdList = new List<tsChartData>();

            for (int i = 0; i <= 23; i++)
            {
                TimeRangeArr[i * 2] = i.ToString() + ":00~" + i.ToString() + ":30";
                TimeRangeArr[i * 2 + 1] = i.ToString() + ":30~" + (i + 1).ToString() + ":00";
            }

            foreach (string TimeRangeItem in TimeRangeArr)
            {
                char[] delimiterChars = { ':', '~' };
                string[] timeElmt = TimeRangeItem.Split(delimiterChars);
                int CourtInTime = timesheetbusinesslayer.CountInTime(null, false, System.DateTime.Now.Year, System.DateTime.Now.Month, Int32.Parse(timeElmt[0]), Int32.Parse(timeElmt[1]), Int32.Parse(timeElmt[2]), Int32.Parse(timeElmt[3]));

                int CourtOutTime = timesheetbusinesslayer.CountOutTime(null, false, System.DateTime.Now.Year, System.DateTime.Now.Month, Int32.Parse(timeElmt[0]), Int32.Parse(timeElmt[1]), Int32.Parse(timeElmt[2]), Int32.Parse(timeElmt[3]));
                tsChartData cdItem = new tsChartData { TimeRange = TimeRangeItem, IntimeCount = CourtInTime, OuttimeCount = CourtOutTime };
                cdList.Add(cdItem);
            }
            JavaScriptSerializer js = new JavaScriptSerializer();
            string jsonStr = js.Serialize(cdList);
            //HttpContext.Response.Write(jsonStr);
            return Json(cdList,JsonRequestBehavior.AllowGet);
        }