//Focus pe label1 private void Login_Shown(object sender, EventArgs e) { label1.Focus(); if (checkBox1.Checked == true) { this.Hide(); Librarie f = new Librarie(); f.Closed += (s, args) => this.Close(); f.Show(); } }
//Logare private void btnLogare_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("Completati ambele campuri."); } else { OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Users.accdb"); OleDbDataAdapter odda = new OleDbDataAdapter("Select * from Client where User='******' and Parola='" + textBox2.Text + "'", con); DataTable dt = new DataTable(); odda.Fill(dt); try { if (dt.Rows[0][0].ToString() != "0") { if (checkBox2.Checked == true) { Properties.Settings.Default.UserName = textBox1.Text; Properties.Settings.Default.Parola = textBox2.Text; Properties.Settings.Default.Save(); } else { Properties.Settings.Default.UserName = ""; Properties.Settings.Default.Parola = ""; Properties.Settings.Default.Save(); } System.IO.File.WriteAllText(@"textbox1.txt", textBox1.Text.ToString()); this.Hide(); Librarie f = new Librarie(); f.Closed += (s, args) => this.Close(); f.Show(); } } catch { label2.Visible = true; label2.Text = "Eroare la autentificare.\nNume de utilizator sau parolă greșită."; } } }