public object Get(JObject req)
 {
     using (var db = new LUOLAI1401Context())
     {
         db.Database.Connection.Open();
         try {
             var cmd = db.Database.Connection.CreateCommand();
             cmd.CommandType = System.Data.CommandType.StoredProcedure;
             cmd.CommandText = "proc_SearchList";
             cmd.Parameters.Add(new SqlParameter("@tableName", "HR_SocialSecRecords"));
             cmd.Parameters.Add(new SqlParameter("@fieldNames", "HR_SocialSecRecords.FYear AS FYear,HR_SocialSecRecords.FMonth AS FMonth,HR_SocialSecRecords.empCode AS empCode,HR_SocialSecRecords.SSType AS SSType,HR_SocialSecRecords.SSAmt AS SSAmt,HR_SocialSecRecords.indvPension AS indvPension,HR_SocialSecRecords.indvMedical AS indvMedical,HR_SocialSecRecords.indvUnemploy AS indvUnemploy,HR_SocialSecRecords.corpPension AS corpPension,HR_SocialSecRecords.corpBaseMedical AS corpBaseMedical,HR_SocialSecRecords.corpLocalMedical AS corpLocalMedical,HR_SocialSecRecords.corpUnemploy AS corpUnemploy,HR_SocialSecRecords.corpInjury AS corpInjury,HR_SocialSecRecords.corpBirth AS corpBirth,HR_SocialSecRecords.indvTotal AS indvTotal,HR_SocialSecRecords.corpTotal AS corpTotal,HR_SocialSecRecords.Total AS Total,HR_SocialSecRecords.Remark AS Remark"));
             cmd.Parameters.Add(new SqlParameter("@fieldSort", "FMonth,FYear desc"));
             var sbCondition = new StringBuilder();
             SerachCondition.TextBox(sbCondition, "FYear", "FYear", "");
             SerachCondition.TextBox(sbCondition, "FMonth", "FMonth", "");
             SerachCondition.PopupSelect(sbCondition, "empCode", "empCode", "");
             SerachCondition.Dropdown(sbCondition, "SSType", "SSType", "");
             if (sbCondition.Length > 5)
             {
                 sbCondition.Length -= 5;
                 cmd.Parameters.Add(new SqlParameter("@condition", sbCondition.ToString()));
             }
             if (HttpContext.Current.Request.Get("_report_") == "1")
             {
                 // 报表请求条件合成
                 return(sbCondition.ToString());
             }
             SqlParameter rowTotalParameter = null;
             int          rowTotal          = 0;
             int.TryParse(HttpContext.Current.Request.Get("total"), out rowTotal);
             var rq = new PageRequest();
             if (rq.Page.HasValue)
             {
                 var pageSize = rq.Rows.HasValue ? rq.Rows.Value : 20;
                 var rowStart = (rq.Page.Value - 1) * pageSize + 1;
                 var rowEnd   = rq.Page.Value * pageSize;
                 cmd.Parameters.Add(new SqlParameter("@rowStart", rowStart));
                 cmd.Parameters.Add(new SqlParameter("@rowEnd", rowEnd));
                 if (rowStart == 1)
                 {
                     cmd.Parameters.Add(rowTotalParameter = new SqlParameter("@rowTotal", System.Data.SqlDbType.Int, 8, System.Data.ParameterDirection.Output, true, 0, 0, null, System.Data.DataRowVersion.Default, 0));
                 }
             }
             string jsonArrayString = null;
             using (var reader = cmd.ExecuteReader())
             {
                 jsonArrayString = reader.ToJsonArrayString();
             }
             if (rowTotalParameter != null)
             {
                 rowTotal = (int)rowTotalParameter.Value;
             }
             return(JObject.Parse("{rows:" + jsonArrayString + ", total:" + rowTotal + "}"));
         } finally {
             db.Database.Connection.Close();
         }
     }
 }
