Exemplo n.º 1
0
        private void ReadIcData(Intent intent)
        {
            m_intent    = intent;
            ic.icserial = ic.FindIC(m_intent);

            Car = new CarInfo();    //初始化一个CarInfo类

            //取出封装在intent中的TAG
            var tag = intent.GetParcelableExtra(NfcAdapter.ExtraTag) as Tag;

            if (tag == null)
            {
                return;
            }
            m_tag = tag;

            #region 清空文本
            carNumber      = FindViewById <EditText>(Resource.Id.carNumber);
            carNumber.Text = "";
            #endregion

            MifareClassic mfc = MifareClassic.Get(m_tag);
            if (mfc != null)
            {
                #region 获取到tag
                try
                {
                    mfc.Connect();
                    var type = mfc.GetType();
                    if (type.Equals(typeof(Android.Nfc.Tech.MifareClassic)))
                    {
                        #region 循环读取5个扇区数据
                        for (int i = 0; i < ic.sectors.Length; i++)
                        {
                            for (int k = 0; k < 3; k++)
                            {
                                int sec = mfc.BlockToSector(ic.sectors[i] * 4 + k);
                                if (sec < mfc.SectorCount)
                                {
                                    if (mfc.AuthenticateSectorWithKeyB(sec, ic.ToDigitsBytes(ic.mb)))
                                    {
                                        int c = mfc.SectorCount;
                                        c = mfc.BlockCount;

                                        byte[] data = new byte[16];
                                        data = mfc.ReadBlock(ic.sectors[i] * 4 + k);
                                        if (data != null)
                                        {
                                            ic.IcDatas[i, k] = ic.ToHexString(data);
                                            ic.isReadIcOK    = true;
                                        }
                                        else
                                        {
                                            CommonFunction.ShowMessage("读取" + ic.sectors[i].ToString() + "扇区" + Convert.ToString(ic.sectors[i] * 4 + k) + "块失败!", this, true);
                                            ic.isReadIcOK = false;
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        CommonFunction.ShowMessage("密码验证失败!", this, true);
                                        ic.isReadIcOK = false;
                                        return;
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                }
                catch (Exception ex)
                {
                    CommonFunction.ShowMessage(ex.Message, this, true);
                }
                finally
                {
                    mfc.Close();
                }

                if (ic.isReadIcOK)
                {
                    try
                    {
                        //解析扇区数据
                        Car = ic.GetCarInfo(ic.IcDatas);

                        if (Car != null)
                        {
                            CommonFunction.ShowMessage("", this, false);

                            #region 读卡正确,显示在窗体文本内,按钮复活

                            carNumber.Text = Car.CarPlate;
                            // carNumber.Text = "GT030108";//暂用

                            //根据车号查询 相关收发货路线信息
                            goodsInfo();
                            #endregion
                        }
                        else
                        {
                            #region 读卡异常,按钮不可用
                            btSender.Enabled = false;

                            btGet.Enabled = false;
                            CommonFunction.ShowMessage("卡内信息错误!", this, true);
                            #endregion
                        }
                    }
                    catch (System.ArgumentOutOfRangeException ax)
                    {
                        CommonFunction.ShowMessage("读卡信息错误!", this, true);
                    }
                    catch (Exception ex)
                    {
                        CommonFunction.ShowMessage(ex.Message, this, true);
                    }
                }

                #endregion
            }
            else
            {
                #region 判断卡类型
                btGet.Enabled    = false;
                btSender.Enabled = false;

                btGet.Checked    = false;
                btSender.Checked = false;
                CommonFunction.ShowMessage("不支持该类型的卡", this, true);
                ic.isReadIcOK = false;
                return;

                #endregion
            }
        }
Exemplo n.º 2
0
        private void ReadIcData(Intent intent)
        {
            m_intent    = intent;
            ic.icserial = ic.FindIC(m_intent);

            Car = new CarInfo();    //初始化一个CarInfo类

            //取出封装在intent中的TAG
            tag = intent.GetParcelableExtra(NfcAdapter.ExtraTag) as Tag;
            if (tag == null)
            {
                return;
            }
            m_tag = tag;

            //清空文本
            extra_bags.Text     = "";
            samp_bags.Text      = "";
            samp_factory.Text   = "";
            samp_goodsname.Text = "";
            samp_carNumber.Text = "";
            cmeasure_Id.Text    = "";
            MifareClassic mfc = MifareClassic.Get(m_tag);

            if (mfc != null)
            {
                #region 获取到tag
                try
                {
                    mfc.Connect();
                    var type = mfc.GetType();
                    if (type.Equals(typeof(Android.Nfc.Tech.MifareClassic)))
                    {
                        #region 循环读取5个扇区数据
                        for (int i = 0; i < ic.sectors.Length; i++)
                        {
                            for (int k = 0; k < 3; k++)
                            {
                                int sec = mfc.BlockToSector(ic.sectors[i] * 4 + k);
                                if (sec < mfc.SectorCount)
                                {
                                    if (mfc.AuthenticateSectorWithKeyB(sec, ic.ToDigitsBytes(ic.mb)))
                                    {
                                        int c = mfc.SectorCount;
                                        c = mfc.BlockCount;

                                        byte[] data = new byte[16];
                                        data = mfc.ReadBlock(ic.sectors[i] * 4 + k);
                                        if (data != null)
                                        {
                                            ic.IcDatas[i, k] = ic.ToHexString(data);
                                            ic.isReadIcOK    = true;
                                        }
                                        else
                                        {
                                            CommonFunction.ShowMessage("读取" + ic.sectors[i].ToString() + "扇区" + Convert.ToString(ic.sectors[i] * 4 + k) + "块失败!", this, true);
                                            ic.isReadIcOK = false;
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        CommonFunction.ShowMessage("密码验证失败!", this, true);
                                        ic.isReadIcOK = false;
                                        return;
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                }
                catch (Exception ex)
                {
                    CommonFunction.ShowMessage(ex.Message, this, true);
                }
                finally
                {
                    mfc.Close();
                }

                if (ic.isReadIcOK)
                {
                    try
                    {
                        //解析扇区数据
                        Car = ic.GetCarInfo(ic.IcDatas);

                        if (Car != null)
                        {
                            // CommonFunction.ShowMessage("", this, false);

                            //将摇号信息写入本地数据表
                            // isEqualFactory();

                            #region 读卡正确,显示在窗体文本内,按钮复活
                            //是否为同一张卡 重复卡不得重复刷
                            if (!isEqualFactory())
                            {
                                samp_carNumber.Text = Car.CarPlate;

                                // bussnise.Text = Car.BusinessType;

                                // measuremode.Text = Car.MeasureMode;

                                cmeasure_Id.Text = Car.MeasureID;

                                //根据车号和计量单号 从计量系统中查询 采购订单号 供应商编号 供应商名称 货物编号 货物名称等信息
                                bsif.selectCmInfo(Car.CarPlate, Car.MeasureID, out cMeasureID, out purchaseOrderID, out car_factoryCode, out car_factoryName, out car_goodsCode, out car_goodsName);
                                samp_factory.Text   = car_factoryName;
                                samp_goodsname.Text = car_goodsName;
                            }
                            #endregion
                        }
                        else
                        {
                            #region 读卡异常,按钮不可用
                            ToggleButton samp = FindViewById <ToggleButton>(Resource.Id.btExtract);
                            samp.Enabled = false;
                            CommonFunction.ShowMessage("卡内信息错误!", this, true);
                            #endregion
                        }
                    }
                    catch (System.ArgumentOutOfRangeException ax)
                    {
                        CommonFunction.ShowMessage("读卡信息错误!", this, true);
                    }
                    catch (Exception ex)
                    {
                        CommonFunction.ShowMessage(ex.Message, this, true);
                    }
                }

                #endregion
            }
            else
            {
                #region 判断卡类型
                btExtra.Enabled = false;

                btExtra.Checked = false;
                CommonFunction.ShowMessage("不支持该类型的卡", this, true);
                ic.isReadIcOK = false;
                return;

                #endregion
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据扇区信息获取车辆信息
        /// </summary>
        public CarInfo GetCarInfo(string[,] icdatas)
        {
            CarInfo car = new CarInfo();

            try
            {
                #region 解析扇区数据

                //--------------内盘-------
                // string ssd = IcDatas[1, 2].Substring(0,4);
                //--------------------取样卡/计量卡标识 3区13块 [2,1]
                car.isSampIc = IcDatas[2, 1].Substring(0, 1);
                if (car.isSampIc != "1")
                {
                    #region 新的计量系统
                    car.CardID   = GetDecryptSequenceNumber(IcDatas[0, 0]).Substring(0, 12); //计量单号
                    car.CarPlate = GetDecryptSequenceNumber(IcDatas[0, 0]).Substring(12);    //车牌号
                    #endregion
                    //--------------------------读取IC卡号和车牌号并显示。      1扇区4块:8位卡号+24位车号
                    //car.CardID = GetDecryptSequenceNumber(IcDatas[0, 0]).Substring(0, 8);
                    //car.CarPlate = GetDecryptSequenceNumber(IcDatas[0, 0]).Substring(8);//旧的读取方法
                    //  car.CarPlate = GetDecryptSequenceNumber(IcDatas[0, 0]).Substring(12);//新的读取方法

                    //读取业务类型 计量方式 计量类型
                    //业务类型 位于1扇区5块第0位;  计量类型 位于1扇区5块第1位;计重方式 位于1扇区5块第2位;退货标识 位于1扇区5块第3位;
                    //0业务类型 1计量类型 2计重方式 3 退货标识


                    //string ywlx = IcDatas[1, 2].Substring(0, 1);
                    // string ddd = IcDatas[1, 2].Substring(1,3);
                    string ywlx = IcDatas[0, 1].Substring(0, 1);
                    //if (ywlx == "0") car.BusinessType = "采购进厂";
                    //else if (ywlx == "1") car.BusinessType = "采购退货";
                    //else if (ywlx == "2") car.BusinessType = "销售出厂";
                    //else if (ywlx == "3") car.BusinessType = "销售退货";
                    //else if (ywlx == "4") car.BusinessType = "其他";


                    //新系统
                    if (ywlx == "1")
                    {
                        car.BusinessType = "采购进厂";
                    }
                    else if (ywlx == "2")
                    {
                        car.BusinessType = "采购退货";
                    }
                    else if (ywlx == "5")
                    {
                        car.BusinessType = "销售出厂";
                    }
                    else if (ywlx == "6")
                    {
                        car.BusinessType = "销售退货";
                    }
                    else if (ywlx == "7")
                    {
                        car.BusinessType = "其他";
                    }


                    //--------------------------计量类型	0:毛重 1:皮重
                    car.MeasurementType = IcDatas[0, 1].Substring(1, 1) == "0" ? "毛重" : "皮重";

                    //业务类型  0:采购进厂1:采购退货2:销售出厂3:销售退货 4:其他

                    //--------------------------计重方式
                    //业务类型为采购进厂或销售出厂时0:一车一货1:一车多货
                    //业务类型为采购退货时:0:卸后退(全车退)。1:半车退
                    //业务类型为销售退货时:0:一车一货1:新安退库
                    //业务类型为其他时:0:普通 1:定期皮
                    string jzfs = IcDatas[0, 1].Substring(2, 1);        //2017-05-28 修改Substring(1, 2)为Substring(2, 1) :原因:读取的卡都是一车多货
                    if (car.BusinessType == "采购进厂" || car.BusinessType == "销售出厂")
                    {
                        car.MeasureMode = (jzfs == "0") ? "一车一货" : "一车多货";
                    }
                    else if (car.BusinessType == "采购退货")
                    {
                        car.MeasureMode = (jzfs == "0") ? "卸后退(全车退)" : "半车退";
                    }
                    else if (car.BusinessType == "销售退货")
                    {
                        car.MeasureMode = (jzfs == "0") ? "一车一货" : "新安退库";
                    }
                    else if (car.BusinessType == "其他")
                    {
                        car.MeasureMode = (jzfs == "0") ? "普通" : "定期皮";
                    }

                    string sdsss = IcDatas[0, 1].Substring(6);
                    car.MeasureID = HexToStr(IcDatas[0, 1].Substring(6)).Trim().Replace("\0", "");   //计量单号

                    //car.MeasureID = HexToStr(IcDatas[0, 1].Substring(8));   //计量单号(旧的读取方法 一区5块)
                    //  car.MeasureID = HexToStr(IcDatas[0, 0].Substring(0,12));   //计量单号(新读取方法 一区4块)


                    //2扇区8块 13位采购订单号 目前来看 好像这个订单号基本上不读取了 2016-6-2 不再读取
                    //Car.OrderID = ic.HexToStr(IcDatas[1, 0].Substring(0, 26));

                    //IcDatas[2,0] - 3扇区 12块 从第一位开始:(卸货:客商名称,占用3个数据块)/(取样:2位取样代码,12位取样时间,18位取样人员名字,占用1个数据块)
                    //IcDatas[2,1] - 3扇区 13块
                    //IcDatas[2,2] - 3扇区 14块
                    //--------------------------    3扇区12、13、14块:		客商名称或者取样标识 统一更改为取样标识
                    if (MainActivity.LoginSystemType == "卸货系统")
                    {
                        //string ksmc = HexToStr(IcDatas[2, 0] + IcDatas[2, 1] + IcDatas[2, 2]);
                        //car.SendUnit = ksmc.Trim();
                        car.QualityType = IcDatas[2, 0].Substring(0, 2);
                    }
                    else if (MainActivity.LoginSystemType == "质检系统") //3扇区12块 前两个字符为取样类型
                    {
                        // car.QualityType = IcDatas[2, 0].Substring(0, 2);
                        car.QualityType = IcDatas[0, 1].Substring(4, 1); //新系统
                        //string ddd  = IcDatas[0,1].Substring(3,1); //新系统
                        //string dddd  = IcDatas[0,1].Substring(0,1); //新系统
                        //string ddddd = IcDatas[0,1].Substring(1,1); //新系统
                        //string dddddd = IcDatas[0,1].Substring(4,1); //新系统
                        //string ddddddd = IcDatas[0,1].Substring(5, 1); //新系统
                    }
                    else if (MainActivity.LoginSystemType == "汽车取样") //3扇区12块 前两个字符为取样类型
                    {
                        car.QualityType = IcDatas[2, 0].Substring(0, 2);
                    }
                    else if (MainActivity.LoginSystemType == "白灰取样") //3扇区12块 前两个字符为取样类型
                    {
                        car.QualityType = IcDatas[2, 0].Substring(0, 2);
                    }
                    else if (MainActivity.LoginSystemType == "取样") //3扇区12块 前两个字符为取样类型
                    {
                        car.QualityType = IcDatas[2, 0].Substring(0, 2);
                    }


                    //--------------------------    4扇区:		存货名称 2016-6-2 不再读取
                    //string chmc = HexToStr(IcDatas[3, 0] + IcDatas[3, 1] + IcDatas[3, 2]);
                    //car.MeterielID = chmc.Trim();

                    //--------------------------    5扇区:		规格+"!"+型号  (此数据可能为空)2016-6-2 不再读取
                    //string ggxh = HexToStr(IcDatas[4, 0] + IcDatas[4, 1] + IcDatas[4, 2]);
                    //int index = ggxh.IndexOf("!", 0);
                    //if (index > 0)
                    //{
                    //    car.Specification = ggxh.Substring(0, index - 1);
                    //    car.Model = ggxh.Substring(index + 1);
                    //}

                    //--------------------------    2扇区9块:	6位毛重+10位毛重时间/6位皮重+10位皮重时间+16位计量员 (此数据可能为空)
                    string zljly = IcDatas[1, 1];
                    try
                    {
                        car.Gross = Convert.ToInt32(zljly.Substring(0, 6));
                    }
                    catch (Exception ex)
                    {
                        car.Gross = 0;
                    }
                    try
                    {
                        car.GrossDateTime = DateTime.ParseExact(zljly.Substring(6, 10), "MMddHHmmss", System.Globalization.CultureInfo.CurrentCulture).ToString();
                    }
                    catch (Exception ex)
                    {
                        car.GrossDateTime = null;
                    }
                    //try
                    //{
                    //    car.Person = HexToStr(zljly.Substring(16, 16)).Trim();    //2017-6-23 屏蔽,原因:这个参数用不到
                    //}
                    //catch (Exception ex)
                    //{
                    //    car.Person = null;
                    //}
                }
                #endregion
                return(car);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        private void ReadIcData(Intent intent)
        {
            m_intent    = intent;
            ic.icserial = ic.FindIC(m_intent);

            Car = new CarInfo();    //初始化一个CarInfo类

            //取出封装在intent中的TAG
            tag = intent.GetParcelableExtra(NfcAdapter.ExtraTag) as Tag;
            if (tag == null)
            {
                return;
            }
            m_tag = tag;

            MifareClassic mfc = MifareClassic.Get(m_tag);

            if (mfc != null)
            {
                #region 获取到tag
                try
                {
                    mfc.Connect();
                    var type = mfc.GetType();
                    if (type.Equals(typeof(Android.Nfc.Tech.MifareClassic)))
                    {
                        #region 循环读取5个扇区数据
                        for (int i = 0; i < ic.sectors.Length; i++)
                        {
                            for (int k = 0; k < 3; k++)
                            {
                                int sec = mfc.BlockToSector(ic.sectors[i] * 4 + k);
                                if (sec < mfc.SectorCount)
                                {
                                    if (mfc.AuthenticateSectorWithKeyB(sec, ic.ToDigitsBytes(ic.mb)))
                                    {
                                        int c = mfc.SectorCount;
                                        c = mfc.BlockCount;

                                        byte[] data = new byte[16];
                                        data = mfc.ReadBlock(ic.sectors[i] * 4 + k);
                                        if (data != null)
                                        {
                                            ic.IcDatas[i, k] = ic.ToHexString(data);
                                            ic.isReadIcOK    = true;
                                        }
                                        else
                                        {
                                            CommonFunction.ShowMessage("读取" + ic.sectors[i].ToString() + "扇区" + Convert.ToString(ic.sectors[i] * 4 + k) + "块失败!", this, true);
                                            ic.isReadIcOK = false;
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        CommonFunction.ShowMessage("密码验证失败!", this, true);
                                        ic.isReadIcOK = false;
                                        return;
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                }
                catch (Exception ex)
                {
                    CommonFunction.ShowMessage(ex.Message, this, true);
                }
                finally
                {
                    mfc.Close();
                }
                if (ic.isReadIcOK)
                {
                    ToggleButton samp = FindViewById <ToggleButton>(Resource.Id.btSamp);
                    //Button samp = FindViewById<Button>(Resource.Id.btSamp);
                    samp.Enabled = true;
                    btSamp.SetBackgroundColor(Android.Graphics.Color.ParseColor("#DB3E3E"));
                }
                else
                {
                    #region 读卡异常,按钮不可用
                    Button samp = FindViewById <Button>(Resource.Id.btSamp);
                    samp.Enabled = false;
                    CommonFunction.ShowMessage("卡内信息错误!", this, true);
                    #endregion
                }
                #endregion
            }
            else
            {
                #region 判断卡类型
                btSamp.Enabled = false;

                btSamp.Checked = false;
                CommonFunction.ShowMessage("不支持该类型的卡", this, true);
                ic.isReadIcOK = false;
                return;

                #endregion
            }
        }
Exemplo n.º 5
0
        private void ReadIcData(Intent intent)
        {
            m_intent    = intent;
            ic.icserial = ic.FindIC(m_intent);

            Car = new CarInfo();    //初始化一个CarInfo类

            //取出封装在intent中的TAG
            var tag = intent.GetParcelableExtra(NfcAdapter.ExtraTag) as Tag;

            if (tag == null)
            {
                return;
            }
            m_tag = tag;

            #region 清空文本
            EditText carinfo = FindViewById <EditText>(Resource.Id.tuCarInfo);
            carinfo.Text = "";

            EditText bussnise = FindViewById <EditText>(Resource.Id.tuBussnise);
            bussnise.Text = "";

            EditText measuretype = FindViewById <EditText>(Resource.Id.tuMeasureType);
            measuretype.Text = "";

            EditText measuremode = FindViewById <EditText>(Resource.Id.tuMeasureMode);
            measuremode.Text = "";

            EditText measureid = FindViewById <EditText>(Resource.Id.tuMeasureID);
            measureid.Text = "";

            EditText goodweight = FindViewById <EditText>(Resource.Id.tuGoodWeight);
            goodweight.Text = "";

            EditText measuredt = FindViewById <EditText>(Resource.Id.tuMeasureDT);
            measuredt.Text = "";

            EditText buckleweight = FindViewById <EditText>(Resource.Id.eBuckleWeight);
            buckleweight.Text = "0";

            #endregion

            MifareClassic mfc = MifareClassic.Get(m_tag);
            if (mfc != null)
            {
                #region 获取到tag
                try
                {
                    mfc.Connect();
                    var type = mfc.GetType();
                    if (type.Equals(typeof(Android.Nfc.Tech.MifareClassic)))
                    {
                        #region 循环读取5个扇区数据
                        for (int i = 0; i < ic.sectors.Length; i++)
                        {
                            for (int k = 0; k < 3; k++)
                            {
                                int sec = mfc.BlockToSector(ic.sectors[i] * 4 + k);
                                if (sec < mfc.SectorCount)
                                {
                                    if (mfc.AuthenticateSectorWithKeyB(sec, ic.ToDigitsBytes(ic.mb)))
                                    {
                                        int c = mfc.SectorCount;
                                        c = mfc.BlockCount;

                                        byte[] data = new byte[16];
                                        data = mfc.ReadBlock(ic.sectors[i] * 4 + k);
                                        if (data != null)
                                        {
                                            ic.IcDatas[i, k] = ic.ToHexString(data);
                                            ic.isReadIcOK    = true;
                                        }
                                        else
                                        {
                                            CommonFunction.ShowMessage("读取" + ic.sectors[i].ToString() + "扇区" + Convert.ToString(ic.sectors[i] * 4 + k) + "块失败!", this, true);
                                            ic.isReadIcOK = false;
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        CommonFunction.ShowMessage("密码验证失败!", this, true);
                                        ic.isReadIcOK = false;
                                        return;
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                }
                catch (Exception ex)
                {
                    CommonFunction.ShowMessage(ex.Message, this, true);
                }
                finally
                {
                    mfc.Close();
                }

                if (ic.isReadIcOK)
                {
                    try
                    {
                        //解析扇区数据
                        Car = ic.GetCarInfo(ic.IcDatas);

                        if (Car != null)
                        {
                            CommonFunction.ShowMessage("", this, false);

                            #region 读卡正确,显示在窗体文本内,按钮复活

                            carinfo.Text = Car.CarPlate;

                            bussnise.Text = Car.BusinessType;

                            measuretype.Text = Car.MeasurementType;

                            measuremode.Text = Car.MeasureMode;

                            measureid.Text = Car.CardID;

                            goodweight.Text = Car.Gross.ToString();

                            measuredt.Text = Car.GrossDateTime;

                            Button unload = FindViewById <Button>(Resource.Id.buUnLoad);
                            unload.Enabled = true;
                            unload.SetBackgroundColor(Android.Graphics.Color.ParseColor("#BD2B32"));
                            unload.SetTextColor(Android.Graphics.Color.ParseColor("#ffffff"));

                            Button halfreturn = FindViewById <Button>(Resource.Id.buHalfReturn);
                            halfreturn.Enabled = true;
                            halfreturn.SetBackgroundColor(Android.Graphics.Color.ParseColor("#BD2B32"));
                            halfreturn.SetTextColor(Android.Graphics.Color.ParseColor("#ffffff"));

                            Button allreturn = FindViewById <Button>(Resource.Id.buAllReturn);
                            allreturn.Enabled = true;
                            allreturn.SetBackgroundColor(Android.Graphics.Color.ParseColor("#BD2B32"));
                            allreturn.SetTextColor(Android.Graphics.Color.ParseColor("#ffffff"));

                            Button unloadandload = FindViewById <Button>(Resource.Id.buUnloadAndLoad);
                            unloadandload.Enabled = true;
                            unloadandload.SetBackgroundColor(Android.Graphics.Color.ParseColor("#BD2B32"));
                            unloadandload.SetTextColor(Android.Graphics.Color.ParseColor("#ffffff"));

                            #endregion
                        }
                        else
                        {
                            #region 读卡异常,按钮不可用
                            Button unload = FindViewById <Button>(Resource.Id.buUnLoad);
                            unload.Enabled = false;

                            Button halfreturn = FindViewById <Button>(Resource.Id.buHalfReturn);
                            halfreturn.Enabled = false;

                            Button allreturn = FindViewById <Button>(Resource.Id.buAllReturn);
                            allreturn.Enabled = false;

                            Button unloadandload = FindViewById <Button>(Resource.Id.buUnloadAndLoad);
                            unloadandload.Enabled = false;

                            CommonFunction.ShowMessage("卡内信息错误!", this, true);
                            #endregion
                        }
                    }
                    catch (System.ArgumentOutOfRangeException ax)
                    {
                        CommonFunction.ShowMessage("读卡信息错误!", this, true);
                    }
                    catch (Exception ex)
                    {
                        CommonFunction.ShowMessage(ex.Message, this, true);
                    }
                }

                #endregion
            }
            else
            {
                #region 判断卡类型
                bunload.Enabled        = false;
                bhalfreturn.Enabled    = false;
                ballreturn.Enabled     = false;
                bunloadandload.Enabled = false;

                bunload.Checked        = false;
                bhalfreturn.Checked    = false;
                ballreturn.Checked     = false;
                bunloadandload.Checked = false;
                CommonFunction.ShowMessage("不支持该类型的卡", this, true);
                ic.isReadIcOK = false;
                return;

                #endregion
            }
        }