private void BtnUpdate_Click(object sender, EventArgs e) { try { if (txtCategory.Text == String.Empty) { WarningIndicator.Visible = true; txtCategory.Focus(); return; } if (MessageBox.Show("Are you sure you want to update this Category?", "Updating Category", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { cn.Open(); cm = new SqlCommand("UPDATE tblCategory Set category = @category, lastupdate = @date WHERE cid like '" + lblID.Text + "'", cn); cm.Parameters.AddWithValue("@category", txtCategory.Text); cm.Parameters.AddWithValue("@date", DateTime.Now); cm.ExecuteNonQuery(); cn.Close(); MessageBox.Show("Category Information has been successfully updated.", "Category Updated", MessageBoxButtons.OK, MessageBoxIcon.Information); flist.ShowCategories(); this.Dispose(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void BtnCategory_Click(object sender, EventArgs e) { if (!AdminAdministrator.Instance.PnlContainer.Controls.ContainsKey("AdminCategory")) { AdminCategory cat = new AdminCategory(); cat.Dock = DockStyle.Fill; AdminAdministrator.Instance.PnlContainer.Controls.Add(cat); cat.ShowCategories(); } AdminAdministrator.Instance.PnlContainer.Controls["AdminCategory"].BringToFront(); AdminAdministrator.Instance.BackButton.Visible = true; }