Beispiel #1
0
        protected void gvPrices_RowUpdate(object sender, GridViewUpdateEventArgs e)
        {
            int         index   = e.RowIndex;
            GridViewRow row     = gvPrices.Rows[index];
            Int64       PriceId = Int64.Parse(gvPrices.DataKeys[index].Value.ToString());
            TextBox     tb      = (TextBox)row.Cells[0].FindControl("txtPriceName");

            if (tb.Text == "")
            {
                Master.MessageCenter.DisplayErrorMessage(PricesStrings.GetText(@"PriceNameRequired"));
                return;
            }
            PriceFilter p = PriceFilter.FetchByName(tb.Text);

            if (p != null && p.PriceId != PriceId)
            {
                Master.MessageCenter.DisplayErrorMessage(PricesStrings.GetText(@"MessageSaveFailedNameAlreadyExists"));
                return;
            }

            p           = PriceFilter.FetchByID(PriceId);
            p.PriceName = tb.Text;
            p.Save();

            gvPrices.EditIndex = -1;

            LoadItems();
        }
Beispiel #2
0
        protected void gvPrices_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (!e.CommandName.Equals("AddNew"))
            {
                return;
            }

            GridViewRow row = gvPrices.FooterRow;
            TextBox     tb  = (TextBox)row.FindControl("txtNewPriceName");

            if (tb.Text == "")
            {
                Master.MessageCenter.DisplayErrorMessage(PricesStrings.GetText(@"PriceNameRequired"));
                return;
            }
            if (PriceFilter.FetchByName(tb.Text) != null)
            {
                Master.MessageCenter.DisplayErrorMessage(PricesStrings.GetText(@"MessageSaveFailedNameAlreadyExists"));
                return;
            }
            PriceFilter p = new PriceFilter();

            p.PriceName = tb.Text;
            p.Save();

            LoadItems();
        }