資源簡介
這里有現成的源代碼、數據庫、及PPT,歡迎下載~!

代碼片段和文件信息
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;
using?System.Media;
namespace?MyQQ
{
????
????public?partial?class?ChatForm?:?Form
????{
????????public?string?nickName;//存放昵稱
????????public?int?friendId;//存儲朋友的賬號
????????int?friendFaceId;//存儲好友的頭像
????????public?ChatForm()
????????{
????????????InitializeComponent();
????????}
????????private?void?GetFriendFaceId()?
????????{
????????????string?sql?=?“select?FaceId?from?Users?where?Id=“?+?UserHelper.friendLoginId;
????????????try
????????????{
????????????????DBHelper.connection.Open();
????????????????SqlCommand?command?=?new?SqlCommand(sql?DBHelper.connection);
????????????????friendFaceId?=?Convert.ToInt32(command.ExecuteScalar());
????????????}
????????????catch?(Exception?ex)
????????????{
????????????????MessageBox.Show(ex.Message);
????????????}
????????????finally?
????????????{
????????????????DBHelper.connection.Close();
????????????}
????????}
????????private?void?ChatForm_Load(object?sender?EventArgs?e)
????????{
????????????GetFriendFaceId();//調用查詢好友頭像Id的方法
????????????this.Text?=?string.Format(“與{0}聊天中...“nickName);//聊天窗體的標題
????????????this.picFace.Image?=?ilFaces.Images[friendFaceId];//在imageList中讀取相應的頭像顯示在pictureBox中
????????????this.lblFriendName.Text?=?string.Format(“{0}({1})“nickNamefriendId);//標簽中顯示好友昵稱和QQ號碼
????????????ReadMessageFromDB();//調用從數據庫讀取消息的方法
????????????tmrRefreshMessage.Start();//刷新消息時間控件開始計時
????????}
????????private?void?btnSend_Click(object?sender?EventArgs?e)
????????{
????????????if?(MessageIsNull())//判斷消息不為空
????????????{
????????????????SendMessageToDB();//發送消息?數據庫
????????????????
????????????}
????????}
????????///?
????????///?判斷消息不為空
????????///?
????????///?
????????private?bool?MessageIsNull()?
????????{
????????????if?(txtSendMessage.Text.Trim()==““)
????????????{
????????????????MessageBox.Show(“請不要發送空消息!““操作提示“MessageBoxButtons.OKMessageBoxIcon.Information);
????????????????return?false;
????????????}
????????????else
????????????{
????????????????return?true;
????????????}
????????}
????????///?
????????///?將消息存儲在數據庫
????????///?
????????private?void?SendMessageToDB()?
????????{
????????????string?dateTime=““;
????????????string?sql?=string.Format(“Insert?into?Messages?(FromUserIdToUserIdMessageMessageTypeIdMessageStateMessageTime)?values?({0}{1}‘{2}‘10GetDate())“UserHelper.loginIdfriendIdthis.txtSendMessage.Text.Trim());
????????????DBHelper.connection.Open();
????????????SqlCommand?command?=?new?SqlCommand(sqlDBHelper.connection);
????????????int?count?=?command.ExecuteNonQuery();
????????????sql?=?string.Format(“select?MessageTime?from?Messages?where?Message=‘{0}‘“this.txtSendMessage.Text.Trim());
????????????command.Comman
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????3145728??2009-09-09?17:44??MyQQ\Data\MyQQ.mdf
?????文件????1048576??2009-09-09?17:44??MyQQ\Data\MyQQ_log.ldf
?????文件???????1157??2009-09-05?12:18??MyQQ\MyQQ\app.config
?????文件???????9156??2007-06-19?11:00??MyQQ\MyQQ\bin\Debug\folder.wav
?????文件???????9220??2007-06-19?11:00??MyQQ\MyQQ\bin\Debug\msg.wav
?????文件????3129344??2009-09-05?13:21??MyQQ\MyQQ\bin\Debug\MyQQ.exe
?????文件???????1157??2009-09-05?12:18??MyQQ\MyQQ\bin\Debug\MyQQ.exe.config
?????文件?????161280??2009-09-05?13:21??MyQQ\MyQQ\bin\Debug\MyQQ.pdb
?????文件???????5632??2005-12-08?14:51??MyQQ\MyQQ\bin\Debug\MyQQ.vshost.exe
?????文件???????1157??2009-09-05?12:18??MyQQ\MyQQ\bin\Debug\MyQQ.vshost.exe.config
?????文件??????40960??2007-09-14?15:51??MyQQ\MyQQ\bin\Debug\SideBar.dll
?????文件???????6947??2007-06-19?11:00??MyQQ\MyQQ\bin\Debug\system.wav
?????文件???????6413??2009-09-05?01:47??MyQQ\MyQQ\ChatForm.cs
?????文件??????14485??2009-09-05?00:26??MyQQ\MyQQ\ChatForm.Designer.cs
?????文件????1009017??2009-09-05?00:26??MyQQ\MyQQ\ChatForm.resx
?????文件????????414??2009-08-22?13:56??MyQQ\MyQQ\ClassDiagram1.cd
?????文件????????391??2009-09-04?18:17??MyQQ\MyQQ\DBHelper.cs
?????文件???????2210??2009-09-04?18:43??MyQQ\MyQQ\FacesForm.cs
?????文件??????10628??2009-09-04?16:48??MyQQ\MyQQ\FacesForm.Designer.cs
?????文件?????242071??2009-09-04?16:48??MyQQ\MyQQ\FacesForm.resx
?????文件???????4092??2009-09-04?18:55??MyQQ\MyQQ\LoginForm.cs
?????文件???????7534??2009-09-04?16:35??MyQQ\MyQQ\LoginForm.Designer.cs
?????文件??????76706??2009-09-04?18:44??MyQQ\MyQQ\LoginForm.resx
?????文件??????24550??2009-09-05?12:18??MyQQ\MyQQ\MainForm.cs
?????文件??????24116??2009-09-05?12:18??MyQQ\MyQQ\MainForm.Designer.cs
?????文件????1775718??2009-09-05?12:18??MyQQ\MyQQ\MainForm.resx
?????文件???????4209??2009-09-04?22:39??MyQQ\MyQQ\MessageRecordsForm.cs
?????文件???????4036??2009-09-04?22:39??MyQQ\MyQQ\MessageRecordsForm.Designer.cs
?????文件???????7846??2009-09-04?22:39??MyQQ\MyQQ\MessageRecordsForm.resx
?????文件???????7231??2009-09-05?00:15??MyQQ\MyQQ\MyQQ.csproj
............此處省略59個文件信息
評論
共有 條評論