private void simpleButton1_Click_1(object sender, EventArgs e) { CDTControl.Log log = new CDTControl.Log(); if (log.Check(tUser.Text, tPass.Text)) { cpu = new CPUid(textCompanyName.Text + _ProductName + "SGDEMTOnline"); textEditMaskcode.Text = cpu.MixString; string key = cpu.KeyString; string keyGet = log.log(textCompanyName.Text, _ProductName, key, tUser.Text, tPass.Text); if (keyGet == key) { textEditValue.Text = key; simpleButtonRegister.Enabled = true; Registry.SetValue(H_KEY, "CompanyName", textCompanyName.Text); Registry.SetValue(H_KEY, "RegisterNumber", key); Registry.SetValue(H_KEY, "isDemo", 0); this.DialogResult = DialogResult.OK; } else { textEditValue.Text = keyGet; } } else { textEditValue.Text = "User hoặc pass chưa đúng,liên hệ SGDSoft để lấy key"; _ProductName = textProduct.Text.Trim().ToUpper(); cpu = new CPUid(textCompanyName.Text + _ProductName + "SGDEMTOnline"); textEditMaskcode.Text = cpu.MixString; } }
private void simpleButton1_Click(object sender, EventArgs e) { companeyName = textEdit1.Text; string Product = textEdit4.Text; CPUid cpu = new CPUid(companeyName + Product); cpu.KeyString = string.Empty; cpu.MixString = textEdit2.Text; textEdit3.Text = cpu.GetKeyString(); }
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(); }
private void Login_Load(object sender, EventArgs e) { textEditUser.Properties.CharacterCasing = CharacterCasing.Upper; vCheckEditRemote.EditValue = bool.Parse(Config.GetValue("isRemote").ToString()); string StructConnectionEx = Registry.GetValue(H_KEY, "StructDb", string.Empty).ToString(); StructConnection = Security.DeCode64(StructConnectionEx); RemoteStructConnection = Registry.GetValue(H_KEY, "RemoteServer", string.Empty).ToString(); RemoteStructConnection = Security.DeCode64(RemoteStructConnection); vCheckEditRemote_CheckedChanged(vCheckEditRemote, new EventArgs()); P_KEY = H_KEY; GetData(); foreach (DevExpress.Skins.SkinContainer cnt in DevExpress.Skins.SkinManager.Default.Skins) { comboBoxEditStyle.Properties.Items.Add(cnt.SkinName); } if (comboBoxEditStyle.Text != string.Empty) { defaultLookAndFeelMain.LookAndFeel.SetSkinStyle(comboBoxEditStyle.Text); } //this.Height = 260; Database _dbStruct = Database.NewCustomDatabase(StructConnection); if (_dbStruct.Connection.DataSource.Contains("45.")) { string _databaseName = _dbStruct.Connection.Database; CPUid cpu = new CPUid(Config.GetValue("ProductName").ToString()); ComputerConnection computer = new ComputerConnection(); computer.ComputerName = SystemInformation.ComputerName; computer.CPUID = cpu.MaMay; computer.DatabaseName = _databaseName; computer.LicenceKey = "";//cpu.GetKeyString(); computer.StructDB = Security.EnCode64(StructConnection); string ob = JsonConvert.SerializeObject(computer); CDTControl.Log log = new CDTControl.Log(); string re = log.CheckComputer(ob); if (re == null || re == "") { MessageBox.Show("Máy này đã không còn được phép truy cập vào dữ liệu, do đổi tên máy hoặc đã bị Admin khóa"); this.DialogResult = DialogResult.Cancel; } } }
private void simpleButton2_Click(object sender, EventArgs e) { CDTControl.Log log = new CDTControl.Log(); string isOnline = int.Parse(rgOnline.EditValue.ToString()) == 0 ? "" : "1"; if (rgCnnType.SelectedIndex == 0) { cpu = new CPUid(textCompanyName.Text + _ProductName + "SGDEMTOnline" + isOnline); } else if (rgCnnType.SelectedIndex == 1) { cpu = new CPUid(textCompanyName.Text + _ProductName + "SGDBPMOnline" + isOnline); } txtMaMay.Text = cpu.MaMay; bool kq = false; try { UserKey uKey = new UserKey(); uKey.ID = 0; uKey.UserID = tfbID.Text; uKey.companyName = textCompanyName.Text; uKey.Mamay = txtMaMay.Text; uKey.CDate = DateTime.Now; uKey.DaTT = 0; uKey.IDGT = tIDGT.Text; uKey.isOnline = int.Parse(rgOnline.EditValue.ToString()); uKey.Product = rgCnnType.SelectedIndex == 0 ? "Phần mềm kế toán" : "Giải pháp BPM"; uKey.Maskcode = cpu.MixString; uKey.LicenseKey = cpu.KeyString; uKey.Exdate = DateTime.Now.AddYears(int.Parse(tSonam.EditValue.ToString())); string ob = JsonConvert.SerializeObject(uKey); textEditMaskcode.Text = cpu.MixString; string key = cpu.KeyString; string keyGet = log.logFb(ob); if (keyGet != "") { UserKey returnKey1 = JsonConvert.DeserializeObject <UserKey>(keyGet); textEditValue.Text = returnKey1.LicenseKey; simpleButtonRegister.Enabled = true; simpleButtonRegister_Click(sender, e); } else { // textEditValue.Text = keyGet; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void simpleButtonRegister_Click(object sender, EventArgs e) { _ProductName = textProduct.Text.Trim().ToUpper(); string isOnline = int.Parse(rgOnline.EditValue.ToString()) == 0 ? "" : "1"; if (rgCnnType.SelectedIndex == 0) { cpu = new CPUid(textCompanyName.Text + _ProductName + "SGDEMTOnline" + isOnline); } else if (rgCnnType.SelectedIndex == 1) { cpu = new CPUid(textCompanyName.Text + _ProductName + "SGDBPMOnline" + isOnline); } textEditMaskcode.Text = cpu.MixString; if (textCompanyName.Text == "SGD") { textEditValue.Text = cpu.KeyString; } cpu.KeyString = string.Empty; if (cpu == null) { return; } string key = cpu.GetKeyString(); //Registry.SetValue(H_KEY, "Structtmp", key); if (textEditValue.Text == key) { Registry.SetValue(H_KEY, "StructName", "CDT" + _ProductName.Substring(3, _ProductName.Length - 3)); Registry.SetValue(H_KEY, "CompanyName", textCompanyName.Text); Registry.SetValue(H_KEY, "RegisterNumber", textEditValue.Text); Registry.SetValue(H_KEY, "isDemo", 0); Registry.SetValue(H_KEY, "isOnline", int.Parse(rgOnline.EditValue.ToString())); Registry.SetValue(H_KEY, "SoftType", rgCnnType.SelectedIndex.ToString(), RegistryValueKind.DWord); if (tfbID.Text != "") { Registry.SetValue(H_KEY, "fbID", tfbID.Text); } this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Vui lòng liên hệ SGD soft để được đăng ký sử dụng!"); } }
private void simpleButtonRegister_Click(object sender, EventArgs e) { _ProductName = textProduct.Text.Trim().ToUpper(); cpu = new CPUid(textCompanyName.Text + _ProductName + "SGDEMTOnline"); textEditMaskcode.Text = cpu.MixString; if (textCompanyName.Text == "SGD") { textEditValue.Text = cpu.KeyString; } cpu.KeyString = string.Empty; if (cpu == null) { return; } string key = cpu.GetKeyString(); Registry.SetValue(H_KEY, "Structtmp", key); if (textEditValue.Text == key) { Registry.SetValue(H_KEY, "CompanyName", textCompanyName.Text); Registry.SetValue(H_KEY, "RegisterNumber", textEditValue.Text); Registry.SetValue(H_KEY, "isDemo", 0); this.DialogResult = DialogResult.OK; } else { if (sl == 10) { Registry.SetValue(H_KEY, "CompanyName", textCompanyName.Text); Registry.SetValue(H_KEY, "RegisterNumber", key); Registry.SetValue(H_KEY, "isDemo", 0); this.DialogResult = DialogResult.OK; } else { sl += 1; MessageBox.Show("Vui lòng liên hệ SGD soft để được đăng ký sử dụng!"); } } }
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)); } }
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(); }
private void simpleButtonOk_Click(object sender, EventArgs e) { if (this.dxErrorProviderMain.HasErrors) { XtraMessageBox.Show("Thông tin chưa hợp lệ, vui lòng kiểm tra lại!"); } else { this._ver = this.txtCDT.Text; string text = this.textEditServer.Text; string textRemote = this.txtRemoteServer.Text; DataMaintain maintain = new DataMaintain(text, textRemote, this.radioGroupCnnType.SelectedIndex, this.textEditUser.Text, this.textEditPassword.Text); maintain.isServer2005 = this.cEis2005.Checked; this.layoutControl1.Refresh(); bool flag = false; if (this.radioGroupType.SelectedIndex == 1) { flag = maintain.ClientExecute(this._ver); string H_KEY = Config.GetValue("H_KEY").ToString(); if (flag) { } if (flag && ckUpdateRemote.Checked) { maintain.UpdateRemoteServer(txtRemoteServer.Text, this._ver); } if (flag && CkUpdateLocal.Checked) { maintain.UpdateLocalServer(text, this._ver); } } else { flag = maintain.ServerExecute(Application.StartupPath, this._ver); } if (flag) { //Đăng ký sử dụng nếu là dataonline if (text.Contains("45.")) { string _databaseName = _ver; CPUid cpu = new CPUid(Config.GetValue("ProductName").ToString()); ComputerConnection computer = new ComputerConnection(); computer.ComputerName = SystemInformation.ComputerName; computer.CPUID = cpu.MaMay; computer.DatabaseName = _databaseName; computer.LicenceKey = "";//cpu.GetKeyString(); computer.StructDB = Security.EnCode64(maintain.Connection); string ob = JsonConvert.SerializeObject(computer); CDTControl.Log log = new CDTControl.Log(); string re = log.RegistComputer(ob); if (re == null || re == "") { XtraMessageBox.Show("Có lỗi trong quá trình tạo số liệu, vui lòng kiểm tra lại!"); return; } } base.DialogResult = DialogResult.OK; } else { XtraMessageBox.Show("Có lỗi trong quá trình tạo số liệu, vui lòng kiểm tra lại!"); } } }
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)); } }
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)); } }
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)); } }
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)); } }
private void simpleButton2_Click(object sender, EventArgs e) { CDTControl.Log log = new CDTControl.Log(); string isOnline = int.Parse(rgOnline.EditValue.ToString()) == 0 ? "" : "1"; if (rgCnnType.SelectedIndex == 0) { cpu = new CPUid(textCompanyName.Text + _ProductName + "SGDEMTOnline" + isOnline); } else if (rgCnnType.SelectedIndex == 1) { cpu = new CPUid(textCompanyName.Text + _ProductName + "SGDBPMOnline" + isOnline); } txtMaMay.Text = cpu.MaMay; bool kq = false; try { UserKey uKey = new UserKey(); uKey.ID = 0; uKey.UserID = tfbID.Text; uKey.companyName = textCompanyName.Text; uKey.Mamay = txtMaMay.Text; uKey.CDate = DateTime.Now; uKey.DaTT = 0; uKey.IDGT = tIDGT.Text; uKey.isOnline = int.Parse(rgOnline.EditValue.ToString()); uKey.Product = rgCnnType.SelectedIndex == 0 ? "Phần mềm kế toán" : "Giải pháp BPM"; uKey.Maskcode = cpu.MixString; uKey.LicenseKey = cpu.KeyString; uKey.Exdate = DateTime.Now.AddYears(1); string ob = JsonConvert.SerializeObject(uKey); textEditMaskcode.Text = cpu.MixString; string key = cpu.KeyString; string keyGet = log.logFb(ob); if (keyGet != "") { UserKey returnKey1 = JsonConvert.DeserializeObject <UserKey>(keyGet); textEditValue.Text = returnKey1.LicenseKey; simpleButtonRegister.Enabled = true; //Đăng ký tên máy - Key cho server if (isOnline == "1") { UserConnection uCon = new UserConnection(); uCon.ComputerName = uKey.Mamay; uCon.DatabaseName = _ProductName; uCon.LicenceKey = returnKey1.LicenseKey; uCon.StructDb = ""; uCon.TimeEx = DateTime.Now.AddYears(int.Parse(sSonam.Value.ToString())); ob = JsonConvert.SerializeObject(uCon); string re = RegistConnection(ob); uCon = JsonConvert.DeserializeObject <UserConnection>(re); if (uCon != null) { string Con = GetConnection(uCon.stt); uCon = JsonConvert.DeserializeObject <UserConnection>(Con); string StructConnection = Security.DeCode64(uCon.StructDb); StructConnection += ";Database = " + Config.GetValue("ProductName").ToString(); Config.NewKeyValue("StructConnection", Security.EnCode64(StructConnection)); } } simpleButtonRegister_Click(sender, e); } else { // textEditValue.Text = keyGet; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }