public JsonResult EditInfo(Sys_Dictionary Mode)
        {
            Random rnd   = new Random();
            bool   IsAdd = false;

            if (!(Mode.DicId != null && !Mode.DicId.ToString().Equals(0)))//DicId为空,是添加
            {
                IsAdd = true;
            }
            if (IsAdd)
            {
                Mode.CreateTime = DateTime.Now;

                DDBiz.Add(Mode);

                return(Json("ok", JsonRequestBehavior.AllowGet));
            }
            else
            {
                Mode.WhereExpression = Sys_DictionarySet.DicId.Equal(Mode.DicId);
                //  spmodel.GroupDicId = GroupDicId;
                Mode.CreateTime = DateTime.Now;

                if (DDBiz.Update(Mode) > 0)
                {
                    return(Json("ok", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json("Nok", JsonRequestBehavior.AllowGet));
                }
            }
        }
        public JsonResult GetInfo(string DicId)
        {
            var            mql    = Sys_DictionarySet.SelectAll().Where(Sys_DictionarySet.DicId.Equal(DicId));
            Sys_Dictionary Rmodel = DDBiz.GetEntity(mql);

            //  groupsBiz.Add(rol);
            return(Json(Rmodel, JsonRequestBehavior.AllowGet));
        }
 public void Edit_CourseType(HttpContext context)
 {
     try
     {
         HttpRequest    request  = context.Request;
         int            Id       = RequestHelper.int_transfer(request, "Id");
         string         Name     = RequestHelper.string_transfer(request, "Name");
         int            IsEnable = RequestHelper.int_transfer(request, "IsEnable");
         Sys_Dictionary dic      = Constant.Sys_Dictionary_List.FirstOrDefault(di => di.Id == Id);
         if (dic != null)
         {
             Sys_Dictionary dic_clone = Constant.Clone <Sys_Dictionary>(dic);
             dic_clone.Value    = Name;
             dic_clone.IsEnable = (byte)IsEnable;
             if (dic_clone != null)
             {
                 jsonModel = Constant.Sys_DictionaryService.Update(dic_clone);
                 if (jsonModel.errNum == 0)
                 {
                     dic.Value    = Name;
                     dic.IsEnable = (byte)IsEnable;
                 }
                 else
                 {
                     jsonModel = JsonModel.get_jsonmodel(3, "failed", "操作失败");
                 }
             }
         }
         else
         {
             jsonModel = JsonModel.get_jsonmodel(3, "failed", "该课程类型不存在");
         }
     }
     catch (Exception ex)
     {
         LogHelper.Error(ex);
     }
     finally
     {
         //无论后端出现什么问题,都要给前端有个通知【为防止jsonModel 为空 ,全局字段 jsonModel 特意声明之后进行初始化】
         context.Response.Write("{\"result\":" + Constant.jss.Serialize(jsonModel) + "}");
     }
 }
        public void Delete_CourseType(HttpContext context)
        {
            try
            {
                HttpRequest request = context.Request;
                int         Id      = RequestHelper.int_transfer(request, "Id");

                Sys_Dictionary dic = Constant.Sys_Dictionary_List.FirstOrDefault(di => di.Id == Id);

                if (dic != null)
                {
                    int count = (from s in Constant.CourseRel_List where s.CourseType_Id == dic.Key select s).Count();
                    if (count == 0)
                    {
                        jsonModel = Constant.Sys_DictionaryService.Delete(Id);
                        Constant.Sys_Dictionary_List.Remove(dic);
                    }
                    else
                    {
                        jsonModel = JsonModel.get_jsonmodel(3, "failed", "该课程类型已有关联的课程");
                    }
                }
                else
                {
                    jsonModel = JsonModel.get_jsonmodel(3, "failed", "该课程类型不存在");
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
            finally
            {
                //无论后端出现什么问题,都要给前端有个通知【为防止jsonModel 为空 ,全局字段 jsonModel 特意声明之后进行初始化】
                context.Response.Write("{\"result\":" + Constant.jss.Serialize(jsonModel) + "}");
            }
        }
        public JsonResult EditInfo(Sys_Dictionary Mode)
        {
            Random rnd   = new Random();
            bool   IsAdd = false;

            if (!(Mode.Id != null && !Mode.Id.ToString().Equals("00000000-0000-0000-0000-000000000000")))//id为空,是添加
            {
                IsAdd = true;
            }
            if (IsAdd)
            {
                Mode.Id         = Guid.NewGuid();
                Mode.CreateTime = DateTime.Now;
                Mode.ModifyTime = DateTime.Now;
                DDBiz.Add(Mode);
                SysOperateLogBiz.AddSysOperateLog(UserData.Id.ToString(), UserData.UserName, e3net.Mode.OperatEnumName.新增, "数据字典--添加", true, WebClientIP, "数据字典");
                return(Json("ok", JsonRequestBehavior.AllowGet));
            }
            else
            {
                Mode.WhereExpression = Sys_DictionarySet.Id.Equal(Mode.Id);
                //  spmodel.GroupId = GroupId;
                Mode.CreateTime = DateTime.Now;
                Mode.ModifyTime = DateTime.Now;
                if (DDBiz.Update(Mode) > 0)
                {
                    SysOperateLogBiz.AddSysOperateLog(UserData.Id.ToString(), UserData.UserName, e3net.Mode.OperatEnumName.修改, "数据字典--修改", true, WebClientIP, "数据字典");
                    return(Json("ok", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    SysOperateLogBiz.AddSysOperateLog(UserData.Id.ToString(), UserData.UserName, e3net.Mode.OperatEnumName.修改, "数据字典--修改", false, WebClientIP, "数据字典");

                    return(Json("Nok", JsonRequestBehavior.AllowGet));
                }
            }
        }
        public void AddCourseType(HttpContext context)
        {
            HttpRequest request        = context.Request;
            string      CourseTypeName = RequestHelper.string_transfer(request, "CourseTypeName");
            string      CreateUID      = RequestHelper.string_transfer(request, "CreateUID");
            int         SectionId      = RequestHelper.int_transfer(request, "SectionId");
            int         IsEnable       = RequestHelper.int_transfer(request, "IsEnable");

            try
            {
                //课程变更【启用禁用】
                if (!string.IsNullOrEmpty(CourseTypeName))
                {
                    //获取课程类型 课程的值 +1
                    Sys_Dictionary dic_max = (from t in Constant.Sys_Dictionary_List where t.Type == "0" orderby Convert.ToInt32(t.Key) descending select t).ToList()[0];
                    if (dic_max != null)
                    {
                        int            va         = Convert.ToInt32(dic_max.Key) + 1;
                        Sys_Dictionary dictionary = new Sys_Dictionary()
                        {
                            Pid        = 0,
                            Key        = Convert.ToString(va),
                            Value      = CourseTypeName,
                            Type       = "0",
                            SectionId  = SectionId,
                            CreateTime = DateTime.Now,
                            EditTime   = DateTime.Now,
                            CreateUID  = CreateUID,
                            EditUID    = CreateUID,
                            IsDelete   = 0,
                            Sort       = 0,
                            IsEnable   = (byte)IsEnable,
                        };
                        //添加一个课程类型
                        jsonModel = Constant.Sys_DictionaryService.Add(dictionary);

                        if (jsonModel.errNum == 0)
                        {
                            dictionary.Id = Convert.ToInt32(jsonModel.retData);
                            Constant.Sys_Dictionary_List.Add(dictionary);
                        }
                    }
                    else
                    {
                        jsonModel = JsonModel.get_jsonmodel((int)errNum.Failed, "failed", "数据出现异常");
                    }
                }
                else
                {
                    jsonModel = JsonModel.get_jsonmodel((int)errNum.Failed, "failed", "数据出现异常");
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
            finally
            {
                //无论后端出现什么问题,都要给前端有个通知【为防止jsonModel 为空 ,全局字段 jsonModel 特意声明之后进行初始化】
                context.Response.Write("{\"result\":" + Constant.jss.Serialize(jsonModel) + "}");
            }
        }
示例#7
0
        public JsonResult EditInfo(Sys_Dictionary EidModle)
        {
            HttpReSultMode ReSultMode = new HttpReSultMode();
            var            mql2       = Sys_DictionarySet.SelectAll().Where(Sys_DictionarySet.DicNo.Equal(EidModle.DicNo));
            Sys_Dictionary Rmodel     = OPBiz.GetEntity(mql2);

            if (Rmodel != null && Rmodel.DicId != EidModle.DicId)
            {
                ReSultMode.Code = -13;
                ReSultMode.Data = "";
                ReSultMode.Msg  = "已经存在相同的编号";
                return(Json(ReSultMode, JsonRequestBehavior.AllowGet));
            }


            bool IsAdd = false;

            if (EidModle.ParentId == EidModle.DicId)//父级不能等于自已
            {
                EidModle.ParentId = 0;
            }

            if (EidModle.DicId == 0) //id为空,是添加
            {
                IsAdd = true;
                EidModle.CreateTime = DateTime.Now;
                EidModle.isValid    = true;
                EidModle.isDeleted  = false;
            }
            if (IsAdd)
            {
                try
                {
                    OPBiz.Add(EidModle);
                    ReSultMode.Code = 11;
                    ReSultMode.Data = EidModle.DicId.ToString();
                    ReSultMode.Msg  = "添加成功";
                }
                catch (Exception e) {
                    ReSultMode.Code = -11;
                    ReSultMode.Data = e.ToString();
                    ReSultMode.Msg  = "添加失败";
                }
            }
            else
            {
                EidModle.WhereExpression = Sys_DictionarySet.DicId.Equal(EidModle.DicId);
                string idfilec = "DicId";
                EidModle.ChangedMap.Remove(idfilec.ToLower());//移除主键值
                if (OPBiz.Update(EidModle) > 0)
                {
                    ReSultMode.Code = 11;
                    ReSultMode.Data = "";
                    ReSultMode.Msg  = "修改成功";
                }
                else
                {
                    ReSultMode.Code = -13;
                    ReSultMode.Data = "";
                    ReSultMode.Msg  = "修改失败";
                }
            }

            return(Json(ReSultMode, JsonRequestBehavior.AllowGet));
        }