关键词不能为空

当前您在: 主页 > 英语 >

qq源代码

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-02-11 08:37
tags:

-

2021年2月11日发(作者:一饱眼福)



UserHelper..cs


类代码



using


System;


using


c;


using




namespace


MyQQ


{



//


记录登录的用户


Id



class



UserHelper


{



public



static



int


loginId;


//


登录的用户


Id


}


}





using


System;


using


c;


using


entModel;


using



using


g;


using



using



using


ent;



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 =


strin g


.Format(




{0}


聊天中



,nickNa me);




//


设置窗体顶部显示的好友信息



= [faceId];


=


string


.Format(


< /p>


,nickName,friendId);




//


读取所有的未读消息,显示在窗体中



ShowMessage();


}




//


关闭窗体




private



void


btnClose_Click(


object


sender,


EventArgs


e)


{



this


.Close();


}




//


发送消息




private



void


btnSend_Click(


object


sender,


EventArgs


e)


{



if


(() ==



)


//


不能发送空消息



{



MessageBox


.Show(



不能发送空消息!



,



提示



,


MessageBoxButtons


.OK,


MessageBoxIcon


.Information);



return


;


}



else



if


(().Length > 50)


{



MessageBox


.Show(


< /p>


消息内容过长,


请分为几条发送!



,



提示



,


MessageBoxButtons


.OK,


MessageBoxIcon


.Information);



return


;


}



else



//


发送消息,写入数据库



{



//


MessageTypeId:1-


表示聊天消息,为简化操作没有读取数据表 ,到


S2


可以用常量或者


枚举实现




// MessageState:0-


表示消息状态是未读




int


result = -1;


//


表示操作数据库的结果




string


sql =


string


.Format(






MessageState) VALUES ({0},{1},'{2}',{3},{4})


,



UserHelper


.loginId, friendId, (), 1, 0);



try


{



//


执行命令




SqlCommand


command =


new



SqlCommand


(sql,


DBHelper


.connection);



DBHelper


.();


result = eNonQuery();


}



catch


(


Exception


ex)


{



Console


.WriteLine(e);


}



finally


{



DBHelper


.();


}



if


(result != 1)


{



Messag eBox


.Show(



服务器出现意外 错误!



,



抱歉



,


MessageBoxButtons


.OK,


MessageBoxIcon


.Error);


}


=



;


//


输入消息清空




this


.Close();


}


}




///





///



读取所有的未读消息,显示在窗体中




///





private



void


ShowMessage()


{



string


messageIdsString =



;


//


消息的


Id


组成的字符串




string


message;


//


消息内容




string


messageTime;


//


消息发出的时间





// < /p>


读取消息的


SQL


语句

< br>



string


sql =


string


.Format(




ToUserId={1} AND MessageTypeId=1 AND MessageState=0


,


friendId,


Use rHelper


.loginId);



try


{



SqlCommand


command =


new



SqlCommand


(sql,


DBHelper


.connection);





DBHelper


.();



SqlDataReader


reader = eReader();




//


循环将消息添加到窗体上




while


(())


{


messageIdsString +=


Convert


.ToString(reader[< /p>



]) +



;


message =

Convert


.ToString(reader[



]);


messageTime


=


Convert


.ToDateTime(reader[



]).To String();


//



换为日期类型,告诉学员




+=


string


.Format(



{2}


,nickName,messageTime,message);


}



();


}



catch


(


Exception


ex)


{



Console


.WriteLine(e);


}



finally


{



DBHelper


.();


}



//


把显示出的消息置为已读




if


( > 1)


{


( - 1);


SetMessageRead(messageIdsString,


'_'


);


}


}




///





///



把显示出的消息置为已读




///






private



void


SetMessageRead(


string


messageIdsString,


char


separator)


{



string


[] messageIds = (separator);


//


分割出每个消息


Id



string


sql =



;


//


更 新状态的


SQL


语句


的固定部分




string


updateSql;


//


执行的


SQL

< br>语句




try


{





SqlCommand


command =


new



SqlCommand


();


//


创建


Command

< p>
对象



tion =


DBHelper


.connection;


//


指定数据库连接




DBHelper


.();


//


打开数据库连接




foreach


(


string


id


in


messageIds)


{



if


(id !=



)


{


updateSql = sql + id;


//


补充 完整的


SQL


语句



dText = updateSql;


//


指定要执行的


SQL


语句




int


result = eNonQuery();


}


}


}



catch


(


Exception


ex)


{



Console


.WriteLine(e);


}



finally


{



DBHelper


.();


}


}




