Exemplo n.º 1
0
        protected void btnSaveCategory_OnClick(object sender, EventArgs e)
        {
            var catDS = new SysParameterDataSet();

            catDS.SysParameter.AddSysParameterRow(Utilities.editId, txtName.Text, txtDescription.InnerText,
                                                  chkActive.Checked);

            if (Utilities.editId != -1)
            {
                int result = dataProvider.UpdateCategory(userToken, catDS, bool.Parse(cbTypes.SelectedValue));

                if (result != -1)
                {
                    Utilities.editId = -1;
                    btnCloseModal_OnClick(sender, e);
                    SetToast("success", "Category updated succesfully.");
                }
                else
                {
                    SetToast("error", "A category with that name exists already.");
                }
            }
            else
            {
                if (!Utilities.CheckGridForText(dgvCategories, txtName.Text))
                {
                    int result = dataProvider.AddCategory(userToken, catDS, bool.Parse(cbTypes.SelectedValue));

                    if (result != -1)
                    {
                        Utilities.editId = -1;
                        btnCloseModal_OnClick(sender, e);
                        SetToast("success", "Category created succesfully.");
                    }
                    else
                    {
                        SetToast("error", "An error occured, try again.");
                    }
                }
                else
                {
                    SetToast("info", "Category exists already");
                }
            }

            DisplayCategoriesInGrid();
        }
Exemplo n.º 2
0
        private void login_Click(object sender, RoutedEventArgs e)
        {
            // Get info
            string categoryName = Category_Name.Text;
            string categoryID   = Category_ID.Text;

            bool res = DataProvider.AddCategory(categoryID, categoryName);

            if (res)
            {
                MessageBox.Show("Add 1 category successfully!");
            }
            else
            {
                MessageBox.Show("Something went wrong!");
            }
        }