Exemple #2
0
 public object Get(JObject req)
 {
     using (var db = new LUOLAI1401Context())
     {
         db.Database.Connection.Open();
         try {
             var cmd = db.Database.Connection.CreateCommand();
             cmd.CommandType = System.Data.CommandType.StoredProcedure;
             cmd.CommandText = "proc_SearchList";
             cmd.Parameters.Add(new SqlParameter("@tableName", "Settlement_Report"));
             cmd.Parameters.Add(new SqlParameter("@fieldNames", "Settlement_Report.no AS no,Settlement_Report.开票日期 AS 开票日期,Settlement_Report.开票摘要 AS 开票摘要,Settlement_Report.号码 AS 号码,Settlement_Report.价税合计 AS 价税合计,Settlement_Report.金额3 AS 金额3,Settlement_Report.金额11 AS 金额11,Settlement_Report.应收税管费 AS 应收税管费,Settlement_Report.日期 AS 日期,Settlement_Report.收付款摘要 AS 收付款摘要,Settlement_Report.收款 AS 收款,Settlement_Report.支付 AS 支付,Settlement_Report.上期结余 AS 上期结余,Settlement_Report.负责人编号 AS CustID,Settlement_Report.年 AS Dates"));
             cmd.Parameters.Add(new SqlParameter("@fieldSort", "no"));
             var sbCondition = new StringBuilder();
             SerachCondition.PopupSelect(sbCondition, "CustID", "CustID", "");
             SerachCondition.TextBox(sbCondition, "Dates", "Dates", "");
             if (sbCondition.Length > 5)
             {
                 sbCondition.Length -= 5;
                 cmd.Parameters.Add(new SqlParameter("@condition", sbCondition.ToString()));
             }
             if (HttpContext.Current.Request.Get("_report_") == "1")
             {
                 // 报表请求条件合成
                 return(sbCondition.ToString());
             }
             SqlParameter rowTotalParameter = null;
             int          rowTotal          = 0;
             int.TryParse(HttpContext.Current.Request.Get("total"), out rowTotal);
             var rq = new PageRequest();
             if (rq.Page.HasValue)
             {
                 var pageSize = rq.Rows.HasValue ? rq.Rows.Value : 20;
                 var rowStart = (rq.Page.Value - 1) * pageSize + 1;
                 var rowEnd   = rq.Page.Value * pageSize;
                 cmd.Parameters.Add(new SqlParameter("@rowStart", rowStart));
                 cmd.Parameters.Add(new SqlParameter("@rowEnd", rowEnd));
                 if (rowStart == 1)
                 {
                     cmd.Parameters.Add(rowTotalParameter = new SqlParameter("@rowTotal", System.Data.SqlDbType.Int, 8, System.Data.ParameterDirection.Output, true, 0, 0, null, System.Data.DataRowVersion.Default, 0));
                 }
             }
             string jsonArrayString = null;
             using (var reader = cmd.ExecuteReader())
             {
                 jsonArrayString = reader.ToJsonArrayString();
             }
             if (rowTotalParameter != null)
             {
                 rowTotal = (int)rowTotalParameter.Value;
             }
             return(JObject.Parse("{rows:" + jsonArrayString + ", total:" + rowTotal + "}"));
         } finally {
             db.Database.Connection.Close();
         }
     }
 }
        public object Get()
        {
            var sbCondition = new System.Text.StringBuilder();

            SerachCondition.PopupSelect(sbCondition, "empID", "a.empID", "");
            SerachCondition.Dropdown(sbCondition, "HFType", "a.HFType", "");

            if (sbCondition.Length > 4)
            {
                sbCondition.Length -= 4;
            }
            var pageReq = new PageRequest();

            using (var db = new LUOLAI1401Context())
            {
                return(pageReq.ToPageList <HR_WageSetsListModel>(db.Database, "a.FID ,b.empID empID_RefText ,a.empID ,c.Text HFType_RefText ,a.HFType ,a.SSBaseAmt ,a.HFBaseAmt ,d.Contact CustID_RefText ,a.CustID ,a.START_TIME ,a.END_TIME ,a.Remark ,a.CreatePerson ,a.CreateDate ,a.UpdateDate ", "HR_WageSets a LEFT JOIN HR_PractiseCerts b ON a.empID = b.FID LEFT JOIN [Bcp.Sysy].dbo.sys_code c ON a.HFType = c.Value AND (c.CodeType='FType') LEFT JOIN BD_Customers d ON a.CustID = d.FID ", sbCondition.ToString(), "a.FID", "desc"));
            }
        }
