예제 #1
0
        public AdminMovieUpdate(AdminMovieContent content, int movie_no)
        {
            InitializeComponent();
            this.content = content;

            dbuse = new DBUSE();
            Movie_tbl movie_Tbl = new Movie_tbl();

            movie_Tbl = dbuse.MovieSelect(movie_no);

            DTP_playdate.Format       = DateTimePickerFormat.Custom;
            DTP_playdate.CustomFormat = "yyyy-MM-dd";

            DTP_time.Format       = DateTimePickerFormat.Custom;
            DTP_time.CustomFormat = "HH:mm";

            MessageBox.Show(movie_Tbl.Movie_No + "/" + movie_Tbl.Title + "/" + movie_Tbl.genre + "/" + movie_Tbl.playdate + "/" + movie_Tbl.time);
            TB_MovieNo.Text          = movie_Tbl.Movie_No.ToString();
            TB_MovieTitle.Text       = movie_Tbl.Title;
            TB_MovieGenre.Text       = movie_Tbl.genre;
            DTP_playdate.MinDate     = movie_Tbl.playdate;
            DTP_time.MinDate         = movie_Tbl.time;
            pictureBox1.Image        = new Bitmap(new MemoryStream(movie_Tbl.ImageFile, 0, movie_Tbl.ImageFile.Length));
            openFileDialog1.FileName = pictureBox1.ImageLocation;
        }
예제 #2
0
        public Movie_tbl MovieSelect(int Movie_No)
        {
            Movie_tbl movie = new Movie_tbl();

            movie.Movie_No = Movie_No;

            String sql = "";

            try
            {
                con.Open();
                sql += "SELECT Title, Genre, PlayDate, Time, Image FROM Movie_TBL WHERE Movie_No='" + Movie_No + "'";
                cmd  = new OracleCommand(sql, con);
                OracleDataReader reader = cmd.ExecuteReader();

                if (reader.Read())
                {
                    movie.Title     = Convert.ToString(reader.GetValue(0));
                    movie.genre     = Convert.ToString(reader.GetValue(1));
                    movie.playdate  = Convert.ToDateTime(reader.GetValue(2));
                    movie.time      = Convert.ToDateTime(reader.GetValue(3));
                    movie.ImageFile = (byte[])reader.GetValue(4);
                }
            }catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                con.Close();
            }


            return(movie);
        }
예제 #3
0
        private void Insert_Movie(object sender, EventArgs e)
        {
            Movie_tbl movie_Tbl = new Movie_tbl();


            try
            {
                movie_Tbl.Movie_No = Convert.ToInt32(TB_MovieNo.Text);
            }
            catch (Exception ex) { Console.WriteLine(ex); }
            movie_Tbl.Title    = TB_MovieTitle.Text;
            movie_Tbl.genre    = TB_MovieGenre.Text;
            movie_Tbl.playdate = DTP_playdate.Value;
            movie_Tbl.time     = DTP_time.Value;
            movie_Tbl.Image    = openFileDialog1.FileName;

            DBUSE dbuse = new DBUSE();
            int   chk   = dbuse.MovieInsert(movie_Tbl);

            if (chk == 0)
            {
                content.selectList();
                this.Close();
            }
        }
