13 Mart 2015 Cuma

ER(Entity - Relationship) Varlık - İlişki, Veritabanı Dersi

SORU: XYZ toptancısı sipariş üzerine Türkiye' nin çeşitli yerlerine mal göndermektedir. Gönderme işlemi hava, kara, deniz ve demir yolları ile sağlanmaktadır. XYZ toptancısı müşterilerine ait bilgileri ve hesapları kayıt altına almaktadır. XYZ toptancısının çalışanlarının iletişim ve kişisel bilgilerinin bulunduğu ER şemasını çiziniz...



Paylaş:

8 Mart 2015 Pazar

6 Mart 2015 Cuma

C# Direnç Renk Kodu Okuma Kodları



















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 direnc_renk_kodu
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
         
            textBox1.TextChanged += new EventHandler(hesapla);
            textBox2.TextChanged += new EventHandler(hesapla);
            textBox3.TextChanged += new EventHandler(hesapla);

            textBox46.TextChanged += new EventHandler(hesapla1);
            textBox47.TextChanged += new EventHandler(hesapla1);
            textBox48.TextChanged += new EventHandler(hesapla1);
            textBox49.TextChanged += new EventHandler(hesapla1);
        }

        private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox4.Text)
            {

                case "Altın": pictureBox4.BackColor = System.Drawing.Color.Gold; textBox3.Text = "0,1"; break;
                case "Gümüş": pictureBox4.BackColor = System.Drawing.Color.Silver; textBox3.Text = "0,01"; break;
                case "Siyah": pictureBox4.BackColor = System.Drawing.Color.Black; textBox3.Text = "1"; break;
                case "K.Rengi": pictureBox4.BackColor = System.Drawing.Color.Brown; textBox3.Text = "10"; break;
                case "Kırmızı": pictureBox4.BackColor = System.Drawing.Color.Red; textBox3.Text = "100"; break;
                case "Turuncu": pictureBox4.BackColor = System.Drawing.Color.Orange; textBox3.Text = "1000"; break;
                case "Sarı": pictureBox4.BackColor = System.Drawing.Color.Yellow; textBox3.Text = "10000"; break;
                case "Yeşil": pictureBox4.BackColor = System.Drawing.Color.Green; textBox3.Text = "100000"; break;
                case "Mavi": pictureBox4.BackColor = System.Drawing.Color.Blue; textBox3.Text = "1000000"; break;


            }
        }
        private void hesapla1(object sender, EventArgs e)
        {
            if (textBox46.Text != "" && textBox47.Text != "" && textBox48.Text != "" && textBox49.Text != "")
            {

                textBox42.Text = Convert.ToString(Convert.ToDecimal(textBox48.Text + textBox47.Text + textBox49.Text) * Convert.ToDecimal(textBox46.Text));
            }

        }

        private void hesapla(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "")
            {

                textBox7.Text = Convert.ToString(Convert.ToDecimal(textBox1.Text + textBox2.Text) * Convert.ToDecimal(textBox3.Text));
            }

        }

        private void textBox7_TextChanged(object sender, EventArgs e)
        {
            textBox6.Text = Convert.ToString(Convert.ToDecimal(textBox7.Text) / 1000);
            textBox5.Text = Convert.ToString(Convert.ToDecimal(textBox7.Text) / 1000000);
            textBox4.Text = Convert.ToString(Convert.ToDecimal(textBox7.Text) / 1000000000);
            textBox8.Text = Convert.ToString(Convert.ToDecimal(textBox7.Text) * 1000);
            textBox9.Text = Convert.ToString(Convert.ToDecimal(textBox7.Text) * 1000000);
            textBox10.Text = Convert.ToString(Convert.ToDecimal(textBox7.Text) * 1000000000);
            textBox11.Text = Convert.ToString(Convert.ToDecimal(textBox7.Text) * 1000000000000);
        }

        private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox3.Text)
            {

                case "Altın": pictureBox5.BackColor = System.Drawing.Color.Gold; textBox12.Text = "± %5 Tolerans"; break;
                case "Gümüş": pictureBox5.BackColor = System.Drawing.Color.Silver; textBox12.Text = "± %10 Tolerans"; break;
                case "K.Rengi": pictureBox5.BackColor = System.Drawing.Color.Brown; textBox12.Text = "± %1 Tolerans"; break;
                case "Kırmızı": pictureBox5.BackColor = System.Drawing.Color.Red; textBox12.Text = "± %2 Tolerans"; break;


                case "Yeşil": pictureBox5.BackColor = System.Drawing.Color.Green; textBox12.Text = "± %0,5 Tolerans"; break;
                case "Mavi": pictureBox5.BackColor = System.Drawing.Color.Blue; textBox12.Text = "± %0,25 Tolerans"; break;
                case "Gri": pictureBox5.BackColor = System.Drawing.Color.Gray; textBox12.Text = "± %0,05 Tolerans"; break;
                case "Mor": pictureBox5.BackColor = System.Drawing.Color.Purple; textBox12.Text = "± %0,1 Tolerans"; break;
                case "Renksiz": pictureBox4.BackColor = System.Drawing.Color.Transparent; textBox12.Text = "± %20 Tolerans"; break;


            }
        }

        private void comboBox16_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox16.Text)
            {
                case "Siyah": pictureBox20.BackColor = System.Drawing.Color.Black; textBox48.Text = "0"; break;
                case "K.rengi": pictureBox20.BackColor = System.Drawing.Color.Brown; textBox48.Text = "1"; break;
                case "Kırmızı": pictureBox20.BackColor = System.Drawing.Color.Red; textBox48.Text = "2"; break;
                case "Turuncu": pictureBox20.BackColor = System.Drawing.Color.Orange; textBox48.Text = "3"; break;
                case "Sarı": pictureBox20.BackColor = System.Drawing.Color.Yellow; textBox48.Text = "4"; break;
                case "Yeşil": pictureBox20.BackColor = System.Drawing.Color.Green; textBox48.Text = "5"; break;
                case "Mavi": pictureBox20.BackColor = System.Drawing.Color.Blue; textBox48.Text = "6"; break;
                case "Mor": pictureBox20.BackColor = System.Drawing.Color.Purple; textBox48.Text = "7"; break;
                case "Gri": pictureBox20.BackColor = System.Drawing.Color.Gray; textBox48.Text = "8"; break;
                case "Beyaz": pictureBox20.BackColor = System.Drawing.Color.White; textBox48.Text = "9"; break;

            }
        }

        private void comboBox15_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox15.Text)
            {
                case "Siyah": pictureBox17.BackColor = System.Drawing.Color.Black; textBox47.Text = "0"; break;
                case "K.rengi": pictureBox17.BackColor = System.Drawing.Color.Brown; textBox47.Text = "1"; break;
                case "Kırmızı": pictureBox17.BackColor = System.Drawing.Color.Red; textBox47.Text = "2"; break;
                case "Turuncu": pictureBox17.BackColor = System.Drawing.Color.Orange; textBox47.Text = "3"; break;
                case "Sarı": pictureBox17.BackColor = System.Drawing.Color.Yellow; textBox47.Text = "4"; break;
                case "Yeşil": pictureBox17.BackColor = System.Drawing.Color.Green; textBox47.Text = "5"; break;
                case "Mavi": pictureBox17.BackColor = System.Drawing.Color.Blue; textBox47.Text = "6"; break;
                case "Mor": pictureBox17.BackColor = System.Drawing.Color.Purple; textBox47.Text = "7"; break;
                case "Gri": pictureBox17.BackColor = System.Drawing.Color.Gray; textBox47.Text = "8"; break;
                case "Beyaz": pictureBox17.BackColor = System.Drawing.Color.White; textBox47.Text = "9"; break;

            }
        }

        private void comboBox17_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox17.Text)
            {
                case "Siyah": pictureBox19.BackColor = System.Drawing.Color.Black; textBox49.Text = "0"; break;
                case "K.rengi": pictureBox19.BackColor = System.Drawing.Color.Brown; textBox49.Text = "1"; break;
                case "Kırmızı": pictureBox19.BackColor = System.Drawing.Color.Red; textBox49.Text = "2"; break;
                case "Turuncu": pictureBox19.BackColor = System.Drawing.Color.Orange; textBox49.Text = "3"; break;
                case "Sarı": pictureBox19.BackColor = System.Drawing.Color.Yellow; textBox49.Text = "4"; break;
                case "Yeşil": pictureBox19.BackColor = System.Drawing.Color.Green; textBox49.Text = "5"; break;
                case "Mavi": pictureBox19.BackColor = System.Drawing.Color.Blue; textBox49.Text = "6"; break;
                case "Mor": pictureBox19.BackColor = System.Drawing.Color.Purple; textBox49.Text = "7"; break;
                case "Gri": pictureBox19.BackColor = System.Drawing.Color.Gray; textBox49.Text = "8"; break;
                case "Beyaz": pictureBox19.BackColor = System.Drawing.Color.White; textBox49.Text = "9"; break;

            }
        }

        private void comboBox14_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox14.Text)
            {

                case "Altın": pictureBox21.BackColor = System.Drawing.Color.Gold; textBox46.Text = "0,1"; break;
                case "Gümüş": pictureBox21.BackColor = System.Drawing.Color.Silver; textBox46.Text = "0,01"; break;
                case "Siyah": pictureBox21.BackColor = System.Drawing.Color.Black; textBox46.Text = "1"; break;
                case "K.Rengi": pictureBox21.BackColor = System.Drawing.Color.Brown; textBox46.Text = "10"; break;
                case "Kırmızı": pictureBox21.BackColor = System.Drawing.Color.Red; textBox46.Text = "100"; break;
                case "Turuncu": pictureBox21.BackColor = System.Drawing.Color.Orange; textBox46.Text = "1000"; break;
                case "Sarı": pictureBox21.BackColor = System.Drawing.Color.Yellow; textBox46.Text = "10000"; break;
                case "Yeşil": pictureBox21.BackColor = System.Drawing.Color.Green; textBox46.Text = "100000"; break;
                case "Mavi": pictureBox21.BackColor = System.Drawing.Color.Blue; textBox46.Text = "1000000"; break;


            }
        }

        private void comboBox13_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox13.Text)
            {

                case "Altın": pictureBox18.BackColor = System.Drawing.Color.Gold; textBox37.Text = "± %5 Tolerans"; break;
                case "Gümüş": pictureBox18.BackColor = System.Drawing.Color.Silver; textBox37.Text = "± %10 Tolerans"; break;
                case "K.Rengi": pictureBox18.BackColor = System.Drawing.Color.Brown; textBox37.Text = "± %1 Tolerans"; break;
                case "Kırmızı": pictureBox18.BackColor = System.Drawing.Color.Red; textBox37.Text = "± %2 Tolerans"; break;


                case "Yeşil": pictureBox18.BackColor = System.Drawing.Color.Green; textBox37.Text = "± %0,5 Tolerans"; break;
                case "Mavi": pictureBox18.BackColor = System.Drawing.Color.Blue; textBox37.Text = "± %0,25 Tolerans"; break;
                case "Gri": pictureBox18.BackColor = System.Drawing.Color.Gray; textBox37.Text = "± %0,05 Tolerans"; break;
                case "Mor": pictureBox18.BackColor = System.Drawing.Color.Purple; textBox37.Text = "± %0,1 Tolerans"; break;
                case "Renksiz": pictureBox18.BackColor = System.Drawing.Color.Transparent; textBox37.Text = "± %20 Tolerans"; break;


            }
        }

        private void textBox42_TextChanged(object sender, EventArgs e)
        {
            textBox43.Text = Convert.ToString(Convert.ToDecimal(textBox42.Text) / 1000);
            textBox44.Text = Convert.ToString(Convert.ToDecimal(textBox42.Text) / 1000000);
            textBox45.Text = Convert.ToString(Convert.ToDecimal(textBox42.Text) / 1000000000);
            textBox41.Text = Convert.ToString(Convert.ToDecimal(textBox42.Text) * 1000);
            textBox40.Text = Convert.ToString(Convert.ToDecimal(textBox42.Text) * 1000000);
            textBox39.Text = Convert.ToString(Convert.ToDecimal(textBox42.Text) * 1000000000);
            textBox38.Text = Convert.ToString(Convert.ToDecimal(textBox42.Text) * 1000000000000);
        }

        private void comboBox1_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            switch (comboBox1.Text)
            {
                case "Siyah": pictureBox2.BackColor = System.Drawing.Color.Black; textBox1.Text = "0"; break;
                case "K.rengi": pictureBox2.BackColor = System.Drawing.Color.Brown; textBox1.Text = "1"; break;
                case "Kırmızı": pictureBox2.BackColor = System.Drawing.Color.Red; textBox1.Text = "2"; break;
                case "Turuncu": pictureBox2.BackColor = System.Drawing.Color.Orange; textBox1.Text = "3"; break;
                case "Sarı": pictureBox2.BackColor = System.Drawing.Color.Yellow; textBox1.Text = "4"; break;
                case "Yeşil": pictureBox2.BackColor = System.Drawing.Color.Green; textBox1.Text = "5"; break;
                case "Mavi": pictureBox2.BackColor = System.Drawing.Color.Blue; textBox1.Text = "6"; break;
                case "Mor": pictureBox2.BackColor = System.Drawing.Color.Purple; textBox1.Text = "7"; break;
                case "Gri": pictureBox2.BackColor = System.Drawing.Color.Gray; textBox1.Text = "8"; break;
                case "Beyaz": pictureBox2.BackColor = System.Drawing.Color.White; textBox1.Text = "9"; break;

            }
        }

        private void comboBox2_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            switch (comboBox2.Text)
            {
                case "Siyah": pictureBox3.BackColor = System.Drawing.Color.Black; textBox2.Text = "0"; break;
                case "K.rengi": pictureBox3.BackColor = System.Drawing.Color.Brown; textBox2.Text = "1"; break;
                case "Kırmızı": pictureBox3.BackColor = System.Drawing.Color.Red; textBox2.Text = "2"; break;
                case "Turuncu": pictureBox3.BackColor = System.Drawing.Color.Orange; textBox2.Text = "3"; break;
                case "Sarı": pictureBox3.BackColor = System.Drawing.Color.Yellow; textBox2.Text = "4"; break;
                case "Yeşil": pictureBox3.BackColor = System.Drawing.Color.Green; textBox2.Text = "5"; break;
                case "Mavi": pictureBox3.BackColor = System.Drawing.Color.Blue; textBox2.Text = "6"; break;
                case "Mor": pictureBox3.BackColor = System.Drawing.Color.Purple; textBox2.Text = "7"; break;
                case "Gri": pictureBox3.BackColor = System.Drawing.Color.Gray; textBox2.Text = "8"; break;
                case "Beyaz": pictureBox3.BackColor = System.Drawing.Color.White; textBox2.Text = "9"; break;

            }
        }

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


Paylaş:

5 Mart 2015 Perşembe

C# İnchi Santimetreye - Santimetreyi İnche Çeviren Program Kodları
















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 inch_santimetre
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        double inch, cm;
        private void button1_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked == true)
            {
                double.TryParse(textBox1.Text,out inch);
                cm = inch * 2.54;
                label2.Text =inch + " İnch " + cm.ToString() + " Santimetre Eder.";
            }
            else if (radioButton2.Checked == true)
            {
                double.TryParse(textBox1.Text, out cm);
                inch = cm / 2.54;
                label2.Text = cm + " Santimetre " + inch.ToString() + " İnch Eder.";
            }
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            label1.Text = "İnch";
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            label1.Text = "Santimetre";
        }
    }
}

Paylaş:

C# Vize ve Final Notu Hesaplama Form Application






















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 vize_final_not_hesaplama
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        double vize, final, final2, ort;
        private void button1_Click(object sender, EventArgs e)
        {          
            double.TryParse(textBox1.Text, out vize);
            double.TryParse(textBox2.Text, out final);
            if (vize < 0)
            {
                vize = 0;
                textBox1.Text = "0";
            }
            if (final < 0)
            {
                final = 0;
                textBox2.Text = "0";
            }
            if (vize > 100)
            {
                vize = 100;
                textBox1.Text = "100";
            }
            if (final > 100)
            {
                final = 100;
                textBox2.Text = "100";
            }

            vize = vize * 4 / 10;
            final2 = final * 6 / 10;
            ort = vize + final2;

            if (final < 50)
            {
                label3.Text="Ortalamanız: " + ort + " Harf Notunuz: FF";
                label3.ForeColor = Color.Red;
                MessageBox.Show("Final Sınavından 50 Barajını Geçemediğiniz İçin Kaldınız!!!","KALDINIZ!!!");
            }
            else
            {
                if (ort >= 90 && ort <= 100)
                {
                    label3.Text="Ortalamanız: " + ort + " Harf Notunuz: AA";
                    label3.ForeColor = Color.Green;
                }
                else if (ort >= 80 && ort < 90)
                {
                    label3.Text="Ortalamanız: " + ort + " Harf Notunuz: BA";
                    label3.ForeColor = Color.Black;
                }
                else if (ort >= 70 && ort < 80)
                {
                    label3.Text="Ortalamanız: " + ort + " Harf Notunuz: BB";
                    label3.ForeColor = Color.Black;
                }
                else if (ort >= 60 && ort < 70)
                {
                    label3.Text="Ortalamanız: " + ort + " Harf Notunuz: CB";
                    label3.ForeColor = Color.Black;
                }
                else if (ort >= 50 && ort < 60)
                {
                    label3.Text="Ortalamanız: " + ort + " Harf Notunuz: CC";
                    label3.ForeColor = Color.Black;
                }
                else if (ort >= 45 && ort < 50)
                {
                    label3.Text="Ortalamanız: " + ort + " Harf Notunuz: DD";
                    label3.ForeColor = Color.Black;
                }
                else if (ort >= 0 && ort < 45)
                {
                    label3.Text="Ortalamanız: " + ort + " Harf Notunuz: FF";
                    label3.ForeColor = Color.Red;
                }
            }
        }
    }
}

