同时单击完整日历中的下一个和上一个按钮如何获取月份和年份

时间:2018-12-28 12:13:59

标签: jquery asp.net-mvc-4

我想在特定月份的完整日历中添加数据。当我单击该时间的下一个按钮或上一个按钮时,我只想获取数据库并获取特定月份的值。如何做到这一点

JavaScript:

$(document).ready(function () {
    var date = '';// for getting the selected month
    var HdnWeek = $("#HdnWeek").val();
    var defaultview;
    if (HdnWeek == 1) {
        defaultview = 'agendaWeek';
    }
    else {
        defaultview = 'agendaDay';
    }
    $('#calendar').fullCalendar({
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay,listWeek'
        },
        businessHours:{
            dow:[0,1,2,3,4,5,6],
            start:'07:00',
            end:'21:00'
        },

       // defaultDate: '2018-03-12',
        navLinks: true, // can click day/week names to navigate views
        editable: false,
        eventLimit: true, // allow "more" link when too many events
        defaultView: defaultview,
        allDaySlot: false,
        selectable: true,
        slotMinutes: 10,
        slotEventoverlap: true,
        slotDuration: '00:10:00',
        events: ' /PatientCalender/CalendarSelect?date=' + date,

    });
});

MVC:

public ActionResult CalendarSelect([FromBody] ClsCalendarSelect objClsCalendarSelect)
    {
        try
        {
            HttpCookie reqCookies = Request.Cookies["userInfo"];
            List<ClsCalenderEvents> Events = new List<ClsCalenderEvents>();
            objClsCalendarSelect.slot_start_time = Request.QueryString["date"];
            string SlotStatus, PatientName,PatientID, ColorCode, url, ImageType = "";
            objClsCalendarSelect.doctor_id = reqCookies["DoctorId"].ToString();
            objresponseMessage = objHttpClient.PostAsJsonAsync(CommonFunction.objWebApiUrl + "CalendarSelect/CalendarSelect", objClsCalendarSelect).Result;
            var CalendarSelect = objresponseMessage.Content.ReadAsStringAsync().Result;


            if (objresponseMessage.IsSuccessStatusCode)
            {
                if (JsonConvert.DeserializeObject<List<ClsCalendarSelect>>(objresponseMessage.Content.ReadAsStringAsync().Result).Where(item => item.StringResult.ToUpper().Trim().Contains("ERROR")).Count() == 0)
                {

                    var responseData = objresponseMessage.Content.ReadAsStringAsync().Result;
                    var objData = JsonConvert.DeserializeObject<List<ClsCalendarSelect>>(responseData);
                    foreach (var objDoctorLogIn in objData)
                    {

                        ImageType = "image";
                        SlotStatus = objDoctorLogIn.doctor_appointment_slot_status;
                        PatientName = objDoctorLogIn.patient_first_name;
                        PatientID = objDoctorLogIn.patient_id;
                        if (SlotStatus == "1" || SlotStatus == "4")
                        {
                            ColorCode = "Green";
                        }
                        else
                        {
                            ColorCode = "";
                        }
                        if (PatientName !=null)
                        {
                            PatientName = objDoctorLogIn.patient_id + " | " + objDoctorLogIn.patient_first_name +" | "+objDoctorLogIn.patient_phone_number; 
                        }
                        else
                        {
                            PatientName = "";
                        }
                        DateTime Currentdates=Convert.ToDateTime(objDoctorLogIn.slot_start_time);
                        string DBDate = Currentdates.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);

                        DateTime dateTime = DateTime.UtcNow.Date;
                        string CurrentDate = dateTime.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                        if (DBDate == CurrentDate && SlotStatus == "1")
                        {
                            url = "/casestudy";
                        }
                        else
                        {
                            url = "/casestudy/CaseStudyView";
                        }

                        Events.Add(new ClsCalenderEvents { title = PatientName, start = objDoctorLogIn.slot_start_time, end = objDoctorLogIn.slot_end_time, color = ColorCode.ToString(), url = url + "?Patient_id=" + PatientID +"&slotdate="+objDoctorLogIn.slot_start_time, allDay = false });

                    }

                    var EventLst = Events.ToArray();
                    return Json(EventLst, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    return Json(new EmptyResult(), JsonRequestBehavior.AllowGet);
                }


            }

        }
        catch (Exception)
        {


        }

        return Json(new EmptyResult(), JsonRequestBehavior.AllowGet);
    }

0 个答案:

没有答案