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