コード例 #1
0
         public void FillData(string url, long id, long matchid, int count, string couponid)
       
         {
            OddsCheckerCrawler crawlcheck = MdiParent as OddsCheckerCrawler;
            string bookies = crawlcheck.SelectedBookies();
            GenerateCoupon coupon = new GenerateCoupon();
            //string msg = crawl.DeleteMarketOdds(id);
            //crawl.CrawlMarkets(url, id, matchid);
            DataGridView dataGridView1 = new DataGridView();
            DataSet ds = coupon.GetCouponMarket(url, id, matchid, bookies, couponid);
            DataTable dt = ds.Tables[0];
            DataRow newrow = dt.NewRow();
            dt.Rows.InsertAt(newrow, dt.Rows.Count);
            dataGridView1.DataSource = dt;
            dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
            dataGridView1.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
            dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            //dataGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
            dataGridView1.AllowUserToDeleteRows = false;
            dataGridView1.AllowUserToAddRows = false;
            dataGridView1.RowHeadersVisible = false;
            dataGridView1.BackgroundColor = SystemColors.ControlLightLight;
            dataGridView1.BorderStyle = BorderStyle.None;
            dataGridView1.DataBindingComplete += dataGridView1_DataBindingComplete;
            dataGridView1.CellDoubleClick += dataGridView1_CellDoubleClick;
            dataGridView1.CellValueChanged += dataGridView1_CellValueChanged;
            dataGridView1.Width = flowLayoutPanel1.Width - 30;
            dataGridView1.Name = Convert.ToString(id);


            if (InvokeRequired)
            {
                Action a = () =>
                {
                    
                    flowLayoutPanel1.Controls.Add(dataGridView1);
                    dataGridView1.Columns[dataGridView1.Columns.Count-1].Visible = false;
                    lblmatch.Text = "Match Name: "+Convert.ToString(ds.Tables[1].Rows[0]["matchname"]);
                    lblmatch.Name = couponid;
                    lbldate.Text = "Match Date: "+ds.Tables[1].Rows[0]["MatchDate"].ToString();
                    lbldate.Name = Convert.ToString(matchid);
                    lblcouponname.Text = "Coupon Name: "+Helper.CouponName(couponid);
                    PricePercent(dataGridView1);

                    for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                    {
                        selections.Add(new Market() { bestbet = Convert.ToString(dataGridView1.Rows[i].Cells[0].Value), beton = Convert.ToString(dataGridView1.Rows[i].Cells[1].Value) });
                    }
                    // Ensure that all UI updates are done on the main thread
                    //lblmatch.Text = ds.Tables[1].Rows[0]["matchname"].ToString();
                    //txtmatchdate.Text = ds.Tables[1].Rows[0]["MatchDate"].ToString();
                    //lblmktpriced.Text = "Markets Priced: " + ds.Tables[1].Rows[0]["MarketPriced"].ToString();
                    //lblmktavail.Text = "Markets Available: " + ds.Tables[1].Rows[0]["MarketAvail"].ToString();
                    foreach (DataGridViewColumn column in dataGridView1.Columns)
                    {

                        column.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;

                    }
                   
                    countthread++;
                    if (countthread.Equals(count))
                    {
                        //dataGridView1.Rows[1].EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
                        crawlcheck.SetProgress(false);
                        crawlcheck.IsCouponProcessRunning = false;
                    }
                };
                BeginInvoke(a);
            }

        }
