Files
MIP/Mip/frmLogin.cs
Culak-HP\Culak 9caf446fe0 New version 1.005
2020-10-20 19:32:25 +02:00

91 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.Odbc;
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());
}
}
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.Hide(); //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)
{
}
}
}