Beispiel #1
0
        protected void dgvCurrency_OnRowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (dgvCurrency.Rows[e.RowIndex].Cells[9].Text != "False")
            {
                Utilities.editId = int.Parse(dgvCurrency.DataKeys[e.RowIndex].Value.ToString());

                string _txtName         = dgvCurrency.Rows[e.RowIndex].Cells[1].Text;
                string _txtSymbol       = HttpUtility.HtmlDecode(dgvCurrency.Rows[e.RowIndex].Cells[2].Text);
                string _txtISO          = dgvCurrency.Rows[e.RowIndex].Cells[3].Text;
                string _txtUnit         = dgvCurrency.Rows[e.RowIndex].Cells[4].Text;
                string _txtSubUnit      = dgvCurrency.Rows[e.RowIndex].Cells[5].Text;
                string _txtUnitSingle   = dgvCurrency.Rows[e.RowIndex].Cells[6].Text;
                string _txtSubUnitSngle = dgvCurrency.Rows[e.RowIndex].Cells[7].Text;
                bool   _chkBaseCurrency = bool.Parse(dgvCurrency.Rows[e.RowIndex].Cells[8].Text);

                CurrencyDataSet curr = new CurrencyDataSet();
                curr.Currency.AddCurrencyRow(_txtName, _txtSymbol, _txtISO, _txtUnit, _txtSubUnit, _txtUnitSingle,
                                             _txtSubUnitSngle,
                                             _chkBaseCurrency, false, Utilities.editId);

                dataProvider.UpdateCurrency(userToken, curr, orgId);
                SetToast("success", "Currency deactivated succesfully");
            }
            else
            {
                SetToast("info", "Currency already deactivated");
            }
            DisplayCurrenciesInGrid();
        }
Beispiel #2
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();
        }
Beispiel #3
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();
        }
Beispiel #4
0
        protected void dgvCurrency_OnRowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (dgvCurrency.Rows[e.RowIndex].Cells[9].Text != "False")
            {
                Utilities.editId = int.Parse(dgvCurrency.DataKeys[e.RowIndex].Value.ToString());

                string _txtName = dgvCurrency.Rows[e.RowIndex].Cells[1].Text;
                string _txtSymbol = HttpUtility.HtmlDecode(dgvCurrency.Rows[e.RowIndex].Cells[2].Text);
                string _txtISO = dgvCurrency.Rows[e.RowIndex].Cells[3].Text;
                string _txtUnit = dgvCurrency.Rows[e.RowIndex].Cells[4].Text;
                string _txtSubUnit = dgvCurrency.Rows[e.RowIndex].Cells[5].Text;
                string _txtUnitSingle = dgvCurrency.Rows[e.RowIndex].Cells[6].Text;
                string _txtSubUnitSngle = dgvCurrency.Rows[e.RowIndex].Cells[7].Text;
                bool _chkBaseCurrency = bool.Parse(dgvCurrency.Rows[e.RowIndex].Cells[8].Text);
                
                CurrencyDataSet curr = new CurrencyDataSet();
                curr.Currency.AddCurrencyRow(_txtName, _txtSymbol, _txtISO, _txtUnit, _txtSubUnit, _txtUnitSingle,
                    _txtSubUnitSngle,
                    _chkBaseCurrency, false, Utilities.editId);
                
                dataProvider.UpdateCurrency(userToken,curr,orgId);
                SetToast("success", "Currency deactivated succesfully");
            }
            else
            {
                SetToast("info", "Currency already deactivated");
            }
            DisplayCurrenciesInGrid();
        }
Beispiel #5
0
        public CurrencyDataSet GetActiveCurrencyByOrgId(string userToken, int orgId)
        {

            var retDataset = new CurrencyDataSet();

            if (IsUserTokenValid(userToken))
            {
                try
                {
                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    SqlCommand cmd = conn.CreateCommand();
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = "spGetActiveCurrencyByOrgId";

                    var p = new SqlParameter("orgId", orgId);

                    cmd.Parameters.Add(p);

                    SqlDataReader reader = cmd.ExecuteReader();
                    if (reader != null)
                    {
                        while (reader.Read())
                        {
                            var sysParam = retDataset.Currency.NewCurrencyRow();

                            sysParam.Id = int.Parse(reader["Id"].ToString());
                            sysParam.Name = reader["Name"].ToString();
                            sysParam.Symbol = reader["Symbol"].ToString();
                            sysParam.ISOCode = reader["ISOCode"].ToString();
                            sysParam.UnitName = reader["UnitName"].ToString();
                            sysParam.SubUnitName = reader["SubUnitName"].ToString();
                            sysParam.UnitNameSingle = reader["UnitNameSingle"].ToString();
                            sysParam.SubUnitNameSingle = reader["SubUnitNameSingle"].ToString();
                            sysParam.BaseCurrency = bool.Parse(reader["BaseCurrency"].ToString());
                            sysParam.Active = bool.Parse(reader["Active"].ToString());


                            retDataset.Currency.AddCurrencyRow(sysParam);
                        }
                        reader.Close();
                    }

                }
                catch (Exception ex)
                {
                    throw new OperationFailedException(ex.Message, ex);
                }
                finally
                {
                    if (conn.State != System.Data.ConnectionState.Closed)
                    {
                        conn.Close();
                    }
                }
            }
            return retDataset;
        }
Beispiel #6
0
        public int UpdateCurrency(string userToken, CurrencyDataSet sysParameter, int orgId)
        {
            int newId = -1;
            if (IsUserTokenValid(userToken))
            {
                try
                {
                    if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
                    SqlCommand cmd = conn.CreateCommand();
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = "spUpdateCurrency";

                    var p2 = new SqlParameter[12];
                    for (int i = 0; i < 12; i++)
                        p2[i] = new SqlParameter();

                    p2[0] = new SqlParameter("name", sysParameter.Currency[0].Name);
                    p2[1] = new SqlParameter("symbol", sysParameter.Currency[0].Symbol);
                    p2[2] = new SqlParameter("iso_code", sysParameter.Currency[0].ISOCode);
                    p2[3] = new SqlParameter("unitName", sysParameter.Currency[0].UnitName);
                    p2[4] = new SqlParameter("subUnitName", sysParameter.Currency[0].SubUnitName);
                    p2[5] = new SqlParameter("unitNameSingle", sysParameter.Currency[0].UnitNameSingle);
                    p2[6] = new SqlParameter("subUnitNameSingle", sysParameter.Currency[0].SubUnitNameSingle);
                    p2[7] = new SqlParameter("baseCurrency", sysParameter.Currency[0].BaseCurrency);
                    p2[8] = new SqlParameter("active", sysParameter.Currency[0].Active);
                    p2[9] = new SqlParameter("updateUser", _userId);
                    p2[10] = new SqlParameter("id", sysParameter.Currency[0].Id);
                    p2[11] = new SqlParameter("orgId", orgId);
                    
                    cmd.Parameters.AddRange(p2);

                    newId = int.Parse(cmd.ExecuteScalar().ToString());
                    if (conn.State != System.Data.ConnectionState.Closed)
                    {
                        conn.Close();
                    }
                    //SetInterestsForEvent(newId, interests);
                }
                catch (Exception ex)
                {
                    throw new OperationFailedException(ex.Message, ex);
                }
                finally
                {
                    if (conn.State != System.Data.ConnectionState.Closed)
                    {
                        conn.Close();
                    }
                }
            }
            return newId;
        }