public Image GetEmployeePhoto(string employeeNumber)
        {
            string sql    = "select Photo from Photo where EmployeeNumber=@en";
            var    reader = SqlHelper.ExecuteReader(conn, System.Data.CommandType.Text, sql, new SqlParameter("@en", employeeNumber));

            try
            {
                if (reader.Read())
                {
                    if (!Convert.IsDBNull(reader["Photo"]))
                    {
                        byte[] bImg = (byte[])reader["Photo"];
                        return(AnnualPartySqlHelper.GetImage(bImg));
                    }
                    else
                    {
                        return(GetNoPhotoImage());
                    }
                }
                return(GetNoPhotoImage());
            }
            finally
            {
                reader.Close();
            }
        }
Beispiel #2
0
 public void LoadWithPhoto(Photo reader)
 {
     if (reader != null)
     {
         byte[] bImg = reader.PhotoData;
         this.Photo = AnnualPartySqlHelper.GetImage(bImg);
     }
 }
Beispiel #3
0
 public void LoadWithPhoto(IDataReader reader)
 {
     LoadBasic(reader);
     if (!Convert.IsDBNull(reader["Photo"]))
     {
         byte[] bImg = (byte[])reader["Photo"];
         this.Photo = AnnualPartySqlHelper.GetImage(bImg);
     }
 }
Beispiel #4
0
        public Image GetEmployeePhoto(string employeeNumber)
        {
            AnnualPartyEntities entities = new AnnualPartyEntities();
            var photo = entities.Photo.SingleOrDefault(e => e.EmployeeNumber == employeeNumber);

            if (photo != null)
            {
                byte[] bImg = photo.PhotoData;
                return(AnnualPartySqlHelper.GetImage(bImg));
            }
            else
            {
                return(GetNoPhotoImage());
            }
            // string sql = "select Photo from Photo where EmployeeNumber=@en";
            //var reader = SqlHelper.ExecuteReader(conn, System.Data.CommandType.Text, sql, new SqlParameter("@en",employeeNumber));
            //try
            //{
            //    if (reader.Read())
            //    {
            //        if (!Convert.IsDBNull(reader["Photo"]))
            //        {
            //            byte[] bImg = (byte[])reader["Photo"];
            //            return AnnualPartySqlHelper.GetImage(bImg);
            //        }
            //        else
            //        {
            //            return GetNoPhotoImage();
            //        }
            //    }
            //    return GetNoPhotoImage();
            //}
            //finally
            //{
            //    reader.Close();
            //}
        }