﻿function giris() 
{
    var kullanici_kodu = document.getElementById('kullanici_kodu').value;
    var sifre = document.getElementById('sifre').value;
    var kurumu = document.getElementById('kurumu').value;
    var calisma_yili = document.getElementById('calisma_yili').value;
    var admin = document.getElementById('kurumu').disabled;
    
    if (kullanici_kodu == "") {
        alert("Kullanıcı Kodu Boş Olamaz...!");
        list2 = document.getElementById('calisma_yili');
        list = document.getElementById('kurumu');
        list.options.length = 0;
        list2.options.length = 0;
    return false;}
    if (sifre==""){alert("Şifre Boş Olamaz...!");return false;}
    if (kurumu == "") { alert("Kullanıcı Adı yada Şifre Hatalı...! Tekrar Deneyiniz."); return false; }
    if (calisma_yili == "") { alert("Kullanıcı Adı yada Şifre Hatalı...! Tekrar Deneyiniz."); return false; }

    if (admin == true) {
        var funckullanicikontrol = ajaxname.girisyap(kullanici_kodu, sifre, kurumu, calisma_yili);
        //---------------
        var kullanicilar = funckullanicikontrol.value;
        if (kullanicilar.Rows.length < 1) {
            list2 = document.getElementById('calisma_yili')
            list = document.getElementById('kurumu');
            list.options.length = 0;
            list2.options.length = 0;
            document.getElementById('sifre').value = "";
            alert("Kullanıcı Adı yada Şifre Hatalı...! Tekrar Deneyiniz.");
            return false;
        }
    }
    if (admin == false) { 
     var funckullanicikontrol = ajaxname.girisyaptin(kullanici_kodu, sifre, kurumu, calisma_yili);
        //---------------
        var kullanicilar = funckullanicikontrol.value;
        if (kullanicilar.Rows.length < 1) {
            list2 = document.getElementById('calisma_yili')
            list = document.getElementById('kurumu');
            list.options.length = 0;
            list2.options.length = 0;
            document.getElementById('sifre').value = "";
            alert("Kullanıcı Adı yada Şifre Hatalı...! Tekrar Deneyiniz.");
            return false;
        }
    
    }
if (kullanicilar.Rows.length =="1")
 {
     window.location = "dosyalar/anasayfa.aspx";
        
 }
    else
 {
        alert("Kayıt Okuma Hatası:" + funckullanicikontrol.error.Message); return false;
 }

}
function kurumkontrol() 
{
    var kullanici_kodu = document.getElementById('kullanici_kodu').value;
    var sifre = document.getElementById('sifre').value;
    if (kullanici_kodu != "" && sifre != "") 
    {
        var function_login = ajaxname.kurumkontrol(kullanici_kodu, sifre);
        var gelenfirma = function_login.value;
        if (gelenfirma.Rows.length < 1) 
        {
            list2 = document.getElementById('calisma_yili')
            //            list = document.getElementById('kurumu');
            document.getElementById('kurumu').value = "";
//            list.options.length = 0;
            list2.options.length = 0;
//            document.getElementById('sifre').value = "";
            alert("Kullanıcı Adı yada Şifre Hatalı...! Tekrar Deneyiniz.");
            return false;
        }
        var row = gelenfirma.Rows[0];

        var list = null;
        var list2 = null;
        if (row.yetki == "1") {document.getElementById('kurumu').disabled = false;}
        list2 = document.getElementById('calisma_yili')
//        list = document.getElementById('kurumu');
//        list.options.length = 0;
        list2.options.length = 0;
        document.getElementById('kurumu').value = row.birimkodu;
//        list.options[0] = new Option(row.birimi, row.birimkodu);
        list2.options[0] = new Option("2010", "2010");


    }
   
}


function form_init()
{
    Ajax_Load();
}