static GridViewModel GetListDetailModel(int Query_Id, int UserId)
        {
            var viewModel = GridViewExtension.GetViewModel("gvDetail|" + Query_Id.ToString() + "|");

            if (viewModel == null)
            {
                viewModel = ReportQueryDetail__List_Model.CreateGridViewModel();
            }

            return(viewModel);
        }
 static void DetailProcessCustomBinding(int userId, ReportQuery_ParamModel param, GridViewModel viewModel)
 {
     viewModel.ProcessCustomBinding(
         new GridViewCustomBindingGetDataRowCountHandler(args =>
     {
         ReportQueryDetail__List_Model.GetDataRowCount(args, userId, param);
     }),
         new GridViewCustomBindingGetDataHandler(args =>
     {
         ReportQueryDetail__List_Model.GetData(args, userId, param);
     })
         );
 }
        public ActionResult ShowResultQuery([ModelBinder(typeof(DevExpressEditorsBinder))] List <CrystalReportParam> Params)
        {
            List <CrystalReportParam> crtParams = new List <CrystalReportParam>();


            int userId = (int)Session["userId"];

            int Query_Id = 0;

            if (Request["Query_Id"] == null)
            {
                Query_Id = 0;
            }
            else
            {
                Query_Id = int.Parse(Request["Query_Id"]);
            }


            //  Query_Id = 2;
            ViewBag.Query_Id = Query_Id;
            var param = GetParam(Query_Id);

            param.crtParams = Params;

            DataTable dataTable = ReportQueryDetail__List_Model.GetDataTable(userId, param);

            ViewBag.dataTable = dataTable;



            //---------------------------------
            var viewModel = GetListDetailModel(Query_Id, userId);

            DetailProcessCustomBinding(userId, param, viewModel);

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            String param1 = MvcHtmlString.Create(serializer.Serialize(Params)).ToString();

            ViewBag.Params = param1;


            ViewBag.RowCount = param.RowCount;

            return(PartialView(VIEW_LIST_DETAIL_PARTIAL, viewModel));
        }
        // Sorting
        public ActionResult ListDetailSorting(GridViewColumnState column, bool reset)
        {
            int userId   = (int)Session["userId"];
            var Query_Id = int.Parse(Request["Query_Id"]);
            var param    = GetParam(Query_Id);


            //-------------------------------------
            string cpParams = "";

            if (ViewBag.Params != null)
            {
                cpParams = ViewBag.Params;
            }
            else
            {
                cpParams = Request["Params"];
            }

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            List <CrystalReportParam> reportParams;

            reportParams    = serializer.Deserialize <List <CrystalReportParam> >(cpParams);
            param.crtParams = reportParams;
            //--------------------------------------


            DataTable dataTable = ReportQueryDetail__List_Model.GetDataTable(userId, param);

            ViewBag.dataTable = dataTable;


            var viewModel = GetListDetailModel(Query_Id, userId);

            viewModel.ApplySortingState(column, reset);
            DetailProcessCustomBinding(userId, param, viewModel);


            ViewBag.RowCount = param.RowCount;

            return(PartialView(VIEW_LIST_DETAIL_PARTIAL, viewModel));
        }
        public ActionResult ExportTo()
        {
            int userId = (int)Session["userId"];

            var hidden_CpGvFind_FilterExpression = Request["hidden_CpGvFind_FilterExpression"];
            var hidden_CpGvFind_SortExpression   = Request["hidden_CpGvFind_SortExpression"];
            var hidden_CpGvFind_PageIndex        = Request["hidden_CpGvFind_PageIndex"];
            var hidden_CpGvFind_PageSize         = Request["hidden_CpGvFind_PageSize"];


            int Query_Id = int.Parse(Request["Query_Id"]);



            var param = GetParam(Query_Id);

            //-------------------------------------
            string cpParams = "";


            cpParams = Request["Params"];


            JavaScriptSerializer serializer = new JavaScriptSerializer();

            List <CrystalReportParam> reportParams;

            reportParams    = serializer.Deserialize <List <CrystalReportParam> >(cpParams);
            param.crtParams = reportParams;
            //--------------------------------------


            IEnumerable items = ReportQueryDetail__List_Model.GetDataList(userId, param, hidden_CpGvFind_FilterExpression, hidden_CpGvFind_SortExpression, Convert.ToInt32(hidden_CpGvFind_PageIndex), Convert.ToInt32(hidden_CpGvFind_PageSize));

            return(GridViewExportHelper.ExportTypes["XLS"].Method(GridViewExportHelper.ExportGridViewSettings(userId, param), items));
        }
        public ActionResult ListDetailPartial()
        {
            int userId = (int)Session["userId"];

            int Query_Id = 0;

            if (Request["Query_Id"] == null)
            {
                Query_Id = 0;
            }
            else
            {
                Query_Id = int.Parse(Request["Query_Id"]);
            }


            //--------------------------------
            if (Query_Id == 0)
            {
                string DXCallbackName = "";

                if (Request["DXCallbackName"] != null)
                {
                    DXCallbackName = Request["DXCallbackName"];

                    if (DXCallbackName.StartsWith("gvDetail|"))
                    {
                        var arr = DXCallbackName.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                        if (arr.Length > 1)
                        {
                            Query_Id = int.Parse(arr[1]);
                        }
                    }
                }
            }

            //  Query_Id = 2;
            ViewBag.Query_Id = Query_Id;
            var param = GetParam(Query_Id);

            //-------------------------------------
            string cpParams = "";

            if (ViewBag.Params != null)
            {
                cpParams = ViewBag.Params;
            }
            else
            {
                cpParams = Request["Params"];
            }

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            List <CrystalReportParam> reportParams;

            reportParams    = serializer.Deserialize <List <CrystalReportParam> >(cpParams);
            param.crtParams = reportParams;
            //--------------------------------------


            DataTable dataTable = ReportQueryDetail__List_Model.GetDataTable(userId, param);

            ViewBag.dataTable = dataTable;



            //---------------------------------
            var viewModel = GetListDetailModel(Query_Id, userId);

            DetailProcessCustomBinding(userId, param, viewModel);


            ViewBag.RowCount = param.RowCount;

            return(PartialView(VIEW_LIST_DETAIL_PARTIAL, viewModel));
        }