Exemplo n.º 1
0
        public void SaveData(ModSysGroup t)
        {
            BllSysGroup   bll  = new BllSysGroup();
            ModJsonResult json = new ModJsonResult();
            string        type = (Request["Type"] == null?"":Request["Type"].ToString());

            switch (type)
            {
            case "ProductType":
                t.Type = 2;
                break;

            case "BookType":
                t.Type = 3;
                break;

            case "QuestionsType":
                t.Type = 0;
                break;

            case "ClassManage":    //公告类型
                t.Type = 1;
                break;
            }
            if (!string.IsNullOrEmpty(Request["modify"])) //修改
            {
                var model = bll.LoadData(t.Id);
                model.Name     = t.Name;
                model.ParentId = "0";//如果引用字典库的类别,修改后变成自己类别
                //判断名称是否存在
                int  count = 0;
                bool flag  = bll.Exists("Sys_Group", " and CompanyId='" + t.CompanyId + "'  and Name='" + t.Name + "' and Type=" + t.Type + " and Id<>'" + t.Id + "' and Status!=" + (int)StatusEnum.除, out count);
                if (flag)
                {
                    json.success = false;
                    json.msg     = " 保存失败,该名称已经存在!";
                }
                else
                {
                    int result = bll.Update(model);
                    if (result <= 0)
                    {
                        json.success = false;
                        json.msg     = "修改失败,请稍后再操作!";
                    }
                }
            }
            else
            {
                string CompanyId = Request["CompanyId"].ToString().Trim();//
                if (string.IsNullOrEmpty(CompanyId))
                {
                    CompanyId = CurrentMaster.Cid;
                }
                //判断名称是否存在
                int  count = 0;
                bool flag  = bll.Exists("Sys_Group", " and CompanyId='" + CompanyId + "' and Name='" + t.Name + "' and Type=" + t.Type + " and Status!=" + (int)StatusEnum.除, out count);
                if (flag)
                {
                    json.success = false;
                    json.msg     = " 保存失败,该名称已经存在!";
                }
                else
                {
                    t.Id         = Guid.NewGuid().ToString();
                    t.Status     = (int)StatusEnum.正常;
                    t.CreaterId  = CurrentMaster.Id;
                    t.CreateTime = DateTime.Now;
                    t.CompanyId  = CompanyId;
                    t.OrderNum   = 0;
                    t.ParentId   = "0";

                    int result = bll.Insert(t);
                    if (result <= 0)
                    {
                        json.success = false;
                        json.msg     = " 保存失败,请稍后再操作!";
                    }
                    new BllSysMaster().ClearCache();
                }
            }


            WriteJsonToPage(json.ToString());
        }
Exemplo n.º 2
0
        public void SaveData(ModSysGroup t)
        {
            BllSysGroup   bll  = new BllSysGroup();
            ModJsonResult json = new ModJsonResult();

            if (CurrentMaster != null)
            {
                if (CurrentMaster.Id == Request["LoginUserId"].ToString())
                {
                    if (!string.IsNullOrEmpty(Request["modify"])) //修改
                    {
                        var model = bll.LoadData(t.Id);
                        model.Name = t.Name;
                        //判断名称是否存在
                        int  count = 0;
                        bool flag  = bll.Exists("Sys_Group", " and Name='" + t.Name + "' and Type=" + t.Type + " and Id<>'" + t.Id + "' and Status!=" + (int)StatusEnum.除, out count);
                        if (flag)
                        {
                            json.success = false;
                            json.msg     = " 保存失败,该名称已经存在!";
                        }
                        else
                        {
                            model.OrderNum = t.OrderNum;
                            model.Code     = t.Code;
                            int result = bll.Update(model);
                            if (result <= 0)
                            {
                                json.success = false;
                                json.msg     = "修改失败,请稍后再操作!";
                            }
                        }
                    }
                    else
                    {
                        //判断名称是否存在
                        int  count = 0;
                        bool flag  = bll.Exists("Sys_Group", " and Name='" + t.Name + "' and Type=" + t.Type + " and Status!=" + (int)StatusEnum.除, out count);
                        if (flag)
                        {
                            json.success = false;
                            json.msg     = " 保存失败,该名称已经存在!";
                        }
                        else
                        {
                            t.Id         = Guid.NewGuid().ToString();
                            t.Status     = (int)StatusEnum.正常;
                            t.CreaterId  = CurrentMaster.Id;
                            t.CreateTime = DateTime.Now;
                            t.CompanyId  = CurrentMaster.Company.Id;
                            t.ParentId   = "0";

                            int result = bll.Insert(t);
                            if (result <= 0)
                            {
                                json.success = false;
                                json.msg     = " 保存失败,请稍后再操作!";
                            }

                            new BllSysMaster().ClearCache();
                        }
                    }
                    LogInsert(OperationTypeEnum.操作, "公告类别", CurrentMaster.UserName + "新增或修改类别成功.");
                }
                else
                {
                    json.success = false;
                    json.msg     = "用户信息已失效,请刷新或登陆.";
                }
            }
            else
            {
                json.success = false;
                json.msg     = "用户信息已过期,请重新登陆.";
            }
            WriteJsonToPage(json.ToString());
        }