public void LoadData() { Groups = OpeRecordDB.GetGroups(); Users = OpeRecordDB.GetUsers(); Rooms = OpeRecordDB.GetRooms(); LoadLocalOrg(); }
private void FormUsersToGroup_Load(object sender, EventArgs e) { Groups = OpeRecordDB.GetGroups(); Users = OpeRecordDB.GetUsers(); LoadLocalOrg(); Users = new List <exUser>();//重新添加用户 }
private void DBRecordToRichTextBox(int Page) { if (Page > PageCount) { return; //如果页数超过当前页数,则退出 } if (Page <= 0) { return; //如果页数为负数,则退出 } this.txtRecord.Clear(); this.CurrPage = Page; this.ButLast.Enabled = true; this.ButDown.Enabled = true; this.ButFirst.Enabled = true; this.ButUp.Enabled = true; this.ButDelRecord.Enabled = true; if (Page == this.PageCount) { this.ButLast.Enabled = false; this.ButDown.Enabled = false; } if (Page == 1) { this.ButFirst.Enabled = false; this.ButUp.Enabled = false; } this.TextBoxPage.Text = Page.ToString() + "/" + this.PageCount.ToString(); bool IsSend = false;//标识此消息是否是对方发送的 #region sql表达式 string sql = ""; switch (this.MessageType) { case IMLibrary3.Enmu.MessageType.User: sql = string.Format("select * from [MsgRecord] where ((froms='{0}' and tos='{1}') or (froms='{1}' and tos='{0}')) And MessageType={2} ORDER BY DateTime DESC limit " + (Page - 1) * pageSize + "," + pageSize, SelectUserID, myUserID, (byte)this.MessageType); break; case IMLibrary3.Enmu.MessageType.Group: sql = string.Format("select * from [MsgRecord] where tos='{0}' and MessageType={1} ORDER BY DateTime DESC limit " + (Page - 1) * pageSize + "," + pageSize, SelectUserID, (byte)this.MessageType); break; case IMLibrary3.Enmu.MessageType.Notice: sql = string.Format("select * from [MsgRecord] where MessageType={0} ORDER BY DateTime DESC limit " + (Page - 1) * pageSize + "," + pageSize, (byte)this.MessageType); break; } #endregion try { SQLiteDataReader dr = SQLiteDBHelper.ExecuteReader(sql, null); if (dr == null) { return; } while (dr.Read()) { IsSend = false;//标识此消息否是对方发送的 #region 获得消息类 Msg = OpeRecordDB.GetDrMsg(dr); if (Msg == null) { continue; } #endregion exUser sendUserInfo = findUser(Msg.from, Users); if (sendUserInfo == null) { return; } if (sendUserInfo.UserID == this.myUserID)//此消息为对方发送的 { IsSend = true; } int iniPos = txtRecord.TextLength;//获得当前记录richBox中最后的位置 string title = sendUserInfo.UserName + "(" + sendUserInfo.UserID + ")" + Msg.DateTime; Color titleColor = Color.Red; if (!IsSend)//如果是收到消息 { titleColor = Color.Blue; } txtRecord.AppendText(title); txtRecord.Select(iniPos, txtRecord.TextLength - iniPos); txtRecord.SelectionFont = new Font("宋体", 10); txtRecord.SelectionColor = titleColor; txtRecord.AppendText("\n "); textMsgToRich(Msg, IsSend); } dr.Close(); dr.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.Source + ex.Message); } }