/// <summary> /// 更新一条数据 /// </summary> public bool Update(Lythen.Model.sys_stu_school model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update sys_stu_school set "); strSql.Append("ss_title=@ss_title"); strSql.Append(" where ss_id=@ss_id"); SqlParameter[] parameters = { new SqlParameter("@ss_title", SqlDbType.VarChar, 100), new SqlParameter("@ss_id", SqlDbType.Int, 4) }; parameters[0].Value = model.ss_title; parameters[1].Value = model.ss_id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lythen.Model.sys_stu_school model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into sys_stu_school("); strSql.Append("ss_title)"); strSql.Append(" values ("); strSql.Append("@ss_title)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@ss_title", SqlDbType.VarChar, 100) }; parameters[0].Value = model.ss_title; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Lythen.Model.sys_stu_school DataRowToModel(DataRow row) { Lythen.Model.sys_stu_school model = new Lythen.Model.sys_stu_school(); if (row != null) { if (row["ss_id"] != null && row["ss_id"].ToString() != "") { model.ss_id = int.Parse(row["ss_id"].ToString()); } if (row["ss_title"] != null) { model.ss_title = row["ss_title"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Lythen.Model.sys_stu_school GetModel(int ss_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ss_id,ss_title from sys_stu_school "); strSql.Append(" where ss_id=@ss_id"); SqlParameter[] parameters = { new SqlParameter("@ss_id", SqlDbType.Int, 4) }; parameters[0].Value = ss_id; Lythen.Model.sys_stu_school model = new Lythen.Model.sys_stu_school(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }