private void btnReturn_Click(object sender, EventArgs e) { if (thislist != null) { int re=-1; string conEventStr = Parameters.event_info; String state2 = "好友分享"; string[] atlist = thislist.Split(','); for (int i = 0; i < atlist.Count(); i++) { String cmdEventInsert2 = "insert into AllEvents(Event_Publisher,Event_Content,Event_PublishTime,Event_Deadline,Event_Class,Event_Authority,Event_State,Event_Pageview,Event_Allowpeople) values('" + atlist[i] + "','" + thisevent[7] + "','" + thisevent[3] + "','" + thisevent[4] + "','" + thisevent[6] + "','" + thisevent[5] + "','" + state2 + "','" + thisevent[8] + "','" + thisevent[11] + "')"; DTConnection con2 = new DTConnection(); re=con2.InsertDelCon(cmdEventInsert2, conEventStr); } if (re == -1) { MessageBox.Show("分享失败!"); } else { MessageBox.Show("已分享!"); } } this.Close(); }
//点击关注 private void btnFollow_Click(object sender, EventArgs e) { if (!Parameters.haslogined) { MessageBox.Show("请先登录!"); } else { Button btnfollow = sender as Button; string userName = btnfollow.Name; if (btnfollow.Text == "关注TA") { DTConnection con = new DTConnection(); String connectionString = Parameters.user_info; String insertStr = "insert into FollowUser(FollowUser_UserName,FollowUser_FollowerName) values('" + userName + "','" + Parameters.username + "')"; int re = con.InsertDelCon(insertStr, connectionString); if (re == -1) { MessageBox.Show("系统繁忙,请重试"); } else { MessageBox.Show("已成功关注"); btnfollow.Text = "取消关注"; btnfollow.BackColor = Color.LightGray; } } else if (btnfollow.Text == "取消关注") { String connectionString = Parameters.user_info; DTConnection con = new DTConnection(); String deleStr = "Delete from FollowUser where FollowUser_FollowerName ='" + Parameters.username + "' and FollowUser_UserName='******'"; int re = con.InsertDelCon(deleStr, connectionString); if (re == -1) { MessageBox.Show("系统繁忙,请重试"); } else { MessageBox.Show("已取关此人!"); btnfollow.Text = "关注TA"; btnfollow.BackColor = Color.GreenYellow; } } } }
// 删除信息 void deleteEvent(object sender, EventArgs e) { Button btn = sender as Button; int idc = int.Parse(btn.Name); String connectionString = Parameters.event_info; String commandDelete = "Delete from AllEvents where Event_Id = " + idc + ";"; DTConnection con = new DTConnection(); int result = con.InsertDelCon(commandDelete, connectionString); if (result == 1) { panel1.Refresh(); this.Refresh(); InitializeForm(); MessageBox.Show("删除成功!"); } else { MessageBox.Show("操作失败!"); } UpdateTag(); }
//收藏 void llblCollect_Click(object sender, EventArgs e) { LinkLabel llbl = sender as LinkLabel; String[] temp = llbl.Name.Split(','); string Event_Publisher = Parameters.username; string Event_PublishTime = temp[3]; string Event_Deadline = temp[4]; string Event_Authority = temp[5]; string Event_Class = temp[6]; string Event_Content = temp[7]; string Event_Pageview = temp[8]; string Event_Follower = temp[9]; string Event_At = temp[10]; string Event_Allowpeople = temp[11]; int eventid = int.Parse(temp[0]); String connectionString = Parameters.event_info; DTConnection con = new DTConnection(); String insertStr = "insert into AllEvents(Event_Publisher,Event_Content,Event_PublishTime,Event_Deadline,Event_Class,Event_Authority,Event_State,Event_Pageview,Event_Allowpeople) values('" + Event_Publisher + "','" + temp[7] + "','" + temp[3] + "','" + temp[4] + "','" + temp[6] + "','" + temp[5] + "','" + "收藏" + "','" + temp[8] + "','" + temp[11] + "')"; con.InsertDelCon(insertStr, connectionString); MessageBox.Show("收藏成功"); }
private void collect_Click(object sender, EventArgs e) { string Event_Publisher = Parameters.username; string Event_PublishTime = readEvent[0][3].ToString(); string Event_Deadline = readEvent[0][4].ToString(); string Event_Authority = readEvent[0][5].ToString(); string Event_Class = readEvent[0][6].ToString(); string Event_Content = readEvent[0][7].ToString(); string Event_Pageview = readEvent[0][8].ToString(); string Event_Follower = readEvent[0][9].ToString(); string Event_At = readEvent[0][10].ToString(); string Event_Allowpeople = readEvent[0][11].ToString(); int eventid = thiseventid; String connectionString = Parameters.event_info; DTConnection con = new DTConnection(); String insertStr = "insert into AllEvents(Event_Publisher,Event_Content,Event_PublishTime,Event_Deadline,Event_Class,Event_Authority,Event_State,Event_Pageview,Event_Allowpeople) values('" + Event_Publisher + "','" + Event_Content + "','" + Event_PublishTime + "','" + Event_Deadline + "','" + Event_Class + "','" + Event_Authority + "','" + "收藏" + "','" + Event_Pageview + "','" + Event_Allowpeople + "')"; con.InsertDelCon(insertStr, connectionString); MessageBox.Show("收藏成功"); }
//关注 private void btnFollowUser_Click(object sender, EventArgs e) { if (this.btnFollowPublisher.Text == "关注TA") { String connectionString = Parameters.user_info; DTConnection con = new DTConnection(); //查看是否已关注 string selectstr = "select * from FollowUser where FollowUser_FollowerName ='" + Parameters.username + "' and FollowUser_UserName='******'"; List<String[]> haveFollow = con.ReadCon(selectstr, connectionString); if (haveFollow.Count == 0)//无此关注 { String insertStr = "insert into FollowUser(FollowUser_UserName,FollowUser_FollowerName) values('" + PublisherName + "','" + Parameters.username + "')"; int re = con.InsertDelCon(insertStr, connectionString); if (re == -1) { MessageBox.Show("系统繁忙,请重试"); } else { MessageBox.Show("已成功关注"); this.btnFollowPublisher.Text = "取消关注"; } } else { MessageBox.Show("已关注此人"); this.btnFollowPublisher.Text = "取消关注"; } } else if (this.btnFollowPublisher.Text == "取消关注") { String connectionString = Parameters.user_info; DTConnection con = new DTConnection(); //查看是否已关注 string selectstr = "select * from FollowUser where FollowUser_FollowerName ='" + Parameters.username + "' and FollowUser_UserName='******'"; List<String[]> haveFollow = con.ReadCon(selectstr, connectionString); if (haveFollow.Count == 0)//无此关注 { MessageBox.Show("未关注此人"); this.btnFollowPublisher.Text = "关注TA"; } else { String deleStr = "Delete from FollowUser where FollowUser_FollowerName ='" + Parameters.username + "' and FollowUser_UserName='******'"; int re = con.InsertDelCon(deleStr, connectionString); if (re == -1) { MessageBox.Show("系统繁忙,请重试"); } else { MessageBox.Show("已取关此人!"); this.btnFollowPublisher.Text = "关注TA"; } } } }
//private void laud_Click(object sender, EventArgs e)//点赞 //{ // //关注 // if (laud.BackColor != Color.Green) // { // laud.BackColor = Color.Green; // laud.Text = "已关注"; // //更新内容 // //根据ID,查询显示事件 // String connectionString1 = Parameters.event_info; // String commandTextQuery1 = "select Event_Follower from AllEvents where Event_Id = '" + eventid + "'"; // using (SqlConnection connection = new SqlConnection(connectionString1)) // { // connection.Open(); // //读取必要信息 // SqlCommand cmdQuery = new SqlCommand(commandTextQuery1, connection); // SqlDataReader reader1 = cmdQuery.ExecuteReader(); // reader1.Read(); // //浏览量 // if (reader1[0] != null) // { // String follwer = reader1[0].ToString().Trim(); // String addtion = "[" + Parameters.username + "]"; // follwer += addtion; // reader1.Close(); // String commandUpdate = "update AllInformation set Follower = '" + follwer + "' where ID = " + eventid + ";"; // SqlCommand cmdUpdate = new SqlCommand(commandUpdate, connection); // cmdUpdate.ExecuteNonQuery(); // String Followers = "[" + Parameters.username + "]"; // lblCurrentFollowers.Text += Followers; // } // } // } // //取消关注 // else // { // laud.BackColor = SystemColors.Control; // laud.Text = "关注"; // String connectionString1 = Parameters.event_info; // /************************/ // using (SqlConnection connection = new SqlConnection(connectionString1)) // { // connection.Open(); // //读取必要信息 // String commandTextQuery1 = "select Follower from AllInformation where ID = " + eventid; // SqlCommand cmdQuery = new SqlCommand(commandTextQuery1, connection); // SqlDataReader reader1 = cmdQuery.ExecuteReader(); // reader1.Read(); // String trim = "[" + Parameters.username + "]"; // String follower = reader1[0].ToString().Remove(reader1[0].ToString().IndexOf(trim)); // lblCurrentFollowers.Text = lblCurrentFollowers.Text.ToString().Remove(lblCurrentFollowers.Text.ToString().IndexOf(trim)); // //浏览量 // if (reader1[0] != null) // { // reader1.Close(); // String commandUpdate = "update AllInformation set Follower = '" + follower + "' where ID = " + eventid + ";"; // SqlCommand cmdUpdate = new SqlCommand(commandUpdate, connection); // cmdUpdate.ExecuteNonQuery(); // } // } // } //} //回复留言 private void comment_Click(object sender, EventArgs e) { DTConnection con = new DTConnection(); string content = this.tboxMyComment.Text; String time = DateTime.Now.ToString("yyyy-MM-dd " + "HH:mm:ss"); string Commentator = Parameters.username; string BeCommentedUser = lblPublisherNme.Text; int EventId = thiseventid; string connectionString = Parameters.event_info; String insertStr = "insert into Event_Comments(Comment_Content,Comment_CommentatorId,Comment_BeCommentedUserId,Comment_Time,Comment_EventId) values('" + content + "','" + Commentator + "','" + BeCommentedUser + "','" + time + "','" + EventId +"')"; int re=con.InsertDelCon(insertStr, connectionString); if (re == -1) { MessageBox.Show("系统繁忙,请重试!"); } else { MessageBox.Show("评论发布成功"); this.rboxComments.Clear(); String selectStr = "select* from Event_Comments where Comment_EventId = '" + thiseventid + "'"; List<String[]> readComments = con.ReadCon(selectStr, connectionString); //通过循环列表显示查询结果集 for (int ii = 0; ii < readComments.Count; ii++) { if (readComments[ii][3] != null) { //用户 内容 发布时间 String comment = readComments[ii][4].ToString().Trim() + "说: " + " " + readComments[ii][3].ToString().Trim() + "\n"; this.rboxComments.AppendText(comment); this.rboxComments.Refresh(); } } } }