private void SaveButton_Click(object sender, EventArgs e) { try { if (MessageBox.Show("Save this category?", "Saving Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ; } { cn.Open(); cm = new SqlCommand("INSERT into CategoryTable(category) VALUES (@category)", cn); cm.Parameters.AddWithValue("@category", CategoryTextBox.Text); cm.ExecuteNonQuery(); cn.Close(); MessageBox.Show("Done!"); Clear(); listForm.LoadCategory(); } } catch (Exception ex) { cn.Close(); MessageBox.Show(ex.Message); } }
private void CategoryButton_Click(object sender, EventArgs e) { CategoryListForm clf = new CategoryListForm(); clf.TopLevel = false; panel3.Controls.Add(clf); clf.BringToFront(); clf.LoadCategory(); clf.Show(); }