Facebook
From Colossal Shama, 3 Years ago, written in C#.
Embed
Download Paste or View Raw
Hits: 166
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Data.SqlClient;
  11.  
  12. namespace Proje_Odevi
  13. {
  14.     public partial class frmSeansEkle : Form
  15.     {
  16.         public frmSeansEkle()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.         string seans = "";
  21.  
  22.         sinemaTableAdapters.Seans_BilgileriTableAdapter filmseansi = new sinemaTableAdapters.Seans_BilgileriTableAdapter();
  23.         SqlConnection baglanti = new SqlConnection("Data Source=SERVER;Initial Catalog=Sinema_Bileti;Integrated Security=True");
  24.         private void RadioButonSeciliyse()
  25.         {
  26.             if (radioButton1.Checked == true) seans = radioButton1.Text;
  27.             else if (radioButton2.Checked == true) seans = radioButton2.Text;
  28.             else if (radioButton3.Checked == true) seans = radioButton3.Text;
  29.             else if (radioButton4.Checked == true) seans = radioButton4.Text;
  30.             else if (radioButton5.Checked == true) seans = radioButton5.Text;
  31.             else if (radioButton6.Checked == true) seans = radioButton6.Text;
  32.             else if (radioButton7.Checked == true) seans = radioButton7.Text;
  33.             else if (radioButton8.Checked == true) seans = radioButton8.Text;
  34.             else if (radioButton9.Checked == true) seans = radioButton9.Text;
  35.             else if (radioButton10.Checked == true) seans = radioButton10.Text;
  36.             else if (radioButton11.Checked == true) seans = radioButton11.Text;
  37.             else if (radioButton12.Checked == true) seans = radioButton12.Text;
  38.         }
  39.  
  40.         private void FilmveSalonGosterim(ComboBox combo, string sql, string sql2)
  41.         {
  42.             baglanti.Open();
  43.             SqlCommand komut = new SqlCommand(sql, baglanti);
  44.             SqlDataReader read = komut.ExecuteReader();
  45.             while (read.Read() == true)
  46.             {
  47.                 combo.Items.Add(read[sql2].ToString());
  48.             }
  49.             baglanti.Close();
  50.         }
  51.         private void frmSeansEkle_Load(object sender, EventArgs e)
  52.         {
  53.             FilmveSalonGosterim(comboFilm, "select *from_filmbilgileri", "filmadi");
  54.             FilmveSalonGosterim(comboSalon, "select *from salon_bilgileri", "salonadi");
  55.         }
  56.        
  57.         private void frmSeansEkle_FormClosing(object sender, FormClosingEventArgs e)
  58.         {
  59.             frmAnaSayfa anasayfa = new frmAnaSayfa();
  60.             anasayfa.Show();
  61.         }
  62.  
  63.         private void btnSeansEkle_Click(object sender, EventArgs e)
  64.         {
  65.             RadioButonSeciliyse();
  66.             if (seans != "")
  67.             {
  68.                 filmseansi.SeansEkleme(comboFilm.Text, comboSalon.Text, dateTimePicker1.Text, seans);
  69.                 MessageBox.Show("Seans Eklendi", "Bilgi");
  70.             }
  71.             else if (seans == "")
  72.             {
  73.                 MessageBox.Show("Seansın saatini seçmediniz", "Uyarı");
  74.             }
  75.             comboFilm.Text = "";
  76.             comboSalon.Text = "";
  77.             dateTimePicker1.Text = DateTime.Now.ToShortDateString();
  78.         }
  79.  
  80.         private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
  81.         {
  82.             foreach (Control item3 in panel1.Controls)
  83.             {
  84.                 item3.Enabled = true;
  85.             }
  86.             DateTime bugun = DateTime.Parse(DateTime.Now.ToLongDateString());
  87.             DateTime yeni = DateTime.Parse(dateTimePicker1.Text);
  88.  
  89.             if (bugun == yeni)
  90.             {
  91.                 foreach (Control item in panel1.Controls)
  92.                 {
  93.                     if (DateTime.Parse(DateTime.Now.ToShortTimeString()) > DateTime.Parse(item.Text))
  94.                     {
  95.                         item.Enabled = false;
  96.                     }
  97.                 }
  98.                 TarihiKarsilastir();
  99.             }
  100.             else if (yeni>bugun)
  101.             {
  102.                 TarihiKarsilastir();
  103.             }
  104.             else if (yeni<bugun)
  105.             {
  106.                 MessageBox.Show("Geriye dönük işlem yapılamaz","Uyarı");
  107.                 dateTimePicker1.Text = DateTime.Now.ToShortDateString();
  108.             }
  109.         }
  110.          private void TarihiKarsilastir()
  111.         {
  112.             baglanti.Open();
  113.             SqlCommand komut = new SqlCommand("select *from seans_bilgileri where salonadi='" + comboSalon.Text + "'and Tarih='" + dateTimePicker1.Text + "'", baglanti);
  114.             SqlDataReader read = komut.ExecuteReader();
  115.             while (read.Read() == true)
  116.             {
  117.                 foreach (Control item2 in panel1.Controls)
  118.                 {
  119.                     if (read["seans"].ToString() == item2.Text)
  120.                     {
  121.                         item2.Enabled = false;
  122.                     }
  123.                 }
  124.             }
  125.             baglanti.Close();
  126.         }
  127.  
  128.     }
  129. }