Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(OS.Model.configs.yl_temp model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update yl_temp set ");
            strSql.Append("name=@name,");
            strSql.Append("title=@title,");
            strSql.Append("status=@status");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@name",   SqlDbType.NVarChar, 100),
                new SqlParameter("@title",  SqlDbType.NVarChar, 100),
                new SqlParameter("@status", SqlDbType.Int,        4),
                new SqlParameter("@id",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.title;
            parameters[2].Value = model.status;
            parameters[3].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(OS.Model.configs.yl_temp model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into yl_temp(");
            strSql.Append("name,title,status)");
            strSql.Append(" values (");
            strSql.Append("@name,@title,@status)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@name",   SqlDbType.NVarChar, 100),
                new SqlParameter("@title",  SqlDbType.NVarChar, 100),
                new SqlParameter("@status", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.title;
            parameters[2].Value = model.status;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public OS.Model.configs.yl_temp GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,name,title,status from yl_temp ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            OS.Model.configs.yl_temp model = new OS.Model.configs.yl_temp();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["name"] != null && ds.Tables[0].Rows[0]["name"].ToString() != "")
                {
                    model.name = ds.Tables[0].Rows[0]["name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "")
                {
                    model.title = ds.Tables[0].Rows[0]["title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["status"] != null && ds.Tables[0].Rows[0]["status"].ToString() != "")
                {
                    model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public OS.Model.configs.yl_temp GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 id,name,title,status from yl_temp ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

            OS.Model.configs.yl_temp model=new OS.Model.configs.yl_temp();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["id"]!=null && ds.Tables[0].Rows[0]["id"].ToString()!="")
                {
                    model.id=int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if(ds.Tables[0].Rows[0]["name"]!=null && ds.Tables[0].Rows[0]["name"].ToString()!="")
                {
                    model.name=ds.Tables[0].Rows[0]["name"].ToString();
                }
                if(ds.Tables[0].Rows[0]["title"]!=null && ds.Tables[0].Rows[0]["title"].ToString()!="")
                {
                    model.title=ds.Tables[0].Rows[0]["title"].ToString();
                }
                if(ds.Tables[0].Rows[0]["status"]!=null && ds.Tables[0].Rows[0]["status"].ToString()!="")
                {
                    model.status=int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }