예제 #1
0
        //Form Load
        private void GirisEkrani_Load(object sender, EventArgs e)
        {
            axCIDv51.Start();
            //Properties.Settings.Default.Reset();
            if (Properties.Settings.Default.FirmaAdi.Trim() == "")
            {
                SifreVeFirmaAdiFormu firmaAdiFormu = new SifreVeFirmaAdiFormu(true);
                firmaAdiFormu.ShowDialog();

                if (firmaAdiFormu.DialogResult == DialogResult.No)
                {
                    System.Windows.Forms.Application.Exit();
                    return;
                }
            }

            try
            {
                gecenSure = Properties.Settings.Default.Port2;

                DateTime x = new DateTime();
                if (gecenSure != -1)
                {
                    if ((DateTime.Now >= Properties.Settings.Default.IP2.AddDays(30) && Properties.Settings.Default.IP2 > x.AddDays(1)) || DateTime.Now < Properties.Settings.Default.IP2 || gecenSure >= 43200)
                    {
                        Properties.Settings.Default.IP2Check.RemoveAt(0);
                        Properties.Settings.Default.Port2 = -1;
                        Properties.Settings.Default.IP2 = default(DateTime);
                        Properties.Settings.Default.Save();
                    }
                }
            }
            catch
            { }

            string sifre = PasswordHash.CreateHash("warkilla");
            bool sifreKaldi = false;

            if (Properties.Settings.Default.IP2Check != null)
            {
                for (int i = 0; i < Properties.Settings.Default.IP2Check.Count; i++)
                {
                    if (Properties.Settings.Default.IP2Check[i] != null && Properties.Settings.Default.IP2Check[i] != "")
                    {
                        sifre = Properties.Settings.Default.IP2Check[i];
                        sifreKaldi = true;
                        break;
                    }
                    else
                    {
                        Properties.Settings.Default.IP2Check.RemoveAt(i);
                        Properties.Settings.Default.Port2 = -1;
                        Properties.Settings.Default.IP2 = default(DateTime);
                        i--;
                    }
                }
                Properties.Settings.Default.Save();
            }

            if (!sifreKaldi) // yeni şifre gönder
            {
                yeniSifreYaratveGonder();
            }

            if (Properties.Settings.Default.IP3 != "warkilla")
            {
                if (!PasswordHash.ValidatePassword(Properties.Settings.Default.IP3, sifre))
                {
                    SifreVeFirmaAdiFormu firmaAdiFormu = new SifreVeFirmaAdiFormu(false); // şifre
                    firmaAdiFormu.ShowDialog();

                    if (firmaAdiFormu.DialogResult == DialogResult.No)
                    {
                        System.Windows.Forms.Application.Exit();
                        return;
                    }
                    bagliKullaniciSayisiIlet();

                    Properties.Settings.Default.Port2 = 0;
                    Properties.Settings.Default.Save();
                }
            }
            else
            {
                bagliKullaniciSayisiIlet();
            }

            //SQL SERVER BAĞLANTI KONTROLÜ YAPILIYOR
            SqlConnection cnn;
            try
            {
                cnn = new SqlConnection("server=.;database=ropv1;integrated security=true");
                cnn.Open();
                cnn.Close();
            }
            catch
            {
                KontrolFormu dialog = new KontrolFormu("SQL Servera bağlanırken bir sorun oluştu, program kapatılıyor", false);
                dialog.ShowDialog();
                cnn = null;

                System.Windows.Forms.Application.Exit();
                return;
            }

            buttonConnection_Click(null, null);

            labelSaat.Text = DateTime.Now.ToString("HH:mm:ss", new CultureInfo("tr-TR"));
            timerSaat.Start();
            labelGun.Text = DateTime.Now.ToString("dddd", new CultureInfo("tr-TR"));
            labelTarih.Text = DateTime.Now.Date.ToString("d MMMM yyyy", new CultureInfo("tr-TR"));

            //açılışta capslock açıksa kapatıyoruz.
            ToggleCapsLock(false);

            //wpflerimizi oluşturduğumuz elementhostların childına atıyoruz
            userNameTextBox = new WPF_UserControls.VerticalCenterTextBox();
            usernameBoxHost.Child = userNameTextBox;
            passwordTextBox = new WPF_UserControls.VerticalCenterPasswordBox();
            passwordBoxHost.Child = passwordTextBox;
            if (File.Exists("urunler.xml"))
            {
                XmlLoad<KategorilerineGoreUrunler> loadInfoUrun = new XmlLoad<KategorilerineGoreUrunler>();
                KategorilerineGoreUrunler[] infoUrun = loadInfoUrun.LoadRestoran("urunler.xml");

                urunListesi.AddRange(infoUrun);
            }
            timer1.Start();
        }
