/// <summary>
        /// 获取JQGrid动态列名
        /// </summary>
        /// <returns></returns>
        public ActionResult GetGridRows()
        {
            List <object> obj = new List <object>();
            //获取商品类别List
            GoodstypeBLL           goodstypebll = new GoodstypeBLL();
            List <GoodstypeEntity> goodList     = goodstypebll.GetListJson("0").ToList();
            DataTable dt = new DataTable();

            if (goodList != null && goodList.Count > 0)
            {
                //1、固定列名
                dt.Columns.Add("部门");//部门
                //2、动态创建列名
                foreach (var item in goodList)
                {
                    dt.Columns.Add(item.ftypename);
                }
                //3、固定列名
                dt.Columns.Add("小计");//小计

                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    var colm = new
                    {
                        label    = dt.Columns[i].ColumnName,
                        name     = dt.Columns[i].ColumnName,
                        align    = "center",
                        sortable = false
                    };
                    obj.Add(colm);
                }
            }
            return(ToJsonResult(obj));
        }
Example #2
0
        public ActionResult GetListJson(string fparentcode)
        {
            var data     = goodstypebll.GetListJson(fparentcode);
            var treeList = new List <TreeEntity>();

            foreach (GoodstypeEntity item in data)
            {
                TreeEntity tree        = new TreeEntity();
                bool       hasChildren = false;//data.Count(t => t.ParentId == item.ItemDetailId) == 0 ? false : true;
                tree.id          = item.ftypecode;
                tree.text        = item.ftypename;
                tree.value       = item.ftypecode;
                tree.parentId    = "0";
                tree.isexpand    = true;
                tree.complete    = true;
                tree.hasChildren = hasChildren;
                treeList.Add(tree);
            }
            return(Content(treeList.TreeToJson()));
        }
        public ActionResult GetReceiveCostJson(string queryJson)
        {
            var          queryParam   = queryJson.ToJObject();
            GoodstypeBLL goodstypebll = new GoodstypeBLL();
            //获取商品类别List
            List <GoodstypeEntity> goodList = goodstypebll.GetListJson("0").ToList();
            DataTable     dt  = new DataTable();
            List <object> obj = new List <object>();

            if (goodList != null && goodList.Count > 0)
            {
                #region 1、创建列名

                //1、固定列名
                dt.Columns.Add("部门");//部门
                //2、动态创建列名
                foreach (var item in goodList)
                {
                    dt.Columns.Add(item.ftypename);
                }
                //3、固定列名
                dt.Columns.Add("小计");//小计

                #endregion 1、创建列名

                #region 2、添加行数据

                //获取部门
                HrDepartmentCache         hrDepartmentCache = new HrDepartmentCache();
                List <HrDepartmentEntity> departList        = hrDepartmentCache.GetList().ToList();

                //获取费用列表
                List <ReceiveCostModel> list     = outbillitembll.GetReceiveCostList().ToList();
                List <ReceiveCostModel> costList = null;
                DataRow dr = dt.NewRow();
                //查询条件 领用时间
                DateTime?startDate = null;
                DateTime?endDate   = null;
                if (!queryParam["StartDate"].IsEmpty())
                {
                    startDate = Convert.ToDateTime(queryParam["StartDate"]);
                }
                if (!queryParam["EndDate"].IsEmpty())
                {
                    endDate = Convert.ToDateTime(queryParam["EndDate"]);
                }
                if (departList != null && departList.Count > 0 && list != null && list.Count > 0)
                {
                    foreach (var dep in departList)
                    {
                        dr       = dt.NewRow();
                        dr["部门"] = dep.deptname;
                        decimal amount = 0;
                        decimal money  = 0;
                        foreach (var li in goodList)
                        {
                            costList = list.FindAll(o => o.fgoodsid == li.frootid && o.fdeptid == dep.deptid).ToList();
                            if (startDate != null)
                            {
                                costList = costList.FindAll(o => o.foutdate >= startDate).ToList();
                            }
                            if (endDate != null)
                            {
                                costList = costList.FindAll(o => o.foutdate <= endDate).ToList();
                            }
                            money            = costList.Sum(o => o.fmoney);
                            dr[li.ftypename] = money.ToString("F");
                            amount          += money;
                        }
                        dr["小计"] = amount.ToString("F");
                        dt.Rows.Add(dr);
                    }
                }

                #endregion 2、添加行数据
            }
            return(ToJsonResult(dt));
        }