Example #1
0
        public ActionResult SubmitUserForm(string KeyValue, Base_User base_user, Base_Employee base_employee, string BuildFormJson)
        {
            string        ModuleId    = DESEncrypt.Decrypt(CookieHelper.GetCookie("ModuleId"));
            IDatabase     database    = DataFactory.Database();
            DbTransaction isOpenTrans = database.BeginTrans();

            try
            {
                string Message = KeyValue == "" ? "新增成功。" : "编辑成功。";
                if (!string.IsNullOrEmpty(KeyValue))
                {
                    //原来无权限修改本人信息 - 改为可以
                    //if (KeyValue == ManageProvider.Provider.Current().UserId)
                    //{
                    //    throw new Exception("无权限编辑本人信息");
                    //}
                    base_user.Modify(KeyValue);
                    //base_employee.Modify(KeyValue);
                    database.Update(base_user, isOpenTrans);
                    //database.Update(base_employee, isOpenTrans);
                }
                else //新建用户
                {
                    base_user.Create();
                    base_user.SortCode = CommonHelper.GetInt(BaseFactory.BaseHelper().GetSortCode <Base_User>("SortCode"));
                    //定义为上级id
                    base_user.InnerUser    = ManageProvider.Provider.Current().InnerUser + 1; //用户层级
                    base_user.DepartmentId = ManageProvider.Provider.Current().UserName;      //上级用户姓名
                    base_user.CompanyId    = ManageProvider.Provider.Current().Account;       //上级用户帐号
                    base_user.Code         = ManageProvider.Provider.Current().UserId;        //上级用户的id
                    database.Insert(base_user, isOpenTrans);
                    //权限分配-复制上级权限
                    CopyUserRight(ManageProvider.Provider.Current().UserId, base_user.UserId, isOpenTrans);
                    Base_DataScopePermissionBll.Instance.AddScopeDefault(ModuleId, ManageProvider.Provider.Current().UserId, base_user.UserId, isOpenTrans);
                }
                Base_FormAttributeBll.Instance.SaveBuildForm(BuildFormJson, base_user.UserId, ModuleId, isOpenTrans);
                database.Commit();
                return(Content(new JsonMessage {
                    Success = true, Code = "1", Message = Message
                }.ToString()));
            }
            catch (Exception ex)
            {
                database.Rollback();
                return(Content(new JsonMessage {
                    Success = false, Code = "-1", Message = "操作失败:" + ex.Message
                }.ToString()));
            }
        }
Example #2
0
        public ActionResult SubmitUserForm(string KeyValue, Base_User base_user, Base_Employee base_employee, string BuildFormJson)
        {
            string        ModuleId    = DESEncrypt.Decrypt(CookieHelper.GetCookie("ModuleId"));
            IDatabase     database    = DataFactory.Database();
            DbTransaction isOpenTrans = database.BeginTrans();

            try
            {
                string Message = KeyValue == "" ? "新增成功。" : "编辑成功。";
                if (!string.IsNullOrEmpty(KeyValue))
                {
                    if (KeyValue == ManageProvider.Provider.Current().UserId)
                    {
                        throw new Exception("无权限编辑本人信息");
                    }
                    base_user.Modify(KeyValue);
                    base_employee.Modify(KeyValue);
                    database.Update(base_user, isOpenTrans);
                    database.Update(base_employee, isOpenTrans);
                }
                else
                {
                    base_user.Create();
                    base_user.SortCode = CommonHelper.GetInt(BaseFactory.BaseHelper().GetSortCode <Base_User>("SortCode"));
                    base_employee.Create();
                    base_employee.EmployeeId = base_user.UserId;
                    base_employee.UserId     = base_user.UserId;
                    database.Insert(base_user, isOpenTrans);
                    database.Insert(base_employee, isOpenTrans);
                    Base_DataScopePermissionBll.Instance.AddScopeDefault(ModuleId, ManageProvider.Provider.Current().UserId, base_user.UserId, isOpenTrans);
                }
                Base_FormAttributeBll.Instance.SaveBuildForm(BuildFormJson, base_user.UserId, ModuleId, isOpenTrans);
                database.Commit();
                return(Content(new JsonMessage {
                    Success = true, Code = "1", Message = Message
                }.ToString()));
            }
            catch (Exception ex)
            {
                database.Rollback();
                database.Close();
                return(Content(new JsonMessage {
                    Success = false, Code = "-1", Message = "操作失败:" + ex.Message
                }.ToString()));
            }
        }
        public ActionResult SetUserForm(string KeyValue)
        {
            Base_User base_user = DataFactory.Database().FindEntity <Base_User>(KeyValue);

            if (base_user == null)
            {
                return(Content(""));
            }
            Base_Employee base_employee = DataFactory.Database().FindEntity <Base_Employee>(KeyValue);
            Base_Company  base_company  = DataFactory.Database().FindEntity <Base_Company>(base_user.CompanyId);
            string        strJson       = base_user.ToJson();

            //公司
            strJson = strJson.Insert(1, "\"CompanyName\":\"" + base_company.FullName + "\",");
            //员工信息
            strJson = strJson.Insert(1, base_employee.ToJson().Replace("{", "").Replace("}", "") + ",");
            //自定义
            strJson = strJson.Insert(1, Base_FormAttributeBll.Instance.GetBuildForm(KeyValue));
            return(Content(strJson));
        }