using System; using System.Data; using System.Diagnostics; using System.Windows.Forms; namespace Mip { public partial class frmLogin : Form { DataTable dTable; public frmLogin() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Application.Exit(); } private void frmLogin_Load(object sender, EventArgs e) { classSQL.SQL("SELECT * FROM tabusers Where `Status` = 'Aktívny' ORDER BY Priezvisko;", out dTable); foreach (DataRow row in dTable.Rows) { comboBox1.Items.Add(row["Titul"].ToString() + " " + row["Priezvisko"].ToString() + " " + row["Meno"].ToString()); } if (Debugger.IsAttached) { comboBox1.Text = "Ing. Čulák Roman"; textBox1.Text = "3"; button2_Click(button2, new EventArgs()); } } private void button2_Click(object sender, EventArgs e) { DataRow myDrow; myDrow = dTable.Rows[comboBox1.SelectedIndex]; if (myDrow[3].ToString() == textBox1.Text) { classUser.Meno = myDrow[0].ToString(); classUser.Priezvisko = myDrow[1].ToString(); classUser.Titul = myDrow[2].ToString(); classUser.ID = Convert.ToInt32(myDrow["IDUsers"]); classUser.Tab = Convert.ToInt32( myDrow[5]); classUser.Zaradenie = myDrow[7].ToString(); this.Close(); //Kontrola hesla } else { MessageBox.Show("Nesprávne heslo!"); textBox1.Clear(); } } private void comboBox1_SelectedValueChanged(object sender, EventArgs e) { button2.Enabled = true; textBox1.Enabled = true; textBox1.Select(); } private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if ((int)e.KeyChar == 13) button2.PerformClick(); } private void textBox1_TextChanged(object sender, EventArgs e) { } } }