예제 #1
0
파일: UsersDTO.cs 프로젝트: tsandtm/BOEdu
        public static Users PopulateFromReader(IDataReader reader)
        {
            Users item = new Users();
            try
            {
                if (reader.Read())
                {

                    try
                    {
                        item.UserId = Int32.Parse(reader["UserId"].ToString());
                    }
                    catch (Exception) { }

                    item.FullName = reader["FullName"].ToString();

                    item.UserName = reader["UserName"].ToString();

                    //item.Password = reader["Password"].ToString();
                    item.DiaChi = reader["DiaChi"].ToString();
                    item.DienThoai = reader["DienThoai"].ToString();
                    item.AvatarExt = reader["AvatarExt"].ToString();

                    try
                    {
                        item.CreatedUser = new Guid(reader["CreatedUser"].ToString());
                    }
                    catch (Exception) { }

                    try
                    {
                        item.CreatedDate = Convert.ToDateTime(reader["CreatedDate"]);
                    }
                    catch (Exception) { }

                    try
                    {
                        item.NgaySinh = Convert.ToDateTime(reader["NgaySinh"]);
                    }
                    catch (Exception) { }

                    try
                    {
                        item.UpdatedUser = new Guid(reader["UpdatedUser"].ToString());
                    }
                    catch (Exception) { }

                    try
                    {
                        item.UpdatedDate = Convert.ToDateTime(reader["UpdatedDate"]);
                    }
                    catch (Exception) { }
                }
            }
            catch { }
            return item;
        }
예제 #2
0
파일: UsersDTO.cs 프로젝트: tsandtm/BOEdu
 public static List<Users> LoadListFromReader(IDataReader reader)
 {
     List<Users> items = new List<Users>();
     try
     {
         while (reader.Read())
         {
             Users item = new Users();
             try
             {
                 item.UserId = Int32.Parse(reader["UserId"].ToString());
             }
             catch (Exception) { }
             item.FullName = reader["FullName"].ToString();
             item.UserName = reader["UserName"].ToString();
             //item.Password = reader["Password"].ToString();
             item.DiaChi = reader["DiaChi"].ToString();
             item.DienThoai = reader["DienThoai"].ToString();
             item.DienThoai = reader["AvatarExt"].ToString();
             try
             {
                 item.NgaySinh = Convert.ToDateTime(reader["NgaySinh"]);
             }
             catch (Exception) { }
             try
             {
                 item.CreatedUser = new Guid(reader["CreatedUser"].ToString());
             }
             catch (Exception) { }
             try
             {
                 item.CreatedDate = Convert.ToDateTime(reader["CreatedDate"]);
             }
             catch (Exception) { }
             try
             {
                 item.UpdatedUser = new Guid(reader["UpdatedUser"].ToString());
             }
             catch (Exception) { }
             try
             {
                 item.UpdatedDate = Convert.ToDateTime(reader["UpdatedDate"]);
             }
             catch (Exception) { }
             items.Add(item);
         }
     }
     catch
     { }
     finally
     {
         reader.Close();
     }
     return items;
 }
예제 #3
0
파일: UsersDAL.cs 프로젝트: tsandtm/BOEdu
        /// <summary>
        /// Inserts a row in the UserProfile table. Returns rows affected count.
        /// </summary>
        /// <returns>int</returns>
        public static int Create(Users item)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionStringStatic.GetWriteConnectionString(), "UserProfile_hoadm01082015_Insert", 8);
            //sph.DefineSqlParameter("@UserID", SqlDbType.Int, ParameterDirection.Input, item.UserId);
            sph.DefineSqlParameter("@UserName", SqlDbType.NVarChar, 256, ParameterDirection.Input, item.UserName);
            sph.DefineSqlParameter("@AvatarExt", SqlDbType.NVarChar, 256, ParameterDirection.Input, item.AvatarExt);
            sph.DefineSqlParameter("@NgaySinh", SqlDbType.DateTime, ParameterDirection.Input, item.NgaySinh);
            sph.DefineSqlParameter("@DienThoai", SqlDbType.NVarChar, 256, ParameterDirection.Input, item.DienThoai);
            sph.DefineSqlParameter("@DiaChi", SqlDbType.NVarChar, 256, ParameterDirection.Input, item.DiaChi);
            //sph.DefineSqlParameter("@Password", SqlDbType.NVarChar, 50, ParameterDirection.Input, item.Password);
            sph.DefineSqlParameter("@CreatedUser", SqlDbType.UniqueIdentifier, ParameterDirection.Input, item.CreatedUser);
            sph.DefineSqlParameter("@CreatedDate", SqlDbType.DateTime, ParameterDirection.Input, item.CreatedDate);
            //sph.DefineSqlParameter("@UpdatedUser", SqlDbType.UniqueIdentifier, ParameterDirection.Input, item.UpdatedUser);
            //sph.DefineSqlParameter("@UpdatedDate", SqlDbType.DateTime, ParameterDirection.Input, item.UpdatedDate);
            sph.DefineSqlParameter("@FullName", SqlDbType.NVarChar, 25, ParameterDirection.Input, item.FullName);

            int rowsAffected = Convert.ToInt32(sph.ExecuteScalar());
            return rowsAffected;
        }
