WPF Form Tc Kimlik Numarası Sorgulama

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Griffin Premium
Katılım
3 Mar 2017
Mesajlar
1,378
Çözümler
1
Tepki puanı
1,001
Ödüller
12
Sosyal
9 HİZMET YILI
:not:

Herkese Merhaba Arkadaşlar, Bugün WPF Form'da TC Kimlik Numarası sorgulayan program yapacağız.

Formumuza 1 Adet Button ve TextBox ekleyeceğiz.

:kullan:

xaml Kodlarımız.

C#:
<Window x:Class="tckimlik.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:tckimlik"
        mc:Ignorable="d"
        Title="www.memoryhackers.org" Height="350" Width="525">
    <Grid>
        <TextBox x:Name="txtTc" HorizontalAlignment="Left" Height="36" Margin="146,71,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="224"/>
        <Button x:Name="button" Content="DOĞRULA" HorizontalAlignment="Left" VerticalAlignment="Top" Width="224" Margin="146,112,0,0" Height="48" Click="button_Click"/>
        <TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="146,185,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Height="37" Width="224"/>

    </Grid>
</Window>

Form Tasarımı

wpf-tc-kimlik-2.png


C# Kodlarımız.

C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace tckimlik
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            string tcKimlikNo = txtTc.Text;
            bool returnvalue = false;
            if (tcKimlikNo.Length == 11)
            {
                Int64 ATCNO, BTCNO, TcNo;
                long C1, C2, C3, C4, C5, C6, C7, C8, C9, Q1, Q2;

                TcNo = Int64.Parse(tcKimlikNo);

                ATCNO = TcNo / 100;
                BTCNO = TcNo / 100;

                C1 = ATCNO % 10; ATCNO = ATCNO / 10;
                C2 = ATCNO % 10; ATCNO = ATCNO / 10;
                C3 = ATCNO % 10; ATCNO = ATCNO / 10;
                C4 = ATCNO % 10; ATCNO = ATCNO / 10;
                C5 = ATCNO % 10; ATCNO = ATCNO / 10;
                C6 = ATCNO % 10; ATCNO = ATCNO / 10;
                C7 = ATCNO % 10; ATCNO = ATCNO / 10;
                C8 = ATCNO % 10; ATCNO = ATCNO / 10;
                C9 = ATCNO % 10; ATCNO = ATCNO / 10;
                Q1 = ((10 - ((((C1 + C3 + C5 + C7 + C9) * 3) + (C2 + C4 + C6 + C8)) % 10)) % 10);
                Q2 = ((10 - (((((C2 + C4 + C6 + C8) + Q1) * 3) + (C1 + C3 + C5 + C7 + C9)) % 10)) % 10);

                returnvalue = ((BTCNO * 100) + (Q1 * 10) + Q2 == TcNo);
            }


            if (returnvalue)
                textBlock.Text = "TC Kimlik Numarası Geçerli";
            else
                textBlock.Text = "TC Kimlik Numarası Geçersiz";
        }
    }
}

 
potential zero
Ultra Üye
Katılım
9 Ocak 2018
Mesajlar
1,557
Çözümler
2
Tepki puanı
341
Ödüller
9
Yaş
23
8 HİZMET YILI
@NightStar özel üye başlığında çok güzelmiş .d
teşekkürler .
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst