private void logIn_btn_Click(object sender, RoutedEventArgs e)
        {
            bool user_pass = false;

            try
            {
                //prisijungia prie serverio
                if (prisijungimas.State != ConnectionState.Open)
                {
                    prisijungimas.Open();
                }

                //komanda patikrinti user + pass combo
                NpgsqlCommand LogIn = new NpgsqlCommand("select * from users where username = @vartotojas and password = @slaptazodis", prisijungimas);
                //komandos parametrai
                LogIn.Parameters.AddWithValue("@vartotojas", this.Username_Tb.Text);
                LogIn.Parameters.AddWithValue("@slaptazodis", this.Password_tb.Password);
                //data readeris su komanda
                NpgsqlDataReader rd = LogIn.ExecuteReader();
                //readerio rezultatai
                if (rd.Read())
                {
                    if (rd["is_admin"].Equals(true))
                    {
                        is_admin = true;
                    }

                    //Pakeicia prisijungusi vartotoja
                    prisijunges_vartotojas = this.Username_Tb.Text;
                    //pakeiciua pass check i taip
                    user_pass = true;

                    //ijungia pagrindini meniu
                    prisijungimas.Close();
                    rd.Close();

                    main_menu main = new main_menu();
                    main.Show();
                    main.log = this;

                    this.Hide();
                }
                if (user_pass == false)
                {
                    //Pranesa jeigu nerado tokio vartotojo su slaptazodziu ir uzdaro connectiona
                    MessageBox.Show("Neteisingas slaptažodis");
                    prisijungimas.Close();
                    rd.Close();
                }
                rd.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Nepavyko prisijungti prie serverio." + Environment.NewLine + ex.Message);
                //MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        private static void OnScaleValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            //log_in_form = window pavadinimas solution explorer        <----------------- komentaras
            main_menu mainWindow = o as main_menu;

            if (mainWindow != null)
            {
                mainWindow.OnScaleValueChanged((double)e.OldValue, (double)e.NewValue);
            }
        }
示例#3
0
        private static object OnCoerceScaleValue(DependencyObject o, object value)
        {
            //log_in_form = window pavadinimas solution explorer   <----------------- komentaras
            main_menu mainWindow = o as main_menu;

            if (mainWindow != null)
            {
                return(mainWindow.OnCoerceScaleValue((double)value));
            }
            else
            {
                return(value);
            }
        }