コード例 #1
0
        private void kisiSayisiHesapla_Click(object sender, EventArgs e)
        {
            if (txtBoxMetreKare.Text.Length == 0)
            {
                MessageBox.Show(" m² bilgisi boş geçilemez !!");
            }
            else if (Hesaplamalar.SayiMi(txtBoxMetreKare.Text) == false)
            {
                MessageBox.Show("Sayısal değer girilmelidir. Harf, boşluk, özel karakter vb. girilemez !");
            }
            else if (radio1.Checked == false && radio2.Checked == false && radio3.Checked == false && radio4.Checked == false && radio5.Checked == false)
            {
                MessageBox.Show("Mekan Sınıflandırmasını Seçmelisinz !! ");
            }
            else
            {
                var    mKare     = Convert.ToDouble(txtBoxMetreKare.Text);
                double kontenjan = radio1.Checked == true?Hesaplamalar.mKare6(mKare) : (radio2.Checked == true ? kontenjan = Hesaplamalar.mKare8(mKare) : (radio3.Checked == true ? kontenjan = Hesaplamalar.mKare10(mKare) : (radio4.Checked == true ? kontenjan = Hesaplamalar.mKare4(mKare) : (radio5.Checked == true ? Hesaplamalar.mKare4(mKare) : 0))));

                GüncelKontenjan gk = new GüncelKontenjan(this, kontenjan);
                gk.Show();
                MessageBox.Show("İşlem başarılı, kontenjan hakkı : " + ((int)kontenjan).ToString());
                this.Hide();
            }
        }
コード例 #2
0
        private void btn_KartKayit_Click(object sender, EventArgs e)
        {
            serialPort1.PortName = "COM3";
            serialPort1.BaudRate = 9600;

            KayitContext ctx   = new KayitContext();
            bool         durum = true;

            if (txtBox_HesKodu.Text == "" || txtBox_TcNo.Text == "" || txtBox_KartNum.Text == "" || txtBox_Ad.Text == "" || txtBox_Soyad.Text == "" || txtBox_KartNum.Text == "")
            {
                MessageBox.Show("Alanlar Boş Geçilemez !");
                durum = false;
            }
            else if (Hesaplamalar.SayiMi(txtBox_TcNo.Text) == false)
            {
                MessageBox.Show("Tc alanına sayisal değer dışında herhangi bir değer girilemez");
                txtBox_TcNo.Text = "";
                durum            = false;
            }
            else if (Hesaplamalar.SayiMi(txtBox_KartNum.Text) == false)
            {
                MessageBox.Show("Kart numarası alanına sayisal değer dışında herhangi bir değer(harf/boşluk) girilemez");
                txtBox_KartNum.Text = "";
                durum = false;
            }
            else if (txtBox_TcNo.Text.Length < 11)
            {
                MessageBox.Show("TC Alanı Eksik !!");
                durum = false;
            }
            else if (txtBox_KartNum.Text.Length < 10)
            {
                MessageBox.Show("Kart Numara Alanı Eksik !!");
                durum = false;
            }
            else if (txtBox_HesKodu.Text != "" || txtBox_TcNo.Text != "" || txtBox_KartNum.Text != "")
            {
                foreach (var item in ctx.Kisiler)
                {
                    if (item.Tc == txtBox_TcNo.Text)
                    {
                        MessageBox.Show("Bu Tc Bilgisiyle Kayıt Mevcut");
                        durum = false;
                    }
                    else if (item.HesKodu == txtBox_HesKodu.Text)
                    {
                        MessageBox.Show("Hes Kodu Sistemde Başkasına Ait");
                        durum = false;
                    }
                    else if (item.kartNumara == txtBox_KartNum.Text)
                    {
                        MessageBox.Show("Kart Sisteme Kayıtlı");
                        durum = false;
                    }
                }
            }
            else
            {
                durum = true;
            }
            if (durum)
            {
                serialPort1.Open();
                using (ctx)
                {
                    try
                    {
                        ctx.Kisiler.Add(new Kisi {
                            Ad = txtBox_Ad.Text, Soyad = txtBox_Soyad.Text, Tc = txtBox_TcNo.Text, HesKodu = txtBox_HesKodu.Text, kartNumara = txtBox_KartNum.Text, KayitTarihi = TimePckr_KartOlusumTarihi.Value
                        });
                        int sonuc = ctx.SaveChanges();
                        d = true;
                        timer1.Start();
                        MessageBox.Show(sonuc > 0 ? "Kart Kayıt İşlemi Başarılı" : "Kart Kayıt İşlemi Başarısız");
                        txtBox_Ad.Text      = "";
                        txtBox_Soyad.Text   = "";
                        txtBox_TcNo.Text    = "";
                        txtBox_HesKodu.Text = "";
                        txtBox_KartNum.Text = "";
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
        }