コード例 #1
0
        public JsonResult AddOrg(string parentNode, string orgName, string orgCode)
        {
            var check = _orgRepository.GetOrgBySpecifiedCondition(orgCode);

            if (check.Count() > 1)
            {
                return Json(new { result = false, msg = "添加失败,已存在相同的组织结构名称或组织机构编码!" }, JsonRequestBehavior.AllowGet);
            }

            var org = new t_org()
            {
                parentCode = parentNode,
                name = orgName,
                orgcode = orgCode
            };

            try
            {
                var result = _orgRepository.AddOrg(org);
                if (result)
                {
                    return Json(new { result = true, msg = "" }, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    return Json(new { result = false, msg = "操作失败!" }, JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception ex)
            {
                return Json(new { result = false, msg = ex.Message }, JsonRequestBehavior.AllowGet);
            }
        }
コード例 #2
0
        public bool ModifyOrg(t_org org)
        {
            dbContext.Set<t_org>().Attach(org);

            dbContext.Entry<t_org>(org).State = EntityState.Modified;

            return dbContext.SaveChanges() > 0;
        }
コード例 #3
0
        public JsonResult DeleteOrg(string orgCode)
        {
            var org = new t_org()
            {
                orgcode = orgCode
            };

            try
            {
                var result = _orgRepository.DeleteOrg(org);
                if (result)
                {
                    return Json(new { result = true, msg = "" }, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    return Json(new { result = false, msg = "操作失败!" }, JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception ex)
            {
                return Json(new { result = false, msg = ex.Message }, JsonRequestBehavior.AllowGet);
            }
        }
コード例 #4
0
        public bool AddOrg(t_org org)
        {
            dbContext.Entry<t_org>(org).State = EntityState.Added;

            return dbContext.SaveChanges() > 0;
        }