资源简介
北大青鸟 Accp5.0 s1 项目实战 MyQQ完整版

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace MyQQ
{
///
/// 聊天窗体
///
public partial class ChatForm : Form
{
public int friendId; // 当前聊天的好友号码
public string nickName; // 当前聊天的好友昵称
public int faceId; // 当前聊天的好友头像Id
public ChatForm()
{
InitializeComponent();
}
// 窗体加载时的动作
private void ChatForm_Load(object sender EventArgs e)
{
// 设置窗体标题
this.Text = string.Format(“与{0}聊天中“nickName);
// 设置窗体顶部显示的好友信息
picFace.Image = ilFaces.Images[faceId];
lblFriend.Text = string.Format(“{0}({1})“nickNamefriendId);
// 读取所有的未读消息,显示在窗体中
ShowMessage();
}
// 关闭窗体
private void btnClose_Click(object sender EventArgs e)
{
this.Close();
}
// 发送消息
private void btnSend_Click(object sender EventArgs e)
{
if (txtChat.Text.Trim() == ““) // 不能发送空消息
{
MessageBox.Show(“不能发送空消息!“ “提示“ MessageBoxButtons.OK MessageBoxIcon.Information);
return;
}
else if (txtChat.Text.Trim().Length > 50)
{
MessageBox.Show(“消息内容过长,请分为几条发送!“ “提示“ MessageBoxButtons.OK MessageBoxIcon.Information);
return;
}
else // 发送消息,写入数据库
{
// MessageTypeId:1-表示聊天消息,为简化操作没有读取数据表,到S2可以用常量或者枚举实现
// MessageState:0-表示消息状态是未读
int result = -1; // 表示操作数据库的结果
string sql = string.Format(
“INSERT INTO Messages (FromUserId ToUserId Message MessageTypeId MessageState) VALUES ({0}{1}‘{2}‘{3}{4})“
UserHelper.loginId friendId txtChat.Text.Trim() 1 0);
try
{
// 执行命令
SqlCommand command = new SqlCommand(sql DBHelper.connection);
DBHelper.connection.Open();
result = command.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
DBHelper.connection.Close();
}
if (result != 1)
{
MessageBox.Show(“服务器出现意外错误!“ “抱歉“ MessageBoxButtons.OK MessageBoxIcon.Error);
}
txtChat.Text = ““; // 输入消息清空
this.Close();
}
}
///
/// 读取所有的未读消息,显示在窗体中
///
private
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9156 2007-06-19 11:00 MyQQ\提供给学员的素材\声音文件\folder.wav
文件 9220 2007-06-19 11:00 MyQQ\提供给学员的素材\声音文件\msg.wav
文件 6947 2007-06-19 11:00 MyQQ\提供给学员的素材\声音文件\system.wav
文件 1080 2007-06-19 10:58 MyQQ\提供给学员的素材\头像图片\1-1.bmp
文件 4856 2007-06-19 11:02 MyQQ\提供给学员的素材\头像图片\1.bmp
文件 1080 2007-06-19 10:58 MyQQ\提供给学员的素材\头像图片\10-1.bmp
文件 4856 2007-06-19 11:02 MyQQ\提供给学员的素材\头像图片\10.bmp
文件 1080 2007-06-19 10:58 MyQQ\提供给学员的素材\头像图片\100-1.bmp
文件 4856 2007-06-19 11:02 MyQQ\提供给学员的素材\头像图片\100.bmp
文件 2680 2007-09-14 10:04 MyQQ\提供给学员的素材\头像图片\101.bmp
文件 1080 2007-06-19 10:58 MyQQ\提供给学员的素材\头像图片\11-1.bmp
文件 4856 2007-06-19 11:02 MyQQ\提供给学员的素材\头像图片\11.bmp
文件 1080 2007-06-19 10:58 MyQQ\提供给学员的素材\头像图片\12-1.bmp
文件 4856 2007-06-19 11:02 MyQQ\提供给学员的素材\头像图片\12.bmp
文件 1080 2007-06-19 10:58 MyQQ\提供给学员的素材\头像图片\13-1.bmp
文件 4856 2007-06-19 11:02 MyQQ\提供给学员的素材\头像图片\13.bmp
文件 1080 2007-06-19 10:58 MyQQ\提供给学员的素材\头像图片\14-1.bmp
文件 4856 2007-06-19 11:02 MyQQ\提供给学员的素材\头像图片\14.bmp
文件 1080 2007-06-19 10:58 MyQQ\提供给学员的素材\头像图片\15-1.bmp
文件 4856 2007-06-19 11:02 MyQQ\提供给学员的素材\头像图片\15.bmp
文件 1080 2007-06-19 10:58 MyQQ\提供给学员的素材\头像图片\16-1.bmp
文件 4856 2007-06-19 11:02 MyQQ\提供给学员的素材\头像图片\16.bmp
文件 1080 2007-06-19 10:58 MyQQ\提供给学员的素材\头像图片\17-1.bmp
文件 4856 2007-06-19 11:02 MyQQ\提供给学员的素材\头像图片\17.bmp
文件 1080 2007-06-19 10:58 MyQQ\提供给学员的素材\头像图片\18-1.bmp
文件 4856 2007-06-19 11:02 MyQQ\提供给学员的素材\头像图片\18.bmp
文件 1080 2007-06-19 10:58 MyQQ\提供给学员的素材\头像图片\19-1.bmp
文件 4856 2007-06-19 11:02 MyQQ\提供给学员的素材\头像图片\19.bmp
文件 1080 2007-06-19 10:58 MyQQ\提供给学员的素材\头像图片\2-1.bmp
文件 4856 2007-06-19 11:02 MyQQ\提供给学员的素材\头像图片\2.bmp
............此处省略270个文件信息
- 上一篇:《设计模式》 中文版 完整高清pdf
- 下一篇:传智播客面试宝典
相关资源
- res10_300x300_ssd_iter_140000.caffemodel与dep
- 基本放大电路multisim仿真.ms14
- TCL-S1916 ,1924交换机管理程序
- 飞思卡尔单片机MC9S12XS12G128驱动(硬件
- 利用DS1302和msp430进行闹钟和万年历的
- DAS1302蜂鸣 独立按键 闹钟设定 IIC存储
- 单片机与温度传感器DS18B20的程序设计
- 毕业论文之温度传感器DS18B20(源码
- stm32 ds18b20 温度传感器 测试通过
- 51单片机读取温度数据存储到SD卡中并
- STM32F103 DS18B20 V3.5.0固件库驱动程序工
- DS18B20分布式多点测温的Proteus仿真
- 单片机 DS18B20 温度控制系统
- dell阵列卡驱动s100 s300 2008 R2.rar
- 课程设计蔬菜大棚自动控制系统,包
- 单片机控制74ls164程序
- 9s12单片机SPI功能代码
- Windows 1.0 软盘镜像
- 通过串口s19文件源代码
- 三星S19C200NW液晶显示器驱动 v1.0 官方
- CS1.6 透视自瞄多功能 开源.e
- ams1117降压电路原理图
- VS1053B编解码器的VDR分布式声音采集卡
- eetop.cn_eetop.cn_hfss15_win32crack
- Lenovo ThinkPad S1 Yoga主板原理图
- Cognos10.1.1 Report Studio条件样式的灵活运
- IBM TS1120磁带机进入加密行列
- TDS1012 使用说明书
- Codewarrior HCS12 V5.1 license
- windows10纯净版ISO种子文件
评论
共有 条评论