Untitled

 avatar
unknown
csharp
3 years ago
3.2 kB
6
Indexable
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.Sql;
using System.Data.SqlClient;

namespace MiniOBS
{
    public partial class Login : Form
    {
        SqlConnection con;
        SqlDataReader dr;
        SqlCommand com;

        public Login()
        {
            InitializeComponent();
        }

        public static string OgrenciNo = "";
        public static string OgretmenNo = "";
        public static string OgrenciIsleriNo = "";


        private void loginbtn_Click(object sender, EventArgs e)
        {
            MiniOBSEntities vt = new MiniOBSEntities();
            
                
               var ogrenci = vt.Ogrenci.FirstOrDefault(u => u.OgrenciNo == tbID.Text.Trim());
               var ogretmen = vt.Ogretmen.FirstOrDefault(u => u.OgretmenNo == tbID.Text.Trim());
               var ogrenciIsleri = vt.OgrenciIsleri.FirstOrDefault(u => u.OgrenciIsleriNo == tbID.Text.Trim());

            if (ogrenci != null)
                {
                    var sifre = vt.Ogrenci.FirstOrDefault(s => s.Sifre == tbPassword.Text.Trim());
                    if (sifre !=null)
                    {
                        OgrenciNo = tbID.Text.Trim();
                        OgrenciForm ogrenciForm = new OgrenciForm();
                        ogrenciForm.Show();
                        this.Hide();
                       
                    }
                    else
                    {
                        MessageBox.Show("Öğrenci Şifre Hatalı");
                    }   
                    
                }
                else if(ogretmen != null)
                {
                    var sifre = vt.Ogretmen.FirstOrDefault(s => s.Sifre == tbPassword.Text.Trim());
                    if (sifre != null)
                    {
                        OgretmenNo = tbID.Text.Trim();
                        OgretmenForm ogretmenForm = new OgretmenForm();
                        ogretmenForm.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Öğretmen Şifre Hatalı");
                    }
                }
            else if (ogrenciIsleri != null)
            {
                var sifre = vt.OgrenciIsleri.FirstOrDefault(s => s.Sifre == tbPassword.Text.Trim());
                if (sifre != null)
                {
                    OgrenciIsleriNo = tbID.Text.Trim();
                    OgrenciIsleriForm ogrenciIsleriForm = new OgrenciIsleriForm();
                    ogrenciIsleriForm.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Şifre Hatalı");
                }
            }
            else
            {
                    MessageBox.Show("Girilen Bilgilere Ait Birisi Bulunamadı");
                }
                    
            
        }
    }
}
Editor is loading...