Exemple #1
0
        public ActionResult Edit(int?id, int?p)
        {
            Dept entity;

            if (!id.HasValue)
            {
                entity = new Dept {
                    Sort = 99
                };

                if (p.HasValue)
                {
                    entity.ParentId = (int)p;
                    var children = DeptUtil.All().Where(d => d.ParentId == p).ToList();
                    entity.Sort = !children.Any() ? 1 : children.Max(c => c.Sort) + 1;
                }
            }
            else
            {
                entity = _service.Load((int)id);
                if (entity == null)
                {
                    return(new EmptyResult());
                }
            }
            InitUi();
            return(View(entity));
        }
Exemple #2
0
        private void InitUi()
        {
            var dept      = DeptUtil.All();
            var listItems = new List <SelectListItem>();

            foreach (var d in dept)
            {
                listItems.Add(new SelectListItem {
                    Text = ShowName(d.Name, d.Level), Value = d.Id.ToString()
                });
            }
            ViewBag.Parents = listItems;

            string ShowName(string txt, int level)
            {
                var str = "";

                if (level > 1)
                {
                    for (var i = 0; i < level; i++)
                    {
                        str += HttpUtility.HtmlDecode("&nbsp;&nbsp;");
                    }
                    str += "|- " + txt;
                }
                else
                {
                    str = txt;
                }

                return(str);
            }
        }
Exemple #3
0
        /// <summary>
        /// 获取月汇总数据
        /// </summary>
        /// <param name="year"></param>
        /// <param name="deptId"></param>
        /// <returns></returns>
        public JsonResult GetSalerMonthData(int year, int deptId)
        {
            var data = reportService.SalerMonthSummary(year, deptId);

            ViewBag.Depts = DeptUtil.All().ToSelectList("Id", "Name", deptId.ToString());
            return(Json(data));
        }
Exemple #4
0
        private void InitUI()
        {
            var year = DateTime.Today.Year;

            List <SelectListItem> years = new List <SelectListItem>();

            for (int i = year - 3; i <= year + 1; i++)
            {
                years.Add(new SelectListItem {
                    Text = i.ToString() + "年", Value = i.ToString()
                });
            }
            ViewBag.Years = years;

            List <SelectListItem> months = new List <SelectListItem>();

            for (int i = 1; i <= 12; i++)
            {
                months.Add(new SelectListItem {
                    Text = i.ToString() + "月", Value = i.ToString()
                });
            }
            ViewBag.Months = months;

            ViewBag.Depts = DeptUtil.All().ToSelectList("Id", "Name");
        }
Exemple #5
0
        public IActionResult Edit(int id)
        {
            var entity = service.Load(id);

            if (entity == null)
            {
                return(Empty());
            }

            var salerService = new SalerService();
            var saler        = salerService.Load(entity.SalerId);

            if (saler == null)
            {
                return(Content("无效数据"));
            }

            var dept = DeptUtil.All().Where(d => d.Id == entity.DeptId).SingleOrDefault();

            if (dept == null)
            {
                return(Content("无效数据"));
            }

            ViewBag.Title = string.Format("[{0}-{1}][{2}]{3}", entity.Year, entity.Month, dept.Name, saler.Name);

            return(View(entity));
        }
Exemple #6
0
        private void InitUI()
        {
            var jobs = DataItemUtil.GetValues("Jobs").ToSelectList();

            ViewBag.Jobs = jobs;

            ViewBag.Depts = DeptUtil.All().ToSelectList("Id", "Name");
        }
        private void InitUI(int?year)
        {
            var currentYear = DateTime.Today.Year;
            var years       = new List <SelectListItem>();

            for (int i = 0; i < 5; i++)
            {
                var temp = currentYear - i;
                years.Add(new SelectListItem
                {
                    Text     = temp.ToString() + "年",
                    Value    = temp.ToString(),
                    Selected = (year.HasValue ? year.Value == temp : currentYear == temp)
                });
            }
            ViewBag.Years = years;

            var month = DateTime.Today.Month;
            List <SelectListItem> months = new List <SelectListItem>();

            for (int i = 1; i <= 12; i++)
            {
                months.Add(new SelectListItem {
                    Text = $"{i}月", Value = i.ToString(), Selected = month == i
                });
            }
            ViewBag.Months = months;

            ViewBag.Groups = new List <SelectListItem>
            {
                new SelectListItem {
                    Text = "效益", Value = "xy"
                },
                new SelectListItem {
                    Text = "业绩", Value = "yj"
                },
                new SelectListItem {
                    Text = "毛利", Value = "ml"
                },
                new SelectListItem {
                    Text = "账面毛利", Value = "zmml"
                },
                new SelectListItem {
                    Text = "成本", Value = "hj"
                }
            };

            ViewBag.Depts = DeptUtil.All().ToSelectList("Id", "Name");
        }
Exemple #8
0
        public IActionResult Depts(AssetSearchParam param)
        {
            InitUi(param);
            //param.IsContainSubDept = true;
            //var list = _service.GetDeptGroup(param);
            //return View("Depts", list);

            var sData = _reportService.DeptSummary();
            var depts = DeptUtil.All();

            var data =
                from cate in depts
                join dto in sData on cate.Id equals dto.Id into dds

                from dd in dds.DefaultIfEmpty()
                select new StringSummaryDto()
            {
                Property = ShowName2(cate.Name, cate.Level),
                Num      = dd?.Num ?? 0
            };

            return(View("Dept2", data.ToList()));
        }
Exemple #9
0
        public ActionResult Get()
        {
            var depts = DeptUtil.All();

            return(Json(ResultUtil.Success(depts)));
        }
        public IActionResult DeptDtos()
        {
            var list = DeptUtil.All();

            return(Json(list));
        }