Exemplo n.º 1
0
        protected void btnSaveUser_OnClick(object sender, EventArgs e)
        {
            var    currencyDS = new CurrencyDataSet();
            string _symbol    = HttpUtility.HtmlDecode(txtSymbol.Text);

            currencyDS.Currency.AddCurrencyRow(txtName.Text, _symbol, txtISO.Text, txtUnit.Text, txtSubUnit.Text
                                               , txtUnitSingle.Text, txtSubUnitSngle.Text, chkBaseCurrency.Checked, chkActive.Checked, Utilities.editId);

            if (Utilities.editId != -1)
            {
                int result = dataProvider.UpdateCurrency(Utilities.userToken, currencyDS, orgId);

                if (result != -1)
                {
                    SetToast("success", "Currency has been succesfully updated");
                    Utilities.editId = -1;
                    btnCloseModal_OnClick(sender, e);
                }
                else
                {
                    SetToast("error", "Currency already exists");
                }
            }
            else
            {
                if (!Utilities.CheckGridForText(dgvCurrency, txtName.Text))
                {
                    int result = dataProvider.AddCurrency(Utilities.userToken, currencyDS, orgId);

                    if (result != -1)
                    {
                        Utilities.editId = -1;
                        SetToast("success", "Currency was created successfully.");
                    }
                    else
                    {
                        SetToast("error", "An error has occured, try again.");
                    }
                }
                else
                {
                    SetToast("info", "Currency already exists");
                }

                DisplayCurrenciesInGrid();
            }

            DisplayCurrenciesInGrid();
        }