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;

namespace FlatDesignEmployeeRecordSystem
{
    public partial class frmLogin : Form
    {
        public frmLogin()
        {
            InitializeComponent();
        }

        SQLConfig config = new SQLConfig();
        string sql;

        private void bunifuButton1_Click(object sender, EventArgs e)
        {
            sql = "SELECT * FROM `useraccounts` WHERE `USERNAME`='" + UsernameTextBox.Text + "' AND  `PASS`= sha1('" + PasswordTextBox.Text + "')";
            config.singleResult(sql);
            if (config.dt.Rows.Count > 0)
            {
                Form1 f = new Form1();
                f.Show();
                this.Hide();
                UsernameTextBox.Clear();
                PasswordTextBox.Clear();


            }
            else
            {
                MessageBox.Show("Accounts does not exist! please contact administrator", "login failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }

        private void bunifuButton2_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
