private void btnAdd_Click(object sender, EventArgs e) { if (txtCat.Text.Trim() == "") { MessageBox.Show("Category required"); return; } cCategory cat = new cCategory(0, txtCat.Text, dtpDtAdd.Value.ToString()); if (cat.checkCategory()) { MessageBox.Show("This category already exits!"); return; } if (cat.SaveRecord()) { MessageBox.Show("Saved"); txtCat.Clear(); txtCat.Focus(); } }
private void btnSave_Click(object sender, EventArgs e) { if (txtCat.Text.Trim() == "") { MessageBox.Show("Select a category"); return; } cCategory cat = new cCategory(); cat.CategoryID = Convert.ToUInt32(dgvCat["CategoryID", dgvCat.CurrentCell.RowIndex].Value); cat.Category = txtCat.Text; cat.DateAdded = dtpDtAdd.Value.ToString(); if (cat.checkCategory()) { MessageBox.Show("This category already exists!"); return; } if (cat.SaveRecord()) { MessageBox.Show("Saved"); txtCat.Clear(); } LoadCategories(); }