示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(LPWeb.Model.Template_RuleGroups model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Template_RuleGroups(");
            strSql.Append("Name,[Desc],[Enabled],RuleScope,LoanTarget)");
            strSql.Append(" values (");
            strSql.Append("@Name,@Desc,@Enabled,@RuleScope,@LoanTarget)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",       SqlDbType.NVarChar,  50),
                new SqlParameter("@Desc",       SqlDbType.NVarChar, 500),
                new SqlParameter("@Enabled",    SqlDbType.Bit,        1),
                new SqlParameter("@RuleScope",  SqlDbType.SmallInt,   2),
                new SqlParameter("@LoanTarget", SqlDbType.SmallInt, 2)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Desc;
            parameters[2].Value = model.Enabled;
            parameters[3].Value = model.RuleScope;
            parameters[4].Value = model.LoanTarget;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(LPWeb.Model.Template_RuleGroups model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Template_RuleGroups set ");
            strSql.Append("RuleGroupId=@RuleGroupId,");
            strSql.Append("Name=@Name,");
            strSql.Append("[Desc]=@Desc,");
            strSql.Append("[Enabled]=@Enabled,");
            strSql.Append("RuleScope=@RuleScope,");
            strSql.Append("LoanTarget=@LoanTarget");
            strSql.Append(" where RuleGroupId=@RuleGroupId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RuleGroupId", SqlDbType.Int,        4),
                new SqlParameter("@Name",        SqlDbType.NVarChar,  50),
                new SqlParameter("@Desc",        SqlDbType.NVarChar, 500),
                new SqlParameter("@Enabled",     SqlDbType.Bit,        1),
                new SqlParameter("@RuleScope",   SqlDbType.SmallInt,   2),
                new SqlParameter("@LoanTarget",  SqlDbType.SmallInt, 2)
            };
            parameters[0].Value = model.RuleGroupId;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Desc;
            parameters[3].Value = model.Enabled;
            parameters[4].Value = model.RuleScope;
            parameters[5].Value = model.LoanTarget;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
示例#3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LPWeb.Model.Template_RuleGroups GetModel(int RuleGroupId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 RuleGroupId,Name,[Desc],[Enabled],RuleScope,LoanTarget from Template_RuleGroups ");
            strSql.Append(" where RuleGroupId=@RuleGroupId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RuleGroupId", SqlDbType.Int, 4)
            };
            parameters[0].Value = RuleGroupId;

            LPWeb.Model.Template_RuleGroups model = new LPWeb.Model.Template_RuleGroups();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["RuleGroupId"].ToString() != "")
                {
                    model.RuleGroupId = int.Parse(ds.Tables[0].Rows[0]["RuleGroupId"].ToString());
                }
                model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                model.Desc = ds.Tables[0].Rows[0]["Desc"].ToString();
                if (ds.Tables[0].Rows[0]["Enabled"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Enabled"].ToString() == "1") || (ds.Tables[0].Rows[0]["Enabled"].ToString().ToLower() == "true"))
                    {
                        model.Enabled = true;
                    }
                    else
                    {
                        model.Enabled = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["RuleScope"].ToString() != "")
                {
                    model.RuleScope = int.Parse(ds.Tables[0].Rows[0]["RuleScope"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LoanTarget"].ToString() != "")
                {
                    model.LoanTarget = int.Parse(ds.Tables[0].Rows[0]["LoanTarget"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }