private void RefreshTheSeats() { flowLayoutPanel2.Controls.Clear(); List <Chair> chairs = HelperChair.GetChairsByShowtimesId(showtimes.ShowtimesId); foreach (var item in chairs) { Button button = new Button(); button.ForeColor = Color.White; button.Text = item.Name; button.TextAlign = ContentAlignment.BottomCenter; button.Size = new Size(75, 75); button.Margin = new Padding(0, 0, 7, 5); button.Click += new EventHandler(NewButton_Click); button.Image = ((System.Drawing.Image)(Properties.Resources.seat2)); button.ImageAlign = ContentAlignment.TopCenter; if (item.IsSold == false) { button.BackColor = Color.Green; } else { button.BackColor = Color.Red; } if (item.Name == "C1" || item.Name == "C2" || item.Name == "C3" || item.Name == "C4" || item.Name == "C5") { button.Margin = new Padding(0, 0, 7, 23); } flowLayoutPanel2.Controls.Add(button); } }
private void BtnBiletIptal_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(buttonText)) { MessageBox.Show("İlk önce koltuk seçmeniz gerekmektedir!", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Chair chair = HelperChair.GetChairByShowtimesIdAndName(showtimes.ShowtimesId, buttonText); if (chair.IsSold == false) { MessageBox.Show("Bu koltuk daha önce satılmamış. Satılmamış bir koltuğun biletini iptal edemezsiniz!", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { chair.IsSold = false; var a = HelperChair.ChairCUD(chair, System.Data.Entity.EntityState.Modified); Ticket ticket = HelperTicket.GetTicketByShowtimesIdAndChairId(showtimes.ShowtimesId, chair.ChairId); var b = HelperTicket.TicketCUD(ticket, System.Data.Entity.EntityState.Deleted); RefreshTheSeats(); RefreshTheTotalBalance(); } } }
private void BtnBiletSat_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(buttonText)) { MessageBox.Show("İlk önce koltuk seçmeniz gerekmektedir!", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Chair chair = HelperChair.GetChairByShowtimesIdAndName(showtimes.ShowtimesId, buttonText); if (chair.IsSold == true) { MessageBox.Show("Bu koltuk daha önce satılmış. Lütfen başka bir koltuk seçiniz.", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (radioButton1.Checked == true && radioButton2.Checked == false) { chair.IsSold = true; var b = HelperChair.ChairCUD(chair, System.Data.Entity.EntityState.Modified); Ticket ticket = new Ticket(); ticket.ShowtimesId = showtimes.ShowtimesId; ticket.ChairId = chair.ChairId; ticket.Type = 0; ticket.UserId = user.UserId; var a = HelperTicket.TicketCUD(ticket, System.Data.Entity.EntityState.Added); if (a.Item2) { RefreshTheTotalBalance(); RefreshTheSeats(); MessageBox.Show($"Salonunun {buttonText} koltuğu satılmıştır.", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show($"Koltuk satılamamıştır.", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else if (radioButton1.Checked == false && radioButton2.Checked == true) { chair.IsSold = true; var b = HelperChair.ChairCUD(chair, System.Data.Entity.EntityState.Modified); Ticket ticket = new Ticket(); ticket.ShowtimesId = showtimes.ShowtimesId; ticket.ChairId = chair.ChairId; ticket.Type = 1; ticket.UserId = user.UserId; var a = HelperTicket.TicketCUD(ticket, System.Data.Entity.EntityState.Added); if (a.Item2) { RefreshTheTotalBalance(); RefreshTheSeats(); MessageBox.Show($"Salonunun {buttonText} koltuğu satılmıştır.", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show($"Koltuk satılamamıştır.", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("İlk önce bilet tipini seçmeniz gerekmektedir!", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }