예제 #1
0
        public void LoadTree(bool IsArchived)
        {
            treeView1.Nodes.Clear();
            GenerateCoupon coupon = new GenerateCoupon();
            DataSet ds = coupon.GetCoupons(IsArchived);
            ds.Relations.Add("Sport_Coupon", ds.Tables[0].Columns["sportid"], ds.Tables[1].Columns["sportid"]);
            ds.Relations.Add("Coupon_Date", ds.Tables[1].Columns["couponid"], ds.Tables[2].Columns["couponid"]);
            //ds.Relations.Add("Date_Match", ds.Tables[1].Columns["couponid"], ds.Tables[2].Columns["couponid"]);
            //ds.Relations.Add("Match_Market", ds.Tables[2].Columns["couponid"], ds.Tables[3].Columns["couponid"]);
            //ds.Relations.Add("Match_Date", ds.Tables[0].Columns["MatchDate"], ds.Tables[1].Columns["MatchDate"]);
            
            foreach (DataRow drSport in ds.Tables[0].Rows)
            {
                TreeNode tn_group = new TreeNode(Convert.ToString(drSport["SportName"]));
                tn_group.Name = Convert.ToString(drSport["sportid"]);
                treeView1.Nodes.Add(tn_group);
                foreach (DataRow dr in drSport.GetChildRows("Sport_Coupon"))
                {
                    TreeNode tn_coupon = new TreeNode(dr["couponname"].ToString());
                    string couponid = dr["couponid"].ToString();
                    tn_coupon.Name = couponid;
                    tn_coupon.ContextMenuStrip = CouponMenuStrip;
                    tn_group.Nodes.Add(tn_coupon);
                    foreach (DataRow dr1 in dr.GetChildRows("Coupon_Date"))
                    {
                        string matchdate = dr1["MatchDate"].ToString();
                        TreeNode tn_date = new TreeNode(matchdate);
                        tn_coupon.Nodes.Add(tn_date);

                        string sql = "(couponid='" + couponid + "') AND (MatchDate='" + matchdate + "')";
                        foreach (DataRow drChild in ds.Tables[3].Select(sql))
                        {

                            string matchid = drChild["matchid"].ToString();
                            TreeNode tn_match = new TreeNode(drChild["Home"].ToString() + " V " + drChild["Away"].ToString());
                            tn_date.Nodes.Add(tn_match);
                            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();
                                tn_match.Nodes.Add(tn_market);

                            }

                        }


                    }

                }
            }
           // treeView1.Nodes.Add(tn_group);
        }
예제 #2
0
 private void LoadComboBox()
 {
     GenerateCoupon coupon = new GenerateCoupon();
     int sportid = Convert.ToInt32(sport.Substring(1));
     comboCoupon.DataSource = coupon.GetLatestCoupons(sportid).Tables[0];
     
     comboCoupon.ValueMember = "couponid";
     comboCoupon.DisplayMember = "couponname";
     comboCoupon.SelectedIndex = -1;
     //comboCoupon.Refresh();
 }
예제 #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);
        }
예제 #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);
        }
예제 #5
0
 private void btnsave_Click(object sender, EventArgs e)
 {
     GenerateCoupon coupon = new GenerateCoupon();
     CrawlFirstPage crawl = new CrawlFirstPage();
     try
     {
         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++)
                     {
                         long id = Convert.ToInt64(grid.Rows[i].Cells[3].Value);
                         DataGridViewComboBoxCell cell = grid.Rows[i].Cells[4] as DataGridViewComboBoxCell;
                         string result = Convert.ToString(cell.Value);
                         coupon.UpdateCoupon(id, result);
                     }
                 }
             }
             MessageBox.Show("Coupon updated successfully");
             flowLayoutPanel1.Refresh();
         }
         else
         {
             MessageBox.Show("Data not available!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("An error occured while saving changes");
     }
 }
