示例#1
0
        private Insan MakeRegister()
        {
            try {
                string           connString = ConfigurationManager.ConnectionStrings["MyKey"].ConnectionString;
                NpgsqlConnection connection = new NpgsqlConnection(connString);
                connection.Open();

                NpgsqlCommand command1 = new NpgsqlCommand("INSERT INTO akillikart(bakiye) VALUES(0)", connection);
                command1.ExecuteNonQuery();

                NpgsqlCommand    command2 = new NpgsqlCommand("SELECT MAX(id) FROM akillikart", connection);
                NpgsqlDataReader reader   = command2.ExecuteReader();
                reader.Read();
                int kartID = int.Parse(reader[0].ToString());
                reader.Close();

                NpgsqlCommand command3 = new NpgsqlCommand("INSERT INTO kisi (eposta,pass,ad,soyad,ak_id,tip) VALUES( '" + (textboxEmail.Text) + "','" + (textboxPassword.Text) + "','" + (textboxName.Text) + "','" + (textboxLastname.Text) + "'," + kartID.ToString() + "," + comboBox1.SelectedIndex + ");", connection);
                command3.ExecuteNonQuery();

                NpgsqlCommand command4 = new NpgsqlCommand("SELECT MAX(id) FROM kisi", connection);
                reader = command4.ExecuteReader();
                reader.Read();
                int id = int.Parse(reader[0].ToString());
                reader.Close();

                Insan notRobot = new Insan(id.ToString(), textboxName.Text, textboxLastname.Text, new AkilliKart(0, kartID.ToString()), textboxEmail.Text, textboxPassword.Text);
                connection.Close();
                MessageBox.Show("Basarılı bir sekilde kayıt oldunuz.");
                return(notRobot);
            } catch (Exception ex) {
                MessageBox.Show(ex.Message.ToString());
                return(null);
            }
        }
示例#2
0
 void setAktifKullaniciFromTextBox(Insan kisi)
 {
     kisi.ad       = txtName.Text;
     kisi.soyad    = txtSurname.Text;
     kisi.eposta   = txtEmail.Text;
     kisi.password = txtPass.Text;
 }
示例#3
0
 void setPersonalInfoTextBox(Insan kisi)
 {
     txtName.Text    = kisi.ad;
     txtSurname.Text = kisi.soyad;
     txtEmail.Text   = kisi.eposta;
     txtPass.Text    = kisi.password;
 }
