public void ShowMsg(Model.messsageInfo msg, bool isSendFromME) { int startPos = this.txtinfo.Text.Length; string title = ""; Color fColor = Color.Black; if (!isSendFromME) { title = this._me.userName + msg.sendTime.ToLongTimeString() + "\r\n\t"; fColor = Color.Red; } else { title = this._nickName + msg.sendTime.ToLongTimeString() + "\r\n\t"; fColor = Color.Blue;; } int titlelen = title.Length; this.txtinfo.AppendText(title); this.txtinfo.SelectionStart = startPos; this.txtinfo.SelectionLength = titlelen; this.txtinfo.SelectionColor = fColor; startPos = this.txtinfo.Text.Length; string comment = msg.messageContent + "\r\n"; int commentlen = comment.Length; this.txtinfo.AppendText(comment); this.txtinfo.SelectionStart = startPos; this.txtinfo.SelectionLength = commentlen; this.txtinfo.SelectionColor = Color.Black; }
private void SendMsg() { string comment = this.txtmessge.Text; if (comment == "") { return; } BLL.messsageInfo BllMsgInfo = new BLL.messsageInfo(); Model.messsageInfo msg = new Model.messsageInfo(); msg.messageContent = comment; msg.senderID = this._me.userID; msg.receiverID = this._friend.userID; msg.messageState = 1; msg.sendTime = BLL.NormalOperation.getServerTime(); int res = BllMsgInfo.Add(msg); if (res <= 0) { MessageBox.Show("消息发送失败或检查网络连接!!"); } this.txtmessge.Text = ""; ShowMsg(msg, false); bool isExist = false; FileStream fst = new FileStream(Application.StartupPath + "\\" + "friend.txt", FileMode.Open, FileAccess.Read); StreamReader srt = new StreamReader(fst); while (srt.Peek() > -1) { string qq = srt.ReadLine(); string[] re = qq.Split(' '); if (re[1] == _friend.userID.ToString() && re[0] == this._me.userID.ToString()) { isExist = true; } } srt.Close(); fst.Close(); if (isExist == false) { using (StreamWriter sw = File.AppendText(Application.StartupPath + "\\" + "friend.txt")) { sw.WriteLine(msg.senderID + " " + msg.receiverID); sw.Close(); } } }
private void TmPicker_Tick(object sender, EventArgs e) { if (this._me != null) { BLL.messsageInfo bllmsg = new BLL.messsageInfo(); List <Model.messsageInfo> msgInfo = bllmsg.GetModelList("senderID= '" + this._friend.userID + "'and receiverID= '" + this._me.userID + "' and messageState=1 or messageState=20 "); foreach (Model.messsageInfo m in msgInfo) { ShowMsg(m, true); BLL.messsageInfo BllMsgInfo = new BLL.messsageInfo(); Model.messsageInfo msg = new Model.messsageInfo(); msg.messageContent = m.messageContent; msg.senderID = m.senderID; msg.receiverID = m.receiverID; msg.messageState = 2; msg.sendTime = m.sendTime; msg.messageID = m.messageID; BllMsgInfo.Update(msg); } } else { BLL.messsageInfo bllmsg = new BLL.messsageInfo(); List <Model.messsageInfo> msgInfo = bllmsg.GetModelList("senderID= '" + this._fid + "'and messageState=20 or messageState=1 "); foreach (Model.messsageInfo m in msgInfo) { ShowMsg2(m, true); BLL.messsageInfo BllMsgInfo = new BLL.messsageInfo(); Model.messsageInfo msg = new Model.messsageInfo(); msg.messageContent = m.messageContent; msg.senderID = m.senderID; msg.receiverID = m.receiverID; msg.messageState = 21; msg.sendTime = m.sendTime; msg.messageID = m.messageID; BllMsgInfo.Update(msg); } } }
private void SendMsg2() { string comment = this.txtmessge.Text; if (comment == "") { return; } BLL.messsageInfo BllMsgInfo = new BLL.messsageInfo(); Model.messsageInfo msg = new Model.messsageInfo(); msg.messageContent = comment; msg.senderID = this._iid; msg.receiverID = this._fid; msg.messageState = 20; msg.sendTime = BLL.NormalOperation.getServerTime(); int res = BllMsgInfo.Add(msg); if (res <= 0) { MessageBox.Show("消息发送失败或检查网络连接!!"); } this.txtmessge.Text = ""; ShowMsg2(msg, false); }
private void timeSystemn_Tick(object sender, EventArgs e) { BLL.messsageInfo bmess = new BLL.messsageInfo(); List <Model.messsageInfo> mmess = bmess.GetModelList("receiverID= '" + this._user.userID + "'and messageState=20 "); foreach (Model.messsageInfo m in mmess) { BLL.messsageInfo BllMsgInfo = new BLL.messsageInfo(); Model.messsageInfo msg = new Model.messsageInfo(); msg.messageContent = m.messageContent; msg.senderID = m.senderID; msg.receiverID = m.receiverID; msg.messageState = 21; msg.sendTime = m.sendTime; msg.messageID = m.messageID; BllMsgInfo.Update(msg); BLL.userInfo bll2 = new BLL.userInfo(); Model.userInfo mfriend2 = bll2.GetModel(m.senderID); FrmimmediatelyMsg frm = new FrmimmediatelyMsg(tbFriendTalkInfo, this, this._user, mfriend2, mfriend2.userName); frm.Show(); } BLL.friendRequest bl = new BLL.friendRequest(); List <Model.friendRequest> mfrien = bl.GetModelList("senderID= '" + this._user.userID + "'and Station=2 "); foreach (Model.friendRequest m in mfrien) { FrmOkWarn sw = new FrmOkWarn(m, this); sw.Show(); Model.friendRequest mf = new Model.friendRequest(); mf.ID = m.ID; mf.NickName = m.NickName; mf.NumOfSameFriend = m.NumOfSameFriend; mf.receiveID = m.receiveID; mf.senderID = m.senderID; mf.ValidationInfo = m.ValidationInfo; mf.ValidationTime = m.ValidationTime; mf.Station = 5; bl.Update(mf); } BLL.friendRequest bll = new BLL.friendRequest(); List <Model.friendRequest> mfriend = bll.GetModelList("receiveID= '" + this._user.userID + "'and Station=1 "); foreach (Model.friendRequest m in mfriend) { SystemWarn sw = new SystemWarn(m, this); sw.Show(); Model.friendRequest mf = new Model.friendRequest(); mf.ID = m.ID; mf.NickName = m.NickName; mf.NumOfSameFriend = m.NumOfSameFriend; mf.receiveID = m.receiveID; mf.senderID = m.senderID; mf.ValidationInfo = m.ValidationInfo; mf.ValidationTime = m.ValidationTime; mf.Station = 5; bll.Update(mf); } BLL.groupu bllgroup = new BLL.groupu(); List <Model.groupu> mgroup = bllgroup.GetModelList("groupuserID=" + this._user.userID); if (mgroup.Count != 0) { int receiverID = mgroup[0].groupID; List <Model.friendRequest> mfriend2 = bll.GetModelList("receiveID= '" + receiverID + "'and Station=1 "); foreach (Model.friendRequest m in mfriend2) { FrmGroupWarn sw = new FrmGroupWarn(m, this); sw.Show(); Model.friendRequest mf = new Model.friendRequest(); mf.ID = m.ID; mf.NumOfSameFriend = m.NumOfSameFriend; mf.receiveID = m.receiveID; mf.senderID = m.senderID; mf.ValidationInfo = m.ValidationInfo; mf.ValidationTime = m.ValidationTime; mf.Station = 5; bll.Update(mf); } } }