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 System.Security.Cryptography;

namespace video_club
{
    public partial class frmlogin : Form
    {
        public frmlogin()
        {
            InitializeComponent();
        }

        private void buttonX1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnsend_Click(object sender, EventArgs e)
        {

         tblusersTableAdapter1.FillBy(dataSet11.tblusers,txtuname.Text,GetMD5(txtpass.Text));
               
              
                if (dataSet11.tblusers.Rows.Count > 0)
                {

                    new frmmain().Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("نام کاربری  یا رمز عبور اشتباه است", "!!!اخطار", MessageBoxButtons.OK);
                }
            
           
        }

        private void login_Load(object sender, EventArgs e)
        {
            txtuname.Text = "admin";

        }
        public byte[] GetMD5(string password)
        {
            byte[] HashedDataBytes = new byte[16];
            UTF8Encoding Encoder = new UTF8Encoding();
            MD5CryptoServiceProvider Md5Hasher = new MD5CryptoServiceProvider();
            HashedDataBytes = Md5Hasher.ComputeHash(Encoder.GetBytes(password));
            return HashedDataBytes;
        }

        private void txtpass_TextChanged(object sender, EventArgs e)
        {
            
            
        }

        private void txtpass_Enter(object sender, EventArgs e)
        {
            
        }

        private void txtpass_Click(object sender, EventArgs e)
        {
            tblusersTableAdapter1.FillBy(dataSet11.tblusers, txtuname.Text, GetMD5(txtpass.Text));


            
        }

        private void txtpass_DragEnter(object sender, DragEventArgs e)
        {
           
        }

        private void txtpass_KeyPress(object sender, KeyPressEventArgs e)
        {
            
        }
    }
}
