using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TinyHeels.App_Code;

namespace TinyHeels
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            Environment.Exit(0);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string id = txtLoginId.Text;
                string pwd = txtLoginPassword.Text;
                pwd = StringCipher.Encrypt("testkey", pwd);
                Employee emp = new Employee();
                emp.EmpLoginId = id;
                emp.EmpLoginPassword = pwd;
                bool x = emp.checkEmployeeLogin();
                if (x)
                {
                    string adminId = emp.getEmpId();
                    Common.adminId = adminId;
                    emp.EmpId = adminId;
                    string admin = emp.getCredentials();
                    Common.des = admin;
                    this.Hide();
                    Dashboard db = new Dashboard();
                    db.ShowDialog();
                }
                else
                {
                    ErrorBox error = new ErrorBox("Sorry Not Allowed");
                    error.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                ErrorBox error = new ErrorBox("Sorry Server Not Found.\nRestart The POS Software.");
                error.ShowDialog();
            }
        }
    }
}