代码



using


System;


using


c;


using


entModel;


using



using


g;


using



using



using


ent;



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 =


strin g


.Format(




{0}


聊天中



,nickNa me);




//


设置窗体顶部显示的好友信息



= [faceId];


=


string


.Format(


< /p>


,nickName,friendId);




//


读取所有的未读消息,显示在窗体中



ShowMessage();


}




//


关闭窗体




private



void


btnClose_Click(


object


sender,


EventArgs


e)


{



this


.Close();


}




//


发送消息




private



void


btnSend_Click(


object


sender,


EventArgs


e)


{



if


(() ==



)


//


不能发送空消息



{



MessageBox


.Show(



不能发送空消息!



,



提示



,


MessageBoxButtons


.OK,


MessageBoxIcon


.Information);



return


;


}



else



if


(().Length > 50)


{



MessageBox


.Show(


< /p>


消息内容过长,


请分为几条发送!



,



提示



,


MessageBoxButtons


.OK,


MessageBoxIcon


.Information);



return


;


}



else



//


发送消息,写入数据库



{



//


MessageTypeId:1-


表示聊天消息,为简化操作没有读取数据表 ,到


S2


可以用常量或者


枚举实现




// MessageState:0-


表示消息状态是未读






int


result = -1;


//


表示操作数据库的结果




string


sql =


string


.Format(




MessageState) VALUES ({0},{1},'{2}',{3},{4})


,



UserHelper


.loginId, friendId, (), 1, 0);



try


{



//


执行命令




SqlCommand


command =


new



SqlCommand


(sql,


DBHelper


.connection);



DBHelper


.();


result = eNonQuery();


}



catch


(


Exception


ex)


{



Console


.WriteLine(e);


}



finally


{



DBHelper


.();


}



if


(result != 1)


{



Messag eBox


.Show(



服务器出现意外 错误!



,



抱歉



,


MessageBoxButtons


.OK,


MessageBoxIcon


.Error);


}


=



;


//


输入消息清空




this


.Close();


}


}




///





///



读取所有的未读消息,显示在窗体中




///





private



void


ShowMessage()


{



string


messageIdsString =



;


//


消息的


Id


组成的字符串




string


message;


//


消息内容




string


messageTime;


//


消息发出的时间





// < /p>


读取消息的


SQL


语句

< br>



string


sql =


string


.Format(




ToUserId={1} AND MessageTypeId=1 AND MessageState=0


,


friendId,


Use rHelper


.loginId);





try


{



SqlCommand


command =


new



SqlCommand


(sql,


DBHelper


.connection);



DBHelper


.();



SqlDataReader


reader = eReader();




//


循环将消息添加到窗体上




while


(())


{


messageIdsString +=


Convert


.ToString(reader[< /p>



]) +



;


message =

Convert


.ToString(reader[



]);


messageTime


=


Convert


.ToDateTime(reader[



]).To String();


//



换为日期类型,告诉学员




+=


string


.Format(



{2}


,nickName,messageTime,message);


}



();


}



catch


(


Exception


ex)


{



Console


.WriteLine(e);


}



finally


{



DBHelper


.();


}



//


把显示出的消息置为已读




if


( > 1)


{


( - 1);


SetMessageRead(messageIdsString,


'_'


);


}


}




///





///



把显示出的消息置为已读




///






private



void


SetMessageRead(


string


messageIdsString,


char


separator)


{



string


[] messageIds = (separator);


//


分割出每个消息


Id



string


sql =



;


//


更 新状态的


SQL


语句


的固定部分






string


updateSql;


//


执行的


SQL

< br>语句




try


{



SqlCommand


command =


new



SqlCommand


();


//


创建


Command

< p>
对象



tion =


DBHelper


.connection;


//


指定数据库连接




DBHelper


.();


//


打开数据库连接




foreach


(


string


id


in


messageIds)


{



if


(id !=



)


{


updateSql = sql + id;


//


补充 完整的


SQL


语句



dText = updateSql;


//


指定要执行的


SQL


语句




int


result = eNonQuery();


//


执行命令



}


}


}



catch


(


Exception


ex)


{



Console


.WriteLine(e);


}



finally


{



DBHelper


.();


}


}




private



void


lblMessages_Click(


object


sender,


EventArgs


e)


{



}


}


}






类代码



using


System;


using


c;


using



using


ent;



namespace


MyQQ


{



//


数据库帮助类,维护数据库连接字符串和数据库连接对象






class



DBHelper


{



private



static



string


connString =



security=sspi


;



public



static



SqlConnection


connection =


new



SqlConnection


(connString);


}


}



