adam4545 Posted March 13, 2012 Share Posted March 13, 2012 (edited) Arkadaşlar c# da dosyaya daha önce yazılan ve yazım formatı kullanıcıadı#sifre seklinde olup bunu split('#') fonksiyonuyla ayırıp sonra kullanıcı girişi yapmak istiyorum kodlar aşağıda yardım edermisiniz. 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 kullanicigirisi { public partial class Form1 : Form { public Form1() { InitializeComponent(); } FileStream fs; StreamReader sr; private void label2_Click(object sender, EventArgs e) { } private void girisyap_buton_Click(object sender, EventArgs e) { // int satirSayisi = System.IO.File.ReadAllText("sifreler.txt").Split(new char[] { '\n' }).Length; string kullanici_adi = "k_aditx"; string sifre = "k_sifretx"; fs = new FileStream(".\\sifreler.txt", FileMode.Open, FileAccess.Read); sr = new StreamReader(fs); string yazilar = sr.ReadToEnd(); string[] sifreler = yazilar.Split('#'); string kullanıcı_adi2 = sifreler[0]; string sifre2 = sifreler[1]; sr.Close(); fs.Close(); if (kullanici_adi==kullanıcı_adi2 && sifre==sifre2) { admin form = new admin(); form.Show(); this.Hide(); } else { MessageBox.Show("Kullanıcı Adı veya Şifre Yanlış", "Hata!"); } } private void cikis_buton_Click(object sender, EventArgs e) { this.Close(); } } } Edited March 13, 2012 by adam4545 Quote Link to comment Share on other sites More sharing options...
adam4545 Posted March 13, 2012 Author Share Posted March 13, 2012 (edited) 32 kişi okumuş yok mu yardım edecek biri bu aşkşam 23:59 ödevi göndermem lazım hocaya sonra sistem dosya alımını kapatıyor form düzenide aşağıdaki gibi [img]http://www.tnctr.com/uploads/imgs/pre_1331666575__ef.png[/img] Edited March 13, 2012 by adam4545 Quote Link to comment Share on other sites More sharing options...
cumman Posted March 13, 2012 Share Posted March 13, 2012 string kullanici_adi = textBox1.Text; string sifre = textBox2.Text; fs = new FileStream(".\\sifreler.txt", FileMode.Open, FileAccess.Read); sr = new StreamReader(fs); string yazilar = sr.ReadToEnd(); string[] sifreler = yazilar.Split('#'); string kullanıcı_adi2 = sifreler[0]; string sifre2 = sifreler[1]; sr.Close(); fs.Close(); if (kullanici_adi == kullanıcı_adi2 && sifre == sifre2) { admin form = new admin(); form.Show(); this.Hide(); }texboxtan aldigin verileri text dosyasi icerigiyle karsilastir eger esitse yeni pencere ac. tek degisiklik textboxtaki verileri almak gerisi dogru Quote Link to comment Share on other sites More sharing options...
artal73 Posted March 13, 2012 Share Posted March 13, 2012 (edited) Giriş butonunun click eventine aşağıdaki kodları ekleyin. string kullanici_adi = textBox1.Text; string sifre = textBox2.Text; fs = new FileStream("sifreler.txt", FileMode.Open, FileAccess.Read); sr = new StreamReader(fs); string yazilar = sr.ReadToEnd(); string[] sifreler = yazilar.Split('#'); string kullanıcı_adi2 = sifreler[0]; string sifre2 = sifreler[1]; sr.Close(); fs.Close(); if (kullanici_adi==kullanıcı_adi2&&sifre==sifre2) MessageBox.Show("Hoş geldiniz"); else MessageBox.Show("Kullanıcı adı yada şifre hatalı"); .................................................................................NOT........................................ [b]K.adi [/b]textbox'ının "name özelliği : [b]textBox1[/b] [b] [/b] [b]şifre[/b] textbox'ının "name özelliği : [b]textBox2[/b], [b]Giriş[/b] butonunun "name özelliği : [b]button1[/b] olmalı Edited March 13, 2012 by artal73 Quote Link to comment Share on other sites More sharing options...
adam4545 Posted March 13, 2012 Author Share Posted March 13, 2012 (edited) [quote name='artal73' date='13 March 2012 - 20:30 ' timestamp='1331670630' post='1169153'] Giriş butonunun click eventine aşağıdaki kodları ekleyin. string kullanici_adi = textBox1.Text; string sifre = textBox2.Text; fs = new FileStream("sifreler.txt", FileMode.Open, FileAccess.Read); sr = new StreamReader(fs); string yazilar = sr.ReadToEnd(); string[] sifreler = yazilar.Split('#'); string kullanıcı_adi2 = sifreler[0]; string sifre2 = sifreler[1]; sr.Close(); fs.Close(); if (kullanici_adi==kullanıcı_adi2&&sifre==sifre2) MessageBox.Show("Hoş geldiniz"); else MessageBox.Show("Kullanıcı adı yada şifre hatalı"); .................................................................................NOT........................................ [b]K.adi [/b]textbox'ının "name özelliği : [b]textBox1[/b] [b] [/b] [b]şifre[/b] textbox'ının "name özelliği : [b]textBox2[/b], [b]Giriş[/b] butonunun "name özelliği : [b]button1[/b] olmalı [/quote] hocam ilgin için teşekkürlerde dosyadaki kayıt sisemi su şekilde kullanıcı1#sifre1 kullanıcı2#sifre2 kullanıcı3#sifre3 kullanıcı4#sifre4 kullanıcı5#sifre5 ilk satırı okuyor onu yaptım onda sorun yok ama sanırım döngüyle satır satır okutup giriş yapmayı denemeli ve tüm satırlar bitince else kısmına gidip şifre hatalı mesajı vermesini bekliyorum ama çok denedim dongüyü nasıl nereye yazacağımı çözemedim Edited March 13, 2012 by adam4545 Quote Link to comment Share on other sites More sharing options...
soulless_body Posted March 13, 2012 Share Posted March 13, 2012 arkadaşım şu şekilde denermisin [code]using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string parola = "deneme"; string kullanıcıadı = "mcfalsi"; if (TextBox2.Text== kullanıcıadı) if (TextBox1.Text == parola) { Response.Redirect("http://www.tnctr.com"); } else { Response.Write("Kullanıcı adı veya parolanız yanlış"); } else Response.Write("Kullanıcı adı yanlış"); } } [/code] Quote Link to comment Share on other sites More sharing options...
adam4545 Posted March 13, 2012 Author Share Posted March 13, 2012 [quote name='Mcfalsi' date='13 March 2012 - 20:56 ' timestamp='1331672207' post='1169174'] arkadaşım şu şekilde denermisin [code]using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string parola = "deneme"; string kullanıcıadı = "mcfalsi"; if (TextBox2.Text== kullanıcıadı) if (TextBox1.Text == parola) { Response.Redirect("http://www.tnctr.com"); } else { Response.Write("Kullanıcı adı veya parolanız yanlış"); } else Response.Write("Kullanıcı adı yanlış"); } } [/code] [/quote] hocam projenin ilk örneği o şekildeydi zaten sonra dosyadan okuma şekline geçtik sonraki haftada da acces veri tabanından çekip kontrol edecek kullanıcı adı ve şifreyi yinede eline sağlık hocam Quote Link to comment Share on other sites More sharing options...
cumman Posted March 13, 2012 Share Posted March 13, 2012 [code]fs = new FileStream(".\\sifreler.txt", FileMode.Open, FileAccess.Read); // sr = new StreamReader(fs); using (StreamReader sr = new StreamReader(fs)) { while (sr.Peek() >= 0) { string yazilar = sr.ReadLine(); string[] sifreler = yazilar.Split('#'); string kullanıcı_adi2 = sifreler[0]; string sifre2 = sifreler[1]; if (kullanici_adi == kullanıcı_adi2 && sifre == sifre2) { admin form = new admin(); form.Show(); this.Hide(); } } }[/code] satir satir boyle okutacaksin Quote Link to comment Share on other sites More sharing options...
adam4545 Posted March 13, 2012 Author Share Posted March 13, 2012 [quote name='cumman' date='13 March 2012 - 21:06 ' timestamp='1331672803' post='1169185'] [code]fs = new FileStream(".\\sifreler.txt", FileMode.Open, FileAccess.Read); // sr = new StreamReader(fs); using (StreamReader sr = new StreamReader(fs)) { while (sr.Peek() >= 0) { string yazilar = sr.ReadLine(); string[] sifreler = yazilar.Split('#'); string kullanıcı_adi2 = sifreler[0]; string sifre2 = sifreler[1]; if (kullanici_adi == kullanıcı_adi2 && sifre == sifre2) { admin form = new admin(); form.Show(); this.Hide(); } } }[/code] satir satir boyle okutacaksin [/quote] oldu hocam eline sağlık Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.