Exemplo n.º 1
0
        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Enter_Click(object sender, EventArgs e)
        {
            string oldpwd = tb_OldPwd.Text.Trim();

            if (oldpwd.Length != tb_OldPwd.MaxLength)
            {
                DisplayContent("旧口令长度为 6 位数字,请重新输入旧口令。");
                tb_OldPwd.Focus();
                return;
            }

            try
            {
                IsEnd = false;
                byte[] by = PortAgreement.GetTemporaryEncryption(oldpwd);
                PortHelper.SerialPortWrite(by);
                p_Top.Enabled = false;
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 设置设备新密码
 /// </summary>
 private void SetDeviceNewPassword()
 {
     PortHelper.SerialPortWrite(PortAgreement.GetTemporaryEncryption(Dal_IcDevicePwd.TempIcDevicePassword.Pwd));
 }
Exemplo n.º 3
0
        /// <summary>
        /// 确认
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Enter_Click(object sender, EventArgs e)
        {
            string oldpwd     = tb_OldPwd.Text.Trim();
            string newpwd     = tb_NewPwd.Text.Trim();
            string confirmpwd = tb_ConfirmPwd.Text.Trim();

            if (Dal_IcDevicePwd.TempIcDevicePassword.ID != 0)
            {
                if (oldpwd.Length != tb_OldPwd.MaxLength)
                {
                    DisplayContent("旧口令长度为 8 位数字,请重新输入旧口令。");
                    tb_OldPwd.Focus();
                    return;
                }
                if (oldpwd != Dal_IcDevicePwd.TempIcDevicePassword.Pwd)
                {
                    DisplayContent("验证旧口令错误,新重新输入口令。");
                    tb_OldPwd.Focus();
                    return;
                }
            }
            if (newpwd.Length != tb_NewPwd.MaxLength)
            {
                DisplayContent("新口令长度为 8 位数字,请重新输入新口令。");
                tb_NewPwd.Focus();
                return;
            }
            if (confirmpwd.Length != tb_ConfirmPwd.MaxLength)
            {
                DisplayContent("确认口令长度为 8 位数字,请重新输入确认口令。");
                tb_ConfirmPwd.Focus();
                return;
            }
            if (newpwd != confirmpwd)
            {
                DisplayContent("新口令与确认口令不一致。");
                tb_ConfirmPwd.Focus();
                return;
            }
            try
            {
                byte[] by = PortAgreement.GetTemporaryEncryption(newpwd);
                PortHelper.SerialPortWrite(by);
                if (Dal_IcDevicePwd.TempIcDevicePassword.ID == 0)
                {
                    //插入新密码
                    CbIcDeviePwd mTempIcPassword = new CbIcDeviePwd()
                    {
                        Pwd = newpwd
                    };
                    mTempIcPassword.ID = Dbhelper.Db.Insert <CbIcDeviePwd>(mTempIcPassword);
                    Dal_IcDevicePwd.TempIcDevicePassword   = mTempIcPassword;
                    Tab1_Form.GetInstance.btn_Tab5.Enabled = true;
                }
                else
                {
                    //更新新密码
                    Dal_IcDevicePwd.TempIcDevicePassword.Pwd = newpwd;
                    Dbhelper.Db.Update <CbIcDeviePwd>(Dal_IcDevicePwd.TempIcDevicePassword);
                }
                if (!PortHelper.IsConnection)
                {
                    DisplayContent("临时 IC 设备口令设置成功,请保管好口令。", Color.Black);
                    ClearTxt();
                }
            }
            catch (Exception ex)
            {
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }