static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);//捕获系统所产生的异常。
            Application.ApplicationExit += new EventHandler(Application_ApplicationExit);

            Program.CheckInstance();                       //检查程序是否运行多实例
            SystemConfig.ReadSettings();                   //读取用户自定义设置

            if (false == BridgeFactory.InitializeBridge()) //初始化桥接功能
            {
                Application.Exit();
                return;
            }

            BonusSkins.Register();         //注册Dev酷皮肤
            OfficeSkins.Register();        ////注册Office样式的皮肤
            SkinManager.EnableFormSkins(); //启用窗体支持换肤特性

            //注意:先打开登陆窗体,登陆成功后正式运行程序(MDI主窗体)
            if (frmLogin.Login())
            {
                Program.MainForm.Show();
                Application.Run();
            }
            else//登录失败,退出程序
            {
                Application.Exit();
            }
        }
Exemple #2
0
        private static void Main()
        {
            try
            {
                Application.ThreadException += ThreadExceptionHandler.Application_ThreadException;

                // skinning
                SkinManager.EnableFormSkins();
                OfficeSkins.Register();
                UserLookAndFeel.Default.ActiveLookAndFeel.SkinName = "Office 2010 Blue";

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.ApplicationExit += Application_Exit;
                Application_Prepare();

                // Spring
                ContextRegistry.GetContext();
                MainForm.Instance.Show();
                TrayNotifier.Instance.UpdateNotifierStartup();

                var appContext = new ApplicationContext();
                Application.Run(appContext);
            }
            catch (Exception ex)
            {
                LoggingHelper.LogError(logger, ex);
                MessageBox.Show(ex.ToString(), "Program exception handler");
            }
        }
Exemple #3
0
 private void ElementRenameForm_Load(object sender, EventArgs e)
 {
     OfficeSkins.Register();
     BonusSkins.Register();
     SkinManager.EnableFormSkins();
     defaultLookAndFeel1.LookAndFeel.SkinName = "McSkin";
 }
Exemple #4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            OfficeSkins.Register();

            Application.Run(new Form1());
        }
        private Program()
        {
            Application.EnableVisualStyles();

            SkinManager.EnableFormSkins();
            OfficeSkins.Register();
            BonusSkins.Register();

            MainForm         = new FrmMain();
            IsSingleInstance = true;
        }
        static void Main()
        {
            //注册皮肤
            BonusSkins.Register();
            OfficeSkins.Register();
            SkinManager.EnableFormSkins();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form9());
        }
        static void Main()
        {
            BonusSkins.Register();
            OfficeSkins.Register();
            SkinManager.EnableFormSkins();
            Thread.CurrentThread.CurrentCulture   = new System.Globalization.CultureInfo("zh-CN");
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");

            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

            new ShellApplication().Run();
        }
Exemple #8
0
        static void Main()
        {
            //注册皮肤
            BonusSkins.Register();
            OfficeSkins.Register();
            SkinManager.EnableFormSkins();

            //Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CHS");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
Exemple #9
0
        static void Main()
        {
            SG.Parameters.SGParameter.sAppPath = Application.StartupPath;

            Application.EnableVisualStyles();                                                            // 启用应用程序的可视样式。
            Application.SetCompatibleTextRenderingDefault(false);                                        //     将某些控件上定义的 UseCompatibleTextRendering 属性设置为应用程序范围内的默认值。
            Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); //捕获系统所产生的异常。
            Application.ApplicationExit += new EventHandler(Application_ApplicationExit);                //程序即将关闭时

            Program.CheckInstance();                                                                     //检查程序是否运行多实例
            SystemConfig.ReadSettings();                                                                 //读取用户自定义设置

            if (false == BridgeFactory.InitializeBridge())                                               //初始化桥接功能
            {
                Application.Exit();
                return;
            }

            BonusSkins.Register();         //注册Dev酷皮肤
            OfficeSkins.Register();        ////注册Office样式的皮肤
            SkinManager.EnableFormSkins(); //启用窗体支持换肤特性

            //SG.AppUpdater.workerFunction au = new SG.AppUpdater.workerFunction();
            //int nResult = au.isServerUpdate();
            //if (nResult == 1)
            //{
            //    MessageBox.Show("有新版本的文件需要更新,请确认下载!");
            //    Process.Start("SG.AppUpdater.exe");
            //    Application.Exit();
            //}
            //else if (nResult == 0)
            //{
            //注意:先打开登陆窗体,登陆成功后正式运行程序(MDI主窗体)
            if (frmLogin.Login())
            {
                Program.MainForm.Show();
                Application.Run();
            }
            else   //登录失败,退出程序
            {
                Application.Exit();
            }
            //}
            //else
            //{
            //    Application.Exit();
            //}
            //Application.ExitThread();
        }
