Пример #1
0
        public void GetSearchParameter(string search)
        {
            panel1.Controls.Clear();
            //MessageBox.Show(search);
            Console.WriteLine(search);
            con.Open();
            DataTable dt5      = new DataTable();
            string    seachsql = "select U.MovieName, U.MID, R.rate from (select M.MovieName, M.MID " +
                                 "from Movie M, (select distinct MID from Casting C,(select * from Actor where FirstName like @search or LastName like @search) T " +
                                 "where C.AID = T.AID) N where M.MID = N.MID union select MovieName, MID from Movie where MovieName like @search" +
                                 ") U left join (Select AVG(Rating) as rate, MID from MovieRating Group by MID) R ON U.MID = R.MID";

            //adapt = new SqlDataAdapter("select * from Movie where MovieName like @search", con);
            adapt = new SqlDataAdapter(seachsql, con);
            adapt.SelectCommand.Parameters.AddWithValue("@search", "%" + search + "%");
            adapt.Fill(dt5);
            con.Close();
            // if (dt5.Rows.Count > 0)
            //      dataGridView1.DataSource = dt5;
            int r = 0;
            int c = 0;

            foreach (DataRow row in dt5.Rows)
            {
                if (c > 0 && c % 3 == 0)
                {
                    r++;
                    c = 0;
                }
                MovieBoxRent mbr = new MovieBoxRent(row["MID"].ToString().Trim());
                mbr.createNewBox(panel1, c, r);
                Image im = GetPoster(row["MID"].ToString().Trim());
                if (im == null)
                {
                    mbr.CreatePictureImage((Image)Properties.Resources.ResourceManager.GetObject("Noimage"));
                }
                else
                {
                    mbr.CreatePictureImage(im);
                }

                mbr.CreateName(row["MovieName"].ToString());
                mbr.CreateScore(row["rate"].ToString());
                mbr.CreateButtonRent();
                c++;
            }

            // con.Close();
        }
Пример #2
0
        public void Genre_Click(object sender, EventArgs e)
        {
            LinkLabel lb = (LinkLabel)sender;

            //MessageBox.Show(lb.Name);
            panelInGerneControl.Controls.Clear();
            SqlConnection connection = new SqlConnection(Form4.connectionString);

            connection.Open();
            SqlDataAdapter dataAdapter = new SqlDataAdapter("Select M.MovieName, Poster, M.MID,rate from Movie M left join (Select AVG(Rating) as rate, MID from MovieRating Group by MID) T ON M.MID = T.MID where M.MovieType = '" + lb.Name.ToString() + "'", connection);
            DataTable      dataTable   = new DataTable();

            dataAdapter.Fill(dataTable);
            int i = 0;

            foreach (DataRow row in dataTable.Rows)
            {
                //foreach (DataColumn column in dataTable.Columns)
                //{
                MovieBoxRent movieBoxRent = new MovieBoxRent(row["MID"].ToString());
                movieBoxRent.createNewBox(panelInGerneControl, i, 0);
                //MessageBox.Show(row["MID"].ToString().Trim());
                if (row["Poster"] == DBNull.Value)
                {
                    //MessageBox.Show("image null");
                    //MemoryStream ms = new MemoryStream((byte[])Properties.Resources.ResourceManager.GetObject("001"));
                    movieBoxRent.CreatePictureImage((Image)Properties.Resources.ResourceManager.GetObject("Noimage"));
                }
                else
                {
                    byte[] ImageArray = (byte[])row["Poster"];
                    Image  image      = Image.FromStream(new MemoryStream(ImageArray));

                    movieBoxRent.CreatePictureImage(image);
                }
                //movieBoxRent.CreatePicture(row["MID"].ToString().Trim());
                movieBoxRent.CreateName(row["MovieName"].ToString());
                //MessageBox.Show(row["MovieName"].ToString());
                movieBoxRent.CreateScore(row["rate"].ToString());
                movieBoxRent.CreateButtonRent();
                //Console.WriteLine(row["MovieName"]);
                i++;
                //}
            }
            connection.Close();
        }
