private int AddSubCategory() { int ret = 0; Cursor.Current = Cursors.WaitCursor; ProductSubcategory psc = new ProductSubcategory(); string subCatName = txtSubcategory.Text.Trim(); try { int categoryID = 0; try { categoryID = Int32.Parse(cmbCategories.SelectedValue.ToString()); } catch { categoryID = 0; } if (categoryID > 0) { psc.Name = subCatName; psc.ProductCategoryID = categoryID; int pscid = psc.Exists(psc.Name, psc.ProductCategoryID); if (pscid > 0) { DialogResult result = MessageBox.Show("Product Subcategory " + psc.Name + " already exists\nWould you like to update it?", "MICS", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { psc.UpdateProductSubcategory(psc); MessageBox.Show("Record updated successfully", "MICS", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Record is not saved", "MICS", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { psc.AddProductSubcategory(psc); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Product Subcategories", MessageBoxButtons.OK, MessageBoxIcon.Error); Cursor.Current = Cursors.Default; } finally { psc = null; } Cursor.Current = Cursors.Default; return(ret); }