关键词不能为空

当前您在: 主页 > 英语 >

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源代码的相关文章

  • 爱心与尊严的高中作文题库

    1.关于爱心和尊严的作文八百字 我们不必怀疑富翁的捐助,毕竟普施爱心,善莫大焉,它是一 种美;我们也不必指责苛求受捐者的冷漠的拒绝,因为人总是有尊 严的,这也是一种美。

    小学作文
  • 爱心与尊严高中作文题库

    1.关于爱心和尊严的作文八百字 我们不必怀疑富翁的捐助,毕竟普施爱心,善莫大焉,它是一 种美;我们也不必指责苛求受捐者的冷漠的拒绝,因为人总是有尊 严的,这也是一种美。

    小学作文
  • 爱心与尊重的作文题库

    1.作文关爱与尊重议论文 如果说没有爱就没有教育的话,那么离开了尊重同样也谈不上教育。 因为每一位孩子都渴望得到他人的尊重,尤其是教师的尊重。可是在现实生活中,不时会有

    小学作文
  • 爱心责任100字作文题库

    1.有关爱心,坚持,责任的作文题库各三个 一则150字左右 (要事例) “胜不骄,败不馁”这句话我常听外婆说起。 这句名言的意思是说胜利了抄不骄傲,失败了不气馁。我真正体会到它

    小学作文
  • 爱心责任心的作文题库

    1.有关爱心,坚持,责任的作文题库各三个 一则150字左右 (要事例) “胜不骄,败不馁”这句话我常听外婆说起。 这句名言的意思是说胜利了抄不骄傲,失败了不气馁。我真正体会到它

    小学作文
  • 爱心责任作文题库

    1.有关爱心,坚持,责任的作文题库各三个 一则150字左右 (要事例) “胜不骄,败不馁”这句话我常听外婆说起。 这句名言的意思是说胜利了抄不骄傲,失败了不气馁。我真正体会到它

    小学作文