/************************/ //验证登录 /// <summary> /// 验证是否有此用户,是-返回true,否-弹出消息 /// </summary> /// <param name="QueryUserStr">语句查询</param> /// <param name="inputPassword">密码</param> /// <param name="inputUsername">用户名</param> /// <returns></returns> public bool Login(String QueryUserStr, String inputPassword, String inputUsername) { bool r = false; String conDBStr = Parameters.user_info; DTConnection con = new DTConnection(); List<String[]> reader = con.ReadCon(QueryUserStr, conDBStr); //验证密码是否正确 int num = reader.Count; while (num>0) { String password = reader[0][0].ToString(); if (password == inputPassword) { r = true; break; } else if (reader.Count==0)//没有内容 { MessageBox.Show("用户类型不正确!"); } else if (password != inputPassword)//密码不匹配 { MessageBox.Show("账户与密码不匹配!"); } num--; } return r; }
private void ImproveAdministratorInformation_Load(object sender, EventArgs e) { AEntryText.Text = Parameters.username; string name = AEntryText.Text; //连接数据库 String connectionString = Parameters.user_info; String commandTextQuery = "select * from AdminInfo where AdminInfo_NickName = '" + name + "'"; DTConnection con = new DTConnection(); List<String[]> reader = con.ReadCon(commandTextQuery, connectionString); int count = reader.Count; foreach (String[] temp in reader) { if (count > 0) { ASexText.Text = reader[count-1][3].ToString(); AAgeText.Text = reader[count - 1][4].ToString(); AEmailText.Text = reader[count - 1][5].ToString(); ACellPText.Text = reader[count - 1][6].ToString(); AWorkPlaceText.Text = reader[count - 1][7].ToString(); AEntryText.Text = reader[count - 1][1].ToString(); if (File.Exists(reader[count - 1][11].ToString().Trim())) { Parameters.iconfullpath = new DirectoryInfo("../../../").FullName+reader[count - 1][11].ToString().Trim(); } this.pboxIcon.Image = Image.FromFile(Parameters.iconfullpath); } else { MessageBox.Show("对不起,信息加载出错"); } count--; } }
//构造函数,实现关键字搜索 public List<String[]> KeySearchResult(String key) { String connectionString = Parameters.event_info; String commandTextQuery = "select * from AllEvents where Event_Content like '%" + key + "%';"; DTConnection con=new DTConnection(); List<String[]> keyResult=con.ReadCon(commandTextQuery,connectionString); return keyResult; }
public void InitializeForm() { this.lblTitle.Text = Parameters.username;//窗口标题 flagi = 0; this.panel1.Controls.Clear();//清空控件 String Event_constr = Parameters.event_info; string User_constr = Parameters.user_info; /************************/ //加载自己发布的所有拼事件 String name = Parameters.username; String QueryMyEvents = "select * from AllEvents where Event_Publisher = '" + name + "' order by Event_PublishTime desc;"; DTConnection con = new DTConnection(); List<String[]> record = con.ReadCon(QueryMyEvents, Event_constr); //通过循环列表显示查询结果集 int recordnum = record.Count; if (recordnum > 0) { for (int i = 0; i < recordnum; i++) { //ID,content,类别,发布时间 this.panel1.Controls.Add(AddControl(int.Parse(record[i][0].ToString()), record[i][7].ToString(), record[i][6].ToString(), record[i][3].ToString(), record[i][1].ToString())); } } else { //MessageBox.Show("你还没有发布信息哦!"); } //读头像 string fieldname = Parameters.userFieldname[Parameters.usertype] + "_NickName"; string tablename = Parameters.userTablename[Parameters.usertype]; String QueryMyIcon = "select * from " + tablename + " where " + fieldname + " = '" + Parameters.username + "' ;"; List<String[]> iconlist = con.ReadCon(QueryMyIcon, User_constr); string tpath = new DirectoryInfo("../../../").FullName+iconlist[0][11].ToString(); //头像和ID Parameters.id = iconlist[0][10].ToString(); if (File.Exists(tpath)) { Parameters.iconfullpath = tpath; } this.pboxFace.SizeMode = PictureBoxSizeMode.Zoom; this.pboxFace.Image = Image.FromFile(Parameters.iconfullpath); UpdateTag(); }
private void UIReportReason_Load(object sender, EventArgs e)//显示举报信息 { String connectionString1 = Parameters.event_info; String commandQuery = "Select Event_Publisher,Event_Content from AllEvents where Event_Id = "+thiseventid+";"; DTConnection dt = new DTConnection(); List<String[]> reader = dt.ReadCon(commandQuery,connectionString1); richTextBox1.Text = reader[0][1].ToString().Trim(); label1.Text = "举报用户" + reader[0][0].ToString().ToString().Trim()+ "的事件:"; }
private void ShareWithFriends_Load(object sender, EventArgs e) { String connectionString = Parameters.user_info; String commandTextQuery = "select * from FollowUser where FollowUser_FollowerName ='" + Parameters.username + "'"; DTConnection con = new DTConnection(); List<String[]> reader = con.ReadCon(commandTextQuery, connectionString); for (int i = 0; i < reader.Count(); i++) { this.lboxFriends.Items.Add(reader[i][1]); } }
private void LoadFollowList() { String connectionString = Parameters.user_info; String commandTextQuery = "select FollowUser_UserName from FollowUser where FollowUser_FollowerName = '" + Parameters.username + "';"; string userConstr = Parameters.user_info; DTConnection con = new DTConnection(); //读数据库 List<String[]> reader = con.ReadCon(commandTextQuery, connectionString); //显示 ShowFollowList(reader); }
public bool Insert(String InputContent,String InputDeadline,String Class1,string atfriends,string allowpeople) { //插入项 String publisher = Parameters.username; String content = InputContent; String time = DateTime.Now.ToString("yyyy-MM-dd " + "HH:mm:ss"); String deadline = InputDeadline; String classi = Class1; int authority = Parameters.messlevel; String state = "未拼"; int pageview = 0; //连接事件数据库&空间数据库 String conEventStr = Parameters.event_info; String conSpatialStr = Parameters.spatial_info; //插入发布人事件表 String cmdEventInsert = "insert into AllEvents(Event_Publisher,Event_Content,Event_PublishTime,Event_Deadline,Event_Class,Event_Authority,Event_State,Event_Pageview,Event_At,Event_Allowpeople) values('" + publisher + "','" + content + "','" + time + "','" + deadline + "','" + classi + "','" + authority + "','" + state + "','" + pageview + "','" + atfriends + "','" + allowpeople+ "')"; DTConnection con = new DTConnection(); int result = con.UpdateCon(cmdEventInsert, conEventStr); //插入AT人事件表 if (atfriends != null) { String state2 = "好友@"; string[] atlist = atfriends.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] + "','" + InputContent + "','" + time + "','" + deadline + "','" + classi + "','" + authority + "','" + state2 + "','" + pageview + "','" + allowpeople + "')"; DTConnection con2 = new DTConnection(); con2.UpdateCon(cmdEventInsert2, conEventStr); } } //空间数据库 //查询对应的Eventid插入空间数据库aaaa String cmdEventSelect = "select Event_Id from AllEvents where Event_Id=(select max(Event_Id) from Allevents)"; List<String[]> reader = con.ReadCon(cmdEventSelect, conEventStr); int id = int.Parse(reader[0][0]); //将该id和事件内容更新到对应的空间数据库中 String cmdSpatialInsert = "update EventLocation set EL_EventId='" + id + "',EL_Content='" + content + "' where EL_LocateId=(select max(EL_LocateId) from EventLocation )"; con.UpdateCon(cmdSpatialInsert, conSpatialStr); if (result == -1) { return false;//发布失败 } else { return true;//发布成功 } }
public void InitializeForm() { tabPage1.Text = "未拼"; tabPage2.Text = "已拼"; String connectionString = Parameters.event_info; String commandTextQuery = "select * from AllEvents where Event_State='未拼' order by Event_PublishTime desc"; DTConnection con = new DTConnection(); List<String[]> reader = con.ReadCon(commandTextQuery, connectionString); //清空原TABPAGE tabPage1.Controls.Clear(); AddKJ(reader, tabPage1); //读头像 this.pboxFace.SizeMode = PictureBoxSizeMode.Zoom; this.pboxFace.Image = Image.FromFile(Parameters.iconfullpath); }
//粉丝数,事件数,关注数更新 public void UpdateTag() { DTConnection con = new DTConnection(); String name = Parameters.username; //粉丝数 String SelectFollower = "select * from FollowUser where FollowUser_UserName = '******';"; string userConstr = Parameters.user_info; List<String[]> Follower = con.ReadCon(SelectFollower, userConstr); this.lblFollowerNum.Text = Follower.Count.ToString(); //关注数 String SelectFollow = "select * from FollowUser where FollowUser_FollowerName = '" + name + "';"; List<String[]> record2 = con.ReadCon(SelectFollow, userConstr); this.lblFollowNum.Text = record2.Count.ToString(); //事件数 String SelectEvent = "select * from AllEvents where Event_Publisher = '" + name + "';"; string eventConstr = Parameters.event_info; List<String[]> record3 = con.ReadCon(SelectEvent, eventConstr); this.lblEventnum.Text = record3.Count.ToString(); }
//验证旧密码 public int CheckOldPassword(String OldPassword) { int check = 0; string commandText = @"Select Password from Student Where Name = '" + Parameters.username + "';"; DTConnection con = new DTConnection(); List<String[]> record = con.ReadCon(connectionString, commandText); if (record.Count >0)//查询到结果 { int num=record.Count; while (num>0) { String OldPass = record[num][1].ToString(); if (OldPassword == OldPass) { check = 1; } num--; } } return check; }
private void LoadRelativeStnUsers() { String connectionString = Parameters.user_info; String commandTextQuery = "select * from StudentInfo where StudentInfo_NickName like '%" + thiskey + "%'order by StudentInfo_NickName desc;"; string userConstr = Parameters.user_info; DTConnection con = new DTConnection(); //读数据库 List<String[]> reader = con.ReadCon(commandTextQuery, connectionString); //显示 ShowRelativeUsers(reader); }
private void ImprovePersonalInformation_Load(object sender, EventArgs e) { tNickName.Text = Parameters.username; string name = tNickName.Text; //已有信息显示 String connectionString = Parameters.user_info; DTConnection con = new DTConnection(); String commandTextQuery = "select * from StudentInfo where StudentInfo_NickName = '" + name + "'"; List<String[]> reader = con.ReadCon(commandTextQuery, connectionString); int count = reader.Count; foreach (String[] temp in reader) { if (count > 0) { tStudentNumber.Text = reader[count - 1][3].ToString(); tSex.Text = reader[count - 1][4].ToString(); tEmail.Text = reader[count - 1][7].ToString(); tLocation.Text = reader[count - 1][10].ToString(); tCollege.Text = reader[count - 1][5].ToString(); tGrade.Text = reader[count - 1][6].ToString(); tCellphoneNumber.Text = reader[count - 1][8].ToString(); tSign.Text = reader[count - 1][10].ToString(); if (File.Exists(reader[count - 1][11].ToString().Trim())) { Parameters.iconfullpath = new DirectoryInfo("../../../").FullName+reader[count - 1][11].ToString().Trim(); } this.pboxIcon.Image = Image.FromFile(Parameters.iconfullpath); } else { MessageBox.Show("系统繁忙,请稍等"); } count--; } }
private void ImproveMerchantInformation_Load(object sender, EventArgs e) { MEntryText.Text = Parameters.username; string name = MEntryText.Text; //连接数据库 String connectionString = Parameters.user_info; String commandTextQuery = "select * from MerchantInfo where Merchant_Name = '" + name + "'"; DTConnection con = new DTConnection(); List<String[]> reader = con.ReadCon(commandTextQuery, connectionString); int count=reader.Count; foreach(String[] temp in reader) { if (count > 0) { MEmailText.Text = reader[count-1][2].ToString(); MCellPText.Text = reader[count - 1][3].ToString(); MAddressText.Text = reader[count - 1][5].ToString(); MphoneText.Text = reader[count - 1][6].ToString(); MEntryText.Text = reader[count - 1][1].ToString(); MBussinessHourText.Text = reader[count - 1][7].ToString(); MAgeText.Text = reader[count - 1][10].ToString(); MSign.Text = reader[count - 1][9].ToString(); MShopText.Text = reader[count - 1][11].ToString(); } else { MessageBox.Show("对不起,信息加载出错"); } count--; } }
//下拉框加载拼友 void addCandi_Follower(object sender, EventArgs e) { ComboBox cbox = sender as ComboBox; cbox.Items.Clear(); int id = int.Parse(cbox.Name); String connectionString = Parameters.event_info; String commandSelect = "select Event_Follower from AllEvents where Event_Id = " + id + ";"; DTConnection con = new DTConnection(); List<String[]> reader = con.ReadCon(commandSelect, connectionString); string[] friendArray = reader[0][0].Split(','); if (reader.Count > 0) { for (int i = 0; i < friendArray.Length; i++) { cbox.Items.Add(friendArray[i]); } } else { MessageBox.Show("暂无接洽者,请耐心等待!"); } }
//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(); } } } }
//已知用户名和用户类别,从各类用户表中选择密码 private void TxtBxPW_Click(object sender, EventArgs e) { String inputname = TxtBxNme.Text;//查询关键字 String SeleAllstr = null;//选择用户名为输入项的所有值 switch (comboBox1.SelectedIndex) { case 0: { Parameters.usertype = 0; SeleAllstr = "select * from StudentInfo where StudentInfo_NickName = '" + inputname + "';"; SelePwStr="select StudentInfo_Password from StudentInfo where StudentInfo_NickName = '" + inputname + "';"; break; } case 1: { Parameters.usertype = 1; SeleAllstr = "select * from MerchantInfo where Merchant_Name = '" + inputname + "';"; SelePwStr = "select Merchant_Password from MerchantInfo where Merchant_Name = '" + inputname + "';"; break; } case 2: { Parameters.usertype = 2; SeleAllstr = "select * from AdminInfo where AdminInfo_NickName = '" + inputname + "';"; SelePwStr = "select AdminInfo_Password from AdminInfo where AdminInfo_NickName = '" + inputname + "';"; break; } } String connectionString = Parameters.user_info; DTConnection con = new DTConnection(); List<String[]> result = con.ReadCon(SeleAllstr, connectionString); //验证用户是否存在 if (result.Count==0) { MessageBox.Show("用户不存在,请先注册!"); } }
private void UISetting_Load(object sender, EventArgs e) { DTConnection con = new DTConnection(); string tname = Parameters.username; string seleiconpath = "select * from StudentInfo where StudentInfo_NickName ='" + tname + "'"; string constr = Parameters.user_info; List<String[]> reader2 = con.ReadCon(seleiconpath, constr); string fllpath = new DirectoryInfo("../../../").FullName + reader2[0][11]; if (!File.Exists(fllpath)) { fllpath = new DirectoryInfo("../../../").FullName + @"picture\icon\doge.ico"; } pboxIco.SizeMode = PictureBoxSizeMode.Zoom; pboxIco.Image = Image.FromFile(fllpath); this.lblNme.Text = Parameters.username; }
//关注 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 Details_Load(object sender, EventArgs e) { //根据ID,查询事件 String constr = Parameters.event_info; String commandTextQuery1 = "select * from AllEvents where Event_Id = '" + thiseventid + "'"; DTConnection con = new DTConnection(); readEvent = con.ReadCon(commandTextQuery1, constr); //加载发布人姓名 lblPublisherNme.Text = readEvent[0][2].ToString(); //加载事件状态 lblState.Text = "事件:"+readEvent[0][1].ToString(); //加载发布时间,截止时间 lblSendTime.Text = "发送时间:"+readEvent[0][3].ToString(); lblDeadline.Text = "截至时间:"+readEvent[0][4].ToString(); //发布人头像 string connectionString= Parameters.user_info; String SlctIcon = "select * from StudentInfo where StudentInfo_NickName = '" + PublisherName + "'"; List<String[]> readIcon=con.ReadCon(SlctIcon, connectionString); string iconpath = new DirectoryInfo("../../../").FullName+readIcon[0][11]; this.pboxPublisherIcon.SizeMode = PictureBoxSizeMode.Zoom; this.pboxPublisherIcon.Image = Image.FromFile(iconpath); //关注按钮文本 string selectstr = "select * from FollowUser where FollowUser_FollowerName ='" + Parameters.username + "' and FollowUser_UserName='******'"; List<String[]> haveFollow = con.ReadCon(selectstr, connectionString); if (haveFollow.Count == 0) { this.btnFollowPublisher.Text = "关注TA"; } else { this.btnFollowPublisher.Text = "取消关注"; } //事件内容 String EventContent = readEvent[0][7].ToString(); content.Text = EventContent.Substring(0, EventContent.IndexOf("】") + 1); content.Text += "\n " + EventContent.Substring(EventContent.IndexOf("】") + 1, EventContent.Length - EventContent.IndexOf("】") - 1); pboxPublisherIcon.BackColor = Color.MistyRose; //浏览量 int ViewNum = int.Parse(readEvent[0][8].ToString()); //加载意向接洽者 if (readEvent[0][9].ToString().Length > 0) { lblCurrentFollowers.Text = "目前有" + readEvent[0][9].ToString() + "愿意接洽该事件"; } else { lblCurrentFollowers.Text = "暂时无人接洽该事件"; } ViewNum++; lblPageview.Text = "浏览量:" + ViewNum + "次"; //更新浏览量 String commandUpdate = "update AllEvents set Event_Pageview ='" + ViewNum + "' where Event_Id = '" + thiseventid + "';"; con.UpdateCon(commandUpdate, constr); //显示评论 String selectStr = "select* from Event_Comments where Comment_EventId = '" + thiseventid + "'"; List<String[]> readComments = con.ReadCon(selectStr, constr); //通过循环列表显示查询结果集 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(); } } }
//切换显示已拼事件 private void tabControl1_Selected(object sender, TabControlEventArgs e) { String connectionString = Parameters.event_info; if (tabControl1.SelectedTab == tabPage1) { String commandTextQuery = "select * from AllEvents where Event_State='未拼' order by Event_PublishTime desc"; DTConnection con = new DTConnection(); List<String[]> reader = con.ReadCon(commandTextQuery, connectionString); AddKJ(reader, tabPage1); } else { String commandTextQuery = "select * from AllEvents where Event_State='已拼' order by Event_PublishTime desc"; DTConnection con = new DTConnection(); List<String[]> reader = con.ReadCon(commandTextQuery, connectionString); AddKJ(reader, tabPage2); } }
//我想拼 void llblAccept_Click(object sender, EventArgs e) { LinkLabel llbl = sender as LinkLabel; String id = llbl.Name; String connectionString = Parameters.event_info; DTConnection con = new DTConnection(); String SeleStr = "select * from AllEvents where Event_Id ='" + id + "'"; List<String[]> reader=con.ReadCon(SeleStr, connectionString); string followers = Parameters.username; string tempfollow = reader[0][9]; if (tempfollow.Length == 0) { tempfollow += followers; } else { tempfollow += "," + followers; } String Updatestr = "update AllEvents set Event_Follower = '" + tempfollow + " 'where Event_Id = " + id + ";"; con.UpdateCon(Updatestr, connectionString); MessageBox.Show("请求已发送"); }
private void ShowRelativeUsers(List<String[]> read) { TabPage searchStudentUserTab = new TabPage(); searchStudentUserTab.AutoScroll = true; searchStudentUserTab.Text = "相关学生用户有:"; DTConnection con = new DTConnection(); int flag = 0; if (read.Count != 0) { for (int i = 0; i < read.Count; i++) { GroupBox studentUserGroup = new GroupBox(); studentUserGroup.Width = 400; studentUserGroup.Height = 60; PictureBox pictbox = new PictureBox(); pictbox.Width = 42; pictbox.Height = 42; pictbox.Location = new System.Drawing.Point(3, 15); string tname = read[i][2]; string seleiconpath = "select * from StudentInfo where StudentInfo_NickName ='" + tname + "'"; string constr = Parameters.user_info; List<String[]> reader2 = con.ReadCon(seleiconpath, constr); string fllpath = new DirectoryInfo("../../../").FullName + reader2[0][11]; if (!File.Exists(fllpath)) { fllpath = new DirectoryInfo("../../../").FullName + @"picture\icon\anonymity.bmp"; } pictbox.SizeMode = PictureBoxSizeMode.Zoom; pictbox.Image = Image.FromFile(fllpath); RichTextBox richtextbox = new RichTextBox(); richtextbox.Width = 200; richtextbox.Height = 42; //richtextbox.ScrollBars = both; richtextbox.Location = new System.Drawing.Point(50, 15); richtextbox.Text = read[i][2]; Button btnToKnowOther = new Button(); btnToKnowOther.Text = "详情"; btnToKnowOther.Name = read[i][2]; btnToKnowOther.Location = new System.Drawing.Point(260, 20); btnToKnowOther.Width = 50; btnToKnowOther.Height = 25; btnToKnowOther.Click += new EventHandler(btnToKnowOther_Click); Button btnFollow = new Button(); btnFollow.Name = read[i][2]; //查看是否已关注 string selectstr = "select * from FollowUser where FollowUser_FollowerName ='" + Parameters.username + "' and FollowUser_UserName='******'"; List<String[]> haveFollow = con.ReadCon(selectstr, constr); if (haveFollow.Count == 0) { btnFollow.Text = "关注TA"; btnFollow.BackColor = Color.GreenYellow; } else { btnFollow.Text = "取消关注"; btnFollow.BackColor = Color.LightGray; } btnFollow.Location = new System.Drawing.Point(320, 20); btnFollow.Width = 70; btnFollow.Height = 25; btnFollow.Click += new EventHandler(btnFollow_Click); studentUserGroup.Controls.Add(pictbox); studentUserGroup.Controls.Add(btnToKnowOther); studentUserGroup.Controls.Add(btnFollow); studentUserGroup.Controls.Add(richtextbox); studentUserGroup.Location = new System.Drawing.Point(10, 10 + (flag++) * 60);//相对应tabpage的 searchStudentUserTab.Controls.Add(studentUserGroup); } } else { TextBox text = new TextBox(); text.Multiline = true; text.Location = new System.Drawing.Point(50, 15); text.Width = 241; text.Height = 200; text.Text = "未找到和“" + thiskey + "”有关的用户"; searchStudentUserTab.Controls.Add(text); } Tabcon.Controls.Add(searchStudentUserTab); }
private void textBox3_TextChanged(object sender, EventArgs e) { //用户名重复 String inputname = tboxUsername.Text;//查询关键字 String SeleAllstr = null;//选择用户名为输入项的所有值 string SelePwStr = null; switch (comboBox1.SelectedIndex) { case 0: { Parameters.usertype = 0; SeleAllstr = "select * from StudentInfo where StudentInfo_NickName = '" + inputname + "';"; SelePwStr = "select StudentInfo_Password from StudentInfo where StudentInfo_NickName = '" + inputname + "';"; break; } case 1: { Parameters.usertype = 1; SeleAllstr = "select * from MerchantInfo where Merchant_Name = '" + inputname + "';"; SelePwStr = "select Merchant_Password from MerchantInfo where Merchant_Name = '" + inputname + "';"; break; } case 2: { Parameters.usertype = 2; SeleAllstr = "select * from AdminInfo where AdminInfo_NickName = '" + inputname + "';"; SelePwStr = "select AdminInfo_Password from AdminInfo where AdminInfo_NickName = '" + inputname + "';"; break; } } String connectionString = Parameters.user_info; DTConnection con = new DTConnection(); List<String[]> result = con.ReadCon(SeleAllstr, connectionString); //提示,清空用户名 //验证用户是否存在 if (result.Count != 0) { MessageBox.Show("用户已存在!"); tboxUsername.Text = null; tboxPw.Text = null; } }
private void Search_Load(object sender, EventArgs e) { TabPage searchtab = new TabPage(); searchtab.AutoScroll = true; searchtab.Width = 300; searchtab.Height = 370; String connectionString = Parameters.event_info; String commandTextQuery = "select * from AllEvents where Event_content like '%" + thiskey + "%' and Event_State='未拼' order by Event_PublishTime desc;"; string userConstr = Parameters.user_info; DTConnection con = new DTConnection(); String name = Parameters.username; //读数据库 List<String[]> reader = con.ReadCon(commandTextQuery, connectionString); //显示 int tabflag = 0;//指示位置 int eventnum = reader.Count(); if (Parameters.haslogined)//已登陆 { for (int k = 0; k < reader.Count; k++)//每条记录 { if (!reader[k][1].Contains("通知"))//非@事件 { if (reader[k][5] == "1")//权限为所有好友 { String SelectMeFollow = "select FollowUser_UserName from FollowUser where FollowUser_FollowerName = '" + name + "';"; List<String[]> MeFollow = con.ReadCon(SelectMeFollow, userConstr);//我关注的人 bool MeFollowbool = false; for (int j = 0; j < MeFollow.Count; j++) { if (MeFollow[j][0] == reader[k][2]) { MeFollowbool = true; break; } } if (!MeFollowbool)//未关注-不加载 { continue; } } else if (reader[k][5] == "2") { List<String> MePartFollow = reader[k][11].Split(',').ToList(); bool MePartFollowbool = false; for (int j = 0; j < MePartFollow.Count; j++) { if (MePartFollow[j] == reader[k][2]) { MePartFollowbool = true; break; } } if (!MePartFollowbool) { continue; } } else if (reader[k][5] == "3") { //仅自己可见 if (name != reader[k][2].Trim()) { continue; } } searchtab.Controls.Add(Parameters.explore.AddShow(reader[k], tabflag++)); } } } else//未登录 { for (int k = 0; k < reader.Count; k++) { if (reader[k][1].Contains("通知")) { continue; } if (reader[k][5] == "0") { GroupBox groupb = Parameters.explore.AddShow(reader[k], tabflag++);//产生了一个tabpage searchtab.Controls.Add(groupb); } } } searchtab.Text = "和“" + thiskey + "”有关的内容有:"; Tabcon.Controls.Add(searchtab); Tabcon.SelectedTab = searchtab; if (tabflag == 0) { TextBox text = new TextBox(); text.Multiline = true; text.Location = new System.Drawing.Point(50, 15); text.Width = 241; text.Height = 200; text.Text = "未找到和“" + thiskey + "”有关的内容"; searchtab.Controls.Add(text); } LoadRelativeStnUsers(); }
//增加显示控件 public GroupBox AddShow(String[]reader,int flag) { String username=reader[2]; String information = reader[7]; GroupBox grbox = new GroupBox(); grbox.Width = 300; grbox.Height = 120; //richtextbox RichTextBox richtextbox = new RichTextBox(); richtextbox.Width = 241; richtextbox.Height = 74; //richtextbox.ScrollBars = both; richtextbox.Location = new System.Drawing.Point(50, 15); richtextbox.Text = information; //头像的位置 PictureBox pictbox = new PictureBox(); pictbox.Width = 42; pictbox.Height = 42; pictbox.Location = new System.Drawing.Point(3, 35); pictbox.BackColor = Color.MistyRose; DTConnection con = new DTConnection(); string tname = reader[2]; string seleiconpath = "select * from StudentInfo where StudentInfo_NickName ='" + tname + "'"; string constr = Parameters.user_info; List<String[]> reader2 = con.ReadCon(seleiconpath, constr); string fllpath = new DirectoryInfo("../../../").FullName + reader2[0][11]; if (!File.Exists(fllpath)) { fllpath = new DirectoryInfo("../../../").FullName + @"picture\icon\doge.ico"; } pictbox.SizeMode = PictureBoxSizeMode.Zoom; pictbox.Image = Image.FromFile(fllpath); //在richBox之下 //想拼 LinkLabel llblAccept = new LinkLabel(); llblAccept.Text = "我想拼"; llblAccept.Location = new System.Drawing.Point(50, 94);//相对应groupBox的 llblAccept.Name = reader[0].ToString(); llblAccept.Click += new EventHandler(llblAccept_Click); //收藏 LinkLabel llblCollect = new LinkLabel(); llblCollect.Text = "收藏"; llblCollect.Location = new System.Drawing.Point(150, 94);//相对应groupBox的 llblCollect.Name = reader[0].ToString() + ',' + reader[1].ToString() + ',' + reader[2].ToString() + ',' + reader[3].ToString() + ',' + reader[4].ToString() + ',' + reader[5].ToString() + ',' + reader[6].ToString() + ',' + reader[7].ToString() + ',' + reader[8].ToString() + ',' + reader[9].ToString() + ',' + reader[10].ToString() + ',' + reader[11].ToString(); llblCollect.Click += new EventHandler(llblCollect_Click); //更多 LinkLabel llblMore = new LinkLabel(); llblMore.Text = "更多"; llblMore.Location = new System.Drawing.Point(260, 94);//相对应groupBox的 llblMore.Name = reader[0].ToString() + ',' + reader[2]; llblMore.Click += new EventHandler(llblMore_Click); //用户名 Label label = new Label(); label.Text = username; label.Location = new System.Drawing.Point(3, 78); grbox.Controls.Add(richtextbox); grbox.Controls.Add(llblAccept); grbox.Controls.Add(llblCollect); grbox.Controls.Add(llblMore); grbox.Controls.Add(pictbox); grbox.Controls.Add(label); grbox.Location = new System.Drawing.Point(10, 10 + (flag++) * 120);//相对应tabpage的 return grbox; }
//增加显示控件 public void AddKJ(List<String[]> reader,TabPage tabpage) { int flag = 0; //对每条信息来说 for (int i = 0; i < reader.Count; i++) { string userConstr = Parameters.user_info; DTConnection con = new DTConnection(); String name = Parameters.username; //为@事件-不加载 if (reader[i][1].Contains("通知")) { continue; } //可见性 if(int.Parse(reader[i][5].Trim())==1) { //我关注的人可见 //获得关注者名单 String SelectMeFollow = "select FollowUser_UserName from FollowUser where FollowUser_FollowerName = '" + name + "';"; List<String[]> MeFollow = con.ReadCon(SelectMeFollow, userConstr); bool MeFollowbool = false; for (int j = 0; j < MeFollow.Count; j++) { if (MeFollow[j][0] == reader[i][2]) { MeFollowbool = true; break; } } if (!MeFollowbool)//未关注-不加载 { continue; } } else if (int.Parse(reader[i][5].Trim()) == 2) { //部分我关注的人可见 //获得名单 List<String> MePartFollow = reader[i][11].Split(',').ToList(); bool MePartFollowbool = false; for (int j = 0; j < MePartFollow.Count; j++) { if (MePartFollow[j] == reader[i][2]) { MePartFollowbool = true; break; } } if (!MePartFollowbool) { continue; } } else if (int.Parse(reader[i][5].Trim()) == 3) { //仅自己可见 if (name != reader[i][2].Trim()) { continue; } } ////// GroupBox grbox = new GroupBox(); grbox.Width = 320; grbox.Height = 125; //richtextbox RichTextBox richtextbox = new RichTextBox(); richtextbox.Width = 241; richtextbox.Height = 74; //richtextbox.ScrollBars = both; richtextbox.Location = new System.Drawing.Point(50, 12); richtextbox.Text = reader[i][7]; //头像的位置 PictureBox pictbox = new PictureBox(); pictbox.Width = 42; pictbox.Height = 42; pictbox.Location = new System.Drawing.Point(3, 35); pictbox.BackColor = Color.MistyRose; pictbox.Name = reader[i][2]; string tname = reader[i][2]; string seleiconpath = "select * from StudentInfo where StudentInfo_NickName ='" + tname + "'"; string constr = Parameters.user_info; List<String[]> reader2 = con.ReadCon(seleiconpath, constr); string fllpath = new DirectoryInfo("../../../").FullName+reader2[0][11]; if (!File.Exists(fllpath)) { fllpath = new DirectoryInfo("../../../").FullName +@"picture\icon\doge.ico"; } pictbox.SizeMode = PictureBoxSizeMode.Zoom; pictbox.Image = Image.FromFile(fllpath); pictbox.Click += new EventHandler(pictbox_Click); //在richBox之下 //想拼 LinkLabel llblAccept = new LinkLabel(); llblAccept.Text = "我想拼"; llblAccept.Location = new System.Drawing.Point(50, richtextbox.Height + 30);//相对应groupBox的 llblAccept.Name = reader[i][0].ToString(); llblAccept.Click += new EventHandler(llblAccept_Click); //收藏 LinkLabel llblCollect = new LinkLabel(); llblCollect.Text = "收藏"; llblCollect.Location = new System.Drawing.Point(150, richtextbox.Height + 30);//相对应groupBox的 llblCollect.Name = reader[i][0].ToString() + ',' + reader[i][1].ToString() + ',' + reader[i][2].ToString() + ',' + reader[i][3].ToString() + ',' + reader[i][4].ToString() + ',' + reader[i][5].ToString() + ',' + reader[i][6].ToString() + ',' + reader[i][7].ToString() + ',' + reader[i][8].ToString() + ',' + reader[i][9].ToString() + ',' + reader[i][10].ToString() + ',' + reader[i][11].ToString(); llblCollect.Click += new EventHandler(llblCollect_Click); //更多 LinkLabel llblMore = new LinkLabel(); llblMore.Text = "详情"; llblMore.Location = new System.Drawing.Point(260, richtextbox.Height + 30);//相对应groupBox的 llblMore.Name = reader[i][0].ToString() + ',' + reader[i][2]; llblMore.Click += new EventHandler(llblMore_Click); //用户名 Label label = new Label(); label.Text = reader[i][2]; label.Location = new System.Drawing.Point(3, 78); //时间 Label label1 = new Label(); label1.Text = reader[i][4]; label1.ForeColor = Color.DarkSlateGray; label1.Location = new System.Drawing.Point(richtextbox.Location.X + 100, richtextbox.Height + 10); Label label2 = new Label(); label2.Text = "分类:" + reader[i][6]; label2.ForeColor = Color.DarkSlateGray; label2.Location = new System.Drawing.Point(richtextbox.Location.X + 5, richtextbox.Height + 10); grbox.Controls.Add(label1); grbox.Controls.Add(label2); grbox.Controls.Add(richtextbox); grbox.Controls.Add(llblAccept); grbox.Controls.Add(llblCollect); grbox.Controls.Add(llblMore); grbox.Controls.Add(pictbox); grbox.Controls.Add(label); grbox.Location = new System.Drawing.Point(10, 10 + (flag++) * 120);//相对应tabpage的 tabpage.Controls.Add(grbox); } }
private void InitializeThisForm() { title.Text = pageHosterName + "的主页"; DTConnection con = new DTConnection(); string constr = Parameters.user_info; string selectstr = "select * from FollowUser where FollowUser_FollowerName ='" + Parameters.username + "' and FollowUser_UserName='******'"; List<String[]> haveFollow = con.ReadCon(selectstr, constr); if (haveFollow.Count == 0) { btnfollow.Text = "关注TA"; btnfollow.BackColor = Color.GreenYellow; } else { btnfollow.Text = "取消关注"; btnfollow.BackColor = Color.LightGray; } tabPage1.AutoScroll = true; //清空控件 tabPage1.Controls.Clear(); String Event_constr = Parameters.event_info; string User_constr = Parameters.user_info; /************************/ //加载自己发布的所有拼事件(需要判断该事件的权限,根据权限来决定显示给哪些用户看) String commandTextQuery = "select * from AllEvents where Event_Publisher='" + pageHosterName + "' and Event_State='未拼' order by Event_PublishTime desc"; List<String[]> reader = con.ReadCon(commandTextQuery, Event_constr); String name = Parameters.username; int recordnum = reader.Count; if (recordnum == 0) { Label label = new Label(); label.Text = "该用户潜水很深,还没有动态..."; label.Font = new Font("宋体", 18); label.AutoSize = true; label.ForeColor = Color.DarkSlateGray; label.Location = new System.Drawing.Point(tabPage1.Location.X + 80, tabPage1.Height - 160); tabPage1.Controls.Add(label); } else { int tabflag = 0;//指示位置 int eventnum = reader.Count(); for (int k = 0; k < reader.Count; k++)//每条记录 { if (reader[k][5] == "1")//权限为所有好友 { String SelectMeFollow = "select FollowUser_UserName from FollowUser where FollowUser_FollowerName = '" + name + "';"; List<String[]> MeFollow = con.ReadCon(SelectMeFollow, User_constr);//我关注的人 bool MeFollowbool = false; for (int j = 0; j < MeFollow.Count; j++) { if (MeFollow[j][0] == reader[k][2]) { MeFollowbool = true; break; } } if (!MeFollowbool)//未关注-不加载 { continue; } } else if (reader[k][5] == "2") { List<String> MePartFollow = reader[k][11].Split(',').ToList(); bool MePartFollowbool = false; for (int j = 0; j < MePartFollow.Count; j++) { if (MePartFollow[j] == reader[k][2]) { MePartFollowbool = true; break; } } if (!MePartFollowbool) { continue; } } else if (reader[k][5] == "3") { //仅自己可见 if (name != reader[k][2].Trim()) { continue; } } this.tabPage1.Controls.Add(Parameters.explore.AddShow(reader[k], tabflag++)); } } //读头像 string fieldname = Parameters.userFieldname[Parameters.usertype] + "_NickName"; string tablename = Parameters.userTablename[Parameters.usertype]; String QueryMyIcon = "select * from " + tablename + " where " + fieldname + " = '" + pageHosterName + "' ;"; List<String[]> iconlist = con.ReadCon(QueryMyIcon, User_constr); string tpath = new DirectoryInfo("../../../").FullName + iconlist[0][11].ToString(); //头像和ID Parameters.id = iconlist[0][10].ToString(); if (!File.Exists(tpath)) { tpath = new DirectoryInfo("../../../").FullName + @"picture\icon\anonymity.bmp"; } this.pboxFace.SizeMode = PictureBoxSizeMode.Zoom; this.pboxFace.Image = Image.FromFile(tpath); UpdateTag(); }