/// <summary>
        /// 解锁
        /// </summary>
        /// <param name="cardnumber"></param>
        /// <param name="flag"></param>
        private void UnlockDistanceCard(int flag)
        {
            try
            {
                StopTimeOutThread();
                int index = -1;
                foreach (KeyValuePair <CbCardInfo, int> item in _mUnLockList)
                {
                    index++;
                    if (_mUnLockCardInfo != null && item.Key == _mUnLockCardInfo)
                    {
                        if (flag == 0)
                        {
                            item.Key.Unlocked = 0;
                            Dbhelper.Db.Update <CbCardInfo>(item.Key);
                            dgv_UnlockList["c_State", index].Value = Properties.Resources.check;
                            OnLockChange(item);
                        }
                        _mUnLockCardInfo = null;
                        continue;
                    }
                    if (_mUnLockCardInfo != null)
                    {
                        continue;
                    }
                    if (item.Key.Unlocked == 0)
                    {
                        continue;
                    }
                    _mUnLockCardInfo = item.Key;
                    DistanceTypeParameter typeparam = new DistanceTypeParameter()
                    {
                        Lock = 0, Distance = item.Key.Distance
                    };
                    int    typebyte = DistanceCardHelper.SetCardTypeByte(typeparam, 1);
                    byte[] by       = PortAgreement.GetDistanceContent(item.Key.CardNumber, typebyte);
                    PortHelper.SerialPortWrite(by);

                    StartTimeOutThread();
                    return;
                }
                foreach (KeyValuePair <CbCardInfo, int> item in _mUnLockList)
                {
                    if (item.Key.Unlocked != 0)
                    {
                        UseControlEnabled();
                        return;
                    }
                }
                dgv_UnlockList.Rows.Clear();
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                UseControlEnabled();
                CustomExceptionHandler.GetExceptionMessage(ex);
                MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }