/// <summary> /// 查询集合 /// </summary> /// <returns></returns> public IList<AgentComplainReply> GetList(String complain_seq) { string sql = "SELECT sequence,complain_seq,createTime,replyComment FROM tb_complain_reply where complain_seq=@complain_seq"; using (MySqlConnection mycn = new MySqlConnection(mysqlConnection)) { mycn.Open(); MySqlCommand command = new MySqlCommand(sql, mycn); command.Parameters.AddWithValue("@complain_seq", complain_seq); MySqlDataReader reader = command.ExecuteReader(); IList<AgentComplainReply> list = new List<AgentComplainReply>(); AgentComplainReply agentComplainReply = null; while (reader.Read()) { agentComplainReply = new AgentComplainReply(); agentComplainReply.sequence = reader["sequence"] == DBNull.Value ? null : reader["sequence"].ToString(); agentComplainReply.complainSequence = reader["complain_seq"] == DBNull.Value ? null : reader["complain_seq"].ToString(); agentComplainReply.replyTime = reader["createTime"] == DBNull.Value ? null : reader["createTime"].ToString(); agentComplainReply.replyContent = reader["replyComment"] == DBNull.Value ? null : reader["replyComment"].ToString(); list.Add(agentComplainReply); } mycn.Close(); return list; } }
protected void btnSave_Click(object sender, EventArgs e) { AgentComplainReplyDao agentComplainReplyDao = new AgentComplainReplyDao(); AgentComplainReply agentComplainReply = new AgentComplainReply(); if (!String.IsNullOrEmpty(this.txtReplyContent.Text)) { agentComplainReply.replyContent = this.txtReplyContent.Text; agentComplainReply.complainSequence = this.lblSeq.Text; agentComplainReply.replyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); agentComplainReplyDao.Add(agentComplainReply); this.Server.Transfer("./MyComplainQuery.aspx?userId=" + this.lblWechatUser.Text); } }
public const string mysqlConnection = DBConstant.mysqlConnection;//"User Id=root;Host=115.29.229.134;Database=chinaunion;password=c513324665;charset=utf8"; /// <summary> /// 添加数据 /// </summary> /// <returns></returns> public int Add(AgentComplainReply entity) { string sql = "INSERT INTO tb_complain_reply (sequence,complain_seq,createTime,replyComment) VALUE (@sequence,@complain_seq,@createTime,@replyComment)"; using (MySqlConnection mycn = new MySqlConnection(mysqlConnection)) { mycn.Open(); MySqlCommand command = new MySqlCommand(sql, mycn); command.Parameters.AddWithValue("@sequence", entity.sequence); command.Parameters.AddWithValue("@complain_seq", entity.complainSequence); command.Parameters.AddWithValue("@createTime", entity.replyTime); command.Parameters.AddWithValue("@replyComment", entity.replyContent); int i = command.ExecuteNonQuery(); mycn.Close(); mycn.Dispose(); return i; } }