Ejemplo n.º 1
0
        private void btnadd_Click(object sender, EventArgs e)
        {
            GenerateCoupon coupon      = new GenerateCoupon();
            List <Market>  updatedOdds = new List <Market>();

            //CrawlFirstPage crawl = new CrawlFirstPage();
            try
            {
                string text = "";
                if (flowLayoutPanel1.Controls.Count > 0)
                {
                    //if (!string.IsNullOrEmpty(txtmatchdate.Text))
                    //{
                    //    string enddatetime = String.Empty;
                    //    string[] matchdate = txtmatchdate.Text.Split(' ');
                    //    enddatetime = matchdate[1].Substring(0, 2) + " " + matchdate[2].Substring(0, 3) + " " + matchdate[3];
                    //    enddatetime = DateTime.Parse(enddatetime).ToString("yyyy-MM-dd");
                    //    crawl.UpdateMatch(Convert.ToInt64(txtmatchdate.Name),txtmatchdate.Text,enddatetime);
                    //}
                    foreach (Control ctrl in flowLayoutPanel1.Controls)
                    {
                        if (ctrl.GetType().Equals(typeof(DataGridView)))
                        {
                            DataGridView grid = ctrl as DataGridView;
                            for (int i = 0; i < grid.Rows.Count - 1; i++)
                            {
                                if (!selections[i].bestbet.Equals(grid.Rows[i].Cells[0].Value) || !selections[i].beton.Equals(grid.Rows[i].Cells[1].Value))
                                {
                                    long   id        = Convert.ToInt64(grid.Rows[i].Cells[grid.Columns.Count - 1].Value);
                                    string toal      = Convert.ToString(grid.Rows[i].Cells[0].Value);
                                    string selection = Convert.ToString(grid.Rows[i].Cells[1].Value);
                                    //coupon.UpdateCoupon(id, toal, selection);
                                    updatedOdds.Add(new Market()
                                    {
                                        id = id, bestbet = toal, beton = selection
                                    });
                                }
                            }
                        }
                    }
                    string couponid = lblmatch.Name;
                    coupon.UpdateOdds(updatedOdds, couponid);

                    MessageBox.Show("Coupon updated successfully");
                    flowLayoutPanel1.Refresh();
                }
                else
                {
                    MessageBox.Show("Data not available!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured while saving changes");
            }
        }
Ejemplo n.º 2
0
        private void RefreshCoupon(int sportid)
        {
            DataTable dt = new DataTable();

            clsCpn = new GenerateCoupon();
            dt     = clsCpn.SelectAllCoupon(sportid);

            if (dt.Rows.Count > 0)
            {
                comboCoupon.DataSource    = dt;
                comboCoupon.DisplayMember = "Couponname";
                comboCoupon.ValueMember   = "cid";
            }
        }
Ejemplo n.º 3
0
        private void LoadTreeView(long matchid, string couponid)
        {
            GenerateCoupon coupon   = new GenerateCoupon();
            DataTable      dt       = coupon.GetAvailableMarkets(matchid, couponid).Tables[0];
            TreeNode       tnmarket = new TreeNode("Available Markets");

            foreach (DataRow row in dt.Rows)
            {
                TreeNode tn_market = new TreeNode(row["bettingmarket"].ToString());
                tn_market.Name = row["id"].ToString() + "," + row["matchid"].ToString() + "," + row["bettinglink"].ToString(); // +"," + row["couponid"].ToString(); ;
                tnmarket.Nodes.Add(tn_market);
            }

            treeView1.Nodes.Add(tnmarket);
        }
Ejemplo n.º 4
0
        private void LoadTree(string couponid, long matchid)
        {
            bool           IsArchived = false;
            GenerateCoupon coupon     = new GenerateCoupon();
            DataSet        ds         = coupon.GetCoupons(IsArchived);
            TreeNode       tnupdate   = new TreeNode("Markets Priced");
            string         sql2       = "(couponid='" + couponid + "') AND (matchid=" + matchid + ")";

            foreach (DataRow drMkt in ds.Tables[4].Select(sql2))
            {
                TreeNode tn_market = new TreeNode(drMkt["bettingmarket"].ToString());
                tn_market.Name = drMkt["bettingmarketid"].ToString() + "," + drMkt["matchid"].ToString() + "," + drMkt["bettinglink"].ToString() + "," + drMkt["couponid"].ToString();
                tnupdate.Nodes.Add(tn_market);
            }
            treeView1.Nodes.Add(tnupdate);
        }
Ejemplo n.º 5
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (comboCoupon.SelectedText == "")
     {
         MessageBox.Show("Please select coupon first.");
     }
     else
     {
         Coupon2 cup = new Coupon2();
         cup.CID = Convert.ToInt32(comboCoupon.SelectedValue);
         clsCpn  = new GenerateCoupon();
         clsCpn.DeleteCoupon(cup);
         MessageBox.Show("Coupon Saved.");
         RefreshCoupon(Convert.ToInt32(sport));
     }
 }
