Exemple #1
0
        private void QQMain_Load(object sender, EventArgs e)
        {
            //本函数用于加载数据库, 加载好友列表

            //加载数据库, 查找所有我的好友
            TFriend_DAL.TFriend manage  = new TFriend_DAL.TFriend();
            DataSet             DataSet = manage.GetList(" QQID= " + Data.QQId + " ");

            //遍历表的每一行
            foreach (DataRow row in DataSet.Tables[0].Rows)
            {
                if (ChatListItem_Exist(row["FriendGroup"].ToString()) == false)
                {
                    ChatListItem_Add_Item(row["FriendGroup"].ToString());
                }
                TFriend_Model.TFriend_data data = new TFriend_Model.TFriend_data();

                data.QQId           = this.Data.QQId;
                data.QQFriendID     = row["QQFriendID"].ToString();
                data.MakeFriendDate = System.DateTime.Now;
                data.FriendName     = row["FriendName"].ToString();
                data.FriendGroup    = row["FriendGroup"].ToString();
                data.FriendSign     = row["FriendSign"].ToString();

                //MessageBox.Show(row["QQID"] + " " + row["QQFriendID"] + " " + row["FriendGroup"] + "\n" );
                ChatListItem_Add_Friend(GetGroup(row["FriendGroup"].ToString()), data);
            }
        }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(RC403ZhangChenYang.TFriend_Model.TFriend_data model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TFriend(");
            strSql.Append("QQId,FriendName,QQFriendID,FriendGroup,MakeFriendDate,FriendSign)");
            strSql.Append(" values (");
            strSql.Append("@QQId,@FriendName,@QQFriendID,@FriendGroup,@MakeFriendDate,@FriendSign)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@QQId",           SqlDbType.NVarChar,  16),
                new SqlParameter("@FriendName",     SqlDbType.NVarChar,  16),
                new SqlParameter("@QQFriendID",     SqlDbType.NVarChar,  16),
                new SqlParameter("@FriendGroup",    SqlDbType.NChar,     20),
                new SqlParameter("@MakeFriendDate", SqlDbType.DateTime),
                new SqlParameter("@FriendSign",     SqlDbType.NVarChar, 100)
            };
            parameters[0].Value = model.QQId;
            parameters[1].Value = model.FriendName;
            parameters[2].Value = model.QQFriendID;
            parameters[3].Value = model.FriendGroup;
            parameters[4].Value = model.MakeFriendDate;
            parameters[5].Value = model.FriendSign;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public RC403ZhangChenYang.TFriend_Model.TFriend_data GetModel(string QQID, string QQFriendID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 QQId,FriendName,QQFriendID,FriendGroup,MakeFriendDate,FriendSign from TFriend ");
            strSql.Append("  where QQID=@QQID and QQFriendID=@QQFriendID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@QQID",       SqlDbType.NVarChar, 16),
                new SqlParameter("@QQFriendID", SqlDbType.NVarChar, 16),
            };
            parameters[0].Value = QQID;
            parameters[1].Value = QQFriendID;

            RC403ZhangChenYang.TFriend_Model.TFriend_data model = new RC403ZhangChenYang.TFriend_Model.TFriend_data();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["QQId"] != null && ds.Tables[0].Rows[0]["QQId"].ToString() != "")
                {
                    model.QQId = ds.Tables[0].Rows[0]["QQId"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FriendName"] != null && ds.Tables[0].Rows[0]["FriendName"].ToString() != "")
                {
                    model.FriendName = ds.Tables[0].Rows[0]["FriendName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["QQFriendID"] != null && ds.Tables[0].Rows[0]["QQFriendID"].ToString() != "")
                {
                    model.QQFriendID = ds.Tables[0].Rows[0]["QQFriendID"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FriendGroup"] != null && ds.Tables[0].Rows[0]["FriendGroup"].ToString() != "")
                {
                    model.FriendGroup = ds.Tables[0].Rows[0]["FriendGroup"].ToString();
                }
                if (ds.Tables[0].Rows[0]["MakeFriendDate"] != null && ds.Tables[0].Rows[0]["MakeFriendDate"].ToString() != "")
                {
                    model.MakeFriendDate = DateTime.Parse(ds.Tables[0].Rows[0]["MakeFriendDate"].ToString());
                }
                if (ds.Tables[0].Rows[0]["FriendSign"] != null && ds.Tables[0].Rows[0]["FriendSign"].ToString() != "")
                {
                    model.FriendSign = ds.Tables[0].Rows[0]["FriendSign"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(RC403ZhangChenYang.TFriend_Model.TFriend_data model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TFriend set ");
            strSql.Append("FriendName=@FriendName,");
            strSql.Append("QQFriendID=@QQFriendID,");
            strSql.Append("FriendGroup=@FriendGroup,");
            strSql.Append("MakeFriendDate=@MakeFriendDate,");
            strSql.Append("FriendSign=@FriendSign");
            strSql.Append(" where QQId=@QQId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FriendName",     SqlDbType.NVarChar,   16),
                new SqlParameter("@QQFriendID",     SqlDbType.NVarChar,   16),
                new SqlParameter("@FriendGroup",    SqlDbType.NChar,      20),
                new SqlParameter("@MakeFriendDate", SqlDbType.DateTime),
                new SqlParameter("@FriendSign",     SqlDbType.NVarChar,  100),
                new SqlParameter("@QQId",           SqlDbType.NVarChar, 16)
            };
            parameters[0].Value = model.FriendName;
            parameters[1].Value = model.QQFriendID;
            parameters[2].Value = model.FriendGroup;
            parameters[3].Value = model.MakeFriendDate;
            parameters[4].Value = model.FriendSign;
            parameters[5].Value = model.QQId;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #5
0
        /// <summary>
        /// 增加结点sub_ttem到parent_item中
        /// </summary>
        /// <param name="parent_item"></param>
        /// <param name="sub_item_id"></param>
        private void ChatListItem_Add_Friend(CCWin.SkinControl.ChatListItem parent_item, TFriend_Model.TFriend_data sub_item_data)
        {
            CCWin.SkinControl.ChatListSubItem chatListSubItem = new CCWin.SkinControl.ChatListSubItem();


            chatListSubItem.DisplayName = sub_item_data.FriendName;//"displayName";
            chatListSubItem.ID          = int.Parse(sub_item_data.QQFriendID);
            chatListSubItem.NicName     = "ID : " + sub_item_data.QQFriendID;
            chatListSubItem.PersonalMsg = sub_item_data.FriendSign;


            //设置一些默认值
            chatListSubItem.Bounds        = new System.Drawing.Rectangle(0, 0, 0, 0);
            chatListSubItem.HeadImage     = null;
            chatListSubItem.HeadRect      = new System.Drawing.Rectangle(0, 0, 0, 0);
            chatListSubItem.IpAddress     = null;
            chatListSubItem.IsTwinkle     = false;
            chatListSubItem.IsTwinkleHide = false;

            chatListSubItem.OwnerListItem = parent_item;
            chatListSubItem.Status        = CCWin.SkinControl.ChatListSubItem.UserStatus.Online;
            chatListSubItem.Tag           = null;
            chatListSubItem.TcpPort       = 0;
            chatListSubItem.UpdPort       = 0;
            parent_item.SubItems.AddRange(new CCWin.SkinControl.ChatListSubItem[] {
                chatListSubItem
            });
        }