在控制器中实现daterangepicker

问题描述:

我已经在视图中添加了一个javascript代码

I already add a javascript code in view

<label>Time of generation:</label>
<input type="text" name="daterange" value=" " />
<script type="text/javascript">
$('input[name="daterange"]').daterangepicker();
</script>





,当我运行应用程序时看起来不错。现在我想为insert_timestamp添加搜索过滤器



私有IEnumerable< view_service> get_schedule_name(string sort_order,string searchString,string current_filter,Guid?Schedule_id)

{

Models.mbt_mainEntities db = new Models.mbt_mainEntities();







string sql = string.Format(@选择a.id作为Schedule_id,a.code,a.insert_timestamp, b.name

来自schedule.service a

左外连接schedule.calendar b

on a.calendar_id = b.id,Schedule_id );





IEnumerable< view_service> schedule_name = db.Database.SqlQuery< models.view_service>(sql).ToList();





//搜索字符串过滤器

if(current_filter == null || current_filter ==_)

current_filter =;



ViewBag.current_filter = current_filter;



//通过bus_name和driver_name在schedule_name中搜索字符串

if(!String.IsNullOrEmpty(current_filter) )

schedule_name = schedule_name.Where

(s => s.code.ToUpper()。包含(current_filter.ToUpper()));





//按代码,名称,insert_timestamp排序顺序



ViewBag.code = sort_order ==代码? code_desc:code;

ViewBag.name = sort_order ==name? name_desc:name;

ViewBag.insert_timestamp = sort_order ==insert_timestamp? insert_timestamp_desc:insert_timestamp;



ViewBag.current_sort = sort_order;





开关(sort_order)

{



我该如何实现?

>
我尝试了什么:



尝试添加相同的搜索字符串,alredy只存在于starDate end endDate但是我的东西我没有正确设置。



and looks ok when i run application. Now I want to add search filter for the "insert_timestamp"

private IEnumerable<view_service> get_schedule_name(string sort_order, string searchString, string current_filter, Guid? Schedule_id)
{
Models.mbt_mainEntities db = new Models.mbt_mainEntities();



string sql = string.Format(@"select a.id as Schedule_id, a.code, a.insert_timestamp, b.name
from schedule.service a
left outer join schedule.calendar b
on a.calendar_id = b.id", Schedule_id);


IEnumerable<view_service> schedule_name = db.Database.SqlQuery<models.view_service>(sql).ToList();


// searching string filter
if (current_filter == null || current_filter == "_")
current_filter = "";

ViewBag.current_filter = current_filter;

// search string in schedule_name by bus_name and driver_name
if (!String.IsNullOrEmpty(current_filter))
schedule_name = schedule_name.Where
(s => s.code.ToUpper().Contains(current_filter.ToUpper()));


//sorting order by code, name, insert_timestamp

ViewBag.code = sort_order == "code" ? "code_desc" : "code";
ViewBag.name = sort_order == "name" ? "name_desc" : "name";
ViewBag.insert_timestamp = sort_order == "insert_timestamp" ? "insert_timestamp_desc" : "insert_timestamp";

ViewBag.current_sort = sort_order;


switch (sort_order)
{

How can I implement that?

What I have tried:

Tried to add same search string that alredy exists only with starDate end endDate but I thing I didn't set it right.

('input [name =daterange]')。daterangepicker();
< / script>
('input[name="daterange"]').daterangepicker(); </script>





,当我运行应用程序时看起来不错。现在我想为insert_timestamp添加搜索过滤器



私有IEnumerable< view_service> get_schedule_name(string sort_order,string searchString,string current_filter,Guid?Schedule_id)

{

Models.mbt_mainEntities db = new Models.mbt_mainEntities();







string sql = string.Format(@选择a.id作为Schedule_id,a.code,a.insert_timestamp, b.name

来自schedule.service a

左外连接schedule.calendar b

on a.calendar_id = b.id,Schedule_id );





IEnumerable< view_service> schedule_name = db.Database.SqlQuery< models.view_service>(sql).ToList();





//搜索字符串过滤器

if(current_filter == null || current_filter ==_)

current_filter =;



ViewBag.current_filter = current_filter;



//通过bus_name和driver_name在schedule_name中搜索字符串

if(!String.IsNullOrEmpty(current_filter) )

schedule_name = schedule_name.Where

(s => s.code.ToUpper()。包含(current_filter.ToUpper()));





//按代码,名称,insert_timestamp排序顺序



ViewBag.code = sort_order ==代码? code_desc:code;

ViewBag.name = sort_order ==name? name_desc:name;

ViewBag.insert_timestamp = sort_order ==insert_timestamp? insert_timestamp_desc:insert_timestamp;



ViewBag.current_sort = sort_order;





开关(sort_order)

{



我该如何实现?

>
我尝试了什么:



尝试添加相同的搜索字符串,alredy只存在于starDate end endDate但是我的东西我没有把它设置正确。



and looks ok when i run application. Now I want to add search filter for the "insert_timestamp"

private IEnumerable<view_service> get_schedule_name(string sort_order, string searchString, string current_filter, Guid? Schedule_id)
{
Models.mbt_mainEntities db = new Models.mbt_mainEntities();



string sql = string.Format(@"select a.id as Schedule_id, a.code, a.insert_timestamp, b.name
from schedule.service a
left outer join schedule.calendar b
on a.calendar_id = b.id", Schedule_id);


IEnumerable<view_service> schedule_name = db.Database.SqlQuery<models.view_service>(sql).ToList();


// searching string filter
if (current_filter == null || current_filter == "_")
current_filter = "";

ViewBag.current_filter = current_filter;

// search string in schedule_name by bus_name and driver_name
if (!String.IsNullOrEmpty(current_filter))
schedule_name = schedule_name.Where
(s => s.code.ToUpper().Contains(current_filter.ToUpper()));


//sorting order by code, name, insert_timestamp

ViewBag.code = sort_order == "code" ? "code_desc" : "code";
ViewBag.name = sort_order == "name" ? "name_desc" : "name";
ViewBag.insert_timestamp = sort_order == "insert_timestamp" ? "insert_timestamp_desc" : "insert_timestamp";

ViewBag.current_sort = sort_order;


switch (sort_order)
{

How can I implement that?

What I have tried:

Tried to add same search string that alredy exists only with starDate end endDate but I thing I didn't set it right.