private void btnAdd_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Do you wish to Continue?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); r = new Conf.Rgx(); if (dr == System.Windows.Forms.DialogResult.Yes) { try { if (Regex.IsMatch(txtBoxAmount.Text, r.Amount())) { dataGridView1.Rows.Add(txtBoxCardNo.Text, Convert.ToDouble(txtBoxAmount.Text), txtBoxHolder.Text, Convert.ToDateTime(dateTimePicker1.Text).ToString("M/dd/yyy")); // gift = new VO.GiftCardVO(); gift.Gc_cardno = txtBoxCardNo.Text; gift.Gc_amount = Convert.ToDouble(txtBoxAmount.Text); gift.Gc_holder = txtBoxHolder.Text; gift.Gc_validuntil = Convert.ToDateTime(dateTimePicker1.Text); gift.AddGC(); //Event txtBoxHolder.Clear(); txtBoxAmount.Clear(); txtBoxCardNo.Clear(); txtBoxCardNo.Focus(); } else { MessageBox.Show("Please Enter the Amount Properly", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception) { MessageBox.Show("Please Check Database Server!", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }