コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Lythen.Model.Sys_job model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Sys_job set ");
            strSql.Append("Job_title=@Job_title");
            strSql.Append(" where Job_id=@Job_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Job_title", SqlDbType.VarChar, 20),
                new SqlParameter("@Job_id",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Job_title;
            parameters[1].Value = model.Job_id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Lythen.Model.Sys_job model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Sys_job(");
            strSql.Append("Job_title)");
            strSql.Append(" values (");
            strSql.Append("@Job_title)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Job_title", SqlDbType.VarChar, 20)
            };
            parameters[0].Value = model.Job_title;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Lythen.Model.Sys_job DataRowToModel(DataRow row)
 {
     Lythen.Model.Sys_job model = new Lythen.Model.Sys_job();
     if (row != null)
     {
         if (row["Job_id"] != null && row["Job_id"].ToString() != "")
         {
             model.Job_id = int.Parse(row["Job_id"].ToString());
         }
         if (row["Job_title"] != null)
         {
             model.Job_title = row["Job_title"].ToString();
         }
     }
     return(model);
 }
コード例 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Lythen.Model.Sys_job GetModel(int Job_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Job_id,Job_title from Sys_job ");
            strSql.Append(" where Job_id=@Job_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Job_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Job_id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }