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 VideoCloop
{
    public partial class frmLogin : Form
    {
        public frmLogin()
        {
            InitializeComponent();
        }

        private void Btn_Login_Click(object sender, EventArgs e)
        {
            if (Txt_UserName.Text == "" || Txt_Password.Text == "")
            {
                MessageBox.Show("ورود نام کاربری و کلمه عبور الزامی می باشد");
                return;
            }
            dtsMainTemplPrjTableAdapters.tblUsersTableAdapter Da = new VideoCloop.dtsMainTemplPrjTableAdapters.tblUsersTableAdapter();
            dtsMainTemplPrj.tblUsersDataTable Dt = new dtsMainTemplPrj.tblUsersDataTable();
            Da.FillBy(Dt, Txt_UserName.Text.Trim(), Txt_Password.Text.Trim());
            if (Dt.Rows.Count <= 0)
            {
                MessageBox.Show("نام کاربری و یا کلمه عبور اشتباه وارد شده اند");
            }
            else
            {
                Txt_Password.Text = "";
                Txt_UserName.Text = "";
                Class_Global_Vars.ThisLogedUserID = Dt.Rows[0][0].ToString();
                Class_Global_Vars.ThisLogedUserName = Dt.Rows[0][1].ToString();
                Dt.Clear();
                this.Hide();
                frmMain frm = new frmMain();
                frm.ShowDialog();
            }
        }

        private void frmLogin_Load(object sender, EventArgs e)
        {
            Class_Register_Logs LogsRegIn = new Class_Register_Logs(this.Text + " is Opened.");
        }

        private void frmLogin_FormClosed(object sender, FormClosedEventArgs e)
        {
            Class_Register_Logs LogsRegIn = new Class_Register_Logs(this.Text + " is Closed");
        }

        private void Btn_Cancel_Click(object sender, EventArgs e)
        {
            Class_Register_Logs LogsRegIn = new Class_Register_Logs(this.Text + " - Login Cancelled");
            Application.Exit();
        }


    }
}
