Beispiel #1
0
        public void PerformRefresh(object sender, EventArgs e)
        {
            //zapisujemy pozycję
            var MyIni = new INIFile("WektorSettings.ini");
            int index = dataGridView1.CurrentRow.Index;

            MyIni.Write("poz", index.ToString(), "poz");
            //przeładowywujemy tabelę
            zamowienia_Load(e, e);
            //odczytujemy pozycję
            var poz = Convert.ToInt32(MyIni.Read("poz", "poz"));

            dataGridView1.FirstDisplayedScrollingRowIndex = poz;
            dataGridView1.Rows[0].Selected   = false;
            dataGridView1.Rows[poz].Selected = true;
            MyIni.DeleteSection("poz");
        }
Beispiel #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string user = txtLogin.Text;
            string pass = txtPassword.Text;

            if (user == "" || pass == "")
            {
                boxes.frmOK frm = new boxes.frmOK();
                frm.Show();
                return;
            }
            bool r = validate_login(user, pass);

            if (r)
            {
                db_connection();
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "Select * from uzytkownicy where username=@user and password=MD5(@pass)";
                cmd.Parameters.AddWithValue("@user", txtLogin.Text);
                cmd.Parameters.AddWithValue("@pass", txtPassword.Text);
                cmd.Connection = connect;
                MySqlDataReader login = cmd.ExecuteReader();

                while (login.Read())
                {
                    string l = login.GetString("allowed");

                    if (l == "1")
                    {
                        bool log = Zalogowany(user, pass);
                        if (log)
                        {
                            db_connection();
                            MySqlCommand cmd2 = new MySqlCommand();
                            cmd2.CommandText = "Select * from uzytkownicy where username=@user and password=MD5(@pass)";
                            cmd2.Parameters.AddWithValue("@user", txtLogin.Text);
                            cmd2.Parameters.AddWithValue("@pass", txtPassword.Text);
                            cmd2.Connection = connect;
                            MySqlDataReader login1 = cmd2.ExecuteReader();
                            while (login1.Read())
                            {
                                string jest = login1.GetString("logged");
                                if (jest == "1")
                                {
                                    boxes.frmUser frm = new boxes.frmUser();
                                    frm.Show();
                                }
                                else
                                {
                                    zapis_login();
                                    boxes.frmZalogowany frms = new boxes.frmZalogowany();
                                    frms.Show();

                                    var MyIni = new INIFile("WektorSettings.ini");
                                    MyIni.Write("user", user, "logged");
                                    Hide();
                                }
                            }
                        }
                    }
                    else
                    {
                        logedError frm = new logedError();
                        frm.Show();
                    }
                }
            }
            else
            {
                MetroMessageBox.Show(this, "Nieprawidłowa nazwa użytkownika lub hasło", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }