예제 #1
0
        private void simpleButtonLogin_Click(object sender, EventArgs e)
        {
            if (dxErrorProviderMain.HasErrors)
            {
                XtraMessageBox.Show("Vui lòng cung cấp đủ thông tin yêu cầu");
                return;
            }

            if (drPackage == null)
            {
                drPackage = (lookUpEditPackage.Properties.GetDataSourceRowByKeyValue(lookUpEditPackage.EditValue) as DataRowView).Row;
            }
            P_KEY = H_KEY;
            Config.NewKeyValue("P_KEY", P_KEY);
            string Product    = drPackage["DbName"].ToString().Trim();
            string oldProduct = Config.GetValue("ProductName").ToString();

            //P_KEY = P_KEY +  Product + "\\";
            if (Product != oldProduct)
            {
                string subkey = @"Software\Combosoft\" + Product;

                RegistryKey pKey = Registry.CurrentUser.OpenSubKey(subkey);
                if (pKey == null)
                {
                    Registry.CurrentUser.CreateSubKey(subkey);
                }
                P_KEY = P_KEY.Replace(oldProduct, Product);
                Config.NewKeyValue("H_KEY", P_KEY);
                string Company        = Registry.GetValue(P_KEY, "CompanyName", "").ToString();
                CPUid  Cpu            = new CPUid(Company + Product + "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 " + Product + " - 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 = Product;
                        rf.ShowDialog();
                        if (rf.DialogResult == DialogResult.Cancel)
                        {
                            return;
                        }
                        Config.NewKeyValue("isDemo", 0);
                    }
                }
                Config.NewKeyValue("ProductName", Product);
            }

            Config.NewKeyValue("Admin", bool.Parse(drPackage["isAdmin"].ToString()));

            Config.NewKeyValue("sysUserPackageID", drPackage["sysUserPackageID"]);
            DangNhap();
        }
예제 #2
0
        private void simpleButtonLogin_Click(object sender, EventArgs e)
        {
            if (dxErrorProviderMain.HasErrors)
            {
                XtraMessageBox.Show("Vui lòng cung cấp đủ thông tin yêu cầu");
                return;
            }

            if (drPackage == null)
            {
                drPackage = (lookUpEditPackage.Properties.GetDataSourceRowByKeyValue(lookUpEditPackage.EditValue) as DataRowView).Row;
            }
            P_KEY = H_KEY;
            Config.NewKeyValue("P_KEY", P_KEY);
            string Product    = drPackage["DbName"].ToString().Trim();
            string oldProduct = Config.GetValue("ProductName").ToString();

            //P_KEY = P_KEY +  Product + "\\";
            if (Product != oldProduct)
            {
                string subkey = @"Software\SGD\" + Product;

                RegistryKey pKey = Registry.CurrentUser.OpenSubKey(subkey);
                P_KEY = P_KEY.Replace(oldProduct, Product);
                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);
                    Registry.SetValue(P_KEY, "SoftType", "0", RegistryValueKind.DWord);
                }

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

            Config.NewKeyValue("Admin", bool.Parse(drPackage["isAdmin"].ToString()));

            Config.NewKeyValue("sysUserPackageID", drPackage["sysUserPackageID"]);
            DangNhap();
        }