Paylaş:

C# Vize ve Final Ortalaması Hesaplama Console Application

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace vize_ve_final_not_hesabı
{
    class Program
    {
        static void Main(string[] args)
        {

            double vize, final, final2, ort;
            Console.Write("Vize Notunuzu Giriniz: ");
            double.TryParse(Console.ReadLine(), out vize);
            Console.Write("Final Notunuzu Giriniz: ");
            double.TryParse(Console.ReadLine(), out final);
            if (vize < 0)
            {
                vize = 0;
            }
            if (final < 0)
            {
                final = 0;
            }
            if (vize > 100)
            {
                vize = 100;
            }
            if (final > 100)
            {
                final = 100;
            }
            vize = vize * 4 / 10;
            final2 = final * 6 / 10;
            ort = vize + final2;

            if (final < 50)
            {
                Console.Write("\nOrtalamanız: " + ort + " Harf Notunuz: FF");
                Console.Write("\nFinal Sınavından 50 Barajını Geçemediğiniz İçin Kaldınız!!!");
            }
            else
            {
                if (ort >= 90 && ort <= 100)
                {
                    Console.Write("\nOrtalamanız: " + ort + " Harf Notunuz: AA");
                }
                else if (ort >= 80 && ort < 90)
                {
                    Console.Write("\nOrtalamanız: " + ort + " Harf Notunuz: BA");
                }
                else if (ort >= 70 && ort < 80)
                {
                    Console.Write("\nOrtalamanız: " + ort + " Harf Notunuz: BB");
                }
                else if (ort >= 60 && ort < 70)
                {
                    Console.Write("\nOrtalamanız: " + ort + " Harf Notunuz: CB");
                }
                else if (ort >= 50 && ort < 60)
                {
                    Console.Write("\nOrtalamanız: " + ort + " Harf Notunuz: CC");
                }
                else if (ort >= 45 && ort < 50)
                {
                    Console.Write("\nOrtalamanız: " + ort + " Harf Notunuz: DD");
                }
                else if (ort >= 0 && ort < 45)
                {
                    Console.Write("\nOrtalamanız: " + ort + " Harf Notunuz: FF");
                }
            }
            Console.ReadKey();
        }
    }
}