示例#4
0
        //private event Action<ListViewItem> OnListViewUpdate;
        #region Global

        public UserPage(Login loginForm, Insan aktifKullanici)
        {
            this.loginForm = loginForm;
            InitializeComponent();
            this.aktifKullanici = aktifKullanici;
            if (aktifKullanici.GetType() != typeof(OgretimUyesi))
            {
                listBox1.Items.RemoveAt(2);
                isOgretimGorevlisi = false;
            }
            labelWelcome.Text += aktifKullanici.ad + " " + aktifKullanici.soyad + " " + aktifKullanici.GetType().Name;
            labelBakiye.Text  += aktifKullanici.kart.getBakiye().ToString() + " TL";
            GetAllItems();
            GetAllUserItems();
            setPersonalInfoTextBox(aktifKullanici);
        }
        private int KartOkut(string kartID)
        {
            try {
                string connString = ConfigurationManager.ConnectionStrings["MyKey"].ConnectionString;

                NpgsqlConnection connection = new NpgsqlConnection(connString);
                connection.Open();

                NpgsqlCommand    command = new NpgsqlCommand("SELECT * FROM kisi,akillikart WHERE kisi.ak_id = akillikart.id AND akillikart.id = " + kartID, connection);
                NpgsqlDataReader reader  = command.ExecuteReader();
                reader.Read();
                if (!reader.HasRows)
                {
                    throw new Exception("ID niz bulunamadı");
                }
                int tip = int.Parse(reader[6].ToString());
                if (tip == 0)
                {
                    aktifKullanici = new Ogrenci(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), new AkilliKart(float.Parse(reader[8].ToString()), reader[7].ToString()), reader[4].ToString(), reader[5].ToString());
                }
                else if (tip == 1)
                {
                    aktifKullanici = new OgretimUyesi(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), new AkilliKart(float.Parse(reader[8].ToString()), reader[7].ToString()), reader[4].ToString(), reader[5].ToString());
                }
                else
                {
                    aktifKullanici = new Memur(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), new AkilliKart(float.Parse(reader[8].ToString()), reader[7].ToString()), reader[4].ToString(), reader[5].ToString());
                }
                reader.Close();
                connection.Close();
                return(1);
            } catch (Exception ex) {
                MessageBox.Show(ex.Message.ToString());
                return(0);
            }
        }
        private void loginButton_Click_1(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textboxPassword.Text) || string.IsNullOrEmpty(textboxUsername.Text))
            {
                return;
            }
            else if (textboxPassword.Text == adminPassword && textboxUsername.Text == adminUserName)
            {
                AdminPage adminPage = new AdminPage(this);
                adminPage.Show();
                this.Hide();
                CheckRememberMeState();
                return;
            }
            else if (textboxPassword.Text == "0")
            {
                TestForm testForm = new TestForm();
                this.Hide();
                testForm.Show();
                CheckRememberMeState();
                return;
            }

            try {
                string           connString = ConfigurationManager.ConnectionStrings["MyKey"].ConnectionString;
                NpgsqlConnection connection = new NpgsqlConnection(connString);
                connection.Open();
                NpgsqlCommand command, command2;

                if (IsNumeric(textboxUsername.Text))  //ak_id
                {
                    command  = new NpgsqlCommand("SELECT * FROM kisi WHERE ak_id = " + textboxUsername.Text, connection);
                    command2 = new NpgsqlCommand("SELECT bakiye FROM akillikart,kisi WHERE akillikart.id = kisi.ak_id AND ak_id=" + textboxUsername.Text, connection);
                }
                else    //eposta
                {
                    command  = new NpgsqlCommand("SELECT * FROM kisi WHERE eposta = '" + textboxUsername.Text + "'", connection);
                    command2 = new NpgsqlCommand("SELECT bakiye FROM akillikart,kisi WHERE akillikart.id = kisi.ak_id AND eposta = '" + textboxUsername.Text + "'", connection);
                }
                NpgsqlDataReader reader = command2.ExecuteReader();
                reader.Read();
                float bakiye = float.Parse(reader[0].ToString());
                reader.Close();

                reader = command.ExecuteReader();
                reader.Read();

                if (reader[0] != null)
                {
                    string password = reader[5].ToString();

                    if (password == textboxPassword.Text)
                    {
                        string     id     = reader[0].ToString();
                        string     ad     = reader[1].ToString();
                        string     soyad  = reader[2].ToString();
                        AkilliKart kart   = new AkilliKart(bakiye, reader[3].ToString());
                        string     eposta = reader[4].ToString();
                        int        tip    = int.Parse(reader[6].ToString());
                        switch (tip)
                        {
                        case 0:    //ogrenci
                            aktifKullanici = new Ogrenci(id, ad, soyad, kart, eposta, password);
                            break;

                        case 1:    //ogretim gorevlisi
                            aktifKullanici = new OgretimUyesi(id, ad, soyad, kart, eposta, password);
                            break;

                        case 2:    //memur
                            aktifKullanici = new Memur(id, ad, soyad, kart, eposta, password);
                            break;

                        default:
                            throw new Exception("Böyle bir tip yok");
                        }


                        //ktifKullanici = new Insan(id, ad, soyad, kart, eposta, password);
                        //MessageBox.Show("Basarili bir sekilde giris yapildi");
                        CheckRememberMeState();
                        UserPage userPage = new UserPage(this, aktifKullanici);
                        Hide();
                        userPage.Show();
                    }
                    else
                    {
                        MessageBox.Show("Lütfen bilgilerinizi kontrol ediniz");
                    }
                }
                else
                {
                    MessageBox.Show("Veri gelmedi");
                }
                reader.Close();
                connection.Close();
            } catch (Exception ex) {
                MessageBox.Show(ex.Message.ToString());
            }
        }