Ejemplo n.º 6
0
        public void AddMarkets(string couponid)
        {
            List <Coupon> couponlist = new List <Coupon>();
            String        msg        = String.Empty;

            if (flowLayoutPanel1.Controls.Count > 0)
            {
                GenerateCoupon coupon = new GenerateCoupon();
                foreach (Control ctrl in flowLayoutPanel1.Controls)
                {
                    if (ctrl.GetType().Equals(typeof(DataGridView)))
                    {
                        //string uniqueid = Guid.NewGuid().ToString().Substring(0, 5);
                        DataGridView grid      = (ctrl as DataGridView);
                        long         matchid   = Convert.ToInt64(grid.Name.Split(',')[1]);
                        string       teamsname = Helper.GetMatchName(matchid);
                        //string identifier = "MH.GaaFootballAEid" + Guid.NewGuid().ToString().Substring(0, 5) + "." + teamsname;
                        for (int i = 0; i < grid.Rows.Count - 1; i++)
                        {
                            //if (string.IsNullOrEmpty(Convert.ToString(grid.Rows[i].Cells[0].Value)))
                            //{
                            //    MessageBox.Show("Please select some value for Toals column in row" + (i + 1).ToString());
                            //    return;
                            //}
                            //else
                            //{
                            int    x          = i + 1;
                            string market     = Helper.GetMarketName(Convert.ToInt64(grid.Name.Split(',')[0]));
                            string identifier = /*"MH.GaaFootballAEid" + uniqueid + "." + teamsname; */ market.Substring(0, 1) + "S" + x + "id";
                            //string market = coupon.GetMarketName(Convert.ToInt64(grid.Name.Split(',')[0]));
                            //identifier = identifier + market.Substring(0, 1) + "S" + i+1 + "id";
                            couponlist.Add(new Coupon()
                            {
                                Bettingmarketid = Convert.ToInt64(grid.Name.Split(',')[0]), Toals = Convert.ToString(grid.Rows[i].Cells[0].Value), Selection = Convert.ToString(grid.Rows[i].Cells[1].Value), Identifier = identifier
                            });
                            //}
                        }
                    }
                }
                // GenerateCoupon coupon = new GenerateCoupon();
                msg = coupon.AddMarket(couponlist, couponid);
                MessageBox.Show(msg);
            }
        }
Ejemplo n.º 7
0
        private void bindAllCoupon(int sportid)
        {
            DataTable dt = new DataTable();

            clsCpn = new GenerateCoupon();
            dt     = clsCpn.SelectAllCoupon(sportid);
            if (InvokeRequired)
            {
                Action a = () =>
                {
                    if (dt.Rows.Count > 0)
                    {
                        comboCoupon.DataSource    = dt;
                        comboCoupon.DisplayMember = "Couponname";
                        comboCoupon.ValueMember   = "cid";
                    }
                }; BeginInvoke(a);
            }
        }
Ejemplo n.º 8
0
 private void btnsave_Click(object sender, EventArgs e)
 {
     if (lblMatchName.Text == "")
     {
         MessageBox.Show("Please select match first.");
     }
     else
     {
         Coupon2 cup = new Coupon2();
         cup.CouponName = txtcouponname.Text;
         string[] match = lblMatchName.Text.ToString().Split(':');
         cup.MatchID = Convert.ToInt32(match[1].ToString());
         string couponid = Guid.NewGuid().ToString().Substring(0, 5);
         cup.CouponID   = couponid;
         cup.IsArchived = false;
         clsCpn         = new GenerateCoupon();
         clsCpn.InsertCoupon(cup);
         MessageBox.Show("Coupon Saved.");
         RefreshCoupon(Convert.ToInt32(sport));
     }
 }
Ejemplo n.º 9
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);
            }
        }