示例#1
0
        private void SendMsg()
        {
            string comment = this.txtmessge.Text;

            if (comment == "")
            {
                return;
            }
            BLL.groupu          bllgroup = new BLL.groupu();
            List <Model.groupu> mgroup   = bllgroup.GetModelList("groupID=" + this._uc.GroupID);

            BLL.groupMessage   BllMsgInfo = new BLL.groupMessage();
            Model.groupMessage msg        = new Model.groupMessage();
            foreach (Model.groupu mgo in mgroup)
            {
                if (mgo.groupfriendID != this._me.userID)
                {
                    msg.messageContent = comment;
                    msg.senderID       = this._me.userID;
                    msg.receiverID     = mgo.groupfriendID;
                    msg.messageState   = 31;
                    msg.sendTime       = BLL.NormalOperation.getServerTime();
                    msg.groupID        = mgo.groupID;
                    int res = BllMsgInfo.Add(msg);
                    if (res <= 0)
                    {
                        MessageBox.Show("消息发送失败或检查网络连接!!");
                    }
                }
            }
            ShowMsg(msg, false);
            this.txtmessge.Text = "";
        }
示例#2
0
        public void ShowMsg(Model.groupMessage msg, bool isSendFromME)
        {
            BLL.userInfo   bll = new BLL.userInfo();
            Model.userInfo mu  = bll.GetModel(msg.senderID);

            int    startPos = this.txtinfo.Text.Length;
            string title    = "";
            Color  fColor   = Color.Black;

            if (isSendFromME)
            {
                title  = mu.userName + msg.sendTime.ToLongTimeString() + "\r\n\t";
                fColor = Color.Red;
            }
            else
            {
                title  = this._me.userName + 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;
        }
示例#3
0
        private void timergroup_Tick(object sender, EventArgs e)
        {
            BLL.groupMessage bllmsg = new BLL.groupMessage();

            List <Model.groupMessage> msgInfo = bllmsg.GetModelList("receiverID= '" + this._me.userID + "'and messageState=31 and groupID= '" + this._uc.GroupID + "' ");

            foreach (Model.groupMessage m in msgInfo)
            {
                ShowMsg(m, true);
                BLL.groupMessage   BllMsgInfo = new BLL.groupMessage();
                Model.groupMessage msg        = new Model.groupMessage();

                msg.messageContent = m.messageContent;
                msg.senderID       = m.senderID;
                msg.receiverID     = m.receiverID;
                msg.messageState   = 32;
                msg.sendTime       = m.sendTime;
                msg.ID             = m.ID;
                msg.groupID        = m.groupID;
                BllMsgInfo.Update(msg);
            }
        }