using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

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

        private void btnLogin_Click(object sender, EventArgs e)
        {
            DataAccess da = new DataAccess();
            da.connect();
            string sql = "Select * from Users where uusername='{0}' and upassword='{1}'";
            sql = string.Format(sql, 
                txtUser.Text.Replace("'","''"), 
                txtPass.Text.Replace("'","''"));
            DataTable dt = new DataTable();
            dt = da.select(sql);
            da.Disconnect();

            if (dt.Rows.Count > 0)
            {
                frmMain fm = new frmMain();
                fm.ShowDialog();
            }
            else
            {
                MessageBox.Show("Incorrect User/Pass");
            }
        }

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

        private void txtUser_TextChanged(object sender, EventArgs e)
        {

        }



    }
}