Exemplo n.º 1
0
        private void cmdQuery_Click(object sender, EventArgs e)
        {
            SQLServerAccess sqa = new SQLServerAccess();

            dgvMovieResults.DataSource = null;
            dgvMovieResults.Rows.Clear();
            dgvMovieResults.Columns.Clear();

            List<WatchedMovieModel> movielist = new List<WatchedMovieModel>();
            movielist = sqa.getAllWatchedMovies();

            if (movielist != null)
            {
                dgvMovieResults.Columns.Add("clmMovieID", "Movie ID");
                dgvMovieResults.Columns.Add("clmMovieTitle", "Movie Title");
                dgvMovieResults.Columns.Add("clmReleaseDate", "Release Date");
                dgvMovieResults.Columns.Add("clmRating", "Rating");

                foreach (WatchedMovieModel m in movielist){
                    string[] row = new string[] { m.movieID.ToString(), m.movieTitle, DateTime.Parse(m.movieReleaseDate.ToString()).ToString("yyyy-MM-dd"), m.personal_rating.ToString() };
                    dgvMovieResults.Rows.Add(row);
                }

                dgvMovieResults.Refresh();
            } else
            {
                dgvMovieResults.Columns.Add("clmError", "Error Message");
                dgvMovieResults.Rows.Add();
                dgvMovieResults.Rows[0].Cells[0].Value = "Error";
                Console.WriteLine("Returned null");
            }
        }
Exemplo n.º 2
0
        private async void frmMovieDetails_Load(object sender, EventArgs e)
        {
            lblLoading.Visible = true;

            sqa = new SQLServerAccess();
            if (sqa.checkIfWatched(movieID))
            {
                movie = new WatchedMovie();
                movie = sqa.getWatchedMovie(movieID);
                getMovieDetails(movieID);
                cmdWatched.Enabled = false;
                cmdWatched.Text = "Watched";
                chklbStarRating.SetItemChecked(movie.personal_rating - 1, true);
            } else
            {
                API_INIT = new APIAccess(); 
                movie = new TmdbMovie();
                movie = await API_INIT.fullMovieDetails(movieID);
                await getMovieDetails();
            }

            MoviePosterURL = movie.poster_path;

            lblTitle.Text = movie.Title;
            lblTagLine.Text = movie.tagline;

            lblStatusActual.Text = movie.status;
            lblDirectorActual.Text = director.director_name;

            if (movie.status == "Released")
            {
                lblStatusActual.ForeColor = Color.Green;
            } else
            {
                lblStatusActual.ForeColor = Color.Red;
            }

            lblReleaseDateActual.Text = movie.release_date.ToString();
            lblRevenueActual.Text = "$" + string.Format("{0:N}", movie.Revenue);
            lblBudgetActual.Text = "$" + string.Format("{0:N}", movie.Budget);
            lblRuntimeActual.Text = movie.Runtime.ToString() + " mins";

            picMoviePoster.ImageLocation = MovieURLPrefix + "w500" + MoviePosterURL;

            

            lblLoading.Visible = false;
        }
