Пример #1
0
        protected void Delete_Clicked(object sender, EventArgs e)
        {
            Guid           id             = new Guid(((Button)sender).CommandArgument);
            Tarifkategorie tarifkategorie = _context.Tarifkategorie.FirstOrDefault(x => x.ID == id);
            var            spieleList     = _context.Spiel.Where(x => x.FK_Tarifkategorie_ID == tarifkategorie.ID).ToList();

            if (spieleList.Count == 0)
            {
                _context.Tarifkategorie.Remove(tarifkategorie);
                _context.SaveChanges();

                BindListView();
            }
        }
Пример #2
0
        protected void Hinzufügen_Click(object sender, EventArgs e)
        {
            double price;

            if (double.TryParse(txtPrice.Text, out price))
            {
                Tarifkategorie tarifkategorie = new Tarifkategorie()
                {
                    ID        = Guid.NewGuid(),
                    Tarifname = txtName.Text,
                    Price     = price
                };

                _context.Tarifkategorie.Add(tarifkategorie);
                _context.SaveChanges();
                BindListView();
            }
        }
Пример #3
0
        protected void Update_Click(object sender, EventArgs e)
        {
            Guid           id               = new Guid(((Button)sender).CommandArgument);
            Tarifkategorie tarifkategorie   = _context.Tarifkategorie.FirstOrDefault(x => x.ID == id);
            Panel          panel            = (Panel)((Button)sender).Parent;
            TextBox        txtEditTarifname = (TextBox)panel.FindControl("txtEditTarifname");
            TextBox        txtEditPrice     = (TextBox)panel.FindControl("txtEditPrice");
            double         price;

            if (double.TryParse(txtEditPrice.Text, out price))
            {
                tarifkategorie.Tarifname = txtEditTarifname.Text;
                tarifkategorie.Price     = price;

                _context.Entry(tarifkategorie).State = EntityState.Modified;
                _context.SaveChanges();

                lstTarifkategorien.EditIndex = -1;
                BindListView();
            }
        }