//檢查環境代碼 private void btnCheckEnvironmentCode_Click(object sender, EventArgs e) { if (txtEnvironmentCode.Text == "") { MessageBox.Show("請輸入環境代碼!!", "檢查環境代碼"); return; } My.MySNAuthority CSNA = new My.MySNAuthority(); string OSName = CSNA.QryOSName(txtEnvironmentCode.Text.Substring(0, 5)); string NICName = CSNA.QryNICName(txtEnvironmentCode.Text.Substring(5, 5)); string msg = ""; if (OSName != "Error" && NICName != "Error") { msg = "環境代碼正確!!\n"; msg = msg + "您的作業系統為:" + OSName + "\n"; msg = msg + "您的網路介面卡為:" + NICName + "\n"; MessageBox.Show(this, msg, "資訊", MessageBoxButtons.OK, MessageBoxIcon.Information); cbxOS.SelectedItem = OSName; cbxNIC.SelectedItem = NICName; } else { msg = "環境代碼錯誤!!\n"; msg = msg + "您的作業系統為:" + OSName + "\n"; msg = msg + "您的網路介面卡為:" + NICName + "\n"; MessageBox.Show(this, msg, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//確定 private void btnOK_Click(object sender, EventArgs e) { if (cbxAgreement.Checked == false) { MessageBox.Show("請勾選同意五大條款規範", "訊息"); return; } if (txtUserName.Text == "" || txtUserName.Text.Length < 3) { MessageBox.Show("使用者名稱不得為空白且長度需大於等於3", "訊息"); return; } if (txtSN.Text == "") { MessageBox.Show("序號不得為空白!!", "訊息"); return; } My.MySNAuthority SNAuth = new My.MySNAuthority(); if (SNAuth.checkSN(txtUserName.Text, txtSN.Text)) { My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "Registration", "RegisterCode", txtSN.Text); My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "Registration", "RegisterEnvironmentCode", txtEnvironmentCode.Text); My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "Registration", "RegisterUser", txtUserName.Text); My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "Registration", "IsRegister", 1); MessageBox.Show("序號正確,恭喜您已經註冊成功!", "註冊結果", MessageBoxButtons.OK, MessageBoxIcon.Information); MdiParent.Text = "超級進銷存系統(SIS) V1.0 - (中文旗艦版)"; this.Close(); } else { MessageBox.Show("序號錯誤", "註冊結果", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//序號驗證 private void btnVerifySN_Click(object sender, EventArgs e) { My.MySNAuthority SNA = new My.MySNAuthority(); if (SNA.checkSN(txtUserName.Text, txtSN.Text)) { MessageBox.Show("序號正確!!"); } else { MessageBox.Show("序號錯誤!!"); } }
private void btnGenSN_Click(object sender, EventArgs e) { if (txtUserName.Text.Length <= 2) { MessageBox.Show("使用者名稱長度至少為3"); return; } if (txtEnvironmentCode.Text.Length != 10) { MessageBox.Show("環境代碼長度為10"); return; } My.MySNAuthority SNA = new My.MySNAuthority(); txtSN.Text = SNA.GenerateKey(txtUserName.Text, txtEnvironmentCode.Text); }
//產生環境代碼 private void btnGenEnviornmentCode_Click(object sender, EventArgs e) { if (cbxOS.Text == "") { MessageBox.Show("請選取作業系統!!"); cbxOS.Focus(); return; } if (cbxNIC.Text == "") { MessageBox.Show("請選取網路卡廠商!!"); cbxNIC.Focus(); return; } My.MySNAuthority SNA = new My.MySNAuthority(); txtEnvironmentCode.Text = SNA.GetOSCode(cbxOS.Text, true) + SNA.GetNICCode(cbxNIC.Text, true); }
//驗證產生環境代碼序號 private void btnEnvironmentCodeSN_Click(object sender, EventArgs e) { if (txtEnvironmentCode.Text.Length != 10) { MessageBox.Show("請先產生環境代碼!!"); return; } My.MySNAuthority SNA = new My.MySNAuthority(); if (SNA.checkSN(txtUserName.Text, txtSN.Text, txtEnvironmentCode.Text)) { MessageBox.Show("序號正確!!"); } else { MessageBox.Show("序號錯誤!!"); } }
private void txtSN_TextChanged(object sender, EventArgs e) { string[] code = txtSN.Text.Split('-'); My.MySNAuthority SNAuth = new My.MySNAuthority(); if (code.Length == 5 && txtSN.Text.Length >= 29 && txtUserName.Text.Length >= 3) { if (SNAuth.checkSN(txtUserName.Text, txtSN.Text)) { this.PicBox_ok.Visible = true; } else { this.PicBox_ok.Visible = false; } } else { this.PicBox_ok.Visible = false; } }
private void FrmProductRegistration_Load(object sender, EventArgs e) { My.MySNAuthority SNA = new My.MySNAuthority(); txtEnvironmentCode.Text = SNA.GenEnvironmentCode(); txtEnvironmentCode.Enabled = false; }
private void txtEnvironmentCode_TextChanged(object sender, EventArgs e) { My.MySNAuthority SNA = new My.MySNAuthority(); txtEnvironmentCode.Text = SNA.GenEnvironmentCode(); }
/// <summary> /// 登錄檔處理 /// </summary> public void RegistryProcess() { //SysProfile系統設定檔變數宣告======================================== bool IsStart; //記錄系統是否啟動過 int SystemUseCount = 0; //記錄系統使用次數 string SetupDate; //記錄系統安裝日期 string PreUser = ""; //記錄系統上次使用者 string PreUseSysTime; //紀錄上次使用系統時間 string SystemName; //記錄系統名稱 string CurrentVersion; //記錄系統目前版本 string SystemTitle; //記錄系統標題名稱 string DefaultLocale; //記錄系統預設語系 string DefaultLanguage; //記錄系統使用何種程式語言開發 string NowDateTime; NowDateTime = DateTime.Now.ToString("yyyy年MM月dd日 hh:mm:ss"); SetupDate = NowDateTime; PreUser = "******"; PreUseSysTime = NowDateTime; SystemName = My.MyGlobal.GlobalSystemName; CurrentVersion = My.MyGlobal.GlobalSystemVersion; SystemTitle = My.MyGlobal.GlobalSystemTitle; DefaultLocale = My.MyGlobal.GlobalUseLocale; DefaultLanguage = My.MyGlobal.GlobalDefaultLanguage; IsStart = Convert.ToBoolean(My.MyWinAPI.GetSubKeyValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "SysProfile", "IsStart")); //IsStart = (IsStartString == "true") ? true : false; if (IsStart) //若IsStart=True表示已經有將基本資料寫入到登錄檔! { //MessageBox.Show(this, "已經有將基本資料寫入到登錄檔!!", "訊息提示"); SystemUseCount = Convert.ToInt16(My.MyWinAPI.GetSubKeyValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "SysProfile", "SystemUseCount")); My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "SysProfile", "SystemUseCount", SystemUseCount + 1); My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "SysProfile", "PreUseSysTime", PreUseSysTime); } else //若IsStart=False表示第一次啟動系統 { MessageBox.Show(this, "第一次啟動系統,執行登錄檔作業!!", "訊息提示"); My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "SysProfile", "IsStart", 1); My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "SysProfile", "SystemUseCount", 1); My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "SysProfile", "SetupDate", SetupDate); My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "SysProfile", "PreUser", PreUser); My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "SysProfile", "PreUseSysTime", PreUseSysTime); My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "SysProfile", "SystemName", SystemName); My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "SysProfile", "CurrentVersion", CurrentVersion); My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "SysProfile", "SystemTitle", SystemTitle); My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "SysProfile", "DefaultLocale", DefaultLocale); My.MyWinAPI.CreateSubKeyAndSetValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "SysProfile", "DefaultLanguage", DefaultLanguage); } //登錄檔讀取註冊訊息==================================================Start string sn = ""; string username = ""; sn = Convert.ToString(My.MyWinAPI.GetSubKeyValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "Registration", "RegisterCode")); username = Convert.ToString(My.MyWinAPI.GetSubKeyValue("CurrentUser", My.MyGlobal.GlobalSysRegDefaultPath + "Registration", "RegisterUser")); //將驗證序號類別My.MySNAuthority實體化 My.MySNAuthority SNAuth = new My.MySNAuthority(); //檢查登錄檔中的序號資料是否正確,若是正確序號則顯示為中文專業版,若是序號錯誤則顯示30天試用版 if (SNAuth.checkSN(username, sn)) { this.Text = "超級進銷存系統(SIS) V1.0 - (中文旗艦版)"; } else { this.Text = "超級進銷存系統(SIS) V1.0 - (30天試用版)"; TrySystemIsTimeOut(); //若尚未註冊則判斷還能試用多久時間 } //登錄檔讀取註冊訊息==================================================End }