private void btnGiris_Click(object sender, EventArgs e) { if (txtKullaniciAdi.Text.Trim() == "Kullanıcı Adı") { MessageBox.Show("Kullanıcı adı girmelisiniz.", "Eksik Bilgi!"); txtKullaniciAdi.Clear(); txtKullaniciAdi.Focus(); } else if (txtKullaniciAdi.Text.Trim() == "") { MessageBox.Show("Kullanıcı adı girmelisiniz.", "Eksik Bilgi!"); txtKullaniciAdi.Clear(); txtKullaniciAdi.Focus(); } else { if (txtSifre.Text.Trim() == "Şifre") { MessageBox.Show("Şifre girmelisiniz.", "Eksik Bilgi!"); txtSifre.Clear(); txtSifre.Focus(); } else if (txtSifre.Text.Trim() == "") { MessageBox.Show("Şifre girmelisiniz.", "Eksik Bilgi!"); txtSifre.Clear(); txtSifre.Focus(); } else { string result = Genel.CheckUser(txtKullaniciAdi.Text, txtSifre.Text); if (result == "1") { AnaSayfa frm = new AnaSayfa(); frm.Show(); this.Hide(); } else if (result == "err_username") { MessageBox.Show("Kullanıcı adınızı kontrol edin.", "Kullanıcı Bulunamadı!"); txtKullaniciAdi.Focus(); txtSifre.PasswordChar = '*'; } else if (result == "err_password") { MessageBox.Show("Şifrenizi kontrol edin.", "Şifre Hatalı!"); txtSifre.PasswordChar = '\0'; txtSifre.Clear(); txtSifre.Focus(); } } } }
private void btnUpdate_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtName.Text.Trim()) && (!string.IsNullOrEmpty(txtSurname.Text.Trim())) && (!string.IsNullOrEmpty(txtUsername.Text.Trim())) && (!string.IsNullOrEmpty(txtPassword.Text.Trim()))) { if (ID != 0) { User u = Genel.Service.User.SelectById(ID); User usernameToUser = Genel.Service.User.SelectByUserName(txtUsername.Text.Trim()); if (usernameToUser != null && usernameToUser.Id != u.Id) { MessageBox.Show("Bu kullanıcı adı başka birine ait.", "Hata!"); txtUsername.Focus(); } else { u.UserName = txtUsername.Text.Trim(); u.Name = txtName.Text.Trim(); u.SurName = txtSurname.Text.Trim(); u.Password = Genel.Hash(txtPassword.Text.Trim()); u.RoleId = selectedRole.Id; Genel.Service.User.Update(u); MessageBox.Show("Kullanıcı başarıyla güncellendi.", "İşlem Başarılı"); btnKaydet.Enabled = false; btnUpdate.Enabled = false; btnUpdate.Visible = false; btnIptal.Enabled = false; btnIptal.Visible = false; btnSil.Enabled = false; btnSil.Visible = false; ID = 0; Disabled(); Temizle(); Listele(); } } else { MessageBox.Show("Kullanıcı seçmelisiniz.", "Hata!"); dgvKullanicilar.Focus(); } } else { MessageBox.Show("Bilgileri kontrol edip tekrar deneyin.", "Eksik Bilgi Girişi!"); txtUsername.Focus(); } }
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 btnKaydet_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtName.Text.Trim()) && (!string.IsNullOrEmpty(txtSurname.Text.Trim())) && (!string.IsNullOrEmpty(txtUsername.Text.Trim())) && (!string.IsNullOrEmpty(txtPassword.Text.Trim()))) { User u = new User(); if (Genel.Service.User.SelectByUserName(txtUsername.Text.Trim()) != null) { MessageBox.Show("Bu Kullanıcı İsmi Kayıtlı!", "Hata!"); txtUsername.Focus(); } else { u.UserName = txtUsername.Text.Trim(); u.Name = txtName.Text.Trim(); u.SurName = txtSurname.Text.Trim(); u.Password = Genel.Hash(txtUsername.Text.Trim()); u.RoleId = selectedRole.Id; Genel.Service.User.Insert(u); MessageBox.Show("Kullanıcı başarıyla eklendi.", "İşlem Başarılı"); btnKaydet.Enabled = false; btnUpdate.Enabled = false; btnUpdate.Visible = false; btnIptal.Enabled = false; btnIptal.Visible = false; btnSil.Enabled = false; btnSil.Visible = false; Disabled(); Temizle(); Listele(); } } else { MessageBox.Show("Bilgileri kontrol edip tekrar deneyin.", "Eksik Bilgi Girişi!"); txtUsername.Focus(); } }
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; } } } }