private void form_load_func() { //while (true) //{ //} work_progress = "正在获取软件版本号..."; productName = ""; int cur_version = get_current_version(ref productName); //if (productName == "收银" || productName == "前台") // register.Visible = true; //else // register.Visible = false; work_progress = "正在检测网络连接..."; db = new BathDBDataContext(connectionString); if (!db.DatabaseExists()) { BathClass.printErrorMsg("连接IP不对或者网络不通,请重试!"); this.Close(); return; //PCListForm pCListForm = new PCListForm(); //if (pCListForm.ShowDialog() != DialogResult.OK) //{ // //_logIn_progress_form.Close(); // this.Close(); // return; //} //connectionIP = pCListForm.ip; //BathClass.set_config_by_key("connectionIP", connectionIP); //db = new BathDBDataContext(connectionString); //if (!db.DatabaseExists()) //{ // BathClass.printErrorMsg("连接IP不对或者网络不通,请重试!"); // //_logIn_progress_form.Close(); // this.Close(); // return; //} } work_progress = "正在检测软件版注册序列号..."; //if (productName == "收银" || productName == "前台") //{ if (!RegisterForm.registered()) { hasRegistered = false; } if (hasRegistered) { register.Visible = false; } else if (!hasRegistered && !checkTrialTimes()) { okBtn.Enabled = false; } //} work_progress = "正在读取软件用户名..."; read_users(); id.Items.AddRange(idList.ToArray()); if (id.Items.Count != 0) { id.Text = id.Items[0].ToString(); } current_box = id; current_box.Focus(); work_progress = "正在从服务器获取最新软件版本号..."; BathClass.download_file(connectionIP, "version.ini", productName + "/version.ini"); int new_version = read_version(); if (new_version > cur_version) { //_logIn_progress_form.Close(); start_updtate(); this.Close(); return; } updateSystemTime(); //_logIn_progress_form.Close(); }
//注册 private void register_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { RegisterForm registerForm = new RegisterForm(); registerForm.ShowDialog(); }
//检查软件使用次数是否超过10次 private bool checkTrialTimes() { BathClass.printWarningMsg("您现在使用的是试用版,可以免费使用10次;"); int tLong = 0; try { tLong = (int)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Angel", "UseTimes", 0); BathClass.printWarningMsg("您已经使用了" + tLong + "次!"); } catch { Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Angel", "UseTimes", 0, RegistryValueKind.DWord); } if (tLong < 10) { int tTimes = tLong + 1; Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Angel", "UseTimes", tTimes); return true; } else { if (BathClass.printAskMsg("试用次数已到!您是否需要注册?") != DialogResult.Yes) return false; RegisterForm regForm = new RegisterForm(); if (regForm.ShowDialog() != DialogResult.OK) return false; return true; } }