Exemple #4
0
        public object Get()
        {
            var sbCondition = new System.Text.StringBuilder();

            sbCondition.AppendFormat("({0}) AND ", string.Format("{0}{1}{2}{3}{4}{5}{6}", "((a.UserCode IN (SELECT UserCode FROM dbo.sys_user WHERE OrganizeName LIKE '", System.Web.HttpContext.Current.Session["OrganizeName"], "%') AND a.CompCode='", (System.Web.HttpContext.Current.Session["sys_user"] as sys_user).CompCode, "') or ('", (System.Web.HttpContext.Current.Session["sys_user"] as sys_user).UserCode, "'='super ' ))"));
            SerachCondition.Date(sbCondition, "Month", "a.Month", "datetime");
            SerachCondition.PopupSelect(sbCondition, "UserCode", "a.UserCode", "varchar");

            if (sbCondition.Length > 4)
            {
                sbCondition.Length -= 4;
            }
            var pageReq = new PageRequest();

            using (var db = new LUOLAI1401Context())
            {
                return(pageReq.ToPageList <wq_incomeListModel>(db.Database, "a.id ,b.PopName PopCode_RefText ,a.PopCode ,a.Month ,a.IncomeAmt ,c.name UserCode_RefText ,a.UserCode ,a.Remark ", "wq_income a LEFT JOIN wq_termPop b ON a.PopCode = b.PopCode LEFT JOIN PersonInfo c ON a.UserCode = c.psncode ", sbCondition.ToString(), "id", "desc"));
            }
        }
        public object Get()
        {
            var sbCondition = new System.Text.StringBuilder();

            sbCondition.AppendFormat("({0}) AND ", string.Format("{0}{1}{2}{3}{4}", "(a.CompCode= '", (System.Web.HttpContext.Current.Session["sys_user"] as sys_user).CompCode, "' or '", (System.Web.HttpContext.Current.Session["sys_user"] as sys_user).UserCode, "'='super') AND c.CodeType='MON'"));
            SerachCondition.PopupSelect(sbCondition, "UserCode", "a.UserCode", "varchar");
            SerachCondition.Dropdown(sbCondition, "Month", "a.Month", "varchar");

            if (sbCondition.Length > 4)
            {
                sbCondition.Length -= 4;
            }
            var pageReq = new PageRequest();

            using (var db = new LUOLAI1401Context())
            {
                return(pageReq.ToPageList <wq_planListModel>(db.Database, "a.id ,b.name UserCode_RefText ,a.UserCode ,c.Text Month_RefText ,a.Month ,a.SellAmt ,a.IncomeAmt ", "wq_plan a LEFT JOIN PersonInfo b ON a.UserCode = b.psncode LEFT JOIN [Bcp.Sys].dbo.sys_code c ON a.Month = c.Value ", sbCondition.ToString(), "id", "desc"));
            }
        }
Exemple #6
0
        public object Get()
        {
            var sbCondition = new System.Text.StringBuilder();

            sbCondition.AppendFormat("({0}) AND ", string.Format("{0}{1}{2}", "a.CompCode= '", (System.Web.HttpContext.Current.Session["sys_user"] as sys_user).CompCode, "'"));
            SerachCondition.PopupSelect(sbCondition, "RoleCode", "a.RoleCode", "varchar");
            SerachCondition.PopupSelect(sbCondition, "psncode", "a.psncode", "varchar");
            SerachCondition.Dropdown(sbCondition, "timingtype", "a.timingtype", "varchar");

            if (sbCondition.Length > 4)
            {
                sbCondition.Length -= 4;
            }
            var pageReq = new PageRequest();

            using (var db = new LUOLAI1401Context())
            {
                return(pageReq.ToPageList <timingSetListModel>(db.Database, "a.id ,b.RoleName RoleCode_RefText ,a.RoleCode ,c.name psncode_RefText ,a.psncode ,d.Text timingtype_RefText ,a.timingtype ,a.interval ,a.mobegintime ,a.moendtime ,a.afbegintime ,a.afendtime ", "timingSet a LEFT JOIN [Bcp.Sys].dbo.sys_role b ON a.RoleCode = b.RoleCode LEFT JOIN PersonInfo c ON a.psncode = c.psncode LEFT JOIN [Bcp.Sys].dbo.sys_code d ON a.timingtype = d.Text ", sbCondition.ToString(), "id", "desc"));
            }
        }
Exemple #7
0
        public object Get()
        {
            var sbCondition = new System.Text.StringBuilder();

            SerachCondition.PopupSelect(sbCondition, "CustID", "a.CustID", "");
            SerachCondition.Date(sbCondition, "BeginDate", "a.BeginDate", "");
            SerachCondition.Date(sbCondition, "EndDate", "a.EndDate", "");
            SerachCondition.Dropdown(sbCondition, "projl", "a.projl", "");

            if (sbCondition.Length > 4)
            {
                sbCondition.Length -= 4;
            }
            var pageReq = new PageRequest();

            using (var db = new LUOLAI1401Context())
            {
                return(pageReq.ToPageList <PM_ProjectInfosListModel>(db.Database, "a.FID ,a.appNumber ,a.Code ,a.ProjName ,b.Contact CustID_RefText ,a.CustID ,a.Owner ,a.BeginDate ,a.EndDate ,a.BaDate ,c.Text bClose_RefText ,a.bClose ,a.exDays ,a.proje ,d.empID projl_RefText ,a.projl ", "PM_ProjectInfos a LEFT JOIN BD_Customers b ON a.CustID = b.FID LEFT JOIN [Bcp.Sysy].dbo.sys_code c ON a.bClose = c.Value AND (c.CodeType='yes/no') LEFT JOIN HR_PractiseCerts d ON a.projl = d.FID ", sbCondition.ToString(), "a.FID", "desc"));
            }
        }
Exemple #8
0
        public object Get()
        {
            var sbCondition = new System.Text.StringBuilder();

            sbCondition.AppendFormat("({0}) AND ", string.Format("{0}{1}{2}{3}{4}{5}{6}", "((a.UserCode IN (SELECT UserCode FROM dbo.sys_user WHERE OrganizeName LIKE '", System.Web.HttpContext.Current.Session["OrganizeName"], "%') AND a.CompCode='", (System.Web.HttpContext.Current.Session["sys_user"] as sys_user).CompCode, "') or ('", (System.Web.HttpContext.Current.Session["sys_user"] as sys_user).UserCode, "'='super ' ))"));
            SerachCondition.PopupSelect(sbCondition, "UserCode", "a.UserCode", "");
            SerachCondition.Date(sbCondition, "AttDateTime", "a.AttDateTime", "");
            SerachCondition.Date(sbCondition, "CreateDate", "a.CreateDate", "");

            if (sbCondition.Length > 4)
            {
                sbCondition.Length -= 4;
            }
            var pageReq = new PageRequest();

            using (var db = new LUOLAI1401Context())
            {
                return(pageReq.ToPageList <wq_dailyLogListModel>(db.Database, "a.code ,b.name UserCode_RefText ,a.UserCode ,a.AttDateTime ,a.DailySummary ,a.DailyPlan ,a.DailyExper ,a.UpdateDate ,a.UpdatePerson ,a.CreateDate ,a.CreatePerson ", "wq_dailyLog a LEFT JOIN PersonInfo b ON a.UserCode = b.psncode ", sbCondition.ToString(), "code", "desc"));
            }
        }
        public object Get()
        {
            var sbCondition = new System.Text.StringBuilder();

            sbCondition.AppendFormat("({0}) AND ", string.Format("{0}{1}{2}{3}{4}", "(a.CompCode +'`' +a.UserCode IN (SELECT UserCode+'`'+CompCode  FROM dbo.sys_user WHERE OrganizeName LIKE '", System.Web.HttpContext.Current.Session["OrganizeName"], "%')) or ('", (System.Web.HttpContext.Current.Session["sys_user"] as sys_user).UserCode, "'='super')"));
            SerachCondition.PopupSelect(sbCondition, "UserCode", "a.UserCode", "");
            SerachCondition.Date(sbCondition, "PrmDate", "a.PrmDate", "");
            SerachCondition.PopupSelect(sbCondition, "DealerCode", "a.DealerCode", "");
            SerachCondition.TextBox(sbCondition, "RPdtCode", "a.RPdtCode", "");

            if (sbCondition.Length > 4)
            {
                sbCondition.Length -= 4;
            }
            var pageReq = new PageRequest();

            using (var db = new LUOLAI1401Context())
            {
                return(pageReq.ToPageList <wq_goodsreportListModel>(db.Database, "b.name UserCode_RefText ,a.UserCode ,a.PrmDate ,c.PopName DealerCode_RefText ,a.DealerCode ,a.RPdtCode ,a.Remark ", "wq_goodsreport a LEFT JOIN PersonInfo b ON a.UserCode = b.psncode LEFT JOIN wq_termPop c ON a.DealerCode = c.PopCode ", sbCondition.ToString(), "RPdtCode", "desc"));
            }
        }
        public object Get()
        {
            var sbCondition = new System.Text.StringBuilder();

            SerachCondition.Dropdown(sbCondition, "Corp", "a.Corp", "");
            SerachCondition.Dropdown(sbCondition, "SZType", "a.SZType", "");
            SerachCondition.PopupSelect(sbCondition, "CustID", "a.CustID", "");
            SerachCondition.Date(sbCondition, "Fdate", "a.Fdate", "");
            SerachCondition.Dropdown(sbCondition, "payType", "a.payType", "");

            if (sbCondition.Length > 4)
            {
                sbCondition.Length -= 4;
            }
            var pageReq = new PageRequest();

            using (var db = new LUOLAI1401Context())
            {
                return(pageReq.ToPageList <FA_ReceiptsListModel>(db.Database, "a.FID ,b.Text Corp_RefText ,a.Corp ,c.Text SZType_RefText ,a.SZType ,d.Contact CustID_RefText ,a.CustID ,a.Fdate ,a.Amt ,e.Text payType_RefText ,a.payType ,a.Remark ,a.CreatePerson ,a.CreateDate ,a.UpdateDate ", "FA_Receipts a LEFT JOIN [Bcp.Sysy].dbo.sys_code b ON a.Corp = b.Value AND (b.CodeType='HtCorp') LEFT JOIN [Bcp.Sysy].dbo.sys_code c ON a.SZType = c.Value AND (c.CodeType='SHZHType') LEFT JOIN BD_Customers d ON a.CustID = d.FID LEFT JOIN [Bcp.Sysy].dbo.sys_code e ON a.payType = e.Value AND (e.CodeType='PayKind') ", sbCondition.ToString(), "a.FID", "desc"));
            }
        }
