Beispiel #1
0
        public ActionResult GetProductTypeList(int id = 0, string KeyWord = "")
        {
            int    count    = 0;
            string sql      = "SELECT [id] ,[code] ,[name],[ParentId],[AddTime] FROM [" + DBName + "].[dbo].[tb_ProductType] ";
            string strWhere = " Where 1=1";

            if (KeyWord != "")
            {
                strWhere += " and ( id in ( select id from  [" + DBName + "].[dbo].[tb_ProductType] where code like '%" + KeyWord + "%' or name like '%" + KeyWord + "%' ) ";
                strWhere += "  or id in ( select ParentId from  [" + DBName + "].[dbo].[tb_ProductType] where code like '%" + KeyWord + "%' or name like '%" + KeyWord + "%' ) ) ";
            }
            //sql = sql + strWhere;
            //DataSet ds = DataPageHelper.GetDataPage(DataPageHelper.GetPageSql(sql, 1, 10000, "id desc"), out count);

            //List<MenuPage> list = TBToList<MenuPage>.ConvertToList(ds.Tables[0]).ToList();
            ////List<tb_ProductType> list = ef.tb_ProductType.Where(p => p.MenuID > 0).ToList();
            //List<MenuPage> listJson = new List<MenuPage>();
            //foreach (tb_ProductType model in list.Where(p => p.ParentId == 0).OrderBy(p => p.id))
            //{
            //    MakeMenuJson(list, model, id);
            //    listJson.Add(model);
            //}


            //return Json(listJson, JsonRequestBehavior.AllowGet);

            GoodsBLL bn = new GoodsBLL();
            //string sql = @"select p.Uname,p.Sex,p.roleId,p.truename,p.UId from Users p order by UId desc";
            //string sql = @"select * ,(select top 1 truename from [dbo].Users where UId=m.UId) as truename, (select roleName from Role where roleId in(select top 1  roleId from Users where UId=m.UId)) as roelName  from .[dbo].Users m  where  " + strWhere;
            DataSet ds = bn.GetMenu();
            // DataSet ds = DataPageHelper.GetDataPage(DataPageHelper.GetPageSql(sql, 7, rows, "UId desc"), out count);
            List <MenuPage> list = TBToList <MenuPage> .ConvertToList(ds.Tables[0]).ToList();

            var grid = new EasyuiDataGrid <List <MenuPage> >();

            grid.total = count;
            grid.rows  = list;
            return(Json(grid, JsonRequestBehavior.AllowGet));
        }