/// <summary> /// 得到一个对象实体 /// </summary> public university.Model.CCOM.SMS GetModel(long SMS_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select SMS_id, Notice_id, SMS_sender_id, SMS_receiver_id, SMS_content, SMS_date "); strSql.Append(" from SMS "); strSql.Append(" where SMS_id=@SMS_id"); SqlParameter[] parameters = { new SqlParameter("@SMS_id", SqlDbType.BigInt) }; parameters[0].Value = SMS_id; university.Model.CCOM.SMS model = new university.Model.CCOM.SMS(); DataSet ds = DBSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["SMS_id"].ToString() != "") { model.SMS_id = long.Parse(ds.Tables[0].Rows[0]["SMS_id"].ToString()); } if (ds.Tables[0].Rows[0]["Notice_id"].ToString() != "") { model.Notice_id = long.Parse(ds.Tables[0].Rows[0]["Notice_id"].ToString()); } if (ds.Tables[0].Rows[0]["SMS_sender_id"].ToString() != "") { model.SMS_sender_id = long.Parse(ds.Tables[0].Rows[0]["SMS_sender_id"].ToString()); } model.SMS_receiver_id = ds.Tables[0].Rows[0]["SMS_receiver_id"].ToString(); model.SMS_content = ds.Tables[0].Rows[0]["SMS_content"].ToString(); if (ds.Tables[0].Rows[0]["SMS_date"].ToString() != "") { model.SMS_date = DateTime.Parse(ds.Tables[0].Rows[0]["SMS_date"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(university.Model.CCOM.SMS model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update SMS set "); strSql.Append(" Notice_id = @Notice_id , "); strSql.Append(" SMS_sender_id = @SMS_sender_id , "); strSql.Append(" SMS_receiver_id = @SMS_receiver_id , "); strSql.Append(" SMS_content = @SMS_content , "); strSql.Append(" SMS_date = @SMS_date "); strSql.Append(" where SMS_id=@SMS_id "); SqlParameter[] parameters = { new SqlParameter("@SMS_id", SqlDbType.BigInt, 8), new SqlParameter("@Notice_id", SqlDbType.BigInt, 8), new SqlParameter("@SMS_sender_id", SqlDbType.BigInt, 8), new SqlParameter("@SMS_receiver_id", SqlDbType.Text), new SqlParameter("@SMS_content", SqlDbType.Text), new SqlParameter("@SMS_date", SqlDbType.DateTime) }; parameters[0].Value = model.SMS_id; parameters[1].Value = model.Notice_id; parameters[2].Value = model.SMS_sender_id; parameters[3].Value = model.SMS_receiver_id; parameters[4].Value = model.SMS_content; parameters[5].Value = model.SMS_date; int rows = DBSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public university.Model.CCOM.SMS GetModel(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select SMS_id, Notice_id, SMS_sender_id, SMS_receiver_id, SMS_content, SMS_date "); strSql.Append(" from SMS "); strSql.Append(" where " + strWhere); university.Model.CCOM.SMS model = new university.Model.CCOM.SMS(); DataSet ds = DBSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["SMS_id"].ToString() != "") { model.SMS_id = long.Parse(ds.Tables[0].Rows[0]["SMS_id"].ToString()); } if (ds.Tables[0].Rows[0]["Notice_id"].ToString() != "") { model.Notice_id = long.Parse(ds.Tables[0].Rows[0]["Notice_id"].ToString()); } if (ds.Tables[0].Rows[0]["SMS_sender_id"].ToString() != "") { model.SMS_sender_id = long.Parse(ds.Tables[0].Rows[0]["SMS_sender_id"].ToString()); } model.SMS_receiver_id = ds.Tables[0].Rows[0]["SMS_receiver_id"].ToString(); model.SMS_content = ds.Tables[0].Rows[0]["SMS_content"].ToString(); if (ds.Tables[0].Rows[0]["SMS_date"].ToString() != "") { model.SMS_date = DateTime.Parse(ds.Tables[0].Rows[0]["SMS_date"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public long Add(university.Model.CCOM.SMS model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into SMS("); strSql.Append("Notice_id,SMS_sender_id,SMS_receiver_id,SMS_content,SMS_date"); strSql.Append(") values ("); strSql.Append("@Notice_id,@SMS_sender_id,@SMS_receiver_id,@SMS_content,@SMS_date"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Notice_id", SqlDbType.BigInt, 8), new SqlParameter("@SMS_sender_id", SqlDbType.BigInt, 8), new SqlParameter("@SMS_receiver_id", SqlDbType.Text), new SqlParameter("@SMS_content", SqlDbType.Text), new SqlParameter("@SMS_date", SqlDbType.DateTime) }; parameters[0].Value = model.Notice_id; parameters[1].Value = model.SMS_sender_id; parameters[2].Value = model.SMS_receiver_id; parameters[3].Value = model.SMS_content; parameters[4].Value = model.SMS_date; object obj = DBSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt64(obj)); } }