private void btnSave_Click(object sender, EventArgs e) { int er = 0; if (txtName.Text == "") { er++; ep.SetError(txtName, "Required"); } if (txtDescription.Text == "") { er++; ep.SetError(txtDescription, "Required"); } if (txtCurrentNumber.Text == "") { er++; ep.SetError(txtCurrentNumber, "Required"); } if (txtPrefix.Text == "") { er++; ep.SetError(txtPrefix, "Required"); } if (txtPostfix.Text == "") { er++; ep.SetError(txtPostfix, "Required"); } if (er > 0) { return; } DAL.Voucher voucher = new DAL.Voucher(); voucher.Name = txtName.Text; voucher.Description = txtDescription.Text; voucher.AutoNumber = chkAutoNumber.Checked; voucher.CurrentNumber = Convert.ToInt32(txtCurrentNumber.Text); voucher.Prefix = txtPrefix.Text; voucher.Postfix = txtPostfix.Text; voucher.Length = Convert.ToInt32(txtLength.Text); voucher.AutoPrint = chkAutoPrint.Checked; if (voucher.Insert()) { MessageBox.Show("Data Saved"); MyControls.Helper.clear(this); txtName.Focus(); } else { MessageBox.Show(voucher.Error); } }
private void Form1_Load(object sender, EventArgs e) { DAL.Voucher vcr = new DAL.Voucher(); DataTable dt = vcr.Select().Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { ToolStripMenuItem mnu = new ToolStripMenuItem(); mnu.Text = dt.Rows[i].ItemArray[1].ToString(); mnu.Tag = dt.Rows[i].ItemArray[0].ToString(); mnu.Click += Mnu_Click; mnuVoucher.DropDownItems.Add(mnu); } }
private void btnSearch_Click(object sender, EventArgs e) { DAL.Voucher voucher = new DAL.Voucher(); dgvVoucher.DataSource = voucher.Select().Tables[0]; }