예제 #1
0
        public IActionResult Add()
        {
            var grainTypeDal  = new GrainTypeDal();
            var grainType2Dal = new GrainType2Dal();
            var model         = new GrainAddModel()
            {
                GrainTypes  = grainTypeDal.Query(),
                GrainType2s = grainType2Dal.Query(),
            };

            return(View(model));
        }
예제 #2
0
        public IActionResult Update(string GrainId)
        {
            var dal           = new GrainDal();
            var grainTypeDal  = new GrainTypeDal();
            var grainType2Dal = new GrainType2Dal();
            var p             = dal.Find(GrainId);
            var model         = mapper.Map <GrainUpdateModel>(p);

            model.GrainTypes  = grainTypeDal.Query();
            model.GrainType2s = grainType2Dal.Query();
            return(View(model));
        }
예제 #3
0
        public IActionResult JsonIndex(GrainJsonIndexModel model)
        {
            //if (model.BeginDateTime == null)
            //    model.BeginDateTime = DateTime.Now.ToString("yyyy-MM-dd");
            //if (model.EndDateTime == null)
            //    model.EndDateTime = DateTime.Now.ToString("yyyy-MM-dd");
            var dal           = new GrainDal();
            var grainTypeDal  = new GrainTypeDal();
            var grainTypeList = grainTypeDal.Query();
            var grainTypeFuc  = new Func <int, string>((id) =>
            {
                var p = grainTypeList.SingleOrDefault(o => o.GrainTypeId == id);
                if (p == null)
                {
                    return(string.Empty);
                }
                return(p.GrainTypeName);
            });

            var grainType2Dal  = new GrainType2Dal();
            var grainType2List = grainType2Dal.Query();
            var grainType2Fuc  = new Func <int, string>((id) =>
            {
                var p = grainType2List.SingleOrDefault(o => o.GrainType2Id == id);
                if (p == null)
                {
                    return(string.Empty);
                }
                return(p.GrainType2Name);
            });
            var param = new GrainDal.QueryByParam1In()
            {
                //BeginDateTime = DateTime.Parse(model.BeginDateTime),
                //EndDateTime = DateTime.Parse(model.EndDateTime),
                Rows = model.Rows,
                Page = model.Page,
            };
            var list  = dal.QueryByParam1(param);
            var list2 = from o in list
                        select new
            {
                GrainId          = o.GrainId,
                GrainName        = o.GrainName,
                GrainCode        = o.GrainCode,
                GrainPinYin      = o.GrainPinYin,
                GrainTypeId      = o.GrainTypeId,
                GrainTypeName    = grainTypeFuc(o.GrainTypeId),
                GrainType2Name   = grainType2Fuc(o.GrainType2Id),
                GrainDescription = o.GrainDescription,
                GrainColor       = o.GrainColor,
                GrainWeight      = o.GrainWeight,
                GrainUnit        = o.GrainUnit,
                GrainTypeId2     = o.GrainType2Id,
                GrainComment     = o.GrainComment,
            };

            var grid = new
            {
                total = param.Total,
                rows  = list2,
            };

            return(Json(grid));
        }