/// <summary> /// 更新一条数据 /// </summary> public bool Update(Class_SQL.Model.Sys_Text model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Sys_Text set "); if (model.TextInfo != null) { strSql.Append("TextInfo='" + model.TextInfo + "',"); } if (model.TextTime != null) { strSql.Append("TextTime='" + model.TextTime + "',"); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where TextNumber='" + model.TextNumber + "' "); int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Class_SQL.Model.Sys_Text DataRowToModel(DataRow row) { Class_SQL.Model.Sys_Text model = new Class_SQL.Model.Sys_Text(); if (row != null) { if (row["TextNumber"] != null) { model.TextNumber = row["TextNumber"].ToString(); } if (row["TextInfo"] != null) { model.TextInfo = row["TextInfo"].ToString(); } if (row["TextTime"] != null && row["TextTime"].ToString() != "") { model.TextTime = DateTime.Parse(row["TextTime"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Class_SQL.Model.Sys_Text GetModel(string TextNumber) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" TextNumber,TextInfo,TextTime "); strSql.Append(" from Sys_Text "); strSql.Append(" where TextNumber='" + TextNumber + "' "); Class_SQL.Model.Sys_Text model = new Class_SQL.Model.Sys_Text(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Class_SQL.Model.Sys_Text model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.TextNumber != null) { strSql1.Append("TextNumber,"); strSql2.Append("'" + model.TextNumber + "',"); } if (model.TextInfo != null) { strSql1.Append("TextInfo,"); strSql2.Append("'" + model.TextInfo + "',"); } if (model.TextTime != null) { strSql1.Append("TextTime,"); strSql2.Append("'" + model.TextTime + "',"); } strSql.Append("insert into Sys_Text("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); int rows = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rows > 0) { return(true); } else { return(false); } }