Exemple #10
0
        public JcwBaseFrm()
        {
            InitializeComponent();

            // register the bonus skins and office skins
            BonusSkins.Register();
            OfficeSkins.Register();

            // set the default skin to use
            DevExpress.LookAndFeel.UserLookAndFeel.Default.Style                 = LookAndFeelStyle.Skin;
            DevExpress.LookAndFeel.UserLookAndFeel.Default.UseWindowsXPTheme     = false;
            DevExpress.LookAndFeel.UserLookAndFeel.Default.UseDefaultLookAndFeel = true;

            // enabled form skinning
            SkinManager.EnableFormSkins();

            // force form's title bar to be repainted
            LookAndFeelHelper.ForceDefaultLookAndFeelChanged();
        }
Exemple #11
0
        static void Main()
        {
            DevExpress.Localization.Util.Set_zhchs_Culture();
            OfficeSkins.Register();
            BonusSkins.Register();
            SkinManager.EnableFormSkins();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);



            UserLookAndFeel.Default.SkinName = RunInfo.Instance.Config.SkinName;


            frmLogin loginForm = new frmLogin();

            if (loginForm.ShowDialog() == DialogResult.OK)
            {
                Application.Run(new frmMain());
            }
        }
        public FrmHome(fLogin _flg, string _tdn)
        {
            InitializeComponent();
            tdn = _tdn;
            fLg = _flg;
            DataProvider _dt = new DataProvider();
            DataTable    dt  = _dt.GetData("select * from ACCOUNT where ACCOUNT.TenDangNhap = '" + tdn + "'");
            string       gt  = dt.Rows[0]["Quyen"].ToString();

            if (gt == "1")
            {
                ribbonTrangChu.Visible = false;
                ribbonThongKe.Visible  = false;
                barBtnQLSach.Enabled   = false;
                barBtnQLPM.Enabled     = false;
                barBtnQLPT.Enabled     = false;
                nBG_QL.Visible         = false;
                nBG_TK.Visible         = false;
            }
            else
            {
                bar_SachDangMuon.Enabled = false;
                bar_LichSu.Enabled       = false;
                nBG_LSMS.Visible         = false;
                rbpG_TK.Visible          = false;
            }
            //lb_ChayChu.Text = "Phần mềm được\n   thực hiện bởi\nPhạm Ngọc Hải\n        và     \nPhạm Minh Hoàng";
            //lb_ChayChu.Text = "Welcome";
            //lb_ChayChu.Top = 1;
            DevExpress.UserSkins.BonusSkins.Register();
            OfficeSkins.Register();
            DevExpress.XtraBars.Helpers.SkinHelper.InitSkinGallery(skinRibbonGalleryBarItem1, true);

            panelCha.Controls.Clear();
            ucIntroduce frm = new ucIntroduce();

            frm.Dock = System.Windows.Forms.DockStyle.Fill;
            panelCha.Controls.Add(frm);
        }
