Ejemplo n.º 1
0
        private void logOutlinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.Hide();
            Prisijungimas p = new Prisijungimas();

            p.Show();
        }
Ejemplo n.º 2
0
 private void RegButton_Click(object sender, EventArgs e)
 {
     if (loginTextBox.Text == "" || pswTextBox.Text == "" || regPswTextBox.Text == "")
     {
         MessageBox.Show("Įveskite visus duomenis!");
     }
     else
     {
         if (regPswTextBox.Text == pswTextBox.Text)
         {
             try
             {
                 string        connString = ConfigurationManager.ConnectionStrings["connect"].ConnectionString;
                 SqlConnection conn       = new SqlConnection(connString);
                 SqlCommand    command    = conn.CreateCommand();
                 command.CommandType = CommandType.Text;
                 conn.Open();
                 try
                 {
                     SqlCommand check_User_Name = new SqlCommand("SELECT * FROM Login WHERE username = '******'", conn);
                     int        UserExist       = (int)check_User_Name.ExecuteScalar();
                     MessageBox.Show("Toks vartotojo vardas jau užimtas!");
                     loginTextBox.Text  = "";
                     pswTextBox.Text    = "";
                     regPswTextBox.Text = "";
                     loginTextBox.Select();
                     conn.Close();
                 }
                 catch (System.NullReferenceException)
                 {
                     command.CommandText = "insert Login (username, password, type) VALUES ('" + loginTextBox.Text + "', '" + pswTextBox.Text + "', 0)";
                     command.ExecuteNonQuery();
                     conn.Close();
                     MessageBox.Show("Registracija sėkminga! Galite prisijungti su savo vartotojo vardu ir slaptažodžiu!");
                     this.Hide();
                     Prisijungimas p = new Prisijungimas();
                     p.Show();
                 }
             }
             catch (System.Data.SqlClient.SqlException)
             {
                 System.Windows.Forms.MessageBox.Show("Patikrinkite ar duomenų bazė yra pasiekiama!");
                 System.Windows.Forms.Application.Exit();
             }
         }
         else
         {
             MessageBox.Show("Jūsų pakartotinai įvestas slaptažodis nesutampa pirmu įvestu slaptažodžiu!");
             regPswTextBox.Text = "";
             pswTextBox.Text    = "";
             pswTextBox.Select();
         }
     }
 }