示例#1
0
        private void cancel_add_movie_button_Click(object sender, RoutedEventArgs e)
        {
            string           message = "This will discard all inputed data";
            string           caption = "Confirm?";
            MessageBoxButton buttons = MessageBoxButton.OKCancel;
            // Show message box
            MessageBoxResult result = MessageBox.Show(message, caption, buttons);


            if (result == MessageBoxResult.OK)
            {
                cnn.Close();
                AddPage add = new AddPage();
                this.NavigationService.Navigate(add);
            }
        }
示例#2
0
        private void cancel_add_release_button_Click(object sender, RoutedEventArgs e)
        {
            if (autoMovieID != 0)
            {
                MessageBox.Show("Please insert the USA release for that movie");
                return;
            }
            else
            {
                string           message = "This will discard all inputed data";
                string           caption = "Confirm?";
                MessageBoxButton buttons = MessageBoxButton.OKCancel;
                // Show message box
                MessageBoxResult result = MessageBox.Show(message, caption, buttons);


                if (result == MessageBoxResult.OK)
                {
                    cnn.Close();
                    AddPage add = new AddPage();
                    this.NavigationService.Navigate(add);
                }
            }
        }
        private void add_writer_button_Click(object sender, RoutedEventArgs e)
        {
            string insertWriter = "movies.sp_AddWriter";

            Writer w = new Writer();

            try
            {
                w.ssn = Convert.ToInt32(ssn.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Argument SSN takes integers only");
                return;
            }

            if (name.Text.Length == 0)
            {
                MessageBox.Show("Name Field is required");
                return;
            }
            else
            {
                w.name = name.Text;
            }

            char[] d = { ':', '-', '/' };
            if (birth_date != null && birth_date.Text != "")
            {
                int      year, month, day;
                string[] date = new string[3];
                date  = birth_date.Text.Split(d);
                year  = Convert.ToInt32(date[2]);
                month = Convert.ToInt32(date[1]);
                day   = Convert.ToInt32(date[0]);

                if (year > 20)
                {
                    year += 1900;
                }
                else
                {
                    year += 2000;
                }

                w.bdate = new DateTime(year, month, day);
            }

            try
            {
                w.rank = Convert.ToInt32(rank.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Argument Rank takes integers only");
                return;
            }

            cmd             = new SqlCommand(insertWriter, cnn);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@ssn", w.ssn);
            cmd.Parameters.AddWithValue("@name", w.name);
            cmd.Parameters.AddWithValue("@bdate", w.bdate.ToString("u"));
            cmd.Parameters.AddWithValue("@rank", w.rank);


            try
            {
                cmd.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("Error on inserting Writer to database");
                return;
            }

            cnn.Close();
            AddPage add = new AddPage();

            this.NavigationService.Navigate(add);
        }
        private void add_studio_button_Click(object sender, RoutedEventArgs e)
        {
            string insertStudio = "movies.sp_AddStudio";
            int    studio_id;
            string studio_name;

            char[] d = { ':', '-', '/' };
            try
            {
                studio_id = Convert.ToInt32(id.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Argument ID takes integers only");
                return;
            }

            if (name.Text.Length == 0)
            {
                MessageBox.Show("Name Field is required");
                return;
            }
            else
            {
                studio_name = name.Text;
            }

            DataTable studio_locations = new DataTable();

            studio_locations.Clear();
            studio_locations.Columns.Add("location");
            foreach (CheckBox s in locations.Items)
            {
                if (s.IsChecked.HasValue && s.IsChecked.Value)
                {
                    DataRow row = studio_locations.NewRow();
                    row["location"] = s.Content.ToString();
                    studio_locations.Rows.Add(row);
                }
            }

            SqlCommand insertQuery = new SqlCommand(insertStudio, cnn);

            insertQuery.CommandType = CommandType.StoredProcedure;

            insertQuery.Parameters.AddWithValue("@id", studio_id);
            insertQuery.Parameters.AddWithValue("@name", studio_name);
            insertQuery.Parameters.AddWithValue("@locations", studio_locations);

            try
            {
                insertQuery.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("Error on inserting Studio to database");
                return;
            }

            cnn.Close();
            AddPage add = new AddPage();

            this.NavigationService.Navigate(add);
        }
示例#5
0
        private void add_release_button_Click(object sender, RoutedEventArgs e)
        {
            string  insertRelease = "movies.sp_AddRelease";
            Release a             = new Release();

            char[] d = { ':', '-', '/' };
            try
            {
                a.id = Convert.ToInt32(id.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Argument ID takes integers only");
                return;
            }

            if (name.Text.Length == 0)
            {
                MessageBox.Show("Title Field is required");
                return;
            }
            else
            {
                a.title = name.Text;
            }

            if (country.Text.Length == 0)
            {
                MessageBox.Show("Country Field is required");
                return;
            }
            else
            {
                a.country = country.Text;
            }

            if (release_date != null && release_date.Text != "")
            {
                int      year, month, day;
                string[] date = new string[3];
                date  = release_date.Text.Split(d);
                year  = Convert.ToInt32(date[2]);
                month = Convert.ToInt32(date[1]);
                day   = Convert.ToInt32(date[0]);

                if (year > 20)
                {
                    year += 1900;
                }
                else
                {
                    year += 2000;
                }

                a.date = new DateTime(year, month, day);

                if (movie_id_combo.Text == "")
                {
                    MessageBox.Show("Please select a Movie ID");
                    return;
                }
                else
                {
                    a.movieID = Convert.ToInt32(movie_id_combo.Text.Split(d)[0]);
                }
            }

            SqlCommand insertQuery = new SqlCommand(insertRelease, cnn);

            insertQuery.CommandType = CommandType.StoredProcedure;

            insertQuery.Parameters.AddWithValue("@id", a.id);
            insertQuery.Parameters.AddWithValue("@title", a.title);
            insertQuery.Parameters.AddWithValue("@country", a.country);
            insertQuery.Parameters.AddWithValue("@movieID", a.movieID);
            insertQuery.Parameters.AddWithValue("@date", a.date.ToString("u"));

            try
            {
                insertQuery.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("Error on inserting Release to database");
                return;
            }

            cnn.Close();
            AddPage add = new AddPage();

            this.NavigationService.Navigate(add);
        }
示例#6
0
        private void add_review_button_Click(object sender, RoutedEventArgs e)
        {
            string insertReview = "movies.sp_AddReview";

            Review r = new Review();

            try
            {
                r.id = Convert.ToInt32(id.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Argument ID takes integers only");
                return;
            }

            try
            {
                r.rating = Convert.ToInt32(rating.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Argument Rating takes integers only");
                return;
            }

            if (review.Text.Length == 0)
            {
                MessageBox.Show("Review Field is required");
                return;
            }
            else
            {
                r.review = review.Text;
            }

            char[] d = { ':', '-', '/' };
            if (date != null && date.Text != "")
            {
                int      year, month, day;
                string[] date2 = new string[3];
                date2 = date.Text.Split(d);
                year  = Convert.ToInt32(date2[2]);
                month = Convert.ToInt32(date2[1]);
                day   = Convert.ToInt32(date2[0]);

                if (year > 20)
                {
                    year += 1900;
                }
                else
                {
                    year += 2000;
                }

                r.date = new DateTime(year, month, day);
            }

            try
            {
                r.movie_id = Convert.ToInt32(movie_id.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Argument Movie ID takes integers only");
                return;
            }

            if (username.Text.Length == 0)
            {
                MessageBox.Show("Username Field is required");
                return;
            }
            else
            {
                r.username = username.Text;
            }



            cmd             = new SqlCommand(insertReview, cnn);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@id", r.id);
            cmd.Parameters.AddWithValue("@rating", r.rating);
            cmd.Parameters.AddWithValue("@review", r.review);
            cmd.Parameters.AddWithValue("@date", r.date.ToString("u"));
            cmd.Parameters.AddWithValue("@movie_id", r.movie_id);
            cmd.Parameters.AddWithValue("@username", r.username);


            try
            {
                cmd.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("Error on inserting Review to database");
                return;
            }

            cnn.Close();
            AddPage add = new AddPage();

            this.NavigationService.Navigate(add);
        }
示例#7
0
        private void add_users_button_Click(object sender, RoutedEventArgs e)
        {
            string insertUser = "******";

            User u = new User();

            if (username.Text.Length == 0)
            {
                MessageBox.Show("Username Field is required");
                return;
            }
            else
            {
                u.username = username.Text;
            }

            if (name.Text.Length == 0)
            {
                MessageBox.Show("Name Field is required");
                return;
            }
            else
            {
                u.name = name.Text;
            }

            char[] d = { ':', '-', '/' };
            if (birth_date != null && birth_date.Text != "")
            {
                int      year, month, day;
                string[] date = new string[3];
                date  = birth_date.Text.Split(d);
                year  = Convert.ToInt32(date[2]);
                month = Convert.ToInt32(date[1]);
                day   = Convert.ToInt32(date[0]);

                if (year > 20)
                {
                    year += 1900;
                }
                else
                {
                    year += 2000;
                }

                u.bdate = new DateTime(year, month, day);
            }

            if (email.Text.Length == 0)
            {
                MessageBox.Show("Email Field is required");
                return;
            }
            else
            {
                u.email = email.Text;
            }

            if (country.Text.Length == 0)
            {
                MessageBox.Show("Country Field is required");
                return;
            }
            else
            {
                u.country = country.Text;
            }

            cmd             = new SqlCommand(insertUser, cnn);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@username", u.username);
            cmd.Parameters.AddWithValue("@name", u.name);
            cmd.Parameters.AddWithValue("@bdate", u.bdate.ToString("u"));
            cmd.Parameters.AddWithValue("@email", u.email);
            cmd.Parameters.AddWithValue("@country", u.country);


            try
            {
                cmd.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("Error on inserting User to database");
                return;
            }

            cnn.Close();
            AddPage add = new AddPage();

            this.NavigationService.Navigate(add);
        }
示例#8
0
        private void add_award_button_Click(object sender, RoutedEventArgs e)
        {
            string insertAward = "movies.sp_AddAward";

            Award a = new Award();

            try
            {
                a.year = Convert.ToInt32(year.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Argument Year takes integers only");
                return;
            }

            if (type.Text.Length == 0)
            {
                MessageBox.Show("Type Field is required");
                return;
            }
            else
            {
                a.type = type.Text;
            }

            if (designation.Text.Length == 0)
            {
                MessageBox.Show("Designation Field is required");
                return;
            }
            else
            {
                a.designation = designation.Text;
            }


            try
            {
                a.movie_id = Convert.ToInt32(movie_id.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Argument Movie ID takes integers only");
                return;
            }



            cmd             = new SqlCommand(insertAward, cnn);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@year", a.year);
            cmd.Parameters.AddWithValue("@type", a.type);
            cmd.Parameters.AddWithValue("@designation", a.designation);
            cmd.Parameters.AddWithValue("@movie_id", a.movie_id);


            try
            {
                cmd.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("Error on inserting Award to database");
                return;
            }

            cnn.Close();
            AddPage add = new AddPage();

            this.NavigationService.Navigate(add);
        }
示例#9
0
        private void add_release_button_Click(object sender, RoutedEventArgs e)
        {
            string  insertTrailer = "movies.sp_AddTrailer";
            Trailer a             = new Trailer();

            char[] d = { ':', '-', '/' };
            try
            {
                a.id = Convert.ToInt32(id.Text);
            }
            catch (FormatException)
            {
                MessageBox.Show("Argument ID takes integers only");
                return;
            }

            if (name.Text.Length == 0)
            {
                MessageBox.Show("Title Field is required");
                return;
            }
            else
            {
                a.title = name.Text;
            }

            if (language.Text.Length == 0)
            {
                MessageBox.Show("Language Field is required");
                return;
            }
            else
            {
                a.language = language.Text;
            }

            if (date != null && date.Text != "")
            {
                int      year, month, day;
                string[] dates = new string[3];
                dates = date.Text.Split(d);
                year  = Convert.ToInt32(dates[2]);
                month = Convert.ToInt32(dates[1]);
                day   = Convert.ToInt32(dates[0]);

                if (year > 20)
                {
                    year += 1900;
                }
                else
                {
                    year += 2000;
                }

                a.date = new DateTime(year, month, day);

                if (movie_id_combo.Text == "")
                {
                    MessageBox.Show("Please select a Movie ID");
                    return;
                }
                else
                {
                    a.movieID = Convert.ToInt32(movie_id_combo.Text.Split(d)[0]);
                }

                string[] time = duration.Text.Split(d);
                try
                {
                    a.duration = new TimeSpan(Convert.ToInt32(time[0]), Convert.ToInt32(time[1]), Convert.ToInt32(time[2]));
                }
                catch (FormatException)
                {
                    MessageBox.Show("Argument Duration takes 3 integers \nFormat: HH:MM:SS");
                    return;
                }
            }

            SqlCommand insertQuery = new SqlCommand(insertTrailer, cnn);

            insertQuery.CommandType = CommandType.StoredProcedure;

            insertQuery.Parameters.AddWithValue("@id", a.id);
            insertQuery.Parameters.AddWithValue("@title", a.title);
            insertQuery.Parameters.AddWithValue("@language", a.language);
            insertQuery.Parameters.AddWithValue("@movieID", a.movieID);
            insertQuery.Parameters.AddWithValue("@date", a.date.ToString("u"));
            insertQuery.Parameters.AddWithValue("@duration", a.duration.ToString(@"hh\:mm\:ss"));

            try
            {
                insertQuery.ExecuteNonQuery();
            }
            catch
            {
                MessageBox.Show("Error on inserting Trailer to database");
                return;
            }

            cnn.Close();
            AddPage add = new AddPage();

            this.NavigationService.Navigate(add);
        }
示例#10
0
        private void goto_add()
        {
            AddPage add = new AddPage();

            this.NavigationService.Navigate(add);
        }