Program.cs

 avatar
unknown
c9search
3 years ago
1.6 kB
2
Indexable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Net.NetworkInformation;

namespace Scoot
{
    static class Program
    {
        /// <summary>
        /// Point d'entrée principal de l'application.
        /// </summary>
        [STAThread]
        static void Main()
        {

            SqlConnection cn = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=scoot;Integrated Security=True;");
            SqlCommand cmd;

            var macAddr =
                (
                    from nic in NetworkInterface.GetAllNetworkInterfaces()
                    where nic.OperationalStatus == OperationalStatus.Up
                    select nic.GetPhysicalAddress().ToString()
                ).FirstOrDefault();

            cn.Open();
            cmd = new SqlCommand("SELECT [key] FROM liscence where id = (select max(id) from liscence)   ", cn);
            object temp1 = cmd.ExecuteScalar();
            string a = temp1.ToString();
            cn.Close();

            if(macAddr != a )
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Forms.liscence());
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new dashboard());
            }
           
        }
    }
}