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

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

        private void btnEnter_Click(object sender, EventArgs e)
        {

            DataAccess da = new DataAccess();
            da.connect();
            string sql = "Select * from Users where UserName='{0}' and pass='{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)
            {
                this.Close();
            }
            else
            {
                MessageBox.Show("نام کاربری یا کلمه عبور صحیح نیست ","خطا",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
                      
        }

        private void close()
        {
            throw new NotImplementedException();
        }

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

        private void Login_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'amozeshgahDataSet1.Term' table. You can move, or remove it, as needed.
            this.termTableAdapter.Fill(this.amozeshgahDataSet1.Term);
            txtUser.Text = "djhamon";
            txtpass.Text = "123";
        }

        private void Login_FormClosing(object sender, FormClosingEventArgs e)
        {
            
        }

        
    }
}
