Exemple #1
0
        public ActionResult GetEmpList()
        {
            string     strJson = string.Empty;
            JsonHelper json    = new JsonHelper();

            try
            {
                var result = EnterRepository.GetRepositoryEnter().EmployeeRepository.LoadEntities().OrderBy(m => m.EmpNo).ToList();

                foreach (Employee item in result)
                {
                    json.AddItem("ID", item.ID.ToString());
                    json.AddItem("EmpNo", item.EmpNo);
                    json.AddItem("Name", item.Name);
                    json.ItemOk();
                }

                json.totlalCount = result.Count;
                strJson          = json.ToEasyuiGridJsonString();
            }
            catch (Exception ex)
            {
                GlobalMethod.log.Error(ex);
            }

            return(Content(strJson));
        }
Exemple #2
0
 /// <summary>
 /// 获取指定ID的数据
 /// </summary>
 public ActionResult QueryOneData()
 {
     try
     {
         int id = Request.Form["id"] != "" ? int.Parse(Request.Form["id"]) : 0;
         //Orgnization item = new Orgnization();
         //short shRet = SystemContext.Instance.OrgnizationServices.GetOrgnizationByID(id, ref item);
         var        item    = EnterRepository.GetRepositoryEnter().OrgnizationRepository.LoadEntities(m => m.ID == id).FirstOrDefault();
         JsonHelper json    = new JsonHelper();
         string     strJson = string.Empty;
         if (item != null)
         {
             if (item.ParentID != 0)
             {
                 item.ParentName = EnterRepository.GetRepositoryEnter().OrgnizationRepository.LoadEntities(m => m.ID == item.ParentID).FirstOrDefault().OrgName;
             }
             json.AddItem("ID", item.ID.ToString());
             json.AddItem("OrgName", item.OrgName);
             json.AddItem("ParentID", item.ParentID.ToString());
             json.AddItem("ParentName", item.ParentName);
             json.AddItem("Description", item.Description);
             json.ItemOk();
         }
         strJson = json.ToEasyuiListJsonString();
         return(Content(strJson));
     }
     catch (Exception ex)
     {
         GlobalMethod.log.Error(ex);
         throw;
     }
 }
