using System;
using System.Data;
using LLNet.Controls;
using Microsoft.Win32;
using System.Threading;
using System.Collections;
using System.Reflection;
using System.Collections.Generic;
using System.Windows.Forms;

namespace LLNet.POSRetail
{
    /// <summary>
    /// Program: Clase principal de la aplicación 
    /// Developer: Wildmar Lopez, CERTIFICADA 28/11/2006
    /// </summary>
    static class Program
    {
        /// <summary>
        /// Formulario principal del ingreso de pedidos
        /// </summary>

        #region The main entry point for the application.
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                GUI.CustomExceptionHandler eh = new GUI.CustomExceptionHandler();

                // Adds the event handler to to the event.
                Application.ThreadException += new ThreadExceptionEventHandler(eh.OnThreadException);

                GUI.CApp.bll = new LLNet.BLL.BLLServer();

                RegistryKey key = Registry.CurrentUser;
                key = key.OpenSubKey(@"Software\Logistika\POS Retail 8.0.0", true);
                GUI.CApp.ExeDir = key.GetValue("Path", Application.StartupPath + "\\").ToString();
                GUI.CApp.ExeDir = (GUI.CApp.ExeDir == "") ? Application.StartupPath + "\\" : GUI.CApp.ExeDir;
                GUI.CApp.EventLog = new LLEventLog(GUI.CApp.ExeDir);
                GUI.CApp.SolutionModule = "LLNET_TIENDA";
                GUI.CApp.CreateModules = true;
                GUI.CApp.ModulePrefix = "TDA_";
                GUI.CApp.idioma = key.GetValue("Idioma", "").ToString();
                GUI.CApp.vLectorBac = key.GetValue("LectorBAC", "").ToString();
                if (GUI.CApp.idioma == "")
                {
                    GUI.CApp.idioma = "ESPANOL";
                    key.SetValue("Idioma", "ESPANOL");
                }

                LLNet.Tienda.Program.FrmLogin = new LLNet.Tienda.MainForms.frmLogin();
                GUI.CApp.InitSkinsDesigners();
                Application.Run(LLNet.Tienda.Program.FrmLogin);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "ˇAtención!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        #endregion

    }
}