예제 #6
0
        public void AddToCoupon(string couponid)
        {
            GenerateCoupon coupon = new GenerateCoupon();
            OddsCheckerCrawler parent = MdiParent as OddsCheckerCrawler;
            try
            {


                List<Coupon> couponlist = new List<Coupon>();
                String msg = String.Empty;
                if (flowLayoutPanel1.Controls.Count > 0)
                {
                    DataTable dt = coupon.GetMatchesByCouponId(couponid).Tables[0];
                    if (lblsportid.Text.Equals(Convert.ToString(dt.Rows[0]["sportid"])))
                    {
                        foreach (Control ctrl in flowLayoutPanel1.Controls)
                        {
                            if (ctrl.GetType().Equals(typeof(GroupBox)))
                            {
                                GroupBox grpBox = ctrl as GroupBox;

                                //string test = grpBox.Name;

                                DataRow[] rows = dt.Select("(id = " + grpBox.Name + ")");
                                if (rows.Length <= 0)
                                {
                                    foreach (Control ctrl1 in grpBox.Controls)
                                    {
                                        if (ctrl1.GetType().Equals(typeof(FlowLayoutPanel)))
                                        {
                                            FlowLayoutPanel panel = ctrl1 as FlowLayoutPanel;
                                            //DataTable dt = coupon.GetMatchesByCouponId(couponid).Tables[0];
                                            //string test = panel.Name;
                                            //DataRow[] rows = dt.Select("(id = " + panel.Name + ")");
                                            //if (ctrl.GetType().Equals(typeof(DataGridView)))
                                            //if (rows.Length <= 0)
                                            //{
                                            foreach (Control ctrl2 in panel.Controls)
                                            {
                                                //string uniqueid = Guid.NewGuid().ToString().Substring(0, 5);
                                                DataGridView grid = (ctrl2 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++)
                                                {

                                                    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 });
                                                    //}
                                                }
                                            }


                                        }
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("Cannot add " + rows[0]["Name"].ToString() + ". It alredy exists in selected coupon.");
                                }
                            }
                        }

                        if (InvokeRequired)
                        {
                            Action a = () =>
                            {
                                parent.IsProcessRunning = false;
                                parent.SetProgress(false);
                                msg = coupon.AddCouponMatches(couponlist, couponid);
                                MessageBox.Show(msg);
                            }; BeginInvoke(a);
                        }
                    }

                    else
                    {
                        
                        if (InvokeRequired)
                        {
                            Action a = () =>
                            {
                                parent.IsProcessRunning = false;
                                parent.SetProgress(false);
                                MessageBox.Show("Sorry! this coupon belongs to a different sport");
                               
                            }; BeginInvoke(a);
                        }
                    }

                   
                }
                else
                {
                    MessageBox.Show("No available markets found!");
                }
            }

            catch (Exception ex)
            {
                if (InvokeRequired)
                {
                    Action b = () =>
                    {
                        parent.IsProcessRunning = false;
                        parent.SetProgress(false);
                        MessageBox.Show("An error occured while updating this coupon");
                    }; BeginInvoke(b);
                }
            }
        }
예제 #7
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);
     }
 }
예제 #8
0
 public static string CouponName(string couponid)
 {
     GenerateCoupon coupon = new GenerateCoupon();
     return Convert.ToString(coupon.GetCouponInfo(couponid).Rows[0]["couponname"]);
 }
예제 #9
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";
             }
 }
예제 #10
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);
            }

        }
예제 #11
0
        public void CreateXMLFile()
        {

            if (treeView1.SelectedNodes.Count.Equals(1))
            {
                foreach (TreeNode node in treeView1.SelectedNodes)
                {
                    if (node.Level == 1)
                    {

                        SaveFileDialog saveFileDialog = new SaveFileDialog();
                        saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                        saveFileDialog.Filter = "XML Files (*.xml)|*.xml";
                        if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                        {
                            string FileName = saveFileDialog.FileName;
                            string couponid = "";

                            couponid = node.Name;

                            //string[] info = node.Split(',');
                            GenerateCoupon coupon = new GenerateCoupon();
                            DataSet ds = coupon.GetCoupons(couponid);
                            GenerateXMLforOdds(FileName, ds);
                            MessageBox.Show("File saved successfully");
                        }
                        // string node = treeView1.SelectedNode.Name;
                        ////string[] info = node.Split(',');
                        // GenerateCoupon coupon = new GenerateCoupon();
                        // DataSet ds = coupon.GetCoupons(Convert.ToInt64(node));
                        // GenerateXMLforOdds(ds);
                    }
                    else
                    {
                        MessageBox.Show("Please select a coupon to generate XML");
                    }
                }
            }

            else
            {
                MessageBox.Show("Please select one coupon to generate XML");
            }
        }
예제 #12
0
        public void SaveCoupon(string couponname)
        {
           
            OddsCheckerCrawler parent = MdiParent as OddsCheckerCrawler;
            try
            {
                    List<Coupon> couponlist = new List<Coupon>();
                    String msg = String.Empty;
                    if (flowLayoutPanel1.Controls.Count > 0)
                    {
                        int count = flowLayoutPanel1.Controls.Count;
                        Task[] tasks = new Task[count];
                        foreach (Control ctrl in flowLayoutPanel1.Controls)
                        {
                             tasks[ctrl.TabIndex] = Task.Factory.StartNew(() =>
                            {
                            if (ctrl.GetType().Equals(typeof(GroupBox)))
                            {
                                GroupBox grpBox = ctrl as GroupBox;

                                foreach (Control ctrl1 in grpBox.Controls)
                                {
                                    if (ctrl1.GetType().Equals(typeof(FlowLayoutPanel)))
                                    {
                                        FlowLayoutPanel panel = ctrl1 as FlowLayoutPanel;
                                        //DataTable dt = coupon.GetMatchesByCouponId(couponid).Tables[0];
                                        //string test = panel.Name;
                                        //DataRow[] rows = dt.Select("(id = " + panel.Name + ")");
                                        //if (ctrl.GetType().Equals(typeof(DataGridView)))
                                        //if (rows.Length <= 0)
                                        //{
                                        foreach (Control ctrl2 in panel.Controls)
                                        {

                                            if (ctrl2.GetType().Equals(typeof(DataGridView)))
                                            {
                                                //string uniqueid = Guid.NewGuid().ToString().Substring(0, 5);
                                                DataGridView grid = (ctrl2 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++)
                                                {
                                                    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 });
                                                    couponmarkets++;
                                                }
                                            }
                                        }
                                    }
                                  }
                                }
                            }, TaskCreationOptions.LongRunning);
                        }
                        Task.WaitAll(tasks);
                       
                            if (InvokeRequired)
                            {
                                Action a = () =>
                                {
                                    parent.IsProcessRunning = false;
                                    parent.SetProgress(false);
                                    string couponid = Guid.NewGuid().ToString().Substring(0, 5);
                                    GenerateCoupon coupon = new GenerateCoupon();
                                    while (coupon.IsCouponIdExist(couponid))
                                    {
                                        couponid = Guid.NewGuid().ToString().Substring(0, 5);
                                    }
                                    msg = coupon.InsertCoupon(couponlist, couponname,couponid);
                                    MessageBox.Show(msg);
                                }; BeginInvoke(a);
                            }
                    }
                    else
                    {
                        Action c = () =>
                        {
                            parent.IsProcessRunning = false;
                            parent.SetProgress(false);
                        }; BeginInvoke(c);
                        MessageBox.Show("No available markets found!");
                    }
                }
              
            
            
            catch (Exception ex)
            {
                if (InvokeRequired)
                {
                    Action b = () =>
                    {
                        parent.IsProcessRunning = false;
                        parent.SetProgress(false);
                        MessageBox.Show("An error occured while saving this coupon");
                    }; BeginInvoke(b);
                }
            }




        }
예제 #13
0
        private void button1_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;

            if (treeView1.SelectedNodes.Count.Equals(1))
            {
                foreach (TreeNode node in treeView1.SelectedNodes)
                {
                    if (node.Level == 1)
                    {
                        TreeNode mynode = new TreeNode();
                        mynode = node;
                        while (mynode.Parent != null)
                        {
                            mynode = mynode.Parent;
                        }
                        SaveFileDialog saveFileDialog = new SaveFileDialog();
                        saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                        saveFileDialog.Filter = "XML Files (*.xml)|*.xml";
                        if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                        {
                            string FileName = saveFileDialog.FileName;
                            string couponid = "";
                            string sportname = mynode.Text;
                            string sportid = mynode.Name;
                            couponid = node.Name;
                            DataSet ds;
                            //string[] info = node.Split(',');
                            GenerateCoupon coupon = new GenerateCoupon();
                            if(btn.Name.Equals("btnxmlall"))
                            {
                               ds = coupon.GetCoupons(couponid);
                            }
                            else
                            {
                                ds = coupon.GetUpdatedCouponInfo(couponid);
                            }
                            Helper.GenerateXMLforOdds(FileName, ds,sportname,sportid);
                            MessageBox.Show("File saved successfully");
                        }
                        // string node = treeView1.SelectedNode.Name;
                        ////string[] info = node.Split(',');
                        // GenerateCoupon coupon = new GenerateCoupon();
                        // DataSet ds = coupon.GetCoupons(Convert.ToInt64(node));
                        // GenerateXMLforOdds(ds);
                    }
                    else
                    {
                        MessageBox.Show("Please select a coupon to generate XML");
                    }
                }
            }
        }
예제 #14
0
 private void btnaddmarket_Click(object sender, EventArgs e)
 {
     if (flowLayoutPanel1.Controls.Count > 0)
     {
         long matchid = Convert.ToInt64(txtmatchdate.Name);
         string couponid = lblmatchnotset.Name;
         GenerateCoupon coupon = new GenerateCoupon();
         DataSet ds = coupon.GetAvailableMarkets(matchid, couponid);
         if (ds.Tables[0].Rows.Count > 0)
         {
             Form childForm = new AddMarket(matchid, couponid);
             childForm.MdiParent = this.MdiParent;
             //childForm.Text = "Window " + childFormNumber++;
             childForm.Show();
         }
         else
         {
             MessageBox.Show("All markets are priced");
         }
     }
     else
     {
         MessageBox.Show("Data not available!");
     }
 }
예제 #15
0
        private void btnxml_Click(object sender, EventArgs e)
        {
             if (treeView1.SelectedNodes.Count.Equals(1))
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                saveFileDialog.Filter = "XML Files (*.xml)|*.xml";
                if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    string FileName = saveFileDialog.FileName;
                    string couponid="";
                    foreach (TreeNode node in treeView1.SelectedNodes)
                    {
                        couponid = node.Name;
                    }
                    //string[] info = node.Split(',');
                    GenerateCoupon coupon = new GenerateCoupon();
                    DataSet ds = coupon.GetCoupons(couponid);
                    GenerateXMLforOdds(FileName,ds);
                    MessageBox.Show("File saved successfully");
                }
                // string node = treeView1.SelectedNode.Name;
                ////string[] info = node.Split(',');
                // GenerateCoupon coupon = new GenerateCoupon();
                // DataSet ds = coupon.GetCoupons(Convert.ToInt64(node));
                // GenerateXMLforOdds(ds);
            }



        }
예제 #16
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);
     }
 }
예제 #17
0
 private void btnUpdate_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.CID = Convert.ToInt32(comboCoupon.SelectedValue);
         cup.CouponID = couponid;
         cup.IsArchived = false;
         clsCpn = new GenerateCoupon();
         clsCpn.UpdateCoupon(cup);
         MessageBox.Show("Coupon Updated successfully.");
         RefreshCoupon(Convert.ToInt32(sport));
     }
 }
예제 #18
0
        private void button1_Click(object sender, EventArgs e)
        {
            OddsCheckerCrawler parent = this.MdiParent as OddsCheckerCrawler;
            try
            {
                GenerateCoupon coupon = new GenerateCoupon();
                if (!string.IsNullOrEmpty(txtcouponname.Text))
                {
                    if (!coupon.IsCouponExist(txtcouponname.Text))
                    {
                        

                        if (parent.IsProcessRunning)
                        {
                            MessageBox.Show("Please wait while selected markets are being processed");
                            return;
                        }

                        parent.IsProcessRunning = true;
                        parent.SetProgress(true);
                        Task taskB = Task.Factory.StartNew(() =>
                               {
                                   SaveCoupon(txtcouponname.Text);
                                   if (InvokeRequired)
                                   {
                                       Action loadCombo = () =>
                                           {
                                               LoadComboBox();
                                           };
                                       BeginInvoke(loadCombo);
                                   }
                               });
                    }
                    else
                    {
                        MessageBox.Show("Coupon name already exist!");
                    }
                }
                else
                {
                    MessageBox.Show("Please enter a coupon name");
                }
            }
            catch (Exception ex)
            {
                parent.IsProcessRunning = false;
                parent.SetProgress(false);
                MessageBox.Show("An error occured while saving this coupon");
            }
        }
예제 #19
0
 private void addToToolStripMenuItem_Click(object sender, EventArgs e)
 {
    
         GenerateCoupon coupon = new GenerateCoupon();
         string msg = coupon.AddToArchive(couponid);
         LoadTree(Is_Archived);
         MessageBox.Show(msg);
     
 }
예제 #20
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");
     }
 }
예제 #21
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);
                }
            }
        }
예제 #22
0
        public static string CouponName(string couponid)
        {
            GenerateCoupon coupon = new GenerateCoupon();

            return(Convert.ToString(coupon.GetCouponInfo(couponid).Rows[0]["couponname"]));
        }
예제 #23
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));
     }
 }