예제 #4
0
파일: UsersDTO.cs 프로젝트: tsandtm/BOEdu
        internal static List<Users> LoadListFromReaderFollowlist(IDataReader reader)
        {
            List<Users> items = new List<Users>();
            try
            {
                while (reader.Read())
                {
                    Users item = new Users();
                    item.ListFlower = reader["Followerlist"].ToString();
                    items.Add(item);
                }
            }
            catch
            { }
            finally
            {
                reader.Close();
            }

            List<Users> returnitems = new List<Users>();
            if (items.Count > 0)
            {
                foreach (Users item1 in items)
                {
                    string[] str = item1.ListFlower.Split(';');
                    int i = 0;
                    int count = str.Length;
                    while (i < count)
                    {
                        if (!string.IsNullOrEmpty(str[i]))
                        {
                            string[] str1 = str[i].Split(':');
                            Users aa = new Users();
                            aa.UserId = Convert.ToInt32(str1[0]);
                            aa.FullName = str1[1];
                            returnitems.Add(aa);
                            i++;
                        }
                    }
                }

            }
            return returnitems;
        }
예제 #5
0
파일: UsersBAL.cs 프로젝트: tsandtm/BOEdu
 private int Create(Users item)
 {
     int rowsAffected = UsersDAL.Create(item);
     item.UserId = rowsAffected;
     return rowsAffected > 0 ? item.UserId : 0;
 }
예제 #6
0
파일: UsersBAL.cs 프로젝트: tsandtm/BOEdu
 // <summary>
 /// Saves this instance of Users. Returns a new Guid on success.
 /// </summary>
 public int Save(Users item)
 {
     if (item.UserId == 0)
         return Create(item);
     return Update(item);
 }
예제 #7
0
파일: UsersBAL.cs 프로젝트: tsandtm/BOEdu
 private int Update(Users item)
 {
     return UsersDAL.Update(item) ? item.UserId : 0;
 }
예제 #8
0
파일: UsersDAL.cs 프로젝트: tsandtm/BOEdu
        /// <summary>
        /// Updates a row in the UserProfile table. Returns true if row updated.
        /// </summary>
        /// <returns>bool</returns>
        public static bool Update(Users item)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionStringStatic.GetWriteConnectionString(), "UserProfile_hoadm01082015_Update", 9);
            sph.DefineSqlParameter("@UserID", SqlDbType.Int, ParameterDirection.Input, item.UserId);
            sph.DefineSqlParameter("@UserName", SqlDbType.NVarChar, 256, ParameterDirection.Input, item.UserName);
            sph.DefineSqlParameter("@AvatarExt", SqlDbType.NVarChar, 256, ParameterDirection.Input, item.AvatarExt);
            sph.DefineSqlParameter("@NgaySinh", SqlDbType.DateTime, ParameterDirection.Input, item.NgaySinh);
            sph.DefineSqlParameter("@DienThoai", SqlDbType.NVarChar, 256, ParameterDirection.Input, item.DienThoai);
            sph.DefineSqlParameter("@DiaChi", SqlDbType.NVarChar, 256, ParameterDirection.Input, item.DiaChi);
            //sph.DefineSqlParameter("@Password", SqlDbType.NVarChar, 50, ParameterDirection.Input, item.Password);
            sph.DefineSqlParameter("@UpdateUser", SqlDbType.UniqueIdentifier, ParameterDirection.Input, item.UpdatedUser);
            sph.DefineSqlParameter("@UpdatedDate", SqlDbType.DateTime, ParameterDirection.Input, item.UpdatedDate);
            sph.DefineSqlParameter("@FullName", SqlDbType.NVarChar, 25, ParameterDirection.Input, item.FullName);

            int rowsAffected = sph.ExecuteNonQuery();
            return (rowsAffected > 0);
        }