private void Login_Load(object sender, EventArgs e) { FileStream fs = new FileStream(Application.LocalUserAppDataPath + "\\BiletFiyat.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite); StreamReader sr = new StreamReader(fs); string okunan = sr.ReadLine(); if (okunan == null) { StreamWriter sw = new StreamWriter(fs); sw.Write("12"); sw.Close(); } sr.Close(); Genel.BiletFiyatBelirleme(); using (SinemaContext ent = new SinemaContext()) { ent.Database.CreateIfNotExists(); User u = new User { Id = 1, UserName = "******", Name = "Serkan", SurName = "Karışan", IsActive = true, Password = "******", AddedDate = DateTime.Now, RoleId = 1 }; Role r1 = new Role { Id = 1, RoleName = "Admin", AddedDate = DateTime.Now, IsActive = true }; Role r2 = new Role { Id = 2, RoleName = "User", AddedDate = DateTime.Now, IsActive = true }; if (ent.Roles.Where(rl => rl.Id == r1.Id && rl.RoleName == r1.RoleName).FirstOrDefault() == null) { ent.Roles.Add(r1); ent.SaveChanges(); } if (ent.Roles.Where(rl => rl.Id == r2.Id && rl.RoleName == r2.RoleName).FirstOrDefault() == null) { ent.Roles.Add(r2); ent.SaveChanges(); } if (ent.Users.Where(us => us.Id == u.Id && us.UserName == u.UserName && us.Name == u.Name && us.SurName == u.SurName).FirstOrDefault() == null) { ent.Users.Add(u); ent.SaveChanges(); } } }
private void btnFiyatOnayla_Click(object sender, EventArgs e) { FileStream fs = new FileStream(Application.LocalUserAppDataPath + "\\BiletFiyat.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite); StreamWriter sw = new StreamWriter(fs); sw.Write(txtYeniFiyat.Text.Trim()); sw.Close(); txtYeniFiyat.Clear(); Genel.BiletFiyatBelirleme(); if (btnSalonDüzenleme.Visible == false && btnSalonDüzenleme.Visible == false) { btnBiletFiyat.Location = new Point(9, 212); pnlFiyat.Location = new Point(9, 258); } else if (btnSalonDüzenleme.Visible == true && btnSalonDüzenleme.Visible == true) { btnBiletFiyat.Location = new Point(9, 300); pnlFiyat.Location = new Point(9, 346); } pnlFiyat.Height = 0; MessageBox.Show("Yeni bilet fiyatınız başarıyla değiştirildi.", "İşlem Başarılı"); }
private void btnBiletOnayla_Click(object sender, EventArgs e) { if (MessageBox.Show("Bilet kesilsin mi?", "Onaylıyor Musunuz?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (txtTel.Text.Trim().Count() < 10) { MessageBox.Show("Telefon numarası hatalı.", "Hata!"); txtTel.Focus(); return; } else { List <int> SeatIDList = new List <int>(); foreach (Control p in this.pnlKoltuklar.Controls) { if (p is PictureBox && p.BackColor == Color.DarkOrange) { PictureBox pb = (PictureBox)p; string[] pbName = pb.Name.Split('_'); SeatIDList.Add(Convert.ToInt32(pbName[1])); } } if (SeatIDList.Count() != 0) { Ticket t = new Ticket(); t.SeanceId = s.Id; t.Validity_Date = s.Start_Time; Genel.BiletFiyatBelirleme(); t.Ticket_Amount = SeatIDList.Count() * Genel.BiletFiyat; t.Ticket_Code = "T" + DateTime.Now.ToShortDateString() + DateTime.Now.ToLongTimeString(); Customer c = new Customer(); c.Name = txtAdi.Text; c.Surname = txtSoyadi.Text; c.Phone = txtTel.Text.Trim(); Genel.Service.Customer.Insert(c); t.CustomerId = Genel.Service.Customer.SelectByPhone(c.Phone).Id; Genel.Service.Ticket.Insert(t); TicketID = Genel.Service.Ticket.SelectByTicketCode(t.Ticket_Code).Id; foreach (int SeatID in SeatIDList) { Ticket_Seat ts = new Ticket_Seat(); ts.SeatId = SeatID; ts.TicketId = Genel.Service.Ticket.SelectByTicketCode(t.Ticket_Code).Id; Genel.Service.TicketSeat.Insert(ts); } string[] Bilet = t.Ticket_Code.Split('.'); string[] Devami = Bilet[2].Split(':'); string TCode = Bilet[0] + Bilet[1] + Devami[0] + Devami[1] + Devami[2]; MessageBox.Show(h.Hall_Code + " Numaralı salonda iyi seyirler dileriz.", "İşlem Başarılı"); Clipboard.SetText(TCode); printPrwDialog1.Document.DocumentName = TCode; printPrwDialog1.Focus(); printPrwDialog1.Width = this.FindForm().Width; printPrwDialog1.Height = this.FindForm().Height + 80; printPrwDialog1.ShowDialog(); Temizle(); } else { MessageBox.Show("Koltuk seçmelisiniz.", "Hata!"); return; } } } }