Beispiel #1
0
        //检查软件使用次数是否超过10次
        private bool checkTrialTimes()
        {
            GeneralClass.printWarningMsg("您现在使用的是试用版,可以免费使用10次;");
            int tLong = 0;

            try
            {
                tLong = (int)Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Angel", "UseTimes", 0);
                GeneralClass.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 (GeneralClass.printAskMsg("试用次数已到!您是否需要注册?") != DialogResult.Yes)
                {
                    return(false);
                }
                RegisterForm regForm = new RegisterForm(db);
                if (regForm.ShowDialog() != DialogResult.OK)
                {
                    return(false);
                }
                return(true);
            }
        }
Beispiel #2
0
        //检验员工号
        private void id_TextChanged(object sender, EventArgs e)
        {
            if (id.Text.Length == 0)
            {
                return;
            }
            int testInt = 0;

            if (!int.TryParse(id.Text, out testInt))
            {
                GeneralClass.printErrorMsg("数据不合规范!");
                id.SelectAll();
                id.Focus();
                return;
            }

            var employee = db.Employee.FirstOrDefault(x => x.id == testInt);

            if (employee != null)
            {
                name.Text = employee.name;
                job.Text  = db.Job.FirstOrDefault(x => x.id == employee.jobId).name;
            }
            else
            {
                name.Text = "";
                job.Text  = "";
            }
        }
Beispiel #3
0
        //验证用户名和密码
        private void verifyEmployee()
        {
            m_User = db.Employee.FirstOrDefault(x => x.id == Convert.ToInt32(id.Text));
            if (m_User == null)
            {
                id.SelectAll();
                id.Focus();
                GeneralClass.printErrorMsg("该员工号不存在!");
                return;
            }
            if (pwd.Text != m_User.password)
            {
                pwd.SelectAll();
                pwd.Focus();
                GeneralClass.printErrorMsg("密码不对!");
                return;
            }

            write_user();
            this.Hide();
            MainWindow mainWindow = new MainWindow(db);

            mainWindow.ShowDialog();
            this.Close();
        }
Beispiel #4
0
 //注册
 private void okBtn_Click(object sender, EventArgs e)
 {
     if (code.Text == GetRNum())
     {
         MessageBox.Show("注册成功!重启软件后生效!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
         RegistryKey retkey = Registry.CurrentUser.OpenSubKey("Software", true).CreateSubKey("wxf").CreateSubKey("wxf.INI").CreateSubKey(code.Text);
         retkey.SetValue("UserName", "Rsoft");
         Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\AngelReg", "AngelReg", DateTime.Now.ToString());
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     else
     {
         GeneralClass.printErrorMsg("注册失败,请联系赵经理:18670068930");
         this.Close();
     }
 }
Beispiel #5
0
        //检车软件是否注册,没有注册的话,检测软件是否使用超过10天的时限
        public static bool registered()
        {
            bool        HasRegistered = false;
            string      regStr        = GetRNum();
            RegistryKey retkey        = Registry.CurrentUser.OpenSubKey("SOFTWARE", true).CreateSubKey("wxf").CreateSubKey("wxf.INI");

            foreach (string strRNum in retkey.GetSubKeyNames())
            {
                if (strRNum == regStr)
                {
                    string   regTimeStr = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\AngelReg", "AngelReg", 0).ToString();
                    DateTime regTime    = Convert.ToDateTime(regTimeStr);
                    TimeSpan tSpan      = DateTime.Now - regTime;
                    if (tSpan.TotalDays > 10)
                    {
                        GeneralClass.printWarningMsg("软件使用已经过期,请联系YouSoft优软公司重新注册!");
                        return(false);
                    }
                    HasRegistered = true;
                }
            }
            return(HasRegistered);
        }