Exemple #1
0
 public void UpdateUserFriend(UserFriendInfo userFriend)
 {
     SqlParameter[] pt = new SqlParameter[] { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@friendName", SqlDbType.NVarChar) };
     pt[0].Value = userFriend.ID;
     pt[1].Value = userFriend.FriendName;
     ShopMssqlHelper.ExecuteNonQuery(ShopMssqlHelper.TablePrefix + "UpdateUserFriend", pt);
 }
        public bool Add(UserFriendInfo userFriendInfo)
        {
            Parameters cmdParams = GetParameters(userFriendInfo);

            cmdParams.AddInParameter("@AddTime", DbType.DateTime, DateTime.Now);
            return(DBHelper.ExecuteSql("INSERT INTO PE_Friend (FriendName, UserName, AddTime, GroupID) VALUES (@FriendName, @UserName, @AddTime, @GroupID)", cmdParams));
        }
        private static Parameters GetParameters(UserFriendInfo userFriendInfo)
        {
            Parameters parameters = new Parameters();

            parameters.AddInParameter("@FriendName", DbType.String, userFriendInfo.FriendName);
            parameters.AddInParameter("@UserName", DbType.String, userFriendInfo.UserName);
            parameters.AddInParameter("@GroupID", DbType.Int32, userFriendInfo.GroupId);
            return(parameters);
        }
Exemple #4
0
 public int AddUserFriend(UserFriendInfo userFriend)
 {
     SqlParameter[] pt = new SqlParameter[] { new SqlParameter("@friendID", SqlDbType.Int), new SqlParameter("@friendName", SqlDbType.NVarChar), new SqlParameter("@userID", SqlDbType.Int), new SqlParameter("@userName", SqlDbType.NVarChar) };
     pt[0].Value = userFriend.FriendID;
     pt[1].Value = userFriend.FriendName;
     pt[2].Value = userFriend.UserID;
     pt[3].Value = userFriend.UserName;
     return(Convert.ToInt32(ShopMssqlHelper.ExecuteScalar(ShopMssqlHelper.TablePrefix + "AddUserFriend", pt)));
 }
Exemple #5
0
 public void PrepareUserFriendModel(SqlDataReader dr, List <UserFriendInfo> userFriendList)
 {
     while (dr.Read())
     {
         UserFriendInfo item = new UserFriendInfo();
         item.ID         = dr.GetInt32(0);
         item.FriendID   = dr.GetInt32(1);
         item.FriendName = dr[2].ToString();
         item.UserID     = dr.GetInt32(3);
         item.UserName   = dr[4].ToString();
         userFriendList.Add(item);
     }
 }
Exemple #6
0
        public UserFriendInfo ReadUserFriendByFriendID(int friendID, int userID)
        {
            SqlParameter[] pt = new SqlParameter[] { new SqlParameter("@friendID", SqlDbType.Int), new SqlParameter("@userID", SqlDbType.Int) };
            pt[0].Value = friendID;
            pt[1].Value = userID;
            UserFriendInfo info = new UserFriendInfo();

            using (SqlDataReader reader = ShopMssqlHelper.ExecuteReader(ShopMssqlHelper.TablePrefix + "ReadUserFriendByFriendID", pt))
            {
                if (reader.Read())
                {
                    info.ID         = reader.GetInt32(0);
                    info.FriendID   = reader.GetInt32(1);
                    info.FriendName = reader[2].ToString();
                    info.UserID     = reader.GetInt32(3);
                    info.UserName   = reader[4].ToString();
                }
            }
            return(info);
        }
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            string selectedValue = this.DropFriendGroup.SelectedValue;

            if (string.IsNullOrEmpty(selectedValue))
            {
                DynamicPage.WriteErrMsg("<li>成员组ID不能为空</li>");
            }
            if (string.IsNullOrEmpty(this.TxtFriendName.Text))
            {
                DynamicPage.WriteErrMsg("<li>好友用户名不能为空!</li>");
            }
            string[] strArray = this.TxtFriendName.Text.Split(new char[] { ',' });
            if (strArray.Length > 5)
            {
                DynamicPage.WriteErrMsg("<li>最多只能同时添加5个用户</li>");
            }
            StringBuilder builder = new StringBuilder();
            bool          flag    = true;

            foreach (string str2 in strArray)
            {
                if (Users.Exists(str2))
                {
                    if (!UserFriend.Exists(str2, this.m_UserName))
                    {
                        UserFriendInfo userFriendInfo = new UserFriendInfo();
                        userFriendInfo.FriendName = str2;
                        userFriendInfo.UserName   = this.m_UserName;
                        userFriendInfo.GroupId    = DataConverter.CLng(selectedValue);
                        if (UserFriend.Add(userFriendInfo))
                        {
                            flag = false;
                        }
                    }
                    else
                    {
                        builder.Append("<li>");
                        builder.Append(str2);
                        builder.Append("已经存在,不能重复添加!</li>");
                    }
                }
                else
                {
                    builder.Append("<li>");
                    builder.Append(str2);
                    builder.Append("用户不存在,只能添加存在的用户!</li>");
                }
            }
            string errorMessage = builder.ToString();

            if (flag)
            {
                DynamicPage.WriteErrMsg(errorMessage);
            }
            else if (string.IsNullOrEmpty(errorMessage))
            {
                DynamicPage.WriteSuccessMsg("添加成功!", "FriendManage.aspx");
            }
            else
            {
                DynamicPage.WriteSuccessMsg("添加成功!同时" + errorMessage, "FriendManage.aspx");
            }
        }
Exemple #8
0
 public static void UpdateUserFriend(UserFriendInfo userFriend)
 {
     dal.UpdateUserFriend(userFriend);
 }
Exemple #9
0
 public static int AddUserFriend(UserFriendInfo userFriend)
 {
     userFriend.ID = dal.AddUserFriend(userFriend);
     return(userFriend.ID);
 }
 public static bool Add(UserFriendInfo userFriendInfo)
 {
     return dal.Add(userFriendInfo);
 }