private void btnOk_Click(object sender, EventArgs e) { btnPromote.Visible = false; cmboxResult.Enabled = false; pnlPromo.Visible = false; lblTotalPoints.Text = selectedGame.TotalPoints.ToString(); using (MCLEntities entities = new MCLEntities()) { PlayerGame pg = entities.PlayerGames.Where(x => x.PlayerGameId == selectedGame.PlayerGameId).FirstOrDefault(); PlayerMaster pm = entities.PlayerMasters.Where(x => x.PlayerMasterId == pg.PlayerMasterId).FirstOrDefault(); pg.ResultId = (cmboxResult.SelectedItem as Result).ResultId; pg.GamePoints = Convert.ToInt32(lblExtraPoints.Text); pg.IsMarked = true; pg.MarkedAt = DateTime.Now; pg.MarkedById = Configuration.User.UserId; entities.SaveChanges(); pm.TierId = (cmbPromoTier.SelectedItem as Tier).TierId; pm.Points = 0; pm.TotalPoints = Convert.ToInt32(lblTotalPoints.Text); pm.PromoEnabled = false; pm.IsPromoBlock = false; entities.SaveChanges(); } }
private void btnSave_Click(object sender, EventArgs e) { using (MCLEntities entities = new MCLEntities()) { PlayerGame pg = entities.PlayerGames.Where(x => x.PlayerGameId == selectedGame.PlayerGameId).FirstOrDefault(); PlayerMaster pm = entities.PlayerMasters.Where(x => x.PlayerMasterId == pg.PlayerMasterId).FirstOrDefault(); if (cmboxResult.Enabled) { pg.ResultId = (cmboxResult.SelectedItem as Result).ResultId; pg.GamePoints = Convert.ToInt32(lblGamePoints.Text); pg.IsMarked = true; pg.MarkedAt = DateTime.Now; pg.MarkedById = Configuration.User.UserId; entities.SaveChanges(); pm.TierId = (cmbTier.SelectedItem as Tier).TierId; pm.Points = pm.Points + Convert.ToInt32(lblGamePoints.Text); pm.TotalPoints = Convert.ToInt32(lblTotalPoints.Text); if (btnPromo.Text == "Disable") { pm.PromoEnabled = true; pm.IsPromoBlock = false; } else { pm.PromoEnabled = false; } entities.SaveChanges(); if (pg.ResultId != 4) { cmboxResult.Enabled = false; } } else { if (btnPromo.Text == "Disable") { pm.PromoEnabled = true; pm.IsPromoBlock = false; } else { pm.PromoEnabled = false; } entities.SaveChanges(); } } }