コード例 #2
0
        //public void FillData(string url, long id, long matchid, string bookies, int count,string couponid)
        //{
        //    OddsCheckerCrawler crawlcheck = MdiParent as OddsCheckerCrawler;
        //    //if (InvokeRequired)
        //    //{
        //    //    Action b = () =>
        //    //    {
        //    //        crawlcheck.IsProcessRunning = true;
        //    //        crawlcheck.SetProgress(true);

        //    //    };
        //    //    BeginInvoke(b);
        //    //}
        //    GenerateCoupon coupon = new GenerateCoupon();
        //    //string msg = crawl.DeleteMarketOdds(id);
        //    //crawl.CrawlMarkets(url, id, matchid);

        //    DataGridView dataGridView1 = new DataGridView();
        //    //DataSet ds = coupon.GetCouponMarket(url, id, matchid, bookies, couponid);
        //    DataSet ds = coupon.GetCouponMarket(id, matchid,couponid);
        //    dataGridView1.DataSource =ds.Tables[0];
        //    //dataGridView1.DataSource = crawl.GetMarketOdds(id, bookies);
        //    dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
        //    dataGridView1.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
        //    dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
        //    //dataGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
        //    dataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
        //    dataGridView1.AllowUserToDeleteRows = false;

        //    dataGridView1.RowHeadersVisible = false;

        //    dataGridView1.CellDoubleClick += dataGridView1_CellDoubleClick;

        //    dataGridView1.Width = flowLayoutPanel1.Width - 30;
        //    dataGridView1.Name = Convert.ToString(id);


        //    if (InvokeRequired)
        //    {
        //        Action a = () =>
        //        {
        //            flowLayoutPanel1.Controls.Add(dataGridView1);
        //            // Ensure that all UI updates are done on the main thread
        //            lblmatchnotset.Text = ds.Tables[1].Rows[0]["matchname"].ToString();
        //            txtmatchdate.Text = ds.Tables[1].Rows[0]["MatchDate"].ToString();
        //            lblmktpriced.Text = "Markets Priced: "+ds.Tables[1].Rows[0]["MarketPriced"].ToString();
        //            lblmktavail.Text = "Markets Available: "+ds.Tables[1].Rows[0]["MarketAvail"].ToString();
        //            foreach (DataGridViewColumn column in dataGridView1.Columns)
        //            {

        //                column.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;

        //            }
        //            int sum = dgvHeight(dataGridView1);
        //            dataGridView1.Height = sum;
        //            dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
        //            countthread++;
        //            if (countthread.Equals(count))
        //            {
        //                //dataGridView1.Rows[1].EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
        //                crawlcheck.SetProgress(false);
        //                crawlcheck.IsCouponProcessRunning = false;
        //            }
        //        };
        //        BeginInvoke(a);
        //    }
        //}

        public void FillData(string url,long id, long matchid, string couponid,int count)
        {
            OddsCheckerCrawler crawlcheck = MdiParent as OddsCheckerCrawler;
            try
            {
                GenerateCoupon coupon = new GenerateCoupon();
                //string msg = crawl.DeleteMarketOdds(id);
                //crawl.CrawlMarkets(url, id, matchid);

                DataGridView dataGridView1 = new DataGridView();

                //DataSet ds = coupon.GetCouponMarket(url, id, matchid, bookies, couponid);
                DataSet ds = coupon.GetCouponMarket(id, matchid, couponid);
                DataTable dt = ds.Tables[0];
                DataRow newrow = dt.NewRow();
                dt.Rows.InsertAt(newrow, dt.Rows.Count);
                dataGridView1.DataSource = dt;
                //dataGridView1.DataSource = crawl.GetMarketOdds(id, bookies);
                dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
                dataGridView1.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
                //dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
                //dataGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
                //dataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                dataGridView1.AllowUserToDeleteRows = false;
                dataGridView1.BackgroundColor = SystemColors.ControlLightLight;
                dataGridView1.AllowUserToAddRows = false;
                //dataGridView1.ReadOnly = true;
                dataGridView1.RowHeadersVisible = false;
                dataGridView1.CellBeginEdit += dataGridView1_CellBeginEdit;
                //dataGridView1.CellClick += dataGridView1_CellClick;
                //dataGridView1.CellDoubleClick += dataGridView1_CellDoubleClick;

                dataGridView1.Width = flowLayoutPanel1.Width - 30;
                dataGridView1.Name = url + "," + Convert.ToString(id) + "," + Convert.ToString(matchid) + "," + Convert.ToString(couponid);

              
                if (InvokeRequired)
                {
                    Action a = () =>
                    {
                        flowLayoutPanel1.Controls.Add(dataGridView1);
                        // Ensure that all UI updates are done on the main thread
                        dataGridView1.Columns[2].Visible = false;
                        dataGridView1.Columns[3].Visible = false;

                        lblmatchnotset.Text = ds.Tables[1].Rows[0]["matchname"].ToString();
                        lblmatchnotset.Name = Convert.ToString(couponid);
                        txtmatchdate.Text = ds.Tables[1].Rows[0]["MatchDate"].ToString()+" "+ds.Tables[1].Rows[0]["Time"].ToString();;
                        txtmatchdate.Name = Convert.ToString(matchid);
                        lblmktpriced.Text = "Markets Priced: " + ds.Tables[1].Rows[0]["MarketPriced"].ToString();
                        lblmktavail.Text = "Markets Available: " + ds.Tables[1].Rows[0]["MarketAvail"].ToString();
                        DataGridViewComboBoxColumn column1 = new DataGridViewComboBoxColumn();
                        column1.HeaderText = "Results";
                        column1.FlatStyle = FlatStyle.Flat;
                        
                        column1.Items.Add("Not Settled");
                        column1.Items.Add("Winner");
                        column1.Items.Add("Beaten");
                       

                        dataGridView1.Columns.Add((column1));
                        
                        PricePercent(dataGridView1);

                        foreach (DataGridViewColumn column in dataGridView1.Columns)
                        {
                            column.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
                        }

                        for (int i = 0; i < dataGridView1.Rows.Count; i++)
                        {
                            if (i < dataGridView1.Rows.Count - 1)
                            {
                                DataGridViewComboBoxCell cell = dataGridView1.Rows[i].Cells[dataGridView1.Columns.Count - 1] as DataGridViewComboBoxCell;
                                cell.Value = dataGridView1.Rows[i].Cells[2].Value;
                            }
                            else
                                if (i == dataGridView1.Rows.Count - 1)
                                {
                                    DataGridViewCell newCell = new DataGridViewTextBoxCell();
                                    dataGridView1[dataGridView1.Columns.Count - 1, i] = newCell;
                                }
                        }
                        int sum = dgvHeight(dataGridView1);
                        dataGridView1.Height = sum;

                        //dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                        countthread++;
                        if (countthread.Equals(count))
                        {
                            //dataGridView1.Rows[1].EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
                            crawlcheck.SetProgress(false);
                            crawlcheck.IsCouponProcessRunning = false;
                        }
                    };
                    BeginInvoke(a);
                }
            }
            catch (Exception ex)
            {
                if (InvokeRequired)
                {
                    Action b = () =>
                    {
                        crawlcheck.SetProgress(false);
                        crawlcheck.IsCouponProcessRunning = false;
                    }; BeginInvoke(b);
                }
            }
        }