bool AddPlayer()
        {
            using (DbDestructorStore context = new DbDestructorStore())
            {
                if (txtFullName != null && txtNick != null && txtPrice != null && !(context.Players.Any(p => p.FullName == txtFullName.Text)))
                {
                    var player = new Player
                    {
                        FullName          = txtFullName.Text,
                        NickName          = txtNick.Text,
                        Price             = Convert.ToDecimal(txtPrice.Text),
                        RegisterationDate = DateTime.Now,
                        IsActive          = true
                    };

                    context.Players.Add(player);
                    return(context.SaveChanges() > 0);
                }

                else if (context.Players.Any(p => p.NickName == txtNick.Text))
                {
                    MessageBox.Show("Girdiğiniz Nick Kullanımda !! ");
                }

                else
                {
                    MessageBox.Show("Tüm Alanları Doldurunuz !! ");
                }
                return(true);
            }
        }
 void GetGames()
 {
     using (DbDestructorStore context = new DbDestructorStore())
     {
         cmbGame.DataSource    = context.Games.ToList();
         cmbGame.DisplayMember = "Name";
         cmbGame.ValueMember   = "GameId";
     }
 }
 void GetPlayers()
 {
     using (DbDestructorStore context = new DbDestructorStore())
     {
         cmbPlayer.DataSource    = context.Players.ToList();
         cmbPlayer.DisplayMember = "FullName";
         cmbPlayer.ValueMember   = "PlayerId";
     }
 }
Ejemplo n.º 4
0
        bool AddGame()
        {
            using (DbDestructorStore context = new DbDestructorStore())
            {
                var game = new Game
                {
                    Name      = txtName.Text,
                    ListPrice = Convert.ToInt32(txtListPrice.Text),
                    Quantity  = Convert.ToInt32(txtQuantity.Text),
                    StockDate = Convert.ToDateTime(dtStockDate.Value),
                    IsActive  = true
                };

                context.Games.Add(game);
                return(context.SaveChanges() > 0);
            }
        }
        bool Sale()
        {
            using (DbDestructorStore context = new DbDestructorStore())
            {
                var gameId = Convert.ToInt32(cmbGame.SelectedValue);       //Combodan Al
                var game   = context.Games.First(g => g.GameId == gameId); //Db Den Getir

                var sale = new Sale
                {
                    PlayerId = Convert.ToInt32(cmbPlayer.SelectedValue),
                    GameId   = game.GameId,
                    Price    = game.ListPrice,
                    Quantity = Convert.ToInt32(txtQuantity.Text),
                    SaleDate = DateTime.Now,
                    IsActive = true
                };

                context.Sales.Add(sale);
                return(context.SaveChanges() > 0);
            }
        }