Пример #3
0
        public void update()
        {
            panelInRanking.Controls.Clear();
            //MessageBox.Show("update");
            SqlConnection connection = new SqlConnection(Form4.connectionString);

            connection.Open();
            SqlDataAdapter dataAdapter = new SqlDataAdapter("SELECT top 5 Poster, MovieName, M.MID, rate from(Select AVG(Rating) as rate, MID FROM MovieRating group by MID) as T , Movie M where T.MID = M.MID Order by rate DESC", connection);
            DataTable      dataTable   = new DataTable();

            dataAdapter.Fill(dataTable);
            int i = 0;

            foreach (DataRow row in dataTable.Rows)
            {
                //foreach (DataColumn column in dataTable.Columns)
                //{
                MovieBoxRent movieBoxRent = new MovieBoxRent(row["MID"].ToString());
                movieBoxRent.createNewBox(panelInRanking, i, 0);
                //MessageBox.Show(row["MID"].ToString().Trim());
                if (row["Poster"] == DBNull.Value)
                {
                    //MessageBox.Show("image null");
                    //MemoryStream ms = new MemoryStream((byte[])Properties.Resources.ResourceManager.GetObject("001"));
                    movieBoxRent.CreatePictureImage((Image)Properties.Resources.ResourceManager.GetObject("Noimage"));
                }
                else
                {
                    byte[] ImageArray = (byte[])row["Poster"];
                    Image  image      = Image.FromStream(new MemoryStream(ImageArray));

                    movieBoxRent.CreatePictureImage(image);
                }

                //movieBoxRent.CreatePicture(row["MID"].ToString().Trim());
                movieBoxRent.CreateName(row["MovieName"].ToString());
                //MessageBox.Show(row["MovieName"].ToString());
                movieBoxRent.CreateScore(row["rate"].ToString());
                movieBoxRent.CreateButtonRent();
                Console.WriteLine(row["MovieName"]);
                i++;
                //}
            }
            connection.Close();
        }
Пример #4
0
        public void update()
        {
            panelinlike.Controls.Clear();
            SqlConnection connection = new SqlConnection(Form4.connectionString);

            connection.Open();
            SqlDataAdapter dataAdapter = new SqlDataAdapter("select top 5 Poster, M.MID, M.MovieName, (select AVG(rating) from MovieRating mr where mr.MID = M.MID ) rate from (select MovieType, O.MID from[Order] O, Movie M where CID = '" + UC1.id + "' and O.MID = M.MID) T, Movie M where M.MovieType = T.MovieType and T.MID != M.MID Order by NEWID()", connection);
            DataTable      dataTable   = new DataTable();

            dataAdapter.Fill(dataTable);
            int i = 0;

            foreach (DataRow row in dataTable.Rows)
            {
                //foreach (DataColumn column in dataTable.Columns)
                //{
                MovieBoxRent movieBoxRent = new MovieBoxRent(row["MID"].ToString());
                movieBoxRent.createNewBox(panelinlike, i, 0);
                //MessageBox.Show(row["MID"].ToString().Trim());
                if (row["Poster"] == DBNull.Value)
                {
                    //MessageBox.Show("null poster");
                    movieBoxRent.CreatePictureImage((Image)Properties.Resources.ResourceManager.GetObject("Noimage"));
                }
                else
                {
                    byte[] ImageArray = (byte[])row["Poster"];
                    Image  image      = Image.FromStream(new MemoryStream(ImageArray));

                    movieBoxRent.CreatePictureImage(image);
                }

                movieBoxRent.CreateName(row["MovieName"].ToString());
                //MessageBox.Show(row["MovieName"].ToString());
                movieBoxRent.CreateScore(row["rate"].ToString());
                movieBoxRent.CreateButtonRent();
                //Console.WriteLine(row["MovieName"]);
                i++;
                //}
            }
            connection.Close();
        }
Пример #5
0
        public void update()
        {
            panelintop.Controls.Clear();
            SqlConnection connection = new SqlConnection(Form4.connectionString);

            connection.Open();
            string         sql         = "select * from (select top 10 count(MID) num, mid from[Order] O group by MID order by num DESC) T , Movie M left join(Select AVG(Rating) as rate, MID from MovieRating Group by MID ) as T2 on T2.MID = m.MID where T.MID = M.mid ";
            SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, connection);
            DataTable      dataTable   = new DataTable();

            dataAdapter.Fill(dataTable);

            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                MovieBoxRent movieBoxRent = new MovieBoxRent(dataTable.Rows[i]["MID"].ToString());
                movieBoxRent.createNewBox(panelintop, i, 0);
                //MessageBox.Show(row["MID"].ToString().Trim());
                if (dataTable.Rows[i]["Poster"] == DBNull.Value)
                {
                    //MessageBox.Show("image null");
                    //MemoryStream ms = new MemoryStream((byte[])Properties.Resources.ResourceManager.GetObject("001"));
                    movieBoxRent.CreatePictureImage((Image)Properties.Resources.ResourceManager.GetObject("Noimage"));
                }
                else
                {
                    byte[] ImageArray = (byte[])dataTable.Rows[i]["Poster"];
                    Image  image      = Image.FromStream(new MemoryStream(ImageArray));

                    movieBoxRent.CreatePictureImage(image);
                }
                //movieBoxRent.CreatePicture(dataTable.Rows[i]["MID"].ToString().Trim());
                movieBoxRent.CreateName(dataTable.Rows[i]["MovieName"].ToString());
                //MessageBox.Show(row["MovieName"].ToString());
                movieBoxRent.CreateScore(dataTable.Rows[i]["rate"].ToString());
                movieBoxRent.CreateButtonRent();
            }

            connection.Close();
        }