Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(LPWeb.Model.Template_RuleCollection model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Template_RuleCollection(");
            strSql.Append("Name,Enabled)");
            strSql.Append(" values (");
            strSql.Append("@Name,@Enabled)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",    SqlDbType.NVarChar, 50),
                new SqlParameter("@Enabled", SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Enabled;

            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_RuleCollection model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Template_RuleCollection set ");
            strSql.Append("RuleCollectionlId=@RuleCollectionlId,");
            strSql.Append("Name=@Name,");
            strSql.Append("Enabled=@Enabled");
            strSql.Append(" where RuleCollectionlId=@RuleCollectionlId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RuleCollectionlId", SqlDbType.Int,       4),
                new SqlParameter("@Name",              SqlDbType.NVarChar, 50),
                new SqlParameter("@Enabled",           SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.RuleCollectionlId;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Enabled;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LPWeb.Model.Template_RuleCollection GetModel(int RuleCollectionlId)
        {
            StringBuilder strSql = new StringBuilder();

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

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["RuleCollectionlId"].ToString() != "")
                {
                    model.RuleCollectionlId = int.Parse(ds.Tables[0].Rows[0]["RuleCollectionlId"].ToString());
                }
                model.Name = ds.Tables[0].Rows[0]["Name"].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;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }