Esempio n. 1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            AdminDomain adminDomain = new AdminDomain();
            AdminDAO adminDAO = new AdminDAO();
            PictureBA pictureBA = new PictureBA();

            string filePath = FileUpload1.PostedFile.FileName;
            Stream fileStream = FileUpload1.PostedFile.InputStream;
            adminDomain.setTitle(title.Text);
            adminDomain.setPictureType(pictureBA.pictureType(filePath));
            adminDomain.setPicture(pictureBA.pictureToByte(fileStream));
            adminDAO.uploadImage(adminDomain);
        }
Esempio n. 2
0
 public AdminDomain getHomePageImage()
 {
     SqlConnection mySqlConnection = sqlQueryConn.getSqlConnection();
     AdminDomain adminDomain = new AdminDomain();
     string query = "SELECT * FROM [admin_image] where id = 1";
     using (mySqlConnection)
     {
         SqlCommand cmd = new SqlCommand(query, mySqlConnection);
         mySqlConnection.Open();
         SqlDataReader rdr = cmd.ExecuteReader();
         while (rdr.Read())
         {
             adminDomain.setId((int)rdr["id"]);
             adminDomain.setTitle(rdr["name"].ToString());
             adminDomain.setPicture((byte[])rdr["image"]);
             adminDomain.setPictureType(rdr["image_type"].ToString());
         }
         rdr.Close();
     }
     return adminDomain;
 }
Esempio n. 3
0
        public void uploadImage(AdminDomain AdminDomain)
        {
            SqlConnection mySqlConnection = sqlQueryConn.getSqlConnection();
            mySqlConnection.Open();
            string query = "INSERT INTO [admin_image] (name, image, image_type) VALUES (@name, @image, @type)";
            try
            {
                SqlCommand cmd = new SqlCommand(query, mySqlConnection);
                cmd.Parameters.Add("name", SqlDbType.NChar).Value = AdminDomain.getTitle();
                cmd.Parameters.Add("image", SqlDbType.VarBinary).Value = AdminDomain.getPicture();
                cmd.Parameters.Add("type", SqlDbType.NChar).Value = AdminDomain.getPictureType();
                cmd.ExecuteNonQuery();
            }
            catch (System.IO.IOException e)
            {

            }
            finally
            {
                mySqlConnection.Close();
            }
        }