示例#1
0
        /// <summary>
        /// 增、改K_SysRole表

        /// </summary>
        /// <param Name="tranType">操作类型,NEW=增,EDIT=改</param>
        /// <param Name="paramsModel"></param>
        /// <returns>返回大于0的数字操作正常,返回非数字表示操作错误,返回的是系统错误说明</returns>
        public string Save(string tranType, KingTop.Model.SysManage.Role paramsModel)
        {
            string isOk = "";

            try
            {
                SqlParameter returnValue = new SqlParameter("@ReturnValue", SqlDbType.Int, 4);
                returnValue.Direction = ParameterDirection.Output;

                string cmdText = "proc_K_SysRoleSave";

                SqlParameter[] paras = new SqlParameter[] {
                    new SqlParameter("tranType", tranType),
                    new SqlParameter("RoleCode", paramsModel.RoleCode),
                    new SqlParameter("RoleName", paramsModel.RoleName),
                    new SqlParameter("SiteID", paramsModel.SiteID),
                    new SqlParameter("InputID", paramsModel.InputID),
                    new SqlParameter("InputPerson", paramsModel.InputPerson),
                    new SqlParameter("InputDate", paramsModel.InputDate),
                    new SqlParameter("RoleDescription", paramsModel.RoleDescription),
                    new SqlParameter("RoleOrder", paramsModel.RoleOrder),
                    returnValue
                };

                SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, cmdText, paras);
                isOk = returnValue.Value.ToString();
            }
            catch (Exception ex)
            {
                isOk = ex.Message;
            }

            return(isOk);
        }
示例#2
0
        protected void btnRole_Click(object sender, EventArgs e)
        {
            string id        = hdnID.Value;
            string returnMsg = "";
            string tranType  = "NEW";

            KingTop.Model.SysManage.Role mode = new KingTop.Model.SysManage.Role();

            if (id != "")   // 修改关键字

            {
                #region 修改角色
                // 权限验证,是否具有修改权限

                if (IsHaveRightByOperCode("Edit"))
                {
                    tranType             = "EDIT";
                    mode.RoleCode        = new Guid(id);
                    mode.RoleName        = Utils.HtmlEncode(txtRoleName.Text.Trim());
                    mode.SiteID          = SiteID;
                    mode.InputID         = Utils.ParseInt(base.GetLoginAccountId().ToString(), 0);
                    mode.InputPerson     = base.GetLoginAccountName();
                    mode.InputDate       = DateTime.Now;
                    mode.RoleDescription = Utils.HtmlEncode(txtRoleDescription.Text.Trim());
                    mode.RoleOrder       = Utils.ParseInt(txtRoleOrder.Text.Trim(), 0);
                    returnMsg            = bll.Save(tranType, mode);
                    int    MsgNum   = Utils.ParseInt(returnMsg, 0);
                    string logTitle = Request.Form["hidLogTitle"];

                    if (logTitle != txtRoleName.Text)
                    {
                        logTitle = logTitle + " => " + txtRoleName.Text;
                    }

                    if (MsgNum == 1)
                    {
                        WriteLog(GetLogValue(logTitle, "Update", "RoleEdit", true), "", 2);     //写日志
                        Utils.RunJavaScript(this, "type=1;title='" + txtRoleName.Text.Trim().Replace("'", "\\'") + "'");
                    }
                    else if (MsgNum == 2)
                    {
                        WriteLog(GetLogValue(logTitle, "Update", "RoleEdit", false), "名称已存", 3); //写日志
                        Utils.RunJavaScript(this, "type=2;title='" + txtRoleName.Text.Trim().Replace("'", "\\'") + "';errmsg='该名称已存在,请重写填写角色名称!';");
                    }
                    else
                    {
                        WriteLog(GetLogValue(logTitle, "Update", "RoleEdit", false), returnMsg, 3); //写日志
                        Utils.RunJavaScript(this, "type=2;title='" + txtRoleName.Text.Trim().Replace("'", "\\'") + "';errmsg='" + returnMsg.Replace("'", "\\'").Replace("\r\n", "<br>") + "';");
                    }
                }
                else
                {
                    sbLog.Append("失败,无权限!");
                    Utils.RunJavaScript(this, "alert({msg:'你没有编辑角色的权限,请联系站点管理员!',title:'提示信息'})");
                }
                #endregion
            }
            else
            {
                #region 新增角色
                // 权限验证,是否具有新增权限

                if (IsHaveRightByOperCode("New"))
                {
                    mode.RoleCode        = Guid.NewGuid();
                    mode.RoleName        = Utils.HtmlEncode(txtRoleName.Text.Trim());
                    mode.SiteID          = SiteID;
                    mode.InputID         = Utils.ParseInt(base.GetLoginAccountId().ToString(), 0);
                    mode.InputPerson     = base.GetLoginAccountName();
                    mode.InputDate       = DateTime.Now;
                    mode.RoleDescription = Utils.HtmlEncode(txtRoleDescription.Text.Trim());
                    mode.RoleOrder       = Utils.ParseInt(txtRoleOrder.Text.Trim(), 0);
                    returnMsg            = bll.Save(tranType, mode);
                    int MsgNum = Utils.ParseInt(returnMsg, 0);
                    if (MsgNum == 1)
                    {
                        WriteLog("新增" + txtRoleName.Text + "角色成功", "", 2);// 写入操作日志
                        Utils.RunJavaScript(this, "type=0;title='" + txtRoleName.Text.Trim().Replace("'", "\\'") + "'");
                    }
                    else if (MsgNum == 2)
                    {
                        WriteLog("新增" + txtRoleName.Text + "角色失败", "该名称已存在", 2);
                        Utils.RunJavaScript(this, "type=2;title='" + txtRoleName.Text.Trim().Replace("'", "\\'") + "';errmsg='该名称已存在,请重写填写角色名称!';");
                    }
                    else
                    {
                        WriteLog("新增" + txtRoleName.Text + "角色失败", returnMsg, 2);
                        Utils.RunJavaScript(this, "type=2;title='" + txtRoleName.Text.Trim().Replace("'", "\\'") + "';errmsg='" + returnMsg.Replace("'", "\\'").Replace("\r\n", "<br>") + "';");
                    }
                }
                else
                {
                    Utils.RunJavaScript(this, "alert({msg:'你没有新增角色的权限,请联系站点管理员!',title:'提示信息'})");
                }
                #endregion
            }
        }
示例#3
0
        /// <summary>
        /// 增、改K_SysRole表

        /// </summary>
        /// <param name="tranType">操作类型,NEW=增,EDIT=改</param>
        /// <param name="AutModel"></param>
        /// <returns>返回大于0的数字操作正常,返回非数字表示操作错误,返回的是系统错误说明</returns>
        public string Save(string trantype, KingTop.Model.SysManage.Role RoleModel)
        {
            return(dal.Save(trantype, RoleModel));
        }