Exemple #11
0
        public object Get()
        {
            var sbCondition = new System.Text.StringBuilder();

            SerachCondition.TextBox(sbCondition, "psncode", "a.psncode", "");
            SerachCondition.TextBox(sbCondition, "name", "a.name", "");
            SerachCondition.TextBox(sbCondition, "Mobile", "a.Mobile", "");
            SerachCondition.Dropdown(sbCondition, "position", "a.position", "");
            SerachCondition.PopupSelect(sbCondition, "RoleCode", "a.RoleCode", "");

            if (sbCondition.Length > 4)
            {
                sbCondition.Length -= 4;
            }
            var pageReq = new PageRequest();

            using (var db = new LUOLAI1401Context())
            {
                return(pageReq.ToPageList <PersonInfoListModel>(db.Database, "a.ID ,a.psncode ,a.name ,a.Mobile ,b.Text sex_RefText ,a.sex ,c.Text EmployeeStatus_RefText ,a.EmployeeStatus ,d.OrganizeName position_RefText ,a.position ,e.RoleName RoleCode_RefText ,a.RoleCode ,a.stuffdate ,a.is_status ,a.kq_status ", "PersonInfo a LEFT JOIN [Bcp.Sys].dbo.sys_code b ON a.sex = b.Value LEFT JOIN [Bcp.Sys].dbo.sys_code c ON a.EmployeeStatus = c.Value LEFT JOIN [Bcp.Sys].dbo.sys_organize d ON a.position = d.OrganizeCode LEFT JOIN [Bcp.Sys].dbo.sys_role e ON a.RoleCode = e.RoleCode ", sbCondition.ToString(), "a.ID", "desc"));
            }
        }
Exemple #12
0
        public object Get()
        {
            var sbCondition = new System.Text.StringBuilder();

            SerachCondition.TextBox(sbCondition, "name", "a.name", "");
            SerachCondition.TextBox(sbCondition, "CertNumber", "a.CertNumber", "");
            SerachCondition.Dropdown(sbCondition, "nativeplace", "a.nativeplace", "");
            SerachCondition.TextBox(sbCondition, "FileNumber", "a.FileNumber", "");
            SerachCondition.PopupSelect(sbCondition, "UserAccount", "a.UserAccount", "");

            if (sbCondition.Length > 4)
            {
                sbCondition.Length -= 4;
            }
            var pageReq = new PageRequest();

            using (var db = new LUOLAI1401Context())
            {
                return(pageReq.ToPageList <PersonInfoListModel>(db.Database, "a.ID ,a.name ,a.Password ,a.CertNumber ,b.Text nativeplace_RefText ,a.nativeplace ,a.FileNumber ,c.Text UserAccount_RefText ,a.UserAccount ,a.psncode ,a.RoleCode ,a.WageCard ,a.SocialSecurity ,a.Mobile ,a.usedname ,a.sex ,a.birthdate ,a.age ,a.stuffdate ,a.effectdate ,a.workaddr ,a.BirthPlace ,a.nationality ,a.position ,a.permanreside ,a.characterrpr ,a.marital ,a.EmployeeStatus ,a.country ,a.idtype ,a.polity ,a.health ,a.Height ,a.Weight ,a.Vision ,a.lasteducation ,a.HighestDegree ,a.major ,a.rank ,a.GraduationSchool ,a.joinworkdate ,a.FreeWorkYears ,a.is_status ,a.kq_status ,a.glbdef1 ,a.Photo ,a.CompCode ,a.soft ,a.phonetype ,a.os ,a.isline ,a.KQ ", "PersonInfo a LEFT JOIN [Bcp.Sys].dbo.sys_code b ON a.nativeplace = b.Value LEFT JOIN [Bcp.Sys].dbo.sys_code c ON a.UserAccount = c.Value ", sbCondition.ToString(), "a.ID", "desc"));
            }
        }