using


System;


using


c;


using


entModel;


using



using


g;


using



using




namespace


MyQQ


{



///





///



头像选择窗体




///





public



partial



class



FacesForm


:


Form


{



public



PersonalInfoForm


personalInfoForm;




public


FacesForm()


{


InitializeComponent();


}





//


个人信息窗体






代码




private



void


FacesForm_Load(


object


sender,


EventArgs


e)


{



for


(


int


i = 0; i < i++)


{


(ng());


[i].ImageIndex = i;


}


}




//


确定选择头像




private



void


btnOK_Click(


object


sender,


EventArgs


e)


{



if


( == 0)


{



MessageBox


.Show(


< /p>


请选择一个头像!



,



提示



,


MessageBoxButtons


.OK,


MessageBoxIcon


.Information);


}



else


{



int


faceId = edItems[0].ImageIndex;


//


获得当前选中的头像的索




ce(faceId);


//


设置个人信息窗体中显示的头像




this


.Close();




}


}




//


双击时选择头像




private



void


lvIcons_MouseDoubleClic k(


object


sender,


MouseEventArgs


e)


{



int


faceId = edItems[0].ImageIndex;


//


获得当前选中的头像的索引



ce(faceId);


//


设置个人信息窗体中显示的头像




this


.Close();


}




//


关闭窗体




private



void


btnCancel_Click(


object


sender,


EventArgs


e)


{



this


.Close();


}


}


}






using


System;


using


c;


using


entModel;




using



using


g;


using



using



using


ent;



namespace


MyQQ


{



///





///



登录窗体




///





public



partial



class



LoginForm


:


Form


{



public


LoginForm()


{


InitializeComponent();


}




//


取消按钮的事件处理




private



void


btnCancel_Click(


object


sender,


EventArgs


e)


{



Application


.Exit();


}




//


打开申请号码界面




private



void


llbl_LinkClicked(


object


sender,


LinkLabelLinkClickedEventArgs


e)


{



RegisterForm


registerForm =


new



RegisterForm


();


();


}




//


登录按钮事件处理




private



void


btnLogin_Click(


object


sender,


EventArgs


e)


{



bool


error =


false


;


//


标志在执行数据库操作的过程中是否出错





//


如果输入验证成功,就验证身份,并转到相应的窗体




if


(ValidateInput())


{



int


num = 0;


//


数据库操作结果





try


{



//

< p>
查询用的


sql


语句



-


-


-


-


-


-


-


-



本文更新与2021-02-11 08:37,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/635190.html

qq源代码的相关文章

  • 余华爱情经典语录,余华爱情句子

    余华的经典语录——余华《第七天》40、我不怕死,一点都不怕,只怕再也不能看见你——余华《第七天》4可是我再也没遇到一个像福贵这样令我难忘的人了,对自己的经历如此清楚,

    语文
  • 心情低落的图片压抑,心情低落的图片发朋友圈

    心情压抑的图片(心太累没人理解的说说带图片)1、有时候很想找个人倾诉一下,却又不知从何说起,最终是什么也不说,只想快点睡过去,告诉自己,明天就好了。有时候,突然会觉得

    语文
  • 经典古训100句图片大全,古训名言警句

    古代经典励志名言100句译:好的药物味苦但对治病有利;忠言劝诫的话听起来不顺耳却对人的行为有利。3良言一句三冬暖,恶语伤人六月寒。喷泉的高度不会超过它的源头;一个人的事

    语文
  • 关于青春奋斗的名人名言鲁迅,关于青年奋斗的名言鲁迅

    鲁迅名言名句大全励志1、世上本没有路,走的人多了自然便成了路。下面是我整理的鲁迅先生的名言名句大全,希望对你有所帮助!当生存时,还是将遭践踏,将遭删刈,直至于死亡而

    语文
  • 三国群英单机版手游礼包码,三国群英手机单机版攻略

    三国群英传7五神兽洞有什么用那是多一个武将技能。青龙飞升召唤出东方的守护兽,神兽之一的青龙。玄武怒流召唤出北方的守护兽,神兽之一的玄武。白虎傲啸召唤出西方的守护兽,

    语文
  • 不收费的情感挽回专家电话,情感挽回免费咨询

    免费的情感挽回机构(揭秘情感挽回机构骗局)1、牛牛(化名)向上海市公安局金山分局报案,称自己为了挽回与女友的感情,被一家名为“实花教育咨询”的情感咨询机构诈骗4万余元。

    语文