private void btnDelete_Click(object sender, EventArgs e) { gift = new VO.GiftCardVO(); DialogResult dr = MessageBox.Show("Do you wish to Continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == System.Windows.Forms.DialogResult.Yes) { try { foreach (DataGridViewCell oneCell in dataGridView1.SelectedCells) { if (oneCell.Selected) { gift.Gc_cardno = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); gift.DeleteGC(); dataGridView1.Rows.RemoveAt(oneCell.RowIndex); btnDelete.Enabled = false; } } } catch (Exception) { MessageBox.Show("Please Check Database Server!", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void frmGiftCard_Load(object sender, EventArgs e) { b.Alignment = AlignmentPositions.CENTER; b.Width = 313; b.Height = 57; TYPE t = TYPE.CODE39; b.IncludeLabel = true; b.LabelPosition = LabelPositions.BOTTOMCENTER; barcode.Image = b.Encode(t, "0"); txtBoxCardNo.Focus(); // gift = new VO.GiftCardVO(); String[,] grabData = gift.ReadGC(); try { dataGridView1.Rows.Clear(); for (int x = 0; x < grabData.GetLength(1); x++) { dataGridView1.Rows.Add(grabData[0, x].ToString(), Convert.ToDouble(grabData[1, x]), grabData[2, x].ToString(), Convert.ToDateTime(grabData[3, x])); } } catch (Exception) { } }
private void txtBoxGCode_KeyDown(object sender, KeyEventArgs e) { gc = new VO.GiftCardVO(); try { if (e.KeyCode == Keys.Enter) { gc.Gc_cardno = txtBoxGCode.Text; if (gc.checkExpiry() == false) { gc.askAmount(); if (getAmount <= gc.askAmount()) { if (gc.askAmount() == 0) { lblNotif.Text = "Gift Card Has Been Consumed/Not Found"; btnProceed.Visible = false; } else { getGCamt = gc.askAmount(); lblNotif.Text = "P " + gc.askAmount().ToString("#,###,##0.00") + " Available Balance."; btnProceed.Visible = true; btnProceed.Focus(); } } else { lblNotif.Text = "P " + gc.askAmount().ToString("#,###,##0.00") + " Available in your Gift Card"; } } else { lblNotif.Text = "Gift Card Number is Expired!"; } } } catch (Exception) { lblNotif.Text = "Check Database Server!"; } }
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); } } }