ASP.NET MVC JS发送JSON格式参数,后台获取

 var queryJson = {
            keyword: $("#txt_keyword").val(),
            starttime: $("#txt_starttime").val(),
            endtime: $("#txt_endtime").val()
        }
        $gridList.jqGrid('setGridParam', {
            postData: {
                keyword: JSON.stringify(queryJson)
            }
        }).trigger('reloadGrid');
var expression = ExtLinq.True();
            var queryParam = queryJson.ToJObject();
            if (!queryParam["keyword"].IsEmpty())
            {
                string keyword = queryParam["keyword"].ToString();
                //keyWord可能为设备型号/设备名称/生产厂商/销售人员名称
                string semId = salesEquipmentModelApp.SearchModelIdBySearchkey(keyword);
                //设备型号/设备名称/生产厂商为空
                List salesRecordList = new List();
                if (string.IsNullOrEmpty(semId))
                {
                    salesRecordList = salesRecordApp.SearchSalesRecordBySalesMan(keyword);
                }
                if (!string.IsNullOrEmpty(keyword))
                {
                    if (!string.IsNullOrEmpty(semId))
                    {
                        expression = expression.And(t => t.SEM_ID.ToLower().Contains(semId.ToLower()));
                    }
                    if (salesRecordList.Count > 0)
                    {
                        foreach (var salesRecord in salesRecordList)
                        {
                            expression = expression.And(t => t.SR_ID.ToLower().Contains(salesRecord.SR_ID.ToLower()));
                        }
                    }
                }
            }
            if (!queryParam["starttime"].IsEmpty() && !queryParam["endtime"].IsEmpty())
            {
                DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();
                dtFormat.ShortDatePattern = "yyyy/MM/dd";
                DateTime starttime = Convert.ToDateTime(queryParam["starttime"], dtFormat);
                DateTime endtime = Convert.ToDateTime(queryParam["endtime"], dtFormat);
                expression = expression.And(t => t.SR_SALESDATE >= starttime && t.SR_SALESDATE <= endtime);
            }
            expression = expression.And(t => t.SRD_STATUS != -1);//已删除的不获取
            return service.FindList(expression, pagination);

你可能感兴趣的:(ASP.NET,MVC)