10 Nisan 2016 Pazar

C# Ay Gün ve Yıl Hesaplayan Program




using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;



namespace Tarih_Hesabi
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" || textBox2.Text != "" || textBox3.Text != "")
            {
                int d_Gun, d_Ay, d_Yil;
                d_Gun = Convert.ToInt32(textBox1.Text);
                d_Ay = Convert.ToInt32(textBox2.Text);
                d_Yil = Convert.ToInt32(textBox3.Text);


                int s_Gun, s_Ay, s_Yil;
                s_Gun = Convert.ToInt32(DateTime.Now.Day);
                s_Ay = Convert.ToInt32(DateTime.Now.Month);
                s_Yil = Convert.ToInt32(DateTime.Now.Year);

                int gun, ay, yil, toplam_Ay, toplam_Gun, toplam_Saat;

                if ((d_Gun >= 1 && d_Gun <= 31) && (d_Ay >= 1 && d_Ay <= 12) && (d_Yil <= s_Yil))
                {
                    if (d_Gun <= s_Gun)
                    {
                        gun = s_Gun - d_Gun;
                    }
                    else
                    {
                        gun = (s_Gun + 30) - d_Gun;
                        s_Ay--;
                    }
                    if (d_Ay <= s_Ay)
                    {
                        ay = s_Ay - d_Ay;
                    }
                    else
                    {
                        ay = (s_Ay + 12) - d_Ay;
                        s_Yil--;
                    }

                    yil = s_Yil - d_Yil;

                    toplam_Ay = (yil * 12) + ay;

                    toplam_Gun = (toplam_Ay * 30) + gun;

                    toplam_Saat = toplam_Gun * 24;

                    MessageBox.Show("Sen Doğalı " + yil + " Yıl " + ay + " Ay " + gun + " Gün Oldu...\nSen Doğalı Toplam " + toplam_Ay + " Ay Oldu...\nSen Doğalı Toplam " + toplam_Gun + " Gün Oldu...\nSen Doğalı Toplam " + toplam_Saat + " Saat Oldu...", "Sonuç", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    textBox1.Clear();
                    textBox2.Clear();
                    textBox3.Clear();
                    textBox1.Focus();
                }
                else
                {
                    MessageBox.Show("Hatalı Giriş Yaptınız Lütfen Kontrol Ediniz!!!", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                textBox1.Focus();
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (textBox1.Text.Length == 2) textBox2.Focus();
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            if (textBox2.Text.Length == 2) textBox3.Focus();
        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {
            if (textBox3.Text.Length == 4) button1.Focus();
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://csharp-uygulamalari.blogspot.com/");
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            label6.Text = label6.Text.Substring(1) + label6.Text.Substring(0, 1);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            label6.Text = " Hazırlayan  Fikri  KOCAOĞLAN  ";
        }
    }
}

Paylaş:

Popüler

Son

Kategoriler