예제 #4
0
        public int MovieInsert(Movie_tbl movie_Tbl)
        {
            String sql = "";

            int chk = 0;

            try
            {
                con.Open();

                FileStream fs    = new FileStream(movie_Tbl.Image, FileMode.Open, FileAccess.Read);
                byte[]     Image = new byte[fs.Length];
                fs.Read(Image, 0, (int)fs.Length);
                fs.Close();

                sql += "INSERT INTO MOVIE_TBL (Movie_No, Title, Genre, PlayDate, Time, Image) ";
                sql += "VALUES (:Movie_no, :Title, :Genre, :PlayDate, " +
                       ":Time, :Image)";

                cmd = new OracleCommand(sql, con);

                cmd.Parameters.Add(":Movie_No", OracleDbType.Int32).Value = movie_Tbl.Movie_No;
                cmd.Parameters.Add(":Title", OracleDbType.Varchar2).Value = movie_Tbl.Title;
                cmd.Parameters.Add(":Genre", OracleDbType.Varchar2).Value = movie_Tbl.genre;
                cmd.Parameters.Add(":PlayDate", OracleDbType.Date).Value  = movie_Tbl.playdate;
                cmd.Parameters.Add(":Time", OracleDbType.Date).Value      = movie_Tbl.time;
                cmd.Parameters.Add(":Image", OracleDbType.Blob).Value     = Image;

                cmd.ExecuteNonQuery();
                MessageBox.Show("업로드 성공");
            }
            catch (Exception e)
            {
                MessageBox.Show("업로드 실패");
                Console.WriteLine(e);
                chk = 1;
            }
            finally
            {
                con.Close();
            }
            return(chk);
        }
예제 #5
0
        public int MovieUpdate(Movie_tbl movie_Tbl)
        {
            String sql = "";
            int    chk = 0;

            try
            {
                con.Open();

                FileStream fs    = new FileStream(movie_Tbl.Image, FileMode.Open, FileAccess.Read);
                byte[]     Image = new byte[fs.Length];
                fs.Read(Image, 0, (int)fs.Length);
                fs.Close();

                sql += "UPDATE Movie_TBL SET Title =:Title, Genre =:Genre, PlayDate =:PlayDate, " +
                       "Time =:Time, Image =:Image WHERE Movie_No =:Movie_No";


                cmd = new OracleCommand(sql, con);

                cmd.Parameters.Add(":Movie_No", OracleDbType.Int32).Value = movie_Tbl.Movie_No;
                cmd.Parameters.Add(":Title", OracleDbType.Varchar2).Value = movie_Tbl.Title;
                cmd.Parameters.Add(":Genre", OracleDbType.Varchar2).Value = movie_Tbl.genre;
                cmd.Parameters.Add(":PlayDate", OracleDbType.Date).Value  = movie_Tbl.playdate;
                cmd.Parameters.Add(":Time", OracleDbType.Date).Value      = movie_Tbl.time;
                cmd.Parameters.Add(":Image", OracleDbType.Blob).Value     = Image;

                cmd.ExecuteNonQuery();
                MessageBox.Show("업데이트 성공");
            }
            catch (Exception e)
            {
                MessageBox.Show("업데이트 실패");
                Console.WriteLine(e);
                chk = 1;
            }
            finally
            {
                con.Close();
            }

            return(chk);
        }
예제 #6
0
        public List <Movie_tbl> MovieList()
        {
            String           sql = "SELECT Movie_No, Title, Genre, TO_CHAR(playdate,'YYYY-MM-DD'), TO_CHAR(time,'HH:MI'), Image FROM movie_tbl";
            Movie_tbl        movie;
            List <Movie_tbl> list       = new List <Movie_tbl>();
            OracleDataReader dataReader = null;

            try
            {
                con.Open();

                cmd        = new OracleCommand(sql, con);
                dataReader = cmd.ExecuteReader();


                while (dataReader.Read())
                {
                    movie = new Movie_tbl();

                    movie.Movie_No  = Convert.ToInt32(dataReader.GetValue(0));
                    movie.Title     = Convert.ToString(dataReader.GetValue(1));
                    movie.genre     = Convert.ToString(dataReader.GetValue(2));
                    movie.playdate  = Convert.ToDateTime(dataReader.GetValue(3));
                    movie.time      = Convert.ToDateTime(dataReader.GetValue(4));
                    movie.ImageFile = (byte[])dataReader.GetValue(5);


                    list.Add(movie);
                }
            }catch (Exception e)
            {
                MessageBox.Show(e + "");
            }
            finally
            {
                dataReader.Close();
                con.Close();
            }


            return(list);
        }