Paylaş:

3 Mart 2015 Salı

C# ta Alarm Yapma Kodları



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;
using System.IO;



namespace Alarm
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
     
        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Start();
         
        }
        int sayac=0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            int saat, dk;
            saat = System.DateTime.Now.Hour;
            dk = System.DateTime.Now.Minute;
            if (saat.ToString() == textBox1.Text && dk.ToString() == textBox2.Text)
            {
                timer3.Start();
                this.Show();
             
            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            label3.Text = System.DateTime.Now.ToLongTimeString();
            int saatt = Convert.ToInt32(textBox1.Text);
            int dkk = Convert.ToInt32(textBox2.Text);
            if (saatt >= 24)
            {
                textBox1.Text = "0";
            }
            if (saatt < 0)
            {
                textBox1.Text = "23";
            }
            if (dkk > 59)
            {
                textBox2.Text = "0";
            }
            if (dkk < 0)
            {
                textBox2.Text = "59";
            }
        }
     
        private void label4_Click(object sender, EventArgs e)
        {
            try
            {
                int saatt = Convert.ToInt32(textBox1.Text);
                saatt++;
                textBox1.Text = saatt.ToString();
            }
            catch
            {
                textBox1.Text = "0";
                int saatt = Convert.ToInt32(textBox1.Text);
                saatt++;
                textBox1.Text = saatt.ToString();
            }
        }

        private void label6_Click(object sender, EventArgs e)
        {
            try
            {
                int saatt = Convert.ToInt32(textBox2.Text);
                saatt++;
                textBox2.Text = saatt.ToString();
            }
            catch
            {
                textBox2.Text = "0";
                int saatt = Convert.ToInt32(textBox2.Text);
                saatt++;
                textBox2.Text = saatt.ToString();
            }
        }

        private void label5_Click(object sender, EventArgs e)
        {
            try
            {
                int saatt = Convert.ToInt32(textBox1.Text);
                saatt--;
                textBox1.Text = saatt.ToString();
            }
            catch
            {
                textBox1.Text = "0";
                int saatt = Convert.ToInt32(textBox1.Text);
                saatt++;
                textBox1.Text = saatt.ToString();
            }
        }

        private void label7_Click(object sender, EventArgs e)
        {
            try
            {
                int saatt = Convert.ToInt32(textBox2.Text);
                saatt--;
                textBox2.Text = saatt.ToString();
            }
            catch
            {
                textBox2.Text = "0";
                int saatt = Convert.ToInt32(textBox2.Text);
                saatt++;
                textBox2.Text = saatt.ToString();
            }
        }

        private void timer3_Tick(object sender, EventArgs e)
        {
            try
            {
                StreamReader oku = new StreamReader("C:\\alarm\\yol.txt", true);
                gelenyol = oku.ReadLine();
                oku.Close();
            }
            catch
            {
                StreamWriter SW;
                //dosyayı olustur
                SW = File.CreateText("C:\\alarm\\yol.txt");
                SW.Close();
            }

            if (gelenyol != null)
            {
                timer4.Start();
            }
            else
            {
                System.Media.SystemSounds.Asterisk.Play();
            }
            sayac++;
            if (sayac >= 60)
            {
                timer3.Stop();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
        }
        string gelenyol;
        string dosyaadi;
        private void button3_Click(object sender, EventArgs e)
        {
            StreamWriter SW;
            //dosyayı olustur
            SW = File.CreateText("C:\\alarm\\yol.txt");
            SW.Close();
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                 dosyaadi = openFileDialog1.FileName.ToString();
                string yol = Path.GetFullPath(dosyaadi);
            }
         
            try
            {
                StreamReader oku = new StreamReader("C:\\alarm\\yol.txt", true);
                gelenyol = oku.ReadLine();
                oku.Close();
                StreamWriter txtyaz = new StreamWriter("C:\\alarm\\yol.txt", true);
                txtyaz.WriteLine(dosyaadi);
                txtyaz.Close();
             
            }
            catch
            {

                string path = @"c:\alarm\"; // or whatever
                if (!Directory.Exists(path))
                {
                    DirectoryInfo di = Directory.CreateDirectory(path);
                    di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;
                }
                StreamWriter SW1;
                //dosyayı olustur
                SW1 = File.CreateText("C:\\alarm\\yol.txt");
                SW1.Close();

                StreamWriter txtyaz = new StreamWriter("C:\\alarm\\yol.txt", true);
                txtyaz.WriteLine(dosyaadi);
                txtyaz.Close();
            }


        }

        int say = 0;
        private void timer4_Tick(object sender, EventArgs e)
        {

            if (say == 1)
            {
                timer4.Interval = 100000;
            }
            axWindowsMediaPlayer1.URL = gelenyol;
            if (say == 2)
            {
                timer4.Stop();
                axWindowsMediaPlayer1.Ctlcontrols.stop();
            }
                say++;
        }
    }
}



















