public ActionResult _GetLastPermitDate(int alienid, string rdate, string pdate) { DateTime?result = null; try { DateTime requestDate = DateTime.ParseExact(rdate, Globals.DateFormat, CultureInfo.InvariantCulture); DateTime permitToDate = DateTime.ParseExact(pdate, Globals.DateFormat, CultureInfo.InvariantCulture); //หาข้อมูล PermitToDate จาก visa ล่าสุด var res = (from p in visaRepo.FindAll(null, null) where (p.RequestDate <= requestDate) && (p.AlienId == alienid) orderby p.RequestDate descending select p.PermitToDate).FirstOrDefault(); // result = res ?? permitToDate; result = res; } catch (FormatException) { } return(new JsonResult { Data = new { permittodate = result } }); }
// // GET: /Visa/ public ActionResult Index(int?dtpSelectRange, DateTime?dtpFromDate, DateTime?dtpToDate) { ToolbarMenuHelpers.SetToolBar(ViewData, new { //Save = "Save", //กรณีปุ่ม Save/GiveUp ให้ link ไปที่ id ของปุ่ม save จริง ๆ ของฟอร์ม New = "Insert", //GiveUp = "Delete", //Print = "Print", //Print1 = "Print", //Other = "Other", //Other1 = "Other", Date = "Index" }, "Visa", null, null, //new { Other1 = "อื่น ๆ ลองดู", }, ref dtpSelectRange, ref dtpFromDate, ref dtpToDate); return(View(visaRepo.FindAll(dtpFromDate, dtpToDate).ToList())); }