Ejemplo n.º 1
0
    protected async void btnUpdate_Click(object sender, EventArgs e)
    {
        serviceDAO service = new serviceDAO();
        try
        {
            if (btnUpdate.Text == "Add")
            {
                Category category = new Category();
                category.Name = txtCategory.Text;
                service.AddCategory(category);

                await loadCategories(service, 0, 0);
                txtCategory.Text = string.Empty;
            }
            else
            {
                List<Category> category = await service.GetCategory(Convert.ToInt32(lblIDHidden.Text));
                category[0].Name = txtCategory.Text;
                service.UpdateCategory(category[0]);

                await loadCategories(service, 0, 0);
                txtCategory.Text = string.Empty;
                btnUpdate.Text = "Add";
            }
        }
        catch (Exception Ex)
        {
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), Guid.NewGuid().ToString(), "alert('An error has ocurred, please contact with your software provider');", true);
        }
    }