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