예제 #2
0
        private void girisButtonPressed(object sender, EventArgs e)
        {
            if (adminForm == null)
            {
                if (!File.Exists("tempfiles.xml")) // ilk açılışta veya bir sıkıntı sonucu kategoriler dosyası silinirse kendi default kategorilerimizi giriyoruz.
                {
                    infoKullanici = new UItemp[1];

                    infoKullanici[0] = new UItemp();
                    infoKullanici[0].UIN = (new UnicodeEncoding()).GetBytes("Adınız");
                    infoKullanici[0].UIS = (new UnicodeEncoding()).GetBytes("Soy Adınız");
                    infoKullanici[0].UIUN = (new UnicodeEncoding()).GetBytes("admin");
                    infoKullanici[0].UIU = (new UnicodeEncoding()).GetBytes("Yönetici");

                    infoKullanici[0].UIPN = PasswordHash.CreateHash("0000");
                    infoKullanici[0].UIPW = PasswordHash.CreateHash("00000");
                    infoKullanici[0].UIY[0] = PasswordHash.CreateHash("true");
                    infoKullanici[0].UIY[1] = PasswordHash.CreateHash("true");
                    infoKullanici[0].UIY[2] = PasswordHash.CreateHash("true");
                    infoKullanici[0].UIY[3] = PasswordHash.CreateHash("true");
                    infoKullanici[0].UIY[4] = PasswordHash.CreateHash("true");

                    XmlSave.SaveRestoran(infoKullanici, "tempfiles.xml");

                    File.SetAttributes("tempfiles.xml", FileAttributes.Archive);
                }
                XmlLoad<UItemp> loadInfoKullanicilar = new XmlLoad<UItemp>();
                infoKullanici = loadInfoKullanicilar.LoadRestoran("tempfiles.xml");

                string[] username = new string[1];
                username[0] = userNameTextBox.getNameText(); //name lazım olduğunda al
                string password = passwordTextBox.getPasswordText(); //password lazım olduğunda al

                int kullaniciAdi = -5;

                if (username[0] == "ropisimiz" && password == "roproprop")
                {
                    XmlSave.SaveRestoran(username, "sonKullanici.xml");

                    try
                    {
                        Task reportTask = Task.Factory.StartNew(
                            () =>
                            {
                                adminForm = new AdminGirisFormu(this, true);
                                adminForm.ShowDialog();
                            }
                            , CancellationToken.None
                            , TaskCreationOptions.None
                            , TaskScheduler.FromCurrentSynchronizationContext()
                            );

                        reportTask.Wait();
                    }
                    catch
                    { }

                    //Task.Factory.StartNew(() => adminForm.ShowDialog());
                    //adminForm.Show();
                }
                else
                {
                    for (int i = 0; i < infoKullanici.Count(); i++)
                    {
                        if (username[0] == (new UnicodeEncoding()).GetString(infoKullanici[i].UIUN))
                        {
                            kullaniciAdi = i;
                            break;
                        }
                    }
                    if (kullaniciAdi != -5)
                    {
                        //bool flag = Helper.VerifyHash(password, "SHA512", infoKullanici[kullaniciAdi].UIPW);

                        bool flag = PasswordHash.ValidatePassword(password, infoKullanici[kullaniciAdi].UIPW);

                        bool adisyonDegistirebilirMi = false;

                        if (PasswordHash.ValidatePassword("true", infoKullanici[kullaniciAdi].UIY[3]))
                            adisyonDegistirebilirMi = true;

                        if (flag == true)
                        { //şifre doğru
                            XmlSave.SaveRestoran(username, "sonKullanici.xml");

                            try
                            {
                                Task reportTask = Task.Factory.StartNew(
                                    () =>
                                    {
                                        adminForm = new AdminGirisFormu(this, adisyonDegistirebilirMi);

                                        adminForm.ShowDialog();
                                    }
                                    , CancellationToken.None
                                    , TaskCreationOptions.None
                                    , TaskScheduler.FromCurrentSynchronizationContext()
                                    );

                                reportTask.Wait();
                            }
                            catch
                            { }
                            //Task.Factory.StartNew(() => adminForm.ShowDialog());
                        }
                        else
                        {
                            KontrolFormu dialog2 = new KontrolFormu("Yanlış kullanıcı adı/şifre girdiniz", false);
                            dialog2.Show();
                        }
                    }
                    else
                    {
                        KontrolFormu dialog2 = new KontrolFormu("Yanlış kullanıcı adı/şifre girdiniz", false);
                        dialog2.Show();
                    }
                }

                userNameTextBox = new WPF_UserControls.VerticalCenterTextBox();
                usernameBoxHost.Child = userNameTextBox;
                passwordTextBox = new WPF_UserControls.VerticalCenterPasswordBox();
                passwordBoxHost.Child = passwordTextBox;
            }
            else
            {
                this.SendToBack();
            }
        }