/// <summary> /// 更新一条数据 /// </summary> public bool Update(UserFB.Model.Reply model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Reply set "); strSql.Append("feedbackID=@feedbackID,"); strSql.Append("replierID=@replierID,"); strSql.Append("receiverID=@receiverID,"); strSql.Append("text=@text,"); strSql.Append("time=@time,"); strSql.Append("remark=@remark"); strSql.Append(" where replyID=@replyID"); SqlParameter[] parameters = { new SqlParameter("@feedbackID", SqlDbType.Int, 4), new SqlParameter("@replierID", SqlDbType.Int, 4), new SqlParameter("@receiverID", SqlDbType.Int, 4), new SqlParameter("@text", SqlDbType.VarChar, 128), new SqlParameter("@time", SqlDbType.SmallDateTime), new SqlParameter("@remark", SqlDbType.VarChar, 64), new SqlParameter("@replyID", SqlDbType.Int, 4) }; parameters[0].Value = model.feedbackID; parameters[1].Value = model.replierID; parameters[2].Value = model.receiverID; parameters[3].Value = model.text; parameters[4].Value = model.time; parameters[5].Value = model.remark; parameters[6].Value = model.replyID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool AddReply(UserFB.Model.Reply model, string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Reply("); strSql.Append("feedbackID,replierID,receiverID,text,time,remark)"); strSql.Append(" values ("); strSql.Append("@feedbackID,@replierID,@receiverID,@text,@time,@remark)"); strSql.Append(";select @@IDENTITY"); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } SqlParameter[] parameters = { new SqlParameter("@feedbackID", SqlDbType.Int, 4), new SqlParameter("@replierID", SqlDbType.Int, 4), new SqlParameter("@receiverID", SqlDbType.Int, 4), new SqlParameter("@text", SqlDbType.VarChar, 128), new SqlParameter("@time", SqlDbType.SmallDateTime), new SqlParameter("@remark", SqlDbType.VarChar, 64) }; parameters[0].Value = model.feedbackID; parameters[1].Value = model.replierID; parameters[2].Value = model.receiverID; parameters[3].Value = model.text; parameters[4].Value = model.time; parameters[5].Value = model.remark; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(false); } else { return(true); } }
/// <summary> /// 得到一个对象实体 /// </summary> public UserFB.Model.Reply DataRowToModel(DataRow row) { UserFB.Model.Reply model = new UserFB.Model.Reply(); if (row != null) { if (row["replyID"] != null && row["replyID"].ToString() != "") { model.replyID = int.Parse(row["replyID"].ToString()); } if (row["feedbackID"] != null && row["feedbackID"].ToString() != "") { model.feedbackID = int.Parse(row["feedbackID"].ToString()); } if (row["replierID"] != null && row["replierID"].ToString() != "") { model.replierID = int.Parse(row["replierID"].ToString()); } if (row["receiverID"] != null && row["receiverID"].ToString() != "") { model.receiverID = int.Parse(row["receiverID"].ToString()); } if (row["text"] != null) { model.text = row["text"].ToString(); } if (row["time"] != null && row["time"].ToString() != "") { model.time = DateTime.Parse(row["time"].ToString()); } if (row["remark"] != null) { model.remark = row["remark"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public UserFB.Model.Reply GetModel(int replyID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 replyID,feedbackID,replierID,receiverID,text,time,remark from Reply "); strSql.Append(" where replyID=@replyID"); SqlParameter[] parameters = { new SqlParameter("@replyID", SqlDbType.Int, 4) }; parameters[0].Value = replyID; UserFB.Model.Reply model = new UserFB.Model.Reply(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(UserFB.Model.Reply model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(UserFB.Model.Reply model) { return(dal.Add(model)); }