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 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--; } }
/// <summary> /// 获得用户名和密码后,点击连接按钮conDB后,查看能否连接数据库 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void conDB_Click(object sender, EventArgs e) { Parameters.dbusername = this.tboxname.Text.Trim(); Parameters.dbpassword = this.tboxpw.Text.Trim(); Parameters.user_info = @"Server = localhost;database = User_info;User ID = " + Parameters.dbusername + ";Password = "******";"; Parameters.event_info = @"Server = localhost;database = Event_info;User ID = " + Parameters.dbusername + ";Password = "******";"; Parameters.spatial_info = @"Server = localhost;database = Spatial_info;User ID = " + Parameters.dbusername + ";Password = "******";"; //测试能否连接数据库 DTConnection conn = new DTConnection(); //显示登录情况 if (conn.TestDBConn()) { this.Hide(); MessageBox.Show("数据库连接成功!"); UILogin log = new UILogin();//打开登录界面 log.Show(); } else { MessageBox.Show("数据库连接失败!"); } }
/************************/ //验证登录 /// <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; }
//修改密码 public int ModifyPassword(String NewPassword) { string commandTextUpdate = @"update Student set Password = '******' Where Name = '" + Parameters.username + "';"; DTConnection con = new DTConnection(); int num = con.UpdateCon(connectionString, commandTextUpdate); return num; }
//构造函数,实现关键字搜索 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; }
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()+ "的事件:"; }
//将数据插入数据库的方法 public void GetInsert() { string connectionString = Parameters.user_info; string commandTextUpdate = "update MerchantInfo set Merchant_ShopName='" + ShopName + "',Merchant_BusinessHour = '" + BusinessHour + "',Merchant_Name = '" + Name + "',Merchant_Address ='" + Address + "',Merchant_Telephone ='" + Telephone + "',Merchant_ShopAge = '" + ShopAge + "',Merchant_Email ='" + Email + "',Merchant_CellphoneNumber ='" + CellphoneNumber + "' ,Merchant_Sign = '" + Sign + "' Where Name = '" + Parameters.username + "';"; DTConnection con = new DTConnection(); con.UpdateCon(commandTextUpdate, connectionString); }
//将数据插入数据库的方法 public void GetInsert() { string connectionString = Parameters.user_info; string commandTextUpdate = "update AdminInfo set AdminInfo_Sex = '" + Sex + "',AdminInfo_Age = '" + Age + "',AdminInfo_Email ='" + Email + "',AdminInfo_PhoneNumber ='" + PhoneNumber + "' ,AdminInfo_WorkPlace = '" + WorkPlace + "',AdminInfo_NickName='" + NickName + "' ,StudentInfo_Icon = '" + Iconpath + "' Where Name = '" + Parameters.username + "';";//用户名的问题 DTConnection con = new DTConnection(); con.UpdateCon(commandTextUpdate, connectionString); }
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]); } }
//将数据插入数据库 public void GetInsert() { string connectionString = Parameters.user_info; string commandTextUpdate = "update StudentInfo set StudentInfo_Gender = '" + Gender + "',StudentInfo_NickName = '" + NickName + "',StudentInfo_Address ='" + Address + "',StudentInfo_Degree ='" + Degree + "',StudentInfo_StudentId = '" + StudentId + "',StudentInfo_Email ='" + Email + "',StudentInfo_Academy = '" + Academy + "',StudentInfo_PhoneNumber ='" + PhoneNumber + "' ,StudentInfo_Sign = '" + Sign + "' ,StudentInfo_Icon = '" +Iconpath + "' Where StudentInfo_NickName = '" + Parameters.username + "';"; /************************/ DTConnection con = new DTConnection(); con.UpdateCon(commandTextUpdate, connectionString); }
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 Insert(String name, String password, int sort) { //匹配 corr1.Add("@username"); corr1.Add("@password"); corr2.Add(name); corr2.Add(password); String insertText = null; switch (sort) { case 0: { insertText = "Insert Into StudentInfo(StudentInfo_NickName,StudentInfo_Password) values('" + name + "','" + password + "')"; break; } case 1: { insertText = "Insert Into MerchantInfo(Merchant_Name,Merchant_Password) values('" + name + "','" + password + "')"; break; } case 2: { insertText = "Insert Into AdminInfo(AdminInfo_NickName,AdminInfo_Password) values('" + name + "','" + password + "')"; break; } } String connectionString = Parameters.user_info; DTConnection con = new DTConnection(); string a = "insert into StudentInfo(StudentInfo_NickName,StudentInfo_Password) values('" + name + "','" + password + "')"; //插入信息 int result = con.UpdateCon(insertText, connectionString); if (result == 1) { MessageBox.Show("注册成功!"); } else { MessageBox.Show("注册失败!"); } UILogin r = new UILogin(); r.Show(); }
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(); }
//粉丝数,事件数,关注数更新 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 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(); }
//点击关注 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; } } } }
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 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); }
//我想拼 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 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); } }
//增加显示控件 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 chooseFollower(object sender, EventArgs e) { ComboBox cbox = sender as ComboBox; int idc = int.Parse(cbox.Name); int select = cbox.SelectedIndex; String connectionString = Parameters.event_info; String followername = cbox.SelectedItem.ToString(); String commandUpdate = "update AllEvents set Event_Follower = '" + followername + "' where Event_Id=" + idc + ";"; DTConnection con = new DTConnection(); try { con.UpdateCon(commandUpdate, connectionString); cbox.Visible = false; MessageBox.Show("此事件接洽成功!\n系统将立即通知[" + followername + "],也请您尽快与之联系."); //修改数据库 int IDc = int.Parse(cbox.Name); String constr = Parameters.event_info; String Update = "update AllEvents set Event_State = " + "'已拼'" + " where Event_Id = " + IDc + ";"; con.UpdateCon(Update, constr); InitializeForm(); } catch { MessageBox.Show("对不起,请稍后重试!"); } }
// 删除信息 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(); }
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; } }
//点击未拼更改拼状态 void statei_Click(object sender, EventArgs e) { Button btn = sender as Button; if (btn.Text == "未拼") { btn.BackColor = Color.Green; btn.Text = "已拼"; int IDc = int.Parse(btn.Name); String connectionString = Parameters.event_info; DTConnection con = new DTConnection(); String commandUpdate = "update AllEvents set Event_State = " + "'已拼'" + " where Event_Id = " + IDc + ";"; con.UpdateCon(commandUpdate, connectionString); } else { MessageBox.Show("事件已拼成功"); } }
//下拉框加载拼友 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("暂无接洽者,请耐心等待!"); } }