コード例 #1
0
        public ActionResult PostEdit(GridMemberModel entity)
        {
            using (LoveBankDBContext db = new LoveBankDBContext())
            {
                GridMember model = db.T_GridMember.Find(entity.Id);

                model.Desc = entity.Desc;
                model.GridName = entity.GridName;
                model.GridNo = entity.GridNo;
                model.GridPhone = entity.GridPhone;
                model.VDeptId = entity.VDeptId;
                model.GridHeaderImg = entity.SourceFile.Domain + entity.SourceFile.Path;

                //grid.Desc = entity.Desc;
                //grid.GridHeaderImg = entity.GridHeaderImg;
                //grid.GridName = entity.GridName;
                //grid.GridNo = entity.GridNo;
                //grid.GridPhone = entity.GridPhone;
                //grid.VDeptId = entity.VDeptId;

                db.Update(model);
                db.SaveChanges();

            }
            return Success("修改成功");
        }
コード例 #2
0
ファイル: AppCommController.cs プロジェクト: gowhy/LoveBank
        /// <summary>
        /// 获取社区网格员
        /// </summary>
        /// <param name="deptId"></param>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public ActionResult App_GridMember(string deptId, int page = 1, int pageSize = 20)
        {
            JsonMessage retJson = new JsonMessage();

            using (LoveBankDBContext db = new LoveBankDBContext())
            {
                var tgm = db.T_GridMember;
                var t_d = db.T_Department;

                var dTable = from d in t_d
                             where d.PId == deptId
                             select d;

                List<Department> dlist = dTable.ToList();

                var list = from gm in tgm
                           where gm.DeptId.IndexOf(deptId) > -1
                           select gm;

                List<GridMember> gList = list.OrderBy(x => x.Id).ToPagedList(page - 1, pageSize).ToList();

                List<GridMemberModel> listModel = new List<GridMemberModel>();

                GridMemberModel tmp = null;
                foreach (var item in gList)
                {
                    tmp = new GridMemberModel();

                    tmp.VDeptName = dlist.Where(x => item.VDeptId.IndexOf(x.Id) > -1).FirstOrDefault().Name;
                    tmp.GridName = item.GridName;
                    tmp.GridNo = item.GridNo;
                    tmp.GridPhone = item.GridPhone;
                    tmp.GridHeaderImg = item.GridHeaderImg;
                    tmp.Desc = item.Desc;

                    listModel.Add(tmp);
                }
                retJson.Data = listModel;
                retJson.Status = true;
                return Json(retJson);
            }
        }
コード例 #3
0
        public ActionResult PostAdd(GridMemberModel entity)
        {
            if (string.IsNullOrEmpty(entity.GridPhone) || string.IsNullOrEmpty(entity.GridName) || string.IsNullOrEmpty(entity.GridNo))
            {
                return RedirectToAction("Add");
            }
            GridMember model = new GridMember();

            model.AddUserId = AdminUser.ID;
            model.AddTime = DateTime.Now;
            model.DeptId = AdminUser.DeptId;

            model.Desc = entity.Desc;
            model.GridName = entity.GridName;
            model.GridNo = entity.GridNo;
            model.GridPhone = entity.GridPhone;
            model.VDeptId = entity.VDeptId;
            model.GridHeaderImg = entity.SourceFile.Domain + entity.SourceFile.Path;

            using (LoveBankDBContext db = new LoveBankDBContext())
            {

                db.Add(model);
                db.SaveChanges();

            }
            return Success("添加成功");
        }