private void одјавиСеToolStripMenuItem_Click(object sender, EventArgs e) { КорисничкаНајава child = new КорисничкаНајава(); this.Close(); child.Show(); }
private void button1_Click(object sender, EventArgs e) { dostapno.Text = ""; match.Text = ""; if (username.Text == "") { dostapno.Text = "Внеси корисничко име!"; } if (textBox2.Text == "" || textBox3.Text == "") { match.Text = "Внеси лозинка!"; } //не се совпаѓаат else if (textBox2.Text != textBox3.Text) { match.Text = "Лозинките не се совпаѓаат!"; textBox2.Text = ""; textBox3.Text = ""; } //се совпаѓаат else if (textBox2.Text == textBox3.Text && username.Text != "") { SqlConnection con = new SqlConnection("Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename = |DataDirectory|\\Inventory.mdf; Integrated Security = True; Connect Timeout = 30"); con.Open(); SqlCommand cmd = new SqlCommand("select count(*) from E_Login where username = '******'", con); bool exists = false; cmd.Parameters.AddWithValue("username", username.Text); exists = (int)cmd.ExecuteScalar() > 0; // postoi korisnickoto ime if (exists) { dostapno.Text = "Ова корисничко име е зафатено!"; textBox2.Text = ""; textBox3.Text = ""; username.Text = ""; } else if (!exists) { cmd.CommandText = "insert into E_Login (username,pasword) values('" + username.Text + "','" + textBox2.Text + "')"; cmd.ExecuteNonQuery(); MessageBox.Show("Вие сте регистрирани !"); this.Close(); КорисничкаНајава ob = new КорисничкаНајава(); ob.Show(); } con.Close(); } }