Exemple #3
0
        /// <summary>
        /// 查询数据
        /// </summary>
        public ActionResult QueryData()
        {
            List <ExamPlace> lstExamPlace = new List <ExamPlace>();
            short            shRet        = SystemContext.Instance.ExamPlaceServices.GetExamPlaceList("", "", "", ref lstExamPlace);
            JsonHelper       json         = new JsonHelper();
            string           strJson      = string.Empty;

            foreach (ExamPlace item in lstExamPlace)
            {
                json.AddItem("id", item.ID.ToString());
                json.AddItem("name", item.PlaceName);
                json.AddItem("pid", item.ParentID);
                //json.AddItem("NewsContent", item.NewsContent);
                json.AddItem("ParentName", item.ParentName);
                json.AddItem("Description", item.Description);
                json.ItemOk();
            }
            if (lstExamPlace.Count > 0)
            {
                strJson = json.ToEasyuiListJsonString();
            }
            else
            {
                strJson = @"[]";
            }
            // json = "{ \"rows\":[ { \"ID\":\"48\",\"NewsTitle\":\"mr\",\"NewsContent\":\"mrsoft\",\"CreateTime\":\"2013-12-23\",\"CreateUser\":\"ceshi\",\"ModifyTime\":\"2013-12-23\",\"ModifyUser\":\"ceshi\"} ],\"total\":3}";
            return(Content(strJson));
        }
 /// <summary>
 /// 获取指定ID的数据
 /// </summary>
 public ActionResult QueryOneData()
 {
     try
     {
         int        id      = Request.Form["id"] != "" ? int.Parse(Request.Form["id"]) : 0;
         var        item    = EnterRepository.GetRepositoryEnter().EmployeeRepository.LoadEntities(m => m.ID == id).FirstOrDefault();
         JsonHelper json    = new JsonHelper();
         string     strJson = string.Empty;
         if (item != null)
         {
             json.AddItem("ID", item.ID.ToString());
             json.AddItem("EmpNo", item.EmpNo);
             json.AddItem("Pwd", item.Pwd);
             json.AddItem("Name", item.Name);
             json.AddItem("Tel", item.Tel);
             json.ItemOk();
         }
         strJson = json.ToEasyuiOneModelJsonString();
         // strJson = "[{\"ID\":\"81\",\"EmpNo\":\"jxdhlgljp\",\"Name\":\"hello\",\"Pwd\":\"111111\",\"Tel\":\"18720081979\"}]";
         return(Content(strJson));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemple #5
0
        public ActionResult QueryDrugComboJson()
        {
            try
            {
                var result = EnterRepository.GetRepositoryEnter().DrugRepository.LoadEntities().OrderBy(m => m.Name).ToList();
                //return Json(new
                //{
                //    result
                //}, JsonRequestBehavior.AllowGet);
                JsonHelper json    = new JsonHelper();
                string     strJson = string.Empty;
                foreach (var item in result)
                {
                    json.AddItem("ID", item.ID.ToString());
                    json.AddItem("Name", item.Name);
                    json.ItemOk();
                }

                //string strJson = "[{\"ID\":\"81\",\"Name\":\"jxdhlgljp\",\"Desc\":\"jxdhlgljp\"},{\"ID\":\"82\",\"Name\":\"hhh\",\"Desc\":\"jxdhlgljp\"}]";
                return(Content(json.ToEasyuiListJsonString()));
            }
            catch (Exception ex)
            {
                GlobalMethod.log.Error(ex);
                throw;
            }
        }
Exemple #6
0
        public ActionResult QueryRoleComboJson()
        {
            try
            {
                var result = SysRoleDao.Instance.GetSysRoles(null).ToList();
                //return Json(new
                //{
                //    result
                //}, JsonRequestBehavior.AllowGet);
                JsonHelper json    = new JsonHelper();
                string     strJson = string.Empty;
                foreach (var item in result)
                {
                    json.AddItem("ID", item.ID.ToString());
                    json.AddItem("Name", item.Name);
                    json.ItemOk();
                }

                //string strJson = "[{\"ID\":\"81\",\"Name\":\"jxdhlgljp\",\"Desc\":\"jxdhlgljp\"},{\"ID\":\"82\",\"Name\":\"hhh\",\"Desc\":\"jxdhlgljp\"}]";
                return(Content(json.ToEasyuiListJsonString()));
            }
            catch (Exception ex)
            {
                GlobalMethod.log.Error(ex);
                throw;
            }
        }
 public ActionResult GetComplicationTypeComboJson()
 {
     try
     {
         string complication_type = SystemContext.Instance.OperationParameter[SystemConst.OperationParameter.complication_type];
         if (string.IsNullOrEmpty(complication_type))
         {
             return(Content(""));
         }
         JsonHelper json    = new JsonHelper();
         string     strJson = string.Empty;
         foreach (var item in complication_type.Split(','))
         {
             json.AddItem("ID", item);
             json.AddItem("Name", item);
             json.ItemOk();
         }
         //string strJson = "[{\"ID\":\"81\",\"Name\":\"jxdhlgljp\",\"Desc\":\"jxdhlgljp\"},{\"ID\":\"82\",\"Name\":\"hhh\",\"Desc\":\"jxdhlgljp\"}]";
         return(Content(json.ToEasyuiListJsonString()));
     }
     catch (Exception ex)
     {
         GlobalMethod.log.Error(ex);
         throw;
     }
 }
Exemple #8
0
        /// <summary>
        /// 查询数据
        /// </summary>
        public ActionResult QueryData()
        {
            try
            {
                int    page  = Request.Form["page"] != "" ? Convert.ToInt32(Request.Form["page"]) : 0;
                int    size  = Request.Form["rows"] != "" ? Convert.ToInt32(Request.Form["rows"]) : 0;
                string sort  = Request.Form["sort"] != "" ? Request.Form["sort"] : "";
                string order = Request.Form["order"] != "" ? Request.Form["order"] : "";
                if (page < 1)
                {
                    return(Content(""));
                }

                //List<Demand> lstDemand = new List<Demand>();
                //short shRet = SystemContext.Instance.DemandService.GetDemandPageList(size, page, "", ref lstDemand);
                var query = EnterRepository.GetRepositoryEnter().DemandRepository.LoadEntities().OrderByDescending(m => m.SubmitTime);

                int totalCount = 0;
                totalCount = query.Count();
                var lstDemand = EnterRepository.GetRepositoryEnter().DemandRepository.LoadPageEnties(query, (page - 1) * size, size).ToList();

                JsonHelper json    = new JsonHelper();
                string     strJson = string.Empty;
                foreach (Demand item in lstDemand)
                {
                    json.AddItem("ID", item.ID.ToString());
                    json.AddItem("Product", item.Product);
                    json.AddItem("Version", item.Version);
                    //json.AddItem("NewsContent", item.NewsContent);
                    json.AddItem("Creater", item.Creater.ToString());
                    json.AddItem("SubmitTime", item.SubmitTime.ToString());
                    json.AddItem("Owener", item.Owener);
                    json.AddItem("SoluteTime", item.SoluteTime.ToString());
                    json.AddItem("State", item.State);
                    json.AddItem("Title", item.Title);
                    json.AddItem("Expense", item.Expense);
                    //json.AddItem("Solution", item.Solution);
                    json.ItemOk();
                }
                //shRet = SystemContext.Instance.DemandService.GetDemandTotalCount("", ref totalCount);
                json.totlalCount = totalCount;
                if (json.totlalCount > 0)
                {
                    strJson = json.ToEasyuiGridJsonString();
                }
                else
                {
                    strJson = @"[]";
                }
                // json = "{ \"rows\":[ { \"ID\":\"48\",\"NewsTitle\":\"mr\",\"NewsContent\":\"mrsoft\",\"CreateTime\":\"2013-12-23\",\"CreateUser\":\"ceshi\",\"ModifyTime\":\"2013-12-23\",\"ModifyUser\":\"ceshi\"} ],\"total\":3}";
                return(Content(strJson));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public ActionResult QueryOneData()
        {
            string strJson = string.Empty;

            int id     = Request.Form["id"] != "" ? int.Parse(Request.Form["id"]) : 0;
            var result = SysMenuDao.Instance.QueryOne(id);

            if (result.ParentName == null)
            {
                result.ParentName = string.Empty;
            }
            JsonHelper json = new JsonHelper();

            if (result != null)
            {
                json.AddItem("ID", result.ID.ToString());
                json.AddItem("MenuName", result.MenuName);
                json.AddItem("Url", result.Url);
                json.AddItem("ParentID", result.ParentID.ToString());
                json.AddItem("ParentName", result.ParentName);
                json.AddItem("Icon", result.Icon);
                json.AddItem("Description", result.Description);
                json.AddItem("MenuType", result.MenuType);
                json.ItemOk();
            }
            strJson = json.ToEasyuiOneModelJsonString();

            // strJson = "[{\"ID\":\"81\",\"EmpNo\":\"jxdhlgljp\",\"Name\":\"hello\",\"Pwd\":\"111111\",\"Tel\":\"18720081979\"}]";
            return(Content(strJson));
        }
Exemple #10
0
        public ActionResult QueryOneData()
        {
            string strJson = string.Empty;

            int id     = Request.Form["id"] != "" ? int.Parse(Request.Form["id"]) : 0;
            var result = EnterRepository.GetRepositoryEnter().MenuRepository.LoadEntities(m => m.ID == id).FirstOrDefault();

            if (result.ParentID != 0)
            {
                result.ParentName = EnterRepository.GetRepositoryEnter().MenuRepository.LoadEntities(m => m.ID == result.ParentID).FirstOrDefault().MenuName;
            }
            JsonHelper json = new JsonHelper();

            if (result != null)
            {
                json.AddItem("ID", result.ID.ToString());
                json.AddItem("MenuName", result.MenuName);
                json.AddItem("Url", result.Url);
                json.AddItem("ParentID", result.ParentID.ToString());
                json.AddItem("ParentName", result.ParentName);
                json.AddItem("Icon", result.Icon);
                json.AddItem("Description", result.Description);
                json.AddItem("MenuType", result.MenuType);
                json.ItemOk();
            }
            strJson = json.ToEasyuiOneModelJsonString();

            // strJson = "[{\"ID\":\"81\",\"EmpNo\":\"jxdhlgljp\",\"Name\":\"hello\",\"Pwd\":\"111111\",\"Tel\":\"18720081979\"}]";
            return(Content(strJson));
        }
Exemple #11
0
        public ActionResult QueryTemplate()
        {
            JsonHelper json    = new JsonHelper();
            string     strJson = string.Empty;

            string[] arrTemplate = SystemContext.Template.GetArrTemplate();
            foreach (string item in arrTemplate)
            {
                json.AddItem("id", item);
                json.AddItem("text", item);
                json.ItemOk();
            }
            strJson = json.ToEasyuiListJsonString();
            return(Content(strJson));
        }
Exemple #12
0
        /// <summary>
        /// 查询数据
        /// </summary>
        public ActionResult QueryData()
        {
            int    page         = Request.Form["page"] != "" ? Convert.ToInt32(Request.Form["page"]) : 0;
            int    size         = Request.Form["rows"] != "" ? Convert.ToInt32(Request.Form["rows"]) : 0;
            string sort         = Request.Form["sort"] != "" ? Request.Form["sort"] : "";
            string order        = Request.Form["order"] != "" ? Request.Form["order"] : "";
            string title        = Request.Form["Title"] != "" ? Request.Form["Title"] : "";
            string categoryCode = Request.Form["CategoryCode"] != null ?Request.Form["CategoryCode"] : "";
            string keywords     = Request.Form["keywords"] != null ? Request.Form["keywords"] : "";

            if (page < 1)
            {
                return(Content(""));
            }
            int totalCount = 0;
            var result     = MeddocEnterRepository.GetRepositoryEnter().QcArticleRepository.LoadPageList(title, 0, categoryCode, keywords, (page - 1) * size, size, out totalCount).ToList();

            JsonHelper json    = new JsonHelper();
            string     strJson = string.Empty;

            foreach (QcArticle item in result)
            {
                json.AddItem("ID", item.ID.ToString());
                json.AddItem("Title", item.Title);
                json.AddItem("CategoryCode", item.CategoryCode);
                json.AddItem("ImagePath", item.ImagePath);
                json.AddItem("Summary", item.Summary == null?"":item.Summary.Replace("\n", "").Replace("\r", "").Replace("\t", ""));
                json.AddItem("Keywords", item.Keywords);
                json.AddItem("CategoryName", SystemConst.CategoryCode.GetCategoryName(item.CategoryCode));
                json.AddItem("CreateTime", item.CreateTime == null ? "" : item.CreateTime.ToString("yyyy-MM-dd HH:mm"));
                json.AddItem("ModifyTime", item.ModifyTime == null ? "" : item.ModifyTime.ToString("yyyy-MM-dd HH:mm"));
                json.AddItem("Content", HtmlContentHelper.GetSummary(item.Content).Replace("\n", "").Replace("\r", "").Replace("\t", ""));
                json.ItemOk();
            }
            json.totlalCount = totalCount;
            if (json.totlalCount > 0)
            {
                strJson = json.ToEasyuiGridJsonString();
            }
            else
            {
                strJson = @"[]";
            }
            return(Content(strJson));
        }
Exemple #13
0
        /// <summary>
        /// 查询数据
        /// </summary>
        public ActionResult QueryData()
        {
            int    page       = Request.Form["page"] != "" ? Convert.ToInt32(Request.Form["page"]) : 0;
            int    size       = Request.Form["rows"] != "" ? Convert.ToInt32(Request.Form["rows"]) : 0;
            string sort       = Request.Form["sort"] != "" ? Request.Form["sort"] : "";
            string order      = Request.Form["order"] != "" ? Request.Form["order"] : "";
            string title      = Request.Form["Title"] != "" ? Request.Form["Title"] : "";
            int    categoryID = Request.Form["CategoryID"] != "" ? int.Parse(Request.Form["CategoryID"]) : 0;
            string keywords   = Request.Form["keywords"] != "" ? Request.Form["keywords"] : "";

            if (page < 1)
            {
                return(Content(""));
            }
            string categoryCode = string.Empty;

            if (categoryID != 0)
            {
                categoryCode = EnterRepository.GetRepositoryEnter().CategoryRepository.LoadEntities(m => m.ID == categoryID).FirstOrDefault().Code;
            }
            int totalCount = 0;
            var result     = EnterRepository.GetRepositoryEnter().ArticleRepository.LoadPageList(title, 0, categoryCode, keywords, (page - 1) * size, size, out totalCount).ToList();

            JsonHelper json    = new JsonHelper();
            string     strJson = string.Empty;

            foreach (Article item in result)
            {
                json.AddItem("ID", item.ID.ToString());
                json.AddItem("Title", item.Title);
                json.AddItem("CategoryName", item.CategoryName);
                json.AddItem("Keywords", item.Keywords);
                json.AddItem("CreateTime", item.CreateTime.ToString("yyyy-MM-dd HH:mm"));
                json.AddItem("CreateName", item.CreateName);
                json.AddItem("ModifyTime", item.ModifyTime.ToString("yyyy-MM-dd HH:mm"));
                json.AddItem("ModifyName", item.ModifyName);
                json.AddItem("ImagePath", item.ImagePath);
                json.ItemOk();
            }
            json.totlalCount = totalCount;
            if (json.totlalCount > 0)
            {
                strJson = json.ToEasyuiGridJsonString();
            }
            else
            {
                strJson = @"[]";
            }
            return(Content(strJson));
        }
Exemple #14
0
 /// <summary>
 /// 返回执行成功JSON字符串
 /// </summary>
 /// <returns></returns>
 public static string SuccessString(string info)
 {
     JsonHelper json = new JsonHelper();
     json.totlal = 0;
     json.success = true;
     json.AddItem("info", info);
     json.ItemOk();
     return json.ToString();
 }
Exemple #15
0
        public ActionResult GetGridList()
        {
            //Employee CurrentEmployee = Session["curUser"] as Employee;
            //if (CurrentEmployee == null)
            //{
            //    return RedirectToAction("Login");
            //}
            int    page  = Request.Form["page"] != "" ? Convert.ToInt32(Request.Form["page"]) : 0;
            int    size  = Request.Form["rows"] != "" ? Convert.ToInt32(Request.Form["rows"]) : 0;
            string sort  = Request.Form["sort"] != "" ? Request.Form["sort"] : "";
            string order = Request.Form["order"] != "" ? Request.Form["order"] : "";

            if (page < 1)
            {
                return(Content(""));
            }

            List <Menus> lstMenus = new List <Menus>();
            short        shRet    = SystemContext.Instance.MenuServices.GetMenuPageList(size, page, "", ref lstMenus);
            JsonHelper   json     = new JsonHelper();
            string       strJson  = string.Empty;

            foreach (Menus item in lstMenus)
            {
                json.AddItem("id", item.ID.ToString());
                json.AddItem("MenuName", item.MenuName);
                json.AddItem("Url", item.Url);
                //json.AddItem("NewsContent", item.NewsContent);
                if (item.ParentID != "" && item.ParentID != "0")
                {
                    json.AddItem("_parentId", item.ParentID);
                }
                json.AddItem("ParentName", item.ParentName);
                json.AddItem("Icon", item.Icon);
                json.AddItem("MenuType", item.MenuType);
                json.AddItem("Description", item.Description);
                json.ItemOk();
            }
            int totalCount = 0;

            shRet            = SystemContext.Instance.MenuServices.GetMenuTotalCount("", ref totalCount);
            json.totlalCount = totalCount;
            if (json.totlalCount > 0)
            {
                strJson = json.ToEasyuiGridJsonString();
            }
            else
            {
                strJson = @"[]";
            }
            // json = "{ \"rows\":[ { \"ID\":\"48\",\"NewsTitle\":\"mr\",\"NewsContent\":\"mrsoft\",\"CreateTime\":\"2013-12-23\",\"CreateUser\":\"ceshi\",\"ModifyTime\":\"2013-12-23\",\"ModifyUser\":\"ceshi\"} ],\"total\":3}";
            //strJson = "{\"total\":2,\"rows\":[{\"id\":\"2\",\"MenuName\":\"ff\",\"Url\":\"ff\",\"ParentName\":\"\",\"Icon\":\"ff\",\"MenuType\":\"\"},{\"id\":\"1\",\"MenuName\":\"日\",\"Url\":\"1\",\"_parentId\":\"2\",\"ParentName\":\"\",\"Icon\":\"2\",\"MenuType\":\"\"}]}";
            return(Content(strJson));
        }
Exemple #16
0
 /// <summary>
 /// 返回失败JSON,但是不包含:操作失败等字样;该方法比较干净,参数是什么就返回什么
 /// </summary>
 /// <param name="FailNotice"></param>
 /// <returns></returns>
 public static string FailStringNohaveOther(string FailNotice)
 {
     JsonHelper json = new JsonHelper();
     json.totlal = 0;
     json.success = false;
     FailNotice = Regex.Replace(FailNotice, @"\r\n", " ");
     json.AddItem("info", FailNotice.Replace("/", "").Replace("\"", "'"));
     json.ItemOk();
     return json.ToString();
 }
        public ActionResult QueryData()
        {
            int     page    = Request.Form["page"] != "" ? Convert.ToInt32(Request.Form["page"]) : 0;
            int     size    = Request.Form["rows"] != "" ? Convert.ToInt32(Request.Form["rows"]) : 0;
            string  sort    = Request.Form["sort"] != "" ? Request.Form["sort"] : "";
            string  order   = Request.Form["order"] != "" ? Request.Form["order"] : "";
            string  Name    = Request.Form["Name"] != null ? Request.Form["Name"] : "";
            SysRole sysRole = new SysRole()
            {
                Name = Name
            };

            if (page < 1)
            {
                return(Content(""));
            }
            var lstSysRole = SysRoleDao.Instance.LoadPageList(page, size, sysRole).ToList();

            JsonHelper json    = new JsonHelper();
            string     strJson = string.Empty;

            foreach (SysRole item in lstSysRole)
            {
                json.AddItem("ID", item.ID.ToString());
                json.AddItem("Name", item.Name);
                json.AddItem("Description", item.Description == null ? string.Empty : item.Description);
                //item.RoleNames = SysRoleServices.GetRoleNames(item.ID);
                //json.AddItem("RoleNames", item.RoleNames);
                json.ItemOk();
            }

            json.totlalCount = SysRoleDao.Instance.GetTotalCount(sysRole);
            if (json.totlalCount > 0)
            {
                strJson = json.ToEasyuiGridJsonString();
            }
            else
            {
                strJson = @"[]";
            }
            // json = "{ \"rows\":[ { \"ID\":\"48\",\"NewsTitle\":\"mr\",\"NewsContent\":\"mrsoft\",\"CreateTime\":\"2013-12-23\",\"CreateRole\":\"ceshi\",\"ModifyTime\":\"2013-12-23\",\"ModifyRole\":\"ceshi\"} ],\"total\":3}";
            return(Content(strJson));
        }
Exemple #18
0
 /// <summary>
 /// 查询数据
 /// </summary>
 public ActionResult QueryData()
 {
     //List<ExamPlace> lstExamPlace = new List<ExamPlace>();
     //short shRet = SystemContext.Instance.ExamPlaceServices.GetExamPlaceList("", "", "", ref lstExamPlace);
     try
     {
         var        lstExamPlace = EnterRepository.GetRepositoryEnter().ExamPlaceRepository.LoadEntities().ToList();
         JsonHelper json         = new JsonHelper();
         string     strJson      = string.Empty;
         foreach (ExamPlace item in lstExamPlace)
         {
             if (item.ParentID != 0)
             {
                 var parent = lstExamPlace.Find(m => m.ID == item.ParentID);
                 if (parent != null)
                 {
                     item.ParentName = parent.PlaceName;
                 }
             }
             json.AddItem("id", item.ID.ToString());
             json.AddItem("name", item.PlaceName);
             json.AddItem("pid", item.ParentID.ToString());
             //json.AddItem("NewsContent", item.NewsContent);
             json.AddItem("ParentName", item.ParentName);
             json.AddItem("Description", item.Description);
             json.ItemOk();
         }
         if (lstExamPlace.Count > 0)
         {
             strJson = json.ToEasyuiListJsonString();
         }
         else
         {
             strJson = @"[]";
         }
         // json = "{ \"rows\":[ { \"ID\":\"48\",\"NewsTitle\":\"mr\",\"NewsContent\":\"mrsoft\",\"CreateTime\":\"2013-12-23\",\"CreateUser\":\"ceshi\",\"ModifyTime\":\"2013-12-23\",\"ModifyUser\":\"ceshi\"} ],\"total\":3}";
         return(Content(strJson));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemple #19
0
 /// <summary>
 /// 返回失败JSON字符串
 /// </summary>
 /// <param name="FailNotice"></param>
 /// <returns></returns>
 public static string FailString(string FailNotice)
 {
     JsonHelper json = new JsonHelper();
     json.totlal = 0;
     json.success = false;
     FailNotice = Regex.Replace(FailNotice, @"\r\n", " ");
     json.AddItem("info", NoticeEnum.GetEnumDesc(NoticeEnum.NOTICE.FAILSURE) + ",可能原因为:" + FailNotice.Replace("/", "").Replace("\"", "'"));
     json.ItemOk();
     return json.ToString();
 }
Exemple #20
0
        public ActionResult GetEmpList()
        {
            List <Employee> lstEmployee = new List <Employee>();
            short           shRet       = SystemContext.Instance.EmployeeService.GetEmployeeList("", "", "", ref lstEmployee);
            JsonHelper      json        = new JsonHelper();

            foreach (Employee item in lstEmployee)
            {
                json.AddItem("ID", item.ID);
                json.AddItem("EmpNo", item.EmpNo);
                json.AddItem("Name", item.Name);
                json.ItemOk();
            }

            json.totlalCount = lstEmployee.Count;
            string strJson = json.ToEasyuiGridJsonString();

            return(Content(strJson));
        }
Exemple #21
0
        /// <summary>
        /// 获取指定ID的数据
        /// </summary>
        public ActionResult QueryOneData()
        {
            string     id      = Request.Form["id"] != "" ? Request.Form["id"] : "0";
            ExamPlace  item    = new ExamPlace();
            short      shRet   = SystemContext.Instance.ExamPlaceServices.GetExamPlaceByID(id, ref item);
            JsonHelper json    = new JsonHelper();
            string     strJson = string.Empty;

            if (shRet == ExecuteResult.OK)
            {
                json.AddItem("ID", item.ID.ToString());
                json.AddItem("PlaceName", item.PlaceName);
                json.AddItem("ParentID", item.ParentID);
                json.AddItem("ParentName", item.ParentName);
                json.AddItem("Description", item.Description);
                json.ItemOk();
            }
            strJson = json.ToEasyuiListJsonString();
            return(Content(strJson));
        }
Exemple #22
0
 /// <summary>
 /// 查询数据
 /// </summary>
 public ActionResult QueryData()
 {
     try
     {
         var        lstOrgnization = EnterRepository.GetRepositoryEnter().OrgnizationRepository.LoadEntities().ToList();
         JsonHelper json           = new JsonHelper();
         string     strJson        = string.Empty;
         foreach (Orgnization item in lstOrgnization)
         {
             json.AddItem("id", item.ID.ToString());
             json.AddItem("name", item.OrgName);
             json.AddItem("pid", item.ParentID.ToString());
             if (item.ParentID != 0)
             {
                 var org = lstOrgnization.Find(m => m.ID == item.ParentID);
                 if (org != null)
                 {
                     item.ParentName = org.OrgName;
                 }
             }
             json.AddItem("ParentName", item.ParentName);
             json.AddItem("Description", item.Description);
             json.ItemOk();
         }
         if (lstOrgnization.Count() > 0)
         {
             strJson = json.ToEasyuiListJsonString();
         }
         else
         {
             strJson = @"[]";
         }
         // json = "{ \"rows\":[ { \"ID\":\"48\",\"NewsTitle\":\"mr\",\"NewsContent\":\"mrsoft\",\"CreateTime\":\"2013-12-23\",\"CreateUser\":\"ceshi\",\"ModifyTime\":\"2013-12-23\",\"ModifyUser\":\"ceshi\"} ],\"total\":3}";
         return(Content(strJson));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemple #23
0
        public ActionResult QueryEmployeeIDs()
        {
            Employee CurrentEmployee = Session["CurrentEmployee"] as Employee;

            if (CurrentEmployee == null)
            {
                return(RedirectToAction("Admin/Home/Login"));
            }
            JsonHelper json    = new JsonHelper();
            string     strJson = string.Empty;

            json.AddItem("id", "");
            json.AddItem("text", "所有");
            json.ItemOk();
            if (CurrentEmployee.RoleType == SystemContext.RoleType.School)
            {
                json.AddItem("id", CurrentEmployee.ID.ToString());
                json.AddItem("text", CurrentEmployee.Name);
                json.ItemOk();
            }
            else
            {
                List <Employee> lstEmployee = new List <Employee>();
                this.GetEmployeeIDs(CurrentEmployee, ref lstEmployee);
                foreach (Employee item in lstEmployee)
                {
                    json.AddItem("id", item.ID.ToString());
                    json.AddItem("text", item.Name);
                    json.ItemOk();
                }
            }
            strJson = json.ToEasyuiListJsonString();
            return(Content(strJson));
        }
Exemple #24
0
        public ActionResult GetGridList()
        {
            int    page  = Request.Form["page"] != "" ? Convert.ToInt32(Request.Form["page"]) : 0;
            int    size  = Request.Form["rows"] != "" ? Convert.ToInt32(Request.Form["rows"]) : 0;
            string sort  = Request.Form["sort"] != "" ? Request.Form["sort"] : "";
            string order = Request.Form["order"] != "" ? Request.Form["order"] : "";

            if (page < 1)
            {
                return(Content(""));
            }
            var result = EnterRepository.GetRepositoryEnter().MenuRepository.GetPageMenuList().ToList();

            //List<Menus> lstMenus = new List<Menus>();
            //short shRet = SystemContext.Instance.MenuServices.GetMenuPageList(size, page, "", ref lstMenus);
            JsonHelper json    = new JsonHelper();
            string     strJson = string.Empty;

            foreach (Menu item in result)
            {
                json.AddItem("id", item.ID.ToString());
                json.AddItem("MenuName", item.MenuName);
                json.AddItem("Url", item.Url);
                if (item.ParentID != 0)
                {
                    json.AddItem("_parentId", item.ParentID.ToString());
                }
                json.AddItem("ParentName", item.ParentName);
                json.AddItem("Icon", item.Icon);
                json.AddItem("MenuType", item.MenuType);
                json.AddItem("Description", item.Description);
                json.ItemOk();
            }
            int totalCount = 0;

            //short shRet = SystemContext.Instance.MenuServices.GetMenuTotalCount("", ref totalCount);
            json.totlalCount = result.Count();
            if (json.totlalCount > 0)
            {
                strJson = json.ToEasyuiGridJsonString();
            }
            else
            {
                strJson = @"[]";
            }
            // json = "{ \"rows\":[ { \"ID\":\"48\",\"NewsTitle\":\"mr\",\"NewsContent\":\"mrsoft\",\"CreateTime\":\"2013-12-23\",\"CreateUser\":\"ceshi\",\"ModifyTime\":\"2013-12-23\",\"ModifyUser\":\"ceshi\"} ],\"total\":3}";
            //strJson = "{\"total\":2,\"rows\":[{\"id\":\"2\",\"MenuName\":\"ff\",\"Url\":\"ff\",\"ParentName\":\"\",\"Icon\":\"ff\",\"MenuType\":\"\"},{\"id\":\"1\",\"MenuName\":\"日\",\"Url\":\"1\",\"_parentId\":\"2\",\"ParentName\":\"\",\"Icon\":\"2\",\"MenuType\":\"\"}]}";
            return(Content(strJson));
        }
        /// <summary>
        /// 查询数据
        /// </summary>
        public ActionResult QueryBuyData()
        {
            int page = Request.Form["page"] != "" ? Convert.ToInt32(Request.Form["page"]) : 0;
            int size = Request.Form["rows"] != "" ? Convert.ToInt32(Request.Form["rows"]) : 0;
            string sort = Request.Form["sort"] != "" ? Request.Form["sort"] : "";
            string order = Request.Form["order"] != "" ? Request.Form["order"] : "";
            if (page < 1) return Content("");

            IList<BuyInfo> lstBuyInfos = BuyInfoDao.Instance.GetPageBuyInfos(page, size, null);
            JsonHelper json = new JsonHelper();
            string strJson = string.Empty;
            foreach (var item in lstBuyInfos)
            {
                json.AddItem("ID", item.ID.ToString());
                json.AddItem("Name", item.Name == null ? "" : item.Name);
                json.AddItem("Place", item.Place == null ? "" : item.Place);
                json.AddItem("Price", item.Price.ToString());
                json.AddItem("Product", item.Product.ToString());
                json.AddItem("SubTime", item.SubTime.ToString());
                json.AddItem("SitePath", item.SitePath == null ? "" : item.SitePath);
                json.AddItem("Tel", item.Tel == null ? "" : item.Tel.ToString());
                json.ItemOk();
            }
            int totalCount = BuyInfoDao.Instance.GetTotalCount(null);
            json.totlalCount = totalCount;
            if (json.totlalCount > 0)
            {
                strJson = json.ToEasyuiGridJsonString();
            }
            else
            {
                strJson = @"[]";
            }
            // json = "{ \"rows\":[ { \"ID\":\"48\",\"NewsTitle\":\"mr\",\"NewsContent\":\"mrsoft\",\"CreateTime\":\"2013-12-23\",\"CreateUser\":\"ceshi\",\"ModifyTime\":\"2013-12-23\",\"ModifyUser\":\"ceshi\"} ],\"total\":3}";
            return Content(strJson);
        }
Exemple #26
0
 /// <summary>
 /// 获取指定ID的数据
 /// </summary>
 public ActionResult QueryOneData()
 {
     try
     {
         int        id      = Request.Form["id"] != "" ? int.Parse(Request.Form["id"]) : 0;
         var        item    = EnterRepository.GetRepositoryEnter().DrugRepository.LoadEntities(m => m.ID == id).FirstOrDefault();
         JsonHelper json    = new JsonHelper();
         string     strJson = string.Empty;
         if (item != null)
         {
             json.AddItem("ID", item.ID.ToString());
             json.AddItem("Name", item.Name);
             json.AddItem("PageNumber", item.PageNumber.ToString());
             json.ItemOk();
         }
         strJson = json.ToEasyuiOneModelJsonString();
         return(Content(strJson));
     }
     catch (Exception ex)
     {
         GlobalMethod.log.Error(ex);
         throw;
     }
 }
Exemple #27
0
        /// <summary>
        /// 查询数据
        /// </summary>
        public ActionResult QueryData()
        {
            try
            {
                int    page    = Request.Form["page"] != "" ? Convert.ToInt32(Request.Form["page"]) : 0;
                int    size    = Request.Form["rows"] != "" ? Convert.ToInt32(Request.Form["rows"]) : 0;
                string Message = Request.Form["Message"];
                string sort    = Request.Form["sort"] != "" ? Request.Form["sort"] : "";
                string order   = Request.Form["order"] != "" ? Request.Form["order"] : "";
                if (page < 1)
                {
                    return(Content(""));
                }

                int totalCount = 0;
                var lstDemand  = EnterRepository.GetRepositoryEnter().LogRepository.LoadPageList(Message, (page - 1) * size, size, out totalCount).ToList();

                JsonHelper json    = new JsonHelper();
                string     strJson = string.Empty;
                foreach (Log item in lstDemand)
                {
                    json.AddItem("ID", item.ID.ToString());
                    json.AddItem("Thread", item.Thread);
                    json.AddItem("Level", item.Level);
                    json.AddItem("Logger", item.Logger.ToString());
                    json.AddItem("Date", item.Date.ToString());
                    json.AddItem("Message", item.Message == null?"":item.Message.Replace("\r\n", "").Replace("\\", "/"));
                    json.AddItem("Exception", item.Exception == null?"": item.Exception.Replace("\r\n", "").Replace("\r", "").Replace("\\", "/"));
                    if (item.ID == 4558)
                    {
                        string s = "2";
                    }
                    json.ItemOk();
                }
                json.totlalCount = totalCount;
                if (json.totlalCount > 0)
                {
                    strJson = json.ToEasyuiGridJsonString();
                }
                else
                {
                    strJson = @"[]";
                }
                // json = "{ \"rows\":[ { \"ID\":\"48\",\"NewsTitle\":\"mr\",\"NewsContent\":\"mrsoft\",\"CreateTime\":\"2013-12-23\",\"CreateUser\":\"ceshi\",\"ModifyTime\":\"2013-12-23\",\"ModifyUser\":\"ceshi\"} ],\"total\":3}";
                return(Content(strJson));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemple #28
0
        public ActionResult QueryData()
        {
            try
            {
                int    page  = Request.Form["page"] != "" ? Convert.ToInt32(Request.Form["page"]) : 0;
                int    size  = Request.Form["rows"] != "" ? Convert.ToInt32(Request.Form["rows"]) : 0;
                string sort  = Request.Form["sort"] != "" ? Request.Form["sort"] : "";
                string order = Request.Form["order"] != "" ? Request.Form["order"] : "";
                string Name  = Request.Form["Name"] != null ? Request.Form["Name"] : "";
                string Tel   = Request.Form["Tel"] != null ? Request.Form["Tel"] : "";
                if (page < 1)
                {
                    return(Content(""));
                }

                int totalCount = 0;

                var        lstEmployee = EnterRepository.GetRepositoryEnter().EmployeeRepository.LoadPageList(Name, Tel, (page - 1) * size, size, out totalCount).ToList();
                JsonHelper json        = new JsonHelper();
                string     strJson     = string.Empty;
                foreach (Employee item in lstEmployee)
                {
                    json.AddItem("ID", item.ID.ToString());
                    json.AddItem("EmpNo", item.EmpNo);
                    json.AddItem("Pwd", item.Pwd);
                    json.AddItem("Name", item.Name);
                    json.AddItem("Tel", item.Tel);
                    item.RoleNames = EmployeeServices.GetRoleNames(item.ID);
                    json.AddItem("RoleNames", item.RoleNames);
                    json.ItemOk();
                }

                json.totlalCount = totalCount;
                if (json.totlalCount > 0)
                {
                    strJson = json.ToEasyuiGridJsonString();
                }
                else
                {
                    strJson = @"[]";
                }
                // json = "{ \"rows\":[ { \"ID\":\"48\",\"NewsTitle\":\"mr\",\"NewsContent\":\"mrsoft\",\"CreateTime\":\"2013-12-23\",\"CreateUser\":\"ceshi\",\"ModifyTime\":\"2013-12-23\",\"ModifyUser\":\"ceshi\"} ],\"total\":3}";
                return(Content(strJson));
            }
            catch (Exception ex)
            {
                GlobalMethod.log.Error(ex);
                throw;
            }
        }
Exemple #29
0
        /// <summary>
        /// 查询数据
        /// </summary>
        public ActionResult QueryData()
        {
            int    page  = Request.Form["page"] != "" ? Convert.ToInt32(Request.Form["page"]) : 0;
            int    size  = Request.Form["rows"] != "" ? Convert.ToInt32(Request.Form["rows"]) : 0;
            string sort  = Request.Form["sort"] != "" ? Request.Form["sort"] : "";
            string order = Request.Form["order"] != "" ? Request.Form["order"] : "";

            if (page < 1)
            {
                return(Content(""));
            }

            List <News> lstNews = new List <News>();
            short       shRet   = SystemContext.Instance.NewsService.GetNewsPageList(size, page, "", ref lstNews);
            JsonHelper  json    = new JsonHelper();
            string      strJson = string.Empty;

            foreach (News item in lstNews)
            {
                json.AddItem("ID", item.ID.ToString());
                json.AddItem("NewsTitle", item.NewsTitle);
                json.AddItem("CategoryName", item.CategoryName);
                //json.AddItem("NewsContent", item.NewsContent);
                json.AddItem("CreateTime", item.CreateTime.ToString());
                json.AddItem("CreateUser", item.CreateUser);
                json.AddItem("ModifyTime", item.ModifyTime.ToString());
                json.AddItem("ModifyUser", item.ModifyUser);
                json.ItemOk();
            }
            int totalCount = 0;

            shRet            = SystemContext.Instance.NewsService.GetNewsTotalCount("", ref totalCount);
            json.totlalCount = totalCount;
            if (json.totlalCount > 0)
            {
                strJson = json.ToEasyuiGridJsonString();
            }
            else
            {
                strJson = @"[]";
            }
            // json = "{ \"rows\":[ { \"ID\":\"48\",\"NewsTitle\":\"mr\",\"NewsContent\":\"mrsoft\",\"CreateTime\":\"2013-12-23\",\"CreateUser\":\"ceshi\",\"ModifyTime\":\"2013-12-23\",\"ModifyUser\":\"ceshi\"} ],\"total\":3}";
            return(Content(strJson));
        }
Exemple #30
0
 /// <summary>
 /// 查询数据
 /// </summary>
 public ActionResult QueryData()
 {
     try
     {
         int    page    = Request.Form["page"] != "" ? Convert.ToInt32(Request.Form["page"]) : 0;
         int    size    = Request.Form["rows"] != "" ? Convert.ToInt32(Request.Form["rows"]) : 0;
         string Message = Request.Form["Message"];
         string sort    = Request.Form["sort"] != "" ? Request.Form["sort"] : "";
         string order   = Request.Form["order"] != "" ? Request.Form["order"] : "";
         if (page < 1)
         {
             return(Content(""));
         }
         SysLog syslog = new SysLog()
         {
             Message = Message
         };
         int totalCount = 0;
         var lstDemand  = IBatisAccess.SysLogDao.Instance.LoadPageList(page, size, syslog);
         totalCount = IBatisAccess.SysLogDao.Instance.GetTotalCount(syslog);
         JsonHelper json    = new JsonHelper();
         string     strJson = string.Empty;
         foreach (SysLog item in lstDemand)
         {
             json.AddItem("Thread", item.Thread);
             json.AddItem("Level", item.LogLevel);
             json.AddItem("Logger", item.Logger.ToString());
             json.AddItem("LogDate", item.LogDate.ToString());
             json.AddItem("Message", item.Message == null?"":item.Message.Replace("\r\n", "").Replace("\\", "/"));
             json.AddItem("Exception", item.Exception == null?"": item.Exception.Replace("\r\n", "").Replace("\\", "/"));
             json.ItemOk();
         }
         json.totlalCount = totalCount;
         if (json.totlalCount > 0)
         {
             strJson = json.ToEasyuiGridJsonString();
         }
         else
         {
             strJson = @"[]";
         }
         // json = "{ \"rows\":[ { \"ID\":\"48\",\"NewsTitle\":\"mr\",\"NewsContent\":\"mrsoft\",\"CreateTime\":\"2013-12-23\",\"CreateUser\":\"ceshi\",\"ModifyTime\":\"2013-12-23\",\"ModifyUser\":\"ceshi\"} ],\"total\":3}";
         return(Content(strJson));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
        public ActionResult GetGridList()
        {
            string       sort           = Request.Form["sort"] != "" ? Request.Form["sort"] : "";
            string       order          = Request.Form["order"] != "" ? Request.Form["order"] : "";
            string       SearchParentID = string.IsNullOrEmpty(Request.Form["SearchParentID"]) ?"0" : Request.Form["SearchParentID"];
            SysParameter sysparameter   = new SysParameter();

            sysparameter.ParentID = int.Parse(SearchParentID);
            var result = IBatisAccess.SysParameterDao.Instance.GetSysParameters(sysparameter).ToList();

            JsonHelper json    = new JsonHelper();
            string     strJson = string.Empty;

            foreach (SysParameter item in result)
            {
                json.AddItem("id", item.ID.ToString());
                json.AddItem("Name", item.Name);
                json.AddItem("Code", item.Code);
                json.AddItem("Value", item.Value);
                if (item.ParentID != 0 && item.ParentID != sysparameter.ParentID)
                {
                    json.AddItem("_parentId", item.ParentID.ToString());
                }
                json.AddItem("ParentName", item.ParentName);
                json.AddItem("Description", item.Description == null?"":item.Description.Replace("\"", ""));
                json.ItemOk();
            }
            int totalCount = 0;

            //short shRet = SystemContext.Instance.MenuServices.GetMenuTotalCount("", ref totalCount);
            json.totlalCount = result.Count();
            if (json.totlalCount > 0)
            {
                strJson = json.ToEasyuiGridJsonString();
            }
            else
            {
                strJson = @"[]";
            }
            // json = "{ \"rows\":[ { \"ID\":\"48\",\"NewsTitle\":\"mr\",\"NewsContent\":\"mrsoft\",\"CreateTime\":\"2013-12-23\",\"CreateUser\":\"ceshi\",\"ModifyTime\":\"2013-12-23\",\"ModifyUser\":\"ceshi\"} ],\"total\":3}";
            //strJson = "{\"total\":2,\"rows\":[{\"id\":\"2\",\"MenuName\":\"ff\",\"Url\":\"ff\",\"ParentName\":\"\",\"Icon\":\"ff\",\"MenuType\":\"\"},{\"id\":\"1\",\"MenuName\":\"日\",\"Url\":\"1\",\"_parentId\":\"2\",\"ParentName\":\"\",\"Icon\":\"2\",\"MenuType\":\"\"}]}";
            return(Content(strJson));
        }
Exemple #32
0
        public ActionResult QueryOneData()
        {
            string     id      = Request.Form["id"] != "" ? Request.Form["id"] : "0";
            Menus      item    = new Menus();
            short      shRet   = SystemContext.Instance.MenuServices.GetMenuByID(id, ref item);
            JsonHelper json    = new JsonHelper();
            string     strJson = string.Empty;

            if (shRet == ExecuteResult.OK)
            {
                json.AddItem("ID", item.ID.ToString());
                json.AddItem("MenuName", item.MenuName);
                json.AddItem("Url", item.Url);
                json.AddItem("ParentID", item.ParentID);
                json.AddItem("ParentName", item.ParentName);
                json.AddItem("Icon", item.Icon);
                json.AddItem("Description", item.Description);
                json.AddItem("MenuType", item.MenuType);
                json.ItemOk();
            }
            strJson = json.ToEasyuiOneModelJsonString();
            // strJson = "[{\"ID\":\"81\",\"EmpNo\":\"jxdhlgljp\",\"Name\":\"hello\",\"Pwd\":\"111111\",\"Tel\":\"18720081979\"}]";
            return(Content(strJson));
        }
Exemple #33
0
        public ActionResult QueryData()
        {
            int     page    = Request.Form["page"] != "" ? Convert.ToInt32(Request.Form["page"]) : 0;
            int     size    = Request.Form["rows"] != "" ? Convert.ToInt32(Request.Form["rows"]) : 0;
            string  sort    = Request.Form["sort"] != "" ? Request.Form["sort"] : "";
            string  order   = Request.Form["order"] != "" ? Request.Form["order"] : "";
            string  Name    = Request.Form["Name"] != null ? Request.Form["Name"] : "";
            string  Tel     = Request.Form["Tel"] != null ? Request.Form["Tel"] : "";
            SysUser sysUser = new SysUser()
            {
                Name = Name, Tel = Tel
            };

            if (page < 1)
            {
                return(Content(""));
            }
            var lstSysUser = SysUserDao.Instance.LoadPageList(page, size, sysUser).ToList();

            JsonHelper json    = new JsonHelper();
            string     strJson = string.Empty;

            foreach (SysUser item in lstSysUser)
            {
                json.AddItem("ID", item.ID.ToString());
                json.AddItem("LoginName", item.LoginName);
                json.AddItem("Password", item.Password);
                json.AddItem("Name", item.Name);
                json.AddItem("Tel", item.Tel);
                item.RoleNames = SysUserServices.GetRoleNames(item.ID);
                json.AddItem("RoleNames", item.RoleNames);
                json.ItemOk();
            }

            json.totlalCount = SysUserDao.Instance.GetTotalCount(sysUser);
            if (json.totlalCount > 0)
            {
                strJson = json.ToEasyuiGridJsonString();
            }
            else
            {
                strJson = @"[]";
            }
            return(Content(strJson));
        }
Exemple #34
0
        public ActionResult QueryEmployeeIDs()
        {
            try
            {
                if (!WebCookieHelper.EmployeeCheckLogin())
                {
                    return(RedirectToAction("Admin/Account/Login"));
                }
                JsonHelper json    = new JsonHelper();
                string     strJson = string.Empty;
                json.AddItem("id", "");
                json.AddItem("text", "所有");
                json.ItemOk();

                int    empid = WebCookieHelper.GetEmployeeId();
                string Name  = WebCookieHelper.GetEmployeeInfo((int)WebCookieHelper.EmployeeInfo.Name);
                if (!RightServices.CheckAuthority(SystemContext.RightPoint.ViewAllUsers, empid))
                {
                    json.AddItem("id", empid.ToString());
                    json.AddItem("text", Name);
                    json.ItemOk();
                }
                else
                {
                    var result = UsersServices.GetStaffEmployee(empid);
                    foreach (Employee item in result)
                    {
                        json.AddItem("id", item.ID.ToString());
                        json.AddItem("text", item.Name);
                        json.ItemOk();
                    }
                }
                strJson = json.ToEasyuiListJsonString();
                return(Content(strJson));
            }
            catch (Exception ex)
            {
                GlobalMethod.log.Error(ex);
                throw;
            }
        }
Exemple #35
0
        /// <summary>
        /// 返回分页后的JSON字符串
        /// </summary>
        /// <param name="SelectColumns">将展示的字段</param>
        /// <param name="KeyID">主键ID</param>
        /// <param name="TableName">表名</param>
        /// <param name="strWhere">条件查询</param>
        /// <param name="strOrder">排序</param>
        /// <param name="DBConn">数据库连接</param>
        /// <param name="start"></param>
        /// <param name="limit"></param>
        /// <param name="isDistinct">过滤重复值</param>
        /// <returns></returns>
        public static string GetPageMethod(string SelectColumns, string KeyID, string TableName, string strWhere, string strOrder, int start, int limit, bool isDistinct)
        {
            #region 参数判定
            if (string.IsNullOrEmpty(SelectColumns)) { return "{total:1,success:true,error:'',data:[{'info':'执行分页方法错误,原因为:缺失参数:SelectColumns!'}]}"; }
            if (string.IsNullOrEmpty(KeyID)) { return "{total:1,success:true,error:'',data:[{'info':'执行分页方法错误,原因为:缺失参数:KeyID!'}]}"; }
            if (string.IsNullOrEmpty(TableName)) { return "{total:1,success:true,error:'',data:[{'info':'执行分页方法错误,原因为:缺失参数:TableName!'}]}"; }
            if (string.IsNullOrEmpty(start.ToString())) { return "{total:1,success:true,error:'',data:[{'info':'执行分页方法错误,原因为:缺失参数:start!'}]}"; }
            if (string.IsNullOrEmpty(limit.ToString())) { return "{total:1,success:true,error:'',data:[{'info':'执行分页方法错误,原因为:缺失参数:limit!'}]}"; }
            #endregion
            try
            {

                StringBuilder strSql = new StringBuilder();
                strSql.Append("select " + (isDistinct ? "distinct" : string.Empty) + " top {0} {2} ");
                strSql.Append(" FROM {4} ");
                strSql.Append(" where {3} not in (select " + (isDistinct ? "distinct" : string.Empty) + " top {1} {3} from {4} {7} {6} ) {5} {6};");
                string sql = strSql.ToString();
                strWhere = strWhere.Trim();

                if (!string.IsNullOrEmpty(strOrder))
                {
                    strOrder = " order by " + strOrder;
                }

                if (KeyID.Equals(string.Empty))
                {
                    KeyID = DataSource.Query("Execute sp_pkeys '" + TableName + "'").Tables[0].Rows[0]["PK_NAME"].ToString();
                }
                if (strWhere.ToLower().IndexOf("and") == 0)
                {
                    strWhere = strWhere.Substring(strWhere.IndexOf("and") + 3);
                }
                sql = string.Format(sql, limit, start, SelectColumns, KeyID, TableName, strWhere.Equals(string.Empty) ? string.Empty : " and " + strWhere, strOrder, strWhere.Equals(string.Empty) ? string.Empty : " where " + strWhere);

                DataTable dt = DataSource.Query(sql).Tables[0];

                JsonHelper json = new JsonHelper();
                json.totlal = 0;
                json.success = true;
                if (dt.Rows.Count > 0)
                {
                    int totalCount = 0;
                    string sqlCount = "select count(" + (isDistinct ? "distinct" : string.Empty) + " {0}) as cou from {1} {2}";
                    if (!string.IsNullOrEmpty(strWhere))
                    {
                        strWhere = " where  " + strWhere;
                    }
                    sqlCount = string.Format(sqlCount, KeyID, TableName, strWhere);
                    object obj = DataSource.Query(sqlCount).Tables[0].Rows[0]["cou"];
                    if (obj != null) totalCount = int.Parse(obj.ToString());

                    json.totlal = totalCount;
                    json.success = true;
                    foreach (DataRow dr in dt.Rows)
                    {
                        foreach (DataColumn dc in dt.Columns)
                        {
                            json.AddItem(dc.ColumnName.ToString(), dr[dc.ColumnName].ToString().Replace("\"", "\\\"").Replace("\r", "").Replace("\n", ""));
                        }
                        json.ItemOk();
                    }
                }
                return json.ToString();
            }
            catch (Exception error) { return "{total:1,success:true,error:'',data:[{'info':'执行分页方法错误,原因为:" + error.Message + "'}]}"; }
        }