Paylaş:

2 Mart 2015 Pazartesi

Kuyu Problemi Algoritması ve C# Kodu

Soru: Bir Kömür Kuyusu 9.80 metredir. En dipte Kepçeye 2586 kg kömür yüklenmektedir. Kepçe yukarı çekilirken her 40 metrede 58 kg kömür dökülmektedir. Kepçe yukarı çıktığında Kaç kg kömür kalır?

1. Başla


2. yukseklik = 980; //cm
    kg = 2586;
    dokulenyukseklik = 4000; //cm
    sonuc = 0;
    bolum = 0;

3. bolum = yukseklik / dokulenyukseklik;

4. sonuc = kg - bolum;

5. sonuc 'u ekrana yazdır.

6. Bitir




C# Kodları

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 komur_kuyusu
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        double yukseklik = 980;//cm hesabı
        double kg = 2586;
        int dokulenyukseklik = 4000;//cm hesabı
        double sonuc = 0, bolum = 0;

        private void button1_Click(object sender, EventArgs e)
        {
            bolum=yukseklik/dokulenyukseklik;
            sonuc = kg - bolum;
            MessageBox.Show("Kepçe Yüzeye Çıktığında "+ sonuc +" Kg Kalır.");
        }
    }

}

Paylaş:

1 Mart 2015 Pazar

C# Mac Adresi Öğrenme












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;
using System.Management;

namespace mac
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //Not: Öncelikle Reference den System.Managament i Ekliyoruz...

        private void Form1_Load(object sender, EventArgs e)
        {

        }
        static string Mac()
        {
            ManagementClass manager = new ManagementClass("Win32_NetworkAdapterConfiguration");
            foreach (ManagementObject obj in manager.GetInstances())
            {
                if ((bool)obj["IPEnabled"])
                {
                    return obj["MacAddress"].ToString();
                }
            }

            return String.Empty;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string mac = Mac();

            if (String.IsNullOrEmpty(mac))
            {
                label1.Text="Biglisayarınızda bir ağ bağdaştırıcısı bulunamadı.";
                label1.ForeColor=Color.Red;
             
            }
            else
            {
                label1.Text="Mac adresiniz=" + mac;
                label1.ForeColor=Color.Green;
            }
         
        }
    }
}
Paylaş:

Popüler

Son

Kategoriler