Exemple #13
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);


            //SkinManager.EnableFormSkins();
            SkinManager.EnableMdiFormSkins();
            SkinManager.EnableFormSkinsIfNotVista();
            BonusSkins.Register();
            OfficeSkins.Register();
            //增加版本号检查 版本不一致 强制更新
            VersionService vr = new VersionService();

            vr.VersionUpdate();


            //DictionOrFilePathOperator.UserNo = "root";
            // ServiceManager.ResourceService.ImagesPath = AppDomain.CurrentDomain.BaseDirectory + "Images\\";

            //string systemProperty = ServiceManager.SystemService.GetSystemProperty("SystemTitle", "FirstLogin");


            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");
            Bootstrap.ApplicationDataDirectory = Directory.GetCurrentDirectory() + @"\Cache";

            if (Bootstrap.Load())
            {
                Bootstrap.RegisterAssemblyResources(System.Reflection.Assembly.GetExecutingAssembly());
                try
                {
                    Application.Run(new Login());
                }
                catch (Exception ew)
                {
                    MessageBox.Show(ew.Message);
                }
            }
        }
Exemple #14
0
 public static void SetDefaultStyle()
 {
     OfficeSkins.Register();
     UserLookAndFeel.Default.SetSkinStyle("Office 2007 Blue");
 }
        private void ModelInsertVerify_Load(object sender, EventArgs e)
        {
            try
            {
                OfficeSkins.Register();
                BonusSkins.Register();
                SkinManager.EnableFormSkins();
                defaultLookAndFeel1.LookAndFeel.SkinName = "McSkin";
                grid1.BorderStyle  = BorderStyle.FixedSingle;
                grid1.ColumnsCount = 4;
                grid1.FixedRows    = 1;
                grid1.Rows.Insert(0);
                grid1[0, 0]            = new SourceGrid.Cells.ColumnHeader("체크");
                grid1[0, 1]            = new SourceGrid.Cells.ColumnHeader("Type");
                grid1[0, 2]            = new SourceGrid.Cells.ColumnHeader("Model Name");
                grid1[0, 3]            = new SourceGrid.Cells.ColumnHeader("Zone Name");
                grid1.Columns[0].Width = 50;
                grid1.Columns[1].Width = 70;
                grid1.Columns[2].Width = 250;
                grid1.Columns[3].Width = 250;
                int rowcnt = 0;

                foreach (DbElement element in pipe_collection)
                {
                    if (element.IsNull == true)
                    {
                        continue;
                    }

                    grid1.Rows.Insert(rowcnt + 1);
                    grid1[rowcnt + 1, 0] = new SourceGrid.Cells.CheckBox(null, false);
                    grid1[rowcnt + 1, 1] = new SourceGrid.Cells.Cell(element.GetAsString(DbAttributeInstance.TYPE), typeof(string));
                    grid1[rowcnt + 1, 2] = new SourceGrid.Cells.Cell(element, typeof(DbElement));
                    grid1[rowcnt + 1, 3] = new SourceGrid.Cells.Cell(element.GetElement(DbAttributeInstance.OWNER).GetAsString(DbAttributeInstance.NAMN), typeof(DbElement));
                    //grid1[rowcnt, 2] = new SourceGrid.Cells.Cell(element.GetAsString(DbAttributeInstance.TYPE), typeof(string));
                    rowcnt++;
                }

                foreach (DbElement element in stru_collection)
                {
                    if (element.IsNull == true)
                    {
                        continue;
                    }

                    grid1.Rows.Insert(rowcnt + 1);
                    grid1[rowcnt + 1, 0] = new SourceGrid.Cells.CheckBox(null, false);
                    grid1[rowcnt + 1, 1] = new SourceGrid.Cells.Cell(element.GetAsString(DbAttributeInstance.TYPE), typeof(string));
                    grid1[rowcnt + 1, 2] = new SourceGrid.Cells.Cell(element, typeof(DbElement));
                    grid1[rowcnt + 1, 3] = new SourceGrid.Cells.Cell(element.GetElement(DbAttributeInstance.OWNER).GetAsString(DbAttributeInstance.NAMN), typeof(DbElement));
                    rowcnt++;
                }
                foreach (DbElement element in equip_collection)
                {
                    if (element.IsNull == true)
                    {
                        continue;
                    }

                    grid1.Rows.Insert(rowcnt + 1);
                    grid1[rowcnt + 1, 0] = new SourceGrid.Cells.CheckBox(null, false);
                    grid1[rowcnt + 1, 1] = new SourceGrid.Cells.Cell(element.GetAsString(DbAttributeInstance.TYPE), typeof(string));
                    grid1[rowcnt + 1, 2] = new SourceGrid.Cells.Cell(element, typeof(DbElement));
                    grid1[rowcnt + 1, 3] = new SourceGrid.Cells.Cell(element.GetElement(DbAttributeInstance.OWNER).GetAsString(DbAttributeInstance.NAMN), typeof(DbElement));
                    rowcnt++;
                }
                foreach (DbElement element in hull_collection)
                {
                    if (element.IsNull == true)
                    {
                        continue;
                    }

                    grid1.Rows.Insert(rowcnt + 1);
                    grid1[rowcnt + 1, 0] = new SourceGrid.Cells.CheckBox(null, false);
                    grid1[rowcnt + 1, 1] = new SourceGrid.Cells.Cell(element.GetAsString(DbAttributeInstance.TYPE), typeof(string));
                    grid1[rowcnt + 1, 2] = new SourceGrid.Cells.Cell(element, typeof(DbElement));
                    grid1[rowcnt + 1, 3] = new SourceGrid.Cells.Cell(element.GetElement(DbAttributeInstance.OWNER).GetAsString(DbAttributeInstance.NAMN), typeof(DbElement));

                    rowcnt++;
                }
                foreach (DbElement element in rso_collection)
                {
                    if (element.IsNull == true)
                    {
                        continue;
                    }

                    grid1.Rows.Insert(rowcnt + 1);
                    grid1[rowcnt + 1, 0] = new SourceGrid.Cells.CheckBox(null, false);
                    grid1[rowcnt + 1, 1] = new SourceGrid.Cells.Cell(element.GetAsString(DbAttributeInstance.TYPE), typeof(string));
                    grid1[rowcnt + 1, 2] = new SourceGrid.Cells.Cell(element, typeof(DbElement));
                    grid1[rowcnt + 1, 3] = new SourceGrid.Cells.Cell(element.GetElement(DbAttributeInstance.OWNER).GetAsString(DbAttributeInstance.NAMN), typeof(DbElement));

                    rowcnt++;
                }
                lblcnt.Text = "검색건수 : " + rowcnt.ToString();
            }catch (Exception ee)
            {
                Console.WriteLine("올류");
            }
        }
Exemple #16
0
        public static void Main(string[] args)
        {
            //args = new string[] { "CBADONGTIEN1" };
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(defaultValue: false);
            BonusSkins.Register();
            OfficeSkins.Register();
            string             defaultStyle2           = "Money Twins";
            DefaultLookAndFeel defaultLookAndFeelMain2 = new DefaultLookAndFeel();

            if (defaultStyle2 != string.Empty)
            {
                defaultLookAndFeelMain2.LookAndFeel.SetSkinStyle(defaultStyle2);
            }
            string      H_KEY = "HKEY_CURRENT_USER\\Software\\SGD\\";
            RegistryKey HKey  = Registry.CurrentUser.OpenSubKey("Software\\SGD\\");

            if (HKey == null)
            {
                Registry.CurrentUser.CreateSubKey("Software\\SGD\\");
                HKey = Registry.CurrentUser.OpenSubKey("Software\\SGD\\");
            }
            string server = ConfigurationSettings.AppSettings["WebServer"];

            Config.NewKeyValue("WebServer", server);
            string productName3 = "CBABPM";

            string[] softList = HKey.GetSubKeyNames();
            string   P_KEY2   = "";

            if (args.Length != 0)
            {
                productName3 = args[0];
                softList     = new[] { args[0] };
            }



            if (softList.Length > 1)
            {
                fSoftList fsl = new fSoftList();
                fsl.ShowDialog();
                productName3 = fsl.Productname;
                P_KEY2       = H_KEY + productName3 + "\\";
                if (productName3 == string.Empty)
                {
                    return;
                }
            }
            else if (softList.Length == 0)
            {
                //productName3 = "CBASGD133";
                string subkey = "Software\\SGD\\" + productName3;
                P_KEY2 = H_KEY + productName3 + "\\";
                RegistryKey pKey = Registry.CurrentUser.OpenSubKey(subkey);
                if (pKey == null)
                {
                    Registry.CurrentUser.CreateSubKey(subkey);
                    Registry.SetValue(P_KEY2, "CompanyName", "SGD", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "Created", "0", RegistryValueKind.DWord);
                    Registry.SetValue(P_KEY2, "isDemo", "0", RegistryValueKind.DWord);
                    Registry.SetValue(P_KEY2, "Language", "0", RegistryValueKind.DWord);
                    Registry.SetValue(P_KEY2, "Package", "7", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "isOnline", "0", RegistryValueKind.DWord);
                    Registry.SetValue(P_KEY2, "Password", "20-2C-B9-62-AC-59-07-5B-96-4B-07-15-2D-23-4B-70", RegistryValueKind.ExpandString);
                    Registry.SetValue(P_KEY2, "RegisterNumber", "", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "SavePassword", "True", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "StructDb", "SGD", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "RemoteServer", "SGD", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "Style", "Money Twins", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "SupportOnline", "SGD", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "UserName", "Admin", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "isRemote", "False", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "SoftType", "0", RegistryValueKind.DWord);
                }
            }
            else
            {
                productName3 = softList[0];
                P_KEY2       = H_KEY + productName3 + "\\";
            }
            Config.NewKeyValue("ProductName", productName3);
            Config.NewKeyValue("H_KEY", P_KEY2);
            defaultStyle2           = Registry.GetValue(P_KEY2, "Style", string.Empty).ToString();
            defaultLookAndFeelMain2 = new DefaultLookAndFeel();
            if (defaultStyle2 != string.Empty)
            {
                defaultLookAndFeelMain2.LookAndFeel.SetSkinStyle(defaultStyle2);
            }
            string created = Registry.GetValue(P_KEY2, "Created", 0).ToString();

            if (created == "0")
            {
                CreateData frmCreateData = new CreateData(productName3);
                frmCreateData.ShowDialog();
                if (frmCreateData.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
                Registry.SetValue(P_KEY2, "Created", 1);
            }
            Config.NewKeyValue("H_KEY", P_KEY2);
            int SoftType = (int)Registry.GetValue(P_KEY2, "SoftType", 1);
            int isOnline = 0;

            try { isOnline = (int)Registry.GetValue(P_KEY2, "isOnline", 0); } catch { }
            string extend         = isOnline == 0 ? "" : "1";
            string Company        = Registry.GetValue(P_KEY2, "CompanyName", "").ToString();
            CPUid  Cpu            = (SoftType != 0) ? new CPUid(Company + productName3 + "SGDBPMOnline" + extend) : new CPUid(Company + productName3 + "SGDEMTOnline" + extend);
            string RegisterNumber = Registry.GetValue(P_KEY2, "RegisterNumber", "").ToString();

            if (RegisterNumber != Cpu.KeyString)
            {
                Config.NewKeyValue("isDemo", 1);
                if (MessageBox.Show("Bạn đang dùng phiên bản demo, bạn có muốn đăng ký lại không?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    RegisterF rf = new RegisterF();
                    rf.producName = productName3;
                    rf.ShowDialog();
                    Config.NewKeyValue("isDemo", 0);
                    if (rf.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }
                    RegisterNumber = rf.textEditValue.Text;
                }
            }
            else
            {
                Config.NewKeyValue("isDemo", 0);
                Config.NewKeyValue("CompanyName", Company);
                Config.NewKeyValue("SoftType", SoftType);
                Config.NewKeyValue("isOnline", isOnline);
            }
            SetEnvironment();
            //Check data online phải có register trên server



            Login frmLogin = new Login();

            frmLogin.ShowDialog();
            if (frmLogin.DialogResult != DialogResult.Cancel)
            {
                if (isOnline == 1)//Kiểm tra ngày hết hạn
                {
                    try
                    {
                        CDTControl.Log log  = new CDTControl.Log();
                        string         uKey = log.GetExDate(RegisterNumber);
                        UserKey        key  = JsonConvert.DeserializeObject <UserKey>(uKey);
                        if (key == null)
                        {
                            if (File.Exists(productName3 + ".txt"))
                            {
                                MessageBox.Show("Máy bạn đã hết hạn sử dụng gói phần mềm này! \n Liên hệ : 0935.45.75.15 Vỹ Công Trần để được hướng dẫn");
                                return;
                            }
                            else
                            {
                                MessageBox.Show("Bạn cần kết nối internet để kiểm tra cập nhật mới nhất!");
                            }
                        }
                        else if (DateTime.Now > key.Exdate)
                        {
                            MessageBox.Show("Máy bạn đã hết hạn sử dụng gói phần mềm này! \n Liên hệ : 00935.45.75.15 Vỹ Công Trần để được hướng dẫn");
                            LogFile.CreateFile(productName3 + ".txt");
                            return;
                        }
                        else
                        {
                            LogFile.DeleteFile(productName3 + ".txt");
                        }
                    }
                    catch { }
                }
                Application.Run(new Main(frmLogin.drUser, frmLogin.drPackage));
            }
        }
Exemple #17
0
        public static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(defaultValue: false);
            BonusSkins.Register();
            OfficeSkins.Register();
            string             defaultStyle2           = "Money Twins";
            DefaultLookAndFeel defaultLookAndFeelMain2 = new DefaultLookAndFeel();

            if (defaultStyle2 != string.Empty)
            {
                defaultLookAndFeelMain2.LookAndFeel.SetSkinStyle(defaultStyle2);
            }
            string server = ConfigurationSettings.AppSettings["WebServer"];

            Config.NewKeyValue("WebServer", server);
            string productName3 = "CBASGD133";

            if (args.Length != 0)
            {
                productName3 = args[0];
            }
            string      H_KEY = "HKEY_CURRENT_USER\\Software\\SGD\\";
            RegistryKey HKey  = Registry.CurrentUser.OpenSubKey("Software\\SGD\\");

            if (HKey == null)
            {
                Registry.CurrentUser.CreateSubKey("Software\\SGD\\");
                HKey = Registry.CurrentUser.OpenSubKey("Software\\SGD\\");
            }
            string[] softList = HKey.GetSubKeyNames();
            string   P_KEY2   = "";

            if (softList.Length > 1)
            {
                fSoftList fsl = new fSoftList();
                fsl.ShowDialog();
                productName3 = fsl.Productname;
                P_KEY2       = H_KEY + productName3 + "\\";
                if (productName3 == string.Empty)
                {
                    return;
                }
            }
            else if (softList.Length == 0)
            {
                productName3 = "CBASGD133";
                string subkey = "Software\\SGD\\" + productName3;
                P_KEY2 = H_KEY + productName3 + "\\";
                RegistryKey pKey = Registry.CurrentUser.OpenSubKey(subkey);
                if (pKey == null)
                {
                    Registry.CurrentUser.CreateSubKey(subkey);
                    Registry.SetValue(P_KEY2, "CompanyName", "SGD", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "Created", "0", RegistryValueKind.DWord);
                    Registry.SetValue(P_KEY2, "isDemo", "0", RegistryValueKind.DWord);
                    Registry.SetValue(P_KEY2, "Language", "0", RegistryValueKind.DWord);
                    Registry.SetValue(P_KEY2, "Package", "7", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "isOnline", "0", RegistryValueKind.DWord);
                    Registry.SetValue(P_KEY2, "Password", "20-2C-B9-62-AC-59-07-5B-96-4B-07-15-2D-23-4B-70", RegistryValueKind.ExpandString);
                    Registry.SetValue(P_KEY2, "RegisterNumber", "", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "SavePassword", "True", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "StructDb", "SGD", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "RemoteServer", "SGD", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "Style", "Money Twins", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "SupportOnline", "SGD", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "UserName", "Admin", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "isRemote", "False", RegistryValueKind.String);
                    Registry.SetValue(P_KEY2, "SoftType", "0", RegistryValueKind.DWord);
                }
            }
            else
            {
                productName3 = softList[0];
                P_KEY2       = H_KEY + productName3 + "\\";
            }
            Config.NewKeyValue("ProductName", productName3);
            Config.NewKeyValue("H_KEY", P_KEY2);
            defaultStyle2           = Registry.GetValue(P_KEY2, "Style", string.Empty).ToString();
            defaultLookAndFeelMain2 = new DefaultLookAndFeel();
            if (defaultStyle2 != string.Empty)
            {
                defaultLookAndFeelMain2.LookAndFeel.SetSkinStyle(defaultStyle2);
            }
            string created = Registry.GetValue(P_KEY2, "Created", 0).ToString();

            int isOnline = 0;

            try { isOnline = (int)Registry.GetValue(P_KEY2, "isOnline", 0); } catch { }
            Config.NewKeyValue("H_KEY", P_KEY2);
            int SoftType = (int)Registry.GetValue(P_KEY2, "SoftType", 1);

            string extend         = "1";
            string Company        = Registry.GetValue(P_KEY2, "CompanyName", "").ToString();
            CPUid  Cpu            = new CPUid(Company + productName3 + "SGDBPMOnline" + extend);
            string RegisterNumber = Registry.GetValue(P_KEY2, "RegisterNumber", "").ToString();

            if (RegisterNumber != Cpu.KeyString)
            {
                Config.NewKeyValue("isDemo", 1);
                if (MessageBox.Show("Bạn đang dùng phiên bản demo, bạn có muốn đăng ký lại không?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    RegisterF rf = new RegisterF();
                    rf.producName = productName3;
                    rf.ShowDialog();
                    Config.NewKeyValue("isDemo", 0);
                    if (rf.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }
            else
            {
                Config.NewKeyValue("isDemo", 0);
                Config.NewKeyValue("CompanyName", Company);
                Config.NewKeyValue("SoftType", SoftType);
                Config.NewKeyValue("isOnline", isOnline);
            }

            if (isOnline == 0)      // Trường hợp off line
            {
                if (created == "0") //
                {
                    CreateData frmCreateData = new CreateData(productName3);
                    frmCreateData.ShowDialog();
                    if (frmCreateData.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }
                    Registry.SetValue(P_KEY2, "Created", 1);
                }
            }
            else
            {
                CPUid          cpu = new CPUid(productName3);
                UserConnection u   = new UserConnection();
                u.DatabaseName = productName3;
                u.ComputerName = cpu.MaMay;
                u.LicenceKey   = "";// Registry.GetValue(P_KEY2, "EBA4330AABE2029DB278B8A049E33A07", ""); ;
                string ob = JsonConvert.SerializeObject(u);
                string re = GetConnection(ob);
                try
                {
                    u = JsonConvert.DeserializeObject <UserConnection>(re);
                    if (u != null)
                    {
                        string structName = Registry.GetValue(P_KEY2, "StructName", "").ToString();
                        string connection = Security.DeCode64(u.StructDb);
                        connection += ";Database=" + structName;
                        Config.NewKeyValue("StructConnection", Security.EnCode64(connection));
                        if (DateTime.Now > u.TimeEx)
                        {
                            MessageBox.Show("Máy bạn đã hết hạn sử dụng gói phần mềm này!");
                            return;
                        }
                    }
                }
                catch  { }
            }
            SetEnvironment();

            Login frmLogin = new Login();

            frmLogin.ShowDialog();
            if (frmLogin.DialogResult != DialogResult.Cancel)
            {
                if (isOnline == 1)//Kiểm tra ngày hết hạn
                {
                    try
                    {
                        //CDTControl.Log log = new CDTControl.Log();
                        //string uKey =  log.GetExDate(RegisterNumber);
                        //UserKey key = JsonConvert.DeserializeObject<UserKey>(uKey);
                        //DateTime Exdate = key.Exdate;
                        //if (DateTime.Now > Exdate)
                        //    MessageBox.Show("Máy bạn đã hết hạn sử dụng gói phần mềm này!");
                    }
                    catch { }
                }
                Application.Run(new Main(frmLogin.drUser, frmLogin.drPackage));
            }
        }