コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(AppMenuVsMerRoleModel model)
        {
            bool          reValue = true;
            int           reCount = 0;
            StringBuilder strSql  = new StringBuilder();

            strSql.Append("update CORE.dbo.AppMenuVsMerRole set ");

            strSql.Append(" AppMenuId = @AppMenuId , ");
            strSql.Append(" MerRoleId = @MerRoleId  ");
            strSql.Append(" where AppMenuId=@AppMenuId and MerRoleId=@MerRoleId  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@AppMenuId", SqlDbType.VarChar, 50),
                new SqlParameter("@MerRoleId", SqlDbType.Decimal, 9)
            };

            parameters[0].Value = model.AppMenuId;
            parameters[1].Value = model.MerRoleId; try
            {//异常处理
                reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters);
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            if (reCount <= 0)
            {
                reValue = false;
            }
            return(reValue);
        }
コード例 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AppMenuVsMerRoleModel GetModel(string AppMenuId, decimal MerRoleId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select AppMenuId, MerRoleId  ");
            strSql.Append("  from CORE.dbo.AppMenuVsMerRole ");
            strSql.Append(" where AppMenuId=@AppMenuId and MerRoleId=@MerRoleId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AppMenuId", SqlDbType.VarChar, 50),
                new SqlParameter("@MerRoleId", SqlDbType.Decimal, 9)
            };
            parameters[0].Value = AppMenuId;
            parameters[1].Value = MerRoleId;


            AppMenuVsMerRoleModel model = new AppMenuVsMerRoleModel();
            DataSet ds = helper.ExecSqlReDs(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.AppMenuId = ds.Tables[0].Rows[0]["AppMenuId"].ToString();
                if (ds.Tables[0].Rows[0]["MerRoleId"].ToString() != "")
                {
                    model.MerRoleId = decimal.Parse(ds.Tables[0].Rows[0]["MerRoleId"].ToString());
                }

                return(model);
            }
            else
            {
                return(model);
            }
        }
コード例 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(AppMenuVsMerRoleModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CORE.dbo.AppMenuVsMerRole (");
            strSql.Append("AppMenuId,MerRoleId");
            strSql.Append(") values (");
            strSql.Append("@AppMenuId,@MerRoleId");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@AppMenuId", SqlDbType.VarChar, 50),
                new SqlParameter("@MerRoleId", SqlDbType.Decimal, 9)
            };

            parameters[0].Value = model.AppMenuId;
            parameters[1].Value = model.MerRoleId;

            bool result = false;

            try
            {
                helper.ExecSqlReInt(strSql.ToString(), parameters);
                result = true;
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            finally
            {
            }
            return(result);
        }