Exemplo n.º 3
0
        public static IDataSource GetDataSource()
        {
            IDataSource dataAccess;

            switch (AppSettings.System.DataSource)
            {
            case DataSourceEnum.SQLServer:
                dataAccess = new SQLServerAccess();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(dataAccess);
        }
Exemplo n.º 4
0
        private void getMovieDetails(int movieID)
        {
            cast = new List<MovieCast>();
            sqa = new SQLServerAccess();

            cast = sqa.getMovieCast(this.movieID);

            foreach (MovieCast m in cast)
            {
                string[] row = new string[] { m.name, m.character };
                dgvMovieCredits.Rows.Add(row);
            }

            director = sqa.getMovieDirector(this.movieID);
        }
Exemplo n.º 5
0
        private void cmdWatched_Click(object sender, EventArgs e)
        {
            int rating = 0;
            if (chklbStarRating.CheckedItems.Count != 0)
            {
                foreach(char s in chklbStarRating.CheckedItems[0].ToString()) {
                    rating++;
                }
            } else
            {
                MessageBox.Show("Please give a movie rating", "Error!");
                return;
            }

            lblLoading.Visible = true;
            lblLoading.Text = "SAVING";
            sqa = new SQLServerAccess();

            sqa.watchMovie(movie, cast, movie.Genres, director, rating);
            cmdWatched.Enabled = false;
            lblLoading.Visible = false;
            lblLoading.Text = "LOADING";
        }
Exemplo n.º 6
0
        public void Run()
        {
            var dt = DateTime.Now;
            //var s = from t in new List<object>()
            //        where t.ToString() == ""
            //        select t;
            var ssa = new SQLServerAccess();

            var lastweek_start = ComFunc.GetMondayDate(DateTime.Now).AddDays(-7);
            var lastweek_end   = ComFunc.GetSundayDate(DateTime.Now).AddDays(-7);
            var dd             = from t in ssa.NewLinqTable("IC_Statistic_Water", "a")
                                 where t.SW_Estate == "1" &&
                                 t.todatetime(t.SW_Year.tostring(4).concat("-", (t.SW_Month + 100).tostring(3).substring(2, 2), "-", (t.SW_Day + 100).tostring(3).substring(2, 2))) >= t.todatetime($"{lastweek_start.Year}-{lastweek_start.Month}-{lastweek_start.Day}") &&
                                 t.todatetime(t.SW_Year.tostring(4).concat("-", (t.SW_Month + 100).tostring(3).substring(2, 2), "-", (t.SW_Day + 100).tostring(3).substring(2, 2))) <= t.todatetime($"{lastweek_end.Year}-{lastweek_end.Month}-{lastweek_end.Day}")
                                 select new
            {
                hour  = t.SW_Hour,
                count = t.SW_Total
            };

            //var filter = "a";
            //var start_time = "";
            //var end_time = "";
            //var s = from t in LinqDLRTable.New<LinqDLRColumn>("a", "", new SqlOperatorFlags())
            //        where t.notnull(filter, (t.Request_Route.contains(filter) || t.Request_IP.contains(filter) || t.Request_SubSystem_Name.contains(filter)))
            //        && t.notnull(start_time, t.add_time >= start_time) && t.notnull(end_time, t.add_time <= end_time) && t.start_time.isnull("").within(",1,2,3")
            //        orderby t.add_time descending
            //        select t;
            Console.WriteLine(dd.ToSql());
            var s = from t in LinqDLRTable.New <LinqDLRColumn>("a", "a", new SqlOperatorFlags())
                    join t2 in LinqDLRTable.New <LinqDLRColumn>("b", "b", new SqlOperatorFlags()) on t.id equals t2.code
                    join t3 in LinqDLRTable.New <LinqDLRColumn>("b", "c", new SqlOperatorFlags()) on t.id2 equals t3.code
                    group t by new { t.a, t.b } into g
            select g;
            var    sql = s.ToSql();

            Console.WriteLine(sql);
            sql = (from t in LinqDLRTable.New <LinqDLRColumn>("a", "", new SqlOperatorFlags())
                   orderby t.time descending
                   select t).ToSql();
            Console.WriteLine(sql);
            sql = (from t in LinqDLRTable.New <LinqDLRColumn>("a", "", new SqlOperatorFlags())
                   orderby t.time descending, t.id
                   select new { t.id, t.name }).ToSql();
            Console.WriteLine(sql);
            sql = (from t in LinqDLRTable.New <LinqDLRColumn>("a", "", new SqlOperatorFlags())
                   group t by new { t.a, t.b } into g
                   select g).ToSql();
            Console.WriteLine(sql);
            sql = (from t in LinqDLRTable.New <LinqDLRColumn>("a", "", new SqlOperatorFlags())
                   from t2 in LinqDLRTable.New <LinqDLRColumn>("b", "", new SqlOperatorFlags())
                   where t.id == t2.id && t.time == "2018/08/17"
                   select new
            {
                t.id,
                t2.name
            }).ToSql();
            Console.WriteLine(sql);
            sql = (from t in LinqDLRTable.New <LinqDLRColumn>("a", "", new SqlServerOperatorFlags())
                   from t2 in LinqDLRTable.New <LinqDLRColumn>("b", "", new SqlServerOperatorFlags())
                   from t3 in LinqDLRTable.New <LinqDLRColumn>("c", "", new SqlServerOperatorFlags())
                   where t.id == t2.id
                   group new { t, t2, t3 } by new
            {
                t.id,
                t2.time
            } into g
                   select new
            {
                g.t.id,
                g.t2.name
            }).ToSql();
            Console.WriteLine(sql);
            Console.WriteLine($"selectmany cast:{(DateTime.Now - dt).TotalMilliseconds}"); dt = DateTime.Now;
        }