public ActionResult getCategory(int?year)
        {
            if (year == null)
            {
                year = DateTime.Now.Year;
            }
            CategoryDao dao      = new CategoryDao();
            var         category = dao.getAll(null).ToList();

            dao.Dispose();
            if (category.Count == 0)
            {
                throw new ApplicationException("信访类别为空");
            }
            List <ChartData> list = new List <ChartData>();
            PetitionDao      dao2 = new PetitionDao();

            foreach (var item in category)
            {
                ChartData chart = new ChartData();
                chart.name  = item.Name;
                chart.value = dao2.getCountByCategoryAndYear(item.Id, year.Value);
                list.Add(chart);
            }
            dao2.Dispose();
            return(Json(list, JsonRequestBehavior.AllowGet));
        }
        public ActionResult getxAxis(int?type)
        {
            if (type == null)
            {
                throw new ApplicationException("统计类型不正确");
            }
            List <string> list = new List <string>();

            if (type == StatisticsType.County)      //县区
            {
                CountyDao dao = new CountyDao();
                list = dao.getByLevel((int)Level.County).Select(t => t.Name).ToList();
                dao.Dispose();
            }
            else if (type == StatisticsType.Category)     //类别
            {
                CategoryDao dao = new CategoryDao();
                list = dao.getAll(null).Select(t => t.Name).ToList();
                dao.Dispose();
            }
            else
            {
                throw new ApplicationException("未知类型");
            }
            return(Json(list, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        /// <summary>
        /// 类别下拉表数据
        /// </summary>
        /// <returns></returns>
        public ActionResult GetCategorySelect()
        {
            CategoryDao     dao  = new CategoryDao();
            List <Category> list = dao.getAll(null);

            dao.Dispose();
            return(Json(list, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public ActionResult getCategoryList()
        {
            CategoryDao     dao  = new CategoryDao();
            List <Category> list = dao.getAll(null);

            dao.Dispose();
            JsonData data = new JsonData();

            data.rows  = list;
            data.total = list.Count;
            return(Json(data));
        }
Beispiel #5
0
        public ActionResult DeleteCategoryPost(int Id)
        {
            MyJsonResult result = new MyJsonResult();

            if (Id == 0)
            {
                result.message = "请选择要删除的类别";
                return(Json(result));
            }
            CategoryDao dao = new CategoryDao();

            dao.remove(Id);
            dao.Dispose();
            result.success = true;
            return(Json(result));
        }
Beispiel #6
0
        public ActionResult CreateCategoryPost(Category model)
        {
            MyJsonResult result = new MyJsonResult();

            if (model == null)
            {
                result.message = "请填写类别";
                return(Json(result));
            }
            CategoryDao dao = new CategoryDao();

            dao.addOrUpdate(model);
            dao.Dispose();
            result.success = true;
            return(Json(result));
        }