Ejemplo n.º 1
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            string categoryName = txtCategory.Text.Trim();

            if (string.IsNullOrEmpty(categoryName))
            {
                txtCategoryValidator.ErrorMessage = "Category cannot be blank";
                return;
            }

            CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();

            int categoryMatches = (int)categoryAdapter.ValidateCategoryName(categoryName);

            if (categoryMatches != 0)
            {
                ErrorMessage = "There's already a category created with that name";
                return;
            }

            categoryAdapter.Insert(StationId, null, categoryName, -1);

            InfoMessage = "Category created";

            Response.Redirect("~/admin/CategoryList.aspx");
        }