Kaydol:
Kayıt Yorumları
(
Atom
)
private void tcNo_dogrulama_Click(object sender, EventArgs e)
{
string tcNo = TCNo.Text.Trim();
if (tcNo.Length != 11)
{
MessageBox.Show("TC No hatalıdır.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string rakam1 = TCNo.Text[0].ToString();
string rakam10 = TCNo.Text[9].ToString();
string rakam11 = TCNo.Text[10].ToString();
int tekler = 0, ciftler = 0;
if (rakam1 == "0")
{
MessageBox.Show("TC No hatalıdır.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
else
{
for (int i = 0; i < 10; i++)
{
if (i % 2 == 1)
ciftler += int.Parse(tcNo[i].ToString());
else tekler += int.Parse(tcNo[i].ToString());
}
int sayi10 = ((tekler * 7) - ciftler) % 10;
int sayi11 = (ciftler + tekler + sayi10) % 10;
if (rakam10 != sayi10.ToString() || rakam11 != sayi11.ToString())
MessageBox.Show("TC No hatalıdır.","Hata",MessageBoxButtons.OK,MessageBoxIcon.Error);
else
MessageBox.Show("TC No Doğrulandı.","Bilgi",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
Hiç yorum yok :
Yorum Gönder