/// <summary> /// 取得名称的16进制编码 /// </summary> /// <param name="p_strName"></param> /// <returns></returns> private static string GetNameCode(string p_strName) { string l_strReturn = EquipmentGeneral.StrToHex(p_strName); l_strReturn = l_strReturn + "0000000000000000"; return(l_strReturn.Substring(0, 16)); }
public override bool WriteInitUserBasicInfo(PaymentCard payCard) { YuChuanDevice.rf_beep(_iBeepInterval); byte bSection = 3; try { Dictionary <byte, List <byte> > dicSection = EquipmentGeneral.GetCardSectionPieceList(); string strPieceData = string.Empty; #region 初始化第1块信息数据 if (!ReadCardsPrepare(bSection)) { return(false); } //卡号 string strCardNo = EquipmentGeneral.IntToHex(payCard.No, 4); strCardNo = strCardNo.Substring(2, 2) + strCardNo.Substring(0, 2); //状态值 string strState = payCard.Valid ? "80" : "00"; //注销时间 string strRegDate = payCard.ExpiryDate.Value.ToString("yyMMdd"); //功能 string strFunc = string.Empty; if (payCard.FunctionCode.Length == 16) { strFunc = EquipmentGeneral.BinToHex(payCard.FunctionCode).PadLeft(4, '0'); } else if (payCard.FunctionCode.Length == 4) { strFunc = payCard.FunctionCode; } else { strFunc = string.Empty.PadRight(4, '0'); } //姓名 string strName = EquipmentGeneral.StrToHex(payCard.Name).PadRight(16, '0'); strPieceData = strCardNo + strState + strRegDate + strFunc + strName; if (strPieceData.Length != 32) { return(false); } byte[] arrData = YuChuanDevice.ChangeStrToHex(strPieceData); int iRes = YuChuanDevice.rf_write(dicSection[bSection][1], arrData); if (iRes != 0) { return(false); } #endregion #region 初始化第2块信息数据 if (!ReadCardsPrepare(bSection)) { return(false); } //卡内最低余额 string strMinVal = EquipmentGeneral.IntToHex((int)(payCard.LimitRemainder * 100), 8); //每日最大消费额 string strMaxPosVal = EquipmentGeneral.IntToHex((int)(payCard.DailyMaxPayment * 100), 8); //时段限次消费次数 string strIntervalCount = EquipmentGeneral.IntToHex(payCard.Span1PaymentCount, 2) + EquipmentGeneral.IntToHex(payCard.Span2PaymentCount, 2) + EquipmentGeneral.IntToHex(payCard.Span3PaymentCount, 2) + EquipmentGeneral.IntToHex(payCard.Span4PaymentCount, 2); //卡片类型 string strType = EquipmentGeneral.IntToHex(Convert.ToInt32(char.Parse(payCard.Type)), 2); strPieceData = strMinVal + payCard.PaymentPassword + strMaxPosVal + strIntervalCount + strType; if (strPieceData.Length != 32) { return(false); } arrData = YuChuanDevice.ChangeStrToHex(strPieceData); iRes = YuChuanDevice.rf_write(dicSection[bSection][2], arrData); if (iRes != 0) { return(false); } #endregion } catch (Exception ex) { throw ex; } YuChuanDevice.rf_beep(_iBeepInterval); return(true); }
/// <summary> /// 写入卡片基本信息 /// </summary> /// <param name="p_intPort"></param> /// <param name="p_objCard"></param> private static bool WriteCard(int p_intPort, int p_intSector, PaymentCard p_objCard) { WriteCardNormalInfo(p_intPort, (p_intSector * 4 + 1), p_objCard.No, p_objCard.Name, p_objCard.PaymentPassword, p_objCard.ExpiryDate.Value.ToString("yyMMdd"), p_objCard.FunctionCode, (decimal)p_objCard.LimitRemainder, (decimal)p_objCard.DailyMaxPayment, p_objCard.Span1PaymentCount, p_objCard.Span2PaymentCount, p_objCard.Span3PaymentCount, p_objCard.Span4PaymentCount, EquipmentGeneral.StrToHex(p_objCard.Type)); CleanCardMoney(p_intPort, (p_intSector * 4 + 1)); CleanCardMoney(p_intPort, (p_intSector * 4 + 8)); AddCardMoney(p_intPort, (p_intSector * 4 + 4), int.Parse(p_objCard.Money.ToString()) * 100); AddCardMoney(p_intPort, (p_intSector * 4 + 8), int.Parse(p_objCard.Subsidize.ToString()) * 100); return(true); }