Exemple #13
0
 public object Get(JObject req)
 {
     using (var db = new LUOLAI1401Context())
     {
         db.Database.Connection.Open();
         try {
             var cmd = db.Database.Connection.CreateCommand();
             cmd.CommandType = System.Data.CommandType.StoredProcedure;
             cmd.CommandText = "proc_SearchList";
             cmd.Parameters.Add(new SqlParameter("@tableName", "wq_dailyLog D INNER JOIN sys_user U ON U.UserCode=D.UserCode and D.CompCode=U.CompCode "));
             cmd.Parameters.Add(new SqlParameter("@fieldNames", "D.UserCode AS UserCode,U.UserName AS UserName,U.OrganizeCode AS OrganizeCode,U.bumenName AS bumenName,D.comments AS comments,D.states AS states,D.No AS No,D.CreatePerson AS CreatePerson,D.CreateDate,D.DailyExper AS DailyExper,D.DailyPlan AS DailyPlan,D.DailySummary AS DailySummary"));
             cmd.Parameters.Add(new SqlParameter("@fieldSort", "D.CreateDate"));
             var sbCondition = new StringBuilder();
             sbCondition.Append(string.Format("{0}{1}{2}{3}{4}{5}{6}", "((D.UserCode IN (SELECT UserCode FROM dbo.sys_user WHERE OrganizeName LIKE '", System.Web.HttpContext.Current.Session["OrganizeName"], "%') AND D.CompCode='", (System.Web.HttpContext.Current.Session["sys_user"] as sys_user).CompCode, "') or ('", (System.Web.HttpContext.Current.Session["sys_user"] as sys_user).UserCode, "'='super ' ))"));
             sbCondition.Append(" AND ");
             SerachCondition.PopupSelect(sbCondition, "UserCode", "UserCode", "");
             SerachCondition.TextBox(sbCondition, "UserName", "UserName", "");
             SerachCondition.PopupSelect(sbCondition, "OrganizeCode", "OrganizeCode", "");
             SerachCondition.Dropdown(sbCondition, "states", "states", "");
             SerachCondition.Date(sbCondition, "D_CreateDate", "D.CreateDate", "");
             if (sbCondition.Length > 5)
             {
                 sbCondition.Length -= 5;
                 cmd.Parameters.Add(new SqlParameter("@condition", sbCondition.ToString()));
             }
             if (HttpContext.Current.Request.Get("_report_") == "1")
             {
                 // 报表请求条件合成
                 return(sbCondition.ToString());
             }
             SqlParameter rowTotalParameter = null;
             int          rowTotal          = 0;
             int.TryParse(HttpContext.Current.Request.Get("total"), out rowTotal);
             var rq = new PageRequest();
             if (rq.Page.HasValue)
             {
                 var pageSize = rq.Rows.HasValue ? rq.Rows.Value : 20;
                 var rowStart = (rq.Page.Value - 1) * pageSize + 1;
                 var rowEnd   = rq.Page.Value * pageSize;
                 cmd.Parameters.Add(new SqlParameter("@rowStart", rowStart));
                 cmd.Parameters.Add(new SqlParameter("@rowEnd", rowEnd));
                 if (rowStart == 1)
                 {
                     cmd.Parameters.Add(rowTotalParameter = new SqlParameter("@rowTotal", System.Data.SqlDbType.Int, 8, System.Data.ParameterDirection.Output, true, 0, 0, null, System.Data.DataRowVersion.Default, 0));
                 }
             }
             string jsonArrayString = null;
             using (var reader = cmd.ExecuteReader())
             {
                 jsonArrayString = reader.ToJsonArrayString();
             }
             if (rowTotalParameter != null)
             {
                 rowTotal = (int)rowTotalParameter.Value;
             }
             return(JObject.Parse("{rows:" + jsonArrayString + ", total:" + rowTotal + "}"));
         } finally {
             db.Database.Connection.Close();
         }
     }
 }