Пример #1
0
        public static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                args = new string[] { "CBAPOS" }
            }
            ;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            DevExpress.UserSkins.BonusSkins.Register();
            DevExpress.UserSkins.OfficeSkins.Register();
            // DevExpress.Skins.SkinManager.EnableFormSkins();

            //tuy theo moi soft co productName khac nhau
            string productName = "CBASFLOW";     //giá trị mặc định

            if (args.Length > 0)
            {
                productName = args[0];
            }
            string H_KEY = "HKEY_CURRENT_USER\\Software\\SGD\\";

            Config.NewKeyValue("H_KEY", H_KEY);
            Config.NewKeyValue("ProductName", productName);
            string subkey = @"Software\SGD\" + productName;
            string P_KEY  = H_KEY + productName + "\\";

            //lay style mac dinh cho form


            //RegisterNumber

            Config.NewKeyValue("H_KEY", P_KEY);
            RegistryKey pKey = Registry.CurrentUser.OpenSubKey(subkey);

            if (pKey == null)
            {
                Registry.CurrentUser.CreateSubKey(subkey);
                Registry.SetValue(P_KEY, "CompanyName", "SGD", RegistryValueKind.String);
                Registry.SetValue(P_KEY, "Created", "0", RegistryValueKind.DWord);
                Registry.SetValue(P_KEY, "isDemo", "0", RegistryValueKind.DWord);
                Registry.SetValue(P_KEY, "Language", "0", RegistryValueKind.DWord);
                Registry.SetValue(P_KEY, "Package", "7", RegistryValueKind.String);
                Registry.SetValue(P_KEY, "Password", "20-2C-B9-62-AC-59-07-5B-96-4B-07-15-2D-23-4B-70", RegistryValueKind.ExpandString);
                Registry.SetValue(P_KEY, "RegisterNumber", "", RegistryValueKind.String);
                Registry.SetValue(P_KEY, "SavePassword", "True", RegistryValueKind.String);
                Registry.SetValue(P_KEY, "StructDb", "SGD", RegistryValueKind.String);
                Registry.SetValue(P_KEY, "RemoteServer", "SGD", RegistryValueKind.String);
                Registry.SetValue(P_KEY, "Style", "Money Twins", RegistryValueKind.String);
                Registry.SetValue(P_KEY, "SupportOnline", "SGD", RegistryValueKind.String);
                Registry.SetValue(P_KEY, "UserName", "Admin", RegistryValueKind.String);
                Registry.SetValue(P_KEY, "isRemote", "False", RegistryValueKind.String);
            }

            //lay style mac dinh cho form
            string defaultStyle = Registry.GetValue(H_KEY, "Style", string.Empty).ToString();

            DevExpress.LookAndFeel.DefaultLookAndFeel defaultLookAndFeelMain = new DevExpress.LookAndFeel.DefaultLookAndFeel();
            if (defaultStyle != string.Empty)
            {
                defaultLookAndFeelMain.LookAndFeel.SetSkinStyle(defaultStyle);
            }

            //RegisterNumber

            string Company        = Registry.GetValue(P_KEY, "CompanyName", "").ToString();
            CPUid  Cpu            = new CPUid(Company + productName + "SGDEMTOnline");
            string RegisterNumber = Registry.GetValue(P_KEY, "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 = productName;
                    rf.ShowDialog();
                    Config.NewKeyValue("isDemo", 0);
                    if (rf.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }
                }
            }
            else
            {
                Config.NewKeyValue("isDemo", 0);
                Config.NewKeyValue("CompanyName", Company);
            }


            //kiem tra so lieu da duoc khoi tao chua, neu chua thuc hien khoi tao so lieu
            string created = Registry.GetValue(P_KEY, "Created", 0).ToString();

            if (created == "0")
            {
                CreateData frmCreateData = new CreateData(productName);
                frmCreateData.ShowDialog();
                if (frmCreateData.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
                Registry.SetValue(P_KEY, "Created", 1);
            }
            //da co so lieu, bat dau thuc hien dang nhap
            SetEnvironment();
            Login frmLogin = new Login();

            frmLogin.ShowDialog();

            //dang nhap thanh cong, bat dau su dung chuong trinh
            if (frmLogin.DialogResult != DialogResult.Cancel)
            {
                Application.Run(new Main(frmLogin.drUser, frmLogin.drPackage));
            }
        }
Пример #2
0
        public static void Main(string[] args)
        {
            //args = new string[] { "CBA12" };
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            DevExpress.UserSkins.BonusSkins.Register();
            DevExpress.UserSkins.OfficeSkins.Register();
            DevExpress.Skins.SkinManager.EnableFormSkins();

            //tuy theo moi soft co productName khac nhau
            string productName = "CDT"; //giá trị mặc định

            if (args.Length > 0)
            {
                productName = args[0];
            }
            string H_KEY = "HKEY_CURRENT_USER\\Software\\Combosoft\\";

            Config.NewKeyValue("H_KEY", H_KEY);
            Config.NewKeyValue("ProductName", productName);

            //lay style mac dinh cho form
            string defaultStyle = Registry.GetValue(H_KEY, "Style", string.Empty).ToString();

            DevExpress.LookAndFeel.DefaultLookAndFeel defaultLookAndFeelMain = new DevExpress.LookAndFeel.DefaultLookAndFeel();
            if (defaultStyle != string.Empty)
            {
                defaultLookAndFeelMain.LookAndFeel.SetSkinStyle(defaultStyle);
            }

            //RegisterNumber
            string subkey = @"Software\Combosoft\" + productName;
            string P_KEY  = H_KEY + productName + "\\";

            Config.NewKeyValue("H_KEY", P_KEY);
            RegistryKey pKey = Registry.CurrentUser.OpenSubKey(subkey);

            if (pKey == null)
            {
                Registry.CurrentUser.CreateSubKey(subkey);
            }
            string Company        = Registry.GetValue(P_KEY, "CompanyName", "").ToString();
            CPUid  Cpu            = new CPUid(Company + productName);
            string RegisterNumber = Registry.GetValue(P_KEY, "RegisterNumber", "").ToString();

            if (RegisterNumber != Cpu.KeyString)
            {
                Cpu = new CPUid("BanDemo" + Company + "BanDemo" + productName);
                if (RegisterNumber != Cpu.KeyString)
                {
                    RegisterF rf = new RegisterF();
                    rf.producName = productName;
                    rf.ShowDialog();
                    if (rf.DialogResult == DialogResult.Cancel)
                    {
                        return;
                    }
                }
                else
                {
                    int      nCount   = 0;
                    string   path     = System.Environment.SystemDirectory + "\\" + "Info.dat";
                    string[] contents = new string[3];
                    if (System.IO.File.Exists(path))
                    {
                        contents = System.IO.File.ReadAllLines(path);
                        nCount   = Int32.Parse(contents[2]);
                    }
                    nCount++;
                    contents[2] = nCount.ToString();
                    int nRemain = 100 - nCount;
                    if (nRemain == 0)
                    {
                        MessageBox.Show("Phiên bản demo đã hết hạn sử dụng");
                        return;
                    }
                    else
                    {
                        System.IO.File.WriteAllLines(path, contents);
                        if (MessageBox.Show("Bạn đang dùng phiên bản demo - (" + nRemain.ToString() + " lần), 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 = productName;
                            rf.ShowDialog();
                        }
                    }
                }
            }


            //kiem tra so lieu da duoc khoi tao chua, neu chua thuc hien khoi tao so lieu
            string created = Registry.GetValue(P_KEY, "Created", 0).ToString();

            if (created == "0")
            {
                CreateData frmCreateData = new CreateData();
                frmCreateData.ShowDialog();
                if (frmCreateData.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
                Registry.SetValue(P_KEY, "Created", 1);
            }
            //da co so lieu, bat dau thuc hien dang nhap
            SetEnvironment();
            Login frmLogin = new Login();

            frmLogin.ShowDialog();

            //dang nhap thanh cong, bat dau su dung chuong trinh
            if (frmLogin.DialogResult != DialogResult.Cancel)
            {
                Application.Run(new Main(frmLogin.drUser, frmLogin.drPackage));
            }
        }
Пример #3
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));
            }
        }
Пример #4
0
        public static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            DevExpress.UserSkins.BonusSkins.Register();
            DevExpress.UserSkins.OfficeSkins.Register();
            DevExpress.Skins.SkinManager.EnableFormSkins();

            //tuy theo moi soft co productName khac nhau
            string productName = "CDT"; //giá trị mặc định

            if (args.Length > 0)
            {
                productName = args[0];
            }
            string H_KEY = "HKEY_CURRENT_USER\\Software\\Combosoft\\";

            Config.NewKeyValue("H_KEY", H_KEY);
            Config.NewKeyValue("ProductName", productName);

            //lay style mac dinh cho form
            string defaultStyle = Registry.GetValue(H_KEY, "Style", string.Empty).ToString();

            DevExpress.LookAndFeel.DefaultLookAndFeel defaultLookAndFeelMain = new DevExpress.LookAndFeel.DefaultLookAndFeel();
            if (defaultStyle != string.Empty)
            {
                defaultLookAndFeelMain.LookAndFeel.SetSkinStyle(defaultStyle);
            }

            //RegisterNumber
            string P_KEY          = H_KEY + productName + "\\";
            string Company        = Registry.GetValue(P_KEY, "CompanyName", "").ToString();
            CPUid  Cpu            = new CPUid(Company + productName);
            string RegisterNumber = Registry.GetValue(P_KEY, "RegisterNumber", "").ToString();

            if (RegisterNumber != Cpu.KeyString)
            {
                RegisterF rf = new RegisterF();
                rf.producName = productName;
                rf.ShowDialog();
                if (rf.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
            }


            //kiem tra so lieu da duoc khoi tao chua, neu chua thuc hien khoi tao so lieu
            string created = Registry.GetValue(P_KEY, "Created", 0).ToString();

            if (created == "0")
            {
                CreateData frmCreateData = new CreateData();
                frmCreateData.ShowDialog();
                if (frmCreateData.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
                Registry.SetValue(P_KEY, "Created", 1);
            }
            //da co so lieu, bat dau thuc hien dang nhap
            SetEnvironment();
            Login frmLogin = new Login();

            frmLogin.ShowDialog();

            //dang nhap thanh cong, bat dau su dung chuong trinh
            if (frmLogin.DialogResult != DialogResult.Cancel)
            {
                Application.Run(new Main(frmLogin.drUser, frmLogin.drPackage));
            }
        }
Пример #5
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));
            }
        }