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;
using MyDataAccess;
using System.Data.SqlClient;
using System.Globalization;
using System.IO;

namespace Amozeshgah
{
    public partial class LoginModir : Form
    {

        public LoginModir()
        {
            InitializeComponent();
        }

        cDataAccess cData = new cDataAccess(clsPath.ConnectionString());

        private void btnExit_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void txtUserName_TextChanged(object sender, EventArgs e)
        {
            if ( txtUserName.Text == "" && txtPass.Text == "")
            {
                btnLogin.Enabled = false;
            }
            else
            {
                btnLogin.Enabled = true;
            }
        }

        private void LoginModir_Load(object sender, EventArgs e)
        {
            btnLogin.Enabled = false;
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            DataSet ret = cData.ExecuteQuery("SELECT UserName , Password FROM tLoginModir  WHERE ([UserName]='" + txtUserName.Text + "') AND (Password ='" + txtPass.Text + "')");
            if (ret.Tables[0].Rows.Count > 0)
            {
                Managment m = new Managment();
                m.Show();
                this.Hide();
            }
            else
            {
               
                FarsiMessage.Show("نام کاربری یا کلمه عبور اشتباه است!", "اخطار", FarsiMessageBoxButtons.OK, FarsiMessageBoxIcons.Error);
            }
        }
    }
}
