Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(string GUID, string UID, rolesEntity UEntity, string FunList)
        {
            int result = _dal.Update(UEntity, FunList);

            //检测执行结果
            CheckResult(result, "");
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加角色权限信息
        /// </summary>
        /// <param name="Entity">角色实体</param>
        /// <param name="FunList">功能数组</param>
        /// <returns></returns>
        public int AddRITMAS(rolesEntity Entity, string[] FunList)
        {
            StringBuilder Builder = new StringBuilder();

            Builder.Append(" BEGIN TRAN tan1");
            Builder.Append(" declare @rolid int");
            int rel = CheckRoleName(Entity.roleid.ToString(), Entity.cname, Entity.buscode);

            if (rel <= 0)
            {
                if (Entity.roleid == 0)
                {
                    Builder.AppendFormat(" INSERT INTO dbo.roles(scope,stocode,cname,[status],descr,cuser,ctime,buscode)VALUES({0},'{1}','{2}','{3}','{4}','{5}',getdate(),'{6}');", Entity.scope, Entity.stocode, Entity.cname, Entity.status, Entity.descr, Entity.cuser, Entity.buscode);
                    Builder.Append(" set @rolid=SCOPE_IDENTITY();");
                }
                else
                {
                    Builder.Append(" UPDATE roles SET scope=" + Entity.scope + ",utime=getdate(),uuser="******" ,stocode='" + Entity.stocode + "'");
                    if (Entity.cname.Length > 0)
                    {
                        Builder.Append(" ,cname='" + Entity.cname + "'");
                    }
                    if (Entity.status.Length > 0)
                    {
                        Builder.Append(" ,[status]='" + Entity.status + "'");
                    }
                    if (Entity.descr.Length > 0)
                    {
                        Builder.Append(" ,descr='" + Entity.descr + "'");
                    }
                    Builder.AppendFormat(" WHERE roleid={0};", Entity.roleid);
                    Builder.Append(" set @rolid=" + Entity.roleid + ";");
                }
                Builder.AppendFormat(" DELETE FROM rolefunction WHERE roleid={0}", Entity.roleid);

                try
                {
                    if (FunList != null && FunList.Length > 0)
                    {
                        foreach (string item in FunList)
                        {
                            if (!string.IsNullOrEmpty(item))
                            {
                                Builder.Append(" INSERT INTO rolefunction(roleid,funid)");
                                Builder.AppendFormat(" VALUES(@rolid,{0});", item);
                            }
                        }
                    }
                }
                catch
                { }
                Builder.Append(" if(@@error=0) begin commit tran tan1 end else begin rollback tran tran1 end");
                return(DBHelper.ExecuteNonQuery(Builder.ToString()));
            }
            else
            {
                return(3);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 //public int Update(StoreEntity Entity, string storetype, string jprice, string paytype, string sqcode, string jcaddress, string isjc, string jctype, string xftime, string sumcode, string mccode, string idtype)
 public int Update(rolesEntity Entity, string funlist)
 {
     SqlParameter[] sqlParameters =
     {
         new SqlParameter("@roleid",  Entity.roleid),
         new SqlParameter("@scope",   Entity.buscode),
         new SqlParameter("@stocode", Entity.stocode),
         new SqlParameter("@cname",   Entity.cname),
         new SqlParameter("@descr",   Entity.descr),
         new SqlParameter("@status",  Entity.status),
         new SqlParameter("@funs",    funlist)
     };
     return(DBHelper.ExecuteNonQuery("dbo.p_roles_Update", CommandType.StoredProcedure, sqlParameters));
 }
Exemplo n.º 4
0
        /// <summary>
        /// 单行数据转实体对象
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>
        private rolesEntity SetEntityInfo(DataRow dr)
        {
            rolesEntity Entity = new rolesEntity();

            Entity.buscode = dr["buscode"].ToString();
            Entity.cname   = dr["cname"].ToString();
            Entity.ctime   = StringHelper.StringToDateTime(dr["ctime"].ToString());
            Entity.cuser   = StringHelper.StringToInt(dr["cuser"].ToString());
            Entity.descr   = dr["descr"].ToString();
            Entity.roleid  = StringHelper.StringToInt(dr["roleid"].ToString());
            Entity.scope   = dr["scope"].ToString();
            Entity.status  = dr["status"].ToString();
            Entity.stocode = dr["stocode"].ToString();
            Entity.utime   = StringHelper.StringToDateTime(dr["utime"].ToString());
            Entity.uuser   = StringHelper.StringToInt(dr["uuser"].ToString());
            return(Entity);
        }
        protected void Save_btn_Click(object sender, EventArgs e)
        {
            rolesEntity ROLMAEntity = new rolesEntity();

            ROLMAEntity.cname  = rol_name.Text;
            ROLMAEntity.descr  = rol_descr.Text;
            ROLMAEntity.status = ddl_status.SelectedValue;
            if (hidId.Value.Length == 0)
            {
                bllroles.AddRITMAS(ROLMAEntity, GetArray(this.HidfunIdStr.Value));
                errormessage.InnerHtml = bllroles.oResult.Msg;
            }
            else
            {
                ROLMAEntity.roleid = StringHelper.StringToInt(hidId.Value);
                bllroles.Update("", "", ROLMAEntity, this.HidfunIdStr.Value);
                if (bllroles.oResult.Code == "1")
                {
                    MenuList.InnerHtml = GetMenuTable(StringHelper.StringToInt(hidId.Value));
                }
                errormessage.InnerHtml = bllroles.oResult.Msg;
                this.PageTitle.Operate = "修改";
            }
        }
Exemplo n.º 6
0
 public int AddRITMAS(rolesEntity Entity, string[] FunList)
 {
     return(_dal.AddRITMAS(Entity, FunList));
 }