Exemplo n.º 1
0
        private ChatListSubItem TurnChatToSubItem(string msg)
        {
            ChatListSubItem sub = new ChatListSubItem();
            MySqlConnection con = new MySqlConnection(UserData.conStr);

            con.Open();
            string          sql = "select * from user where id='" + this.m_id + "'";
            MySqlCommand    cmd = new MySqlCommand(sql, con);
            MySqlDataReader mdr = cmd.ExecuteReader();

            while (mdr.Read())
            {
                sub.DisplayName = mdr.GetString("name");
                sub.ID          = Convert.ToUInt32(mdr.GetString("id"));
                sub.HeadImage   = MyOperation.LoadImage(mdr.GetString("photoPath").ToString());
                sub.PersonalMsg = msg;//这里显示最近聊天内容
                sub.IsTwinkle   = true;
            }
            con.Close();
            cmd.Dispose();
            return(sub);
        }
Exemplo n.º 2
0
 public Chat(string id)
 {
     if (MyOperation.JudgeIfServer(MyOperation.MyId))
     {
         if (!MyOperation.JudgeIfServer2(id))
         {
             goServer();
             // UserData.isClient = true;
         }
     }
     else
     {
         if (MyOperation.JudgeIfServer2(id))
         {
             goClient();
             // UserData.isClient = true;
         }
     }
     m_id = id;
     InitializeComponent();
     scanner.Focus();
     #region 数据库读取信息
     MySqlConnection con = new MySqlConnection(UserData.conStr);
     con.Open();
     string          sql = "select * from user where id='" + id + "'";
     MySqlCommand    cmd = new MySqlCommand(sql, con);
     MySqlDataReader mdr = cmd.ExecuteReader();
     while (mdr.Read())
     {
         lab_Name.Text  = mdr.GetString("name");
         this.Text      = "与" + mdr.GetString("name") + "的聊天";
         picture.Image  = MyOperation.LoadImage(mdr.GetString("photoPath").ToString());
         lab_sign.Text += mdr.GetString("sign");
     }
     con.Close();
     cmd.Dispose();
     #endregion
 }