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

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

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "" || textBox2.Text == "")
            {
                MessageBox.Show("مقادیر فیلدها نمی توانند خالی باشند");
            }
            else
            {
                FirstClass dbCheck = new FirstClass();
                DataTable dtChek = new DataTable();

                dtChek = dbCheck.dbOut("SELECT     TOP 100 PERCENT UserName, Password FROM userInfo WHERE     (Password = '" + textBox2.Text.Trim() + "' AND UserName = '" + textBox1.Text.Trim() + "') ORDER BY UserName");
                if (dtChek.Rows.Count <= 0)
                {
                    MessageBox.Show("نام کاربری و کلمه عبور اشتباه وارد شده اند");
                }
                else
                {
                    GlobalClass.GlobalVar = textBox1.Text.Trim();
                    textBox1.Text = "";
                    textBox2.Text = "";
                    dtChek.Clear();
                    
                    this.Visible = false;
                    frmMDI frm = new frmMDI();
                    frm.Show();
                }
            }
        }

        private void frmLogin_Load(object sender, EventArgs e)
        {

        }
    }
}