聊天程序详细设计 小组成员表 组长:魏杰 成员:魏杰 周兰 验收项目:仿Q Q 聊天程序 一. 建立数据库 创建MyQQ 数据库 建立用户表“UserLog 的表“MessageLog UserLog 中有 xm(姓名),ID(账号),pw(密码),sq(权限),sj(时间) MessageLog 中有 fz(发送),sz(收收),xx(信息),sj(时间) 二、 基本框架 开始界面 登录界面 查看好友界面: 聊天界面: 取回密码界面: 注册界面: 注册成功界面: 具体代码实现见附件源代码 二. 实现数据库连接 添加 Data 类 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using System.Data; namespace MyQQ { class Data { private static string constring = "server=.;database=MyQQ;uid=sa;pwd="; private static SqlConnection sqlcon = new SqlConnection(); private static SqlCommand sqlcom = new SqlCommand(); private static void openConnection() // 打开连接 { if (sqlcon.State == ConnectionState.Closed) { try { sqlcon.ConnectionString = constring; sqlcom.Connection = sqlcon; sqlcon.Open(); } catch (Exception e) { throw new Exception(e.Message); } } } private static void closeConnection()// 关闭连接 { if (sqlcon.State == ConnectionState.Open) { sqlcon.Close(); } sqlcon.Dispose(); sqlcom.Dispose(); } public static void ExecuteSql(string sqlStr)// 执行一条sql语句 { try { openConnection(); sqlcom.CommandType = CommandType.Text; sqlcom.CommandText = sqlStr; sqlcom.ExecuteNonQuery(); } catch (Exception e) { throw new Exception(e.Message); } finally { closeConnection(); } } public static DataSet ExecuteDataSet(string sqlStr)// 执行一条sql语句 { try { openConnection(); sqlcom.CommandType = CommandType.Text; sqlcom.CommandText = sqlStr; SqlDataAdapter sqlda = new SqlDataAdapter(sqlStr, sqlcon); DataSet ds = new DataSet(); sqlda.Fill(ds); return ds; } catch (Exception e) { throw new Exception(e.Message); } finally { ...