/// <summary> /// 功能:补卡 /// </summary> /// <param name="port">端口号</param> /// <param name="CardNO">卡号</param> /// <param name="Gas">气量</param> /// <param name="Times">次数</param> /// <param name="AlarmGas1">报警气量1</param> /// <param name="AlarmGas2">报警气量2</param> /// <param name="MostGas">最多存气量</param> /// <param name="UserKey">卡密码</param> /// <returns></returns> public int UPCard(Int32 port, string CardNO, string Gas, string Times, string AlarmGas1, string AlarmGas2, string MostGas, string UserKey) { int ReturnCode = -1; ReMakeCardChangChun reMakeCard = new ReMakeCardChangChun(); PortModal ComPt = ComClass.SetCom(port); ulong userNo = ulong.Parse(CardNO.Trim()); uint buyGasValue = uint.Parse(Gas.Trim()); uint buyGasCount = uint.Parse(Times.Trim()); uint warn1 = uint.Parse(AlarmGas1.Trim()); uint warn2 = uint.Parse(AlarmGas2.Trim()); uint limitMaxGas = uint.Parse(MostGas.Trim()); string password = UserKey.Trim(); ReMakeCardModal remakeCardData = new ReMakeCardModal(userNo, buyGasValue, buyGasCount, warn1, warn2, limitMaxGas, password); SGError TemError = reMakeCard.ReMakeCard(ComPt, remakeCardData); if (TemError == SGError.OK) { ReturnCode = 0; } else { ReturnCode = ReturnErrorCode(TemError); } return(ReturnCode); }
/// <summary> /// 功能:回收卡 /// </summary> /// <param name="port">端口号</param> /// <param name="Times">次数</param> /// <param name="UserKey">卡密码</param> /// <returns></returns> public int InitCard(Int32 port, string Times, string UserKey) { int ReturnCode = -1; RepairCardChangChun repair = new RepairCardChangChun(); PortModal ComPt = ComClass.SetCom(port); SGError TemError = repair.RestoreCard(UserKey.Trim(), int.Parse(Times.Trim()), ComPt); if (TemError == SGError.OK) { ReturnCode = 0; } else { ReturnCode = ReturnErrorCode(TemError); } return(ReturnCode); }
/// <summary> /// 功能:读卡 /// </summary> /// <param name="port">端口号</param> /// <param name="CardNO">卡号</param> /// <param name="Gas">气量</param> /// <param name="Times">次数</param> /// <param name="SumGas">累计气量</param> /// <param name="AlarmGas1">报警气量1</param> /// <param name="AlarmGas2">报警气量2</param> /// <param name="MostGas">最多存气量</param> /// <param name="CardType">卡类型编码</param> /// <param name="DataError">卡数据正确性</param> /// <param name="ReturnData">有无返回数据</param> /// <returns></returns> public int ReadCard(Int32 port, out string CardNO, out string Gas, out string Times, out string SumGas, out string AlarmGas1, out string AlarmGas2, out string MostGas, out Int32 CardType, out Int32 DataError, out Int32 ReturnData) { int str = -1; CardNO = ""; Gas = ""; Times = ""; MostGas = ""; SumGas = ""; AlarmGas1 = ""; AlarmGas2 = ""; CardType = -1; DataError = -1; ReturnData = -1; PortModal ComPt = ComClass.SetCom(port); ReadCardModal userData = new ReadCardModal(); ReadCardChangChun read = new ReadCardChangChun(); SGError TemError = read.readUserCard(ComPt, out userData); if (TemError == SGError.OK) { CardNO = userData.UserNo.ToString(); Gas = userData.BuyGasValue.ToString(); Times = userData.BuyGasCount.ToString(); MostGas = userData.LimitGas.ToString(); SumGas = userData.TotalBuyGasNum.ToString(); AlarmGas1 = userData.Warn1.ToString(); AlarmGas2 = userData.Warn2.ToString(); CardType = ReturnCardType(userData.CardType); DataError = ReturnDataError(userData.IsUserDataFommatError); ReturnData = ReturnBlData(userData.HasReWriteData); str = 0; } else { str = ReturnErrorCode(TemError); } return(str); }
/// <summary> /// 功能:换表 /// </summary> /// <param name="port">端口号</param> /// <param name="CardNO">卡号</param> /// <param name="Gas">气量</param> /// <param name="Times">次数</param> /// <param name="PresetGas">补尝气量</param> /// <param name="AlarmGas1">报警气量1</param> /// <param name="AlarmGas2">报警气量2</param> /// <param name="MostGas">最多存气量</param> /// <param name="UserKey">卡密码</param> /// <param name="OldNew">旧卡/新卡</param> /// <returns></returns> public int ChMeter(Int32 port, string CardNO, string Gas, string Times, string PresetGas, string AlarmGas1, string AlarmGas2, string MostGas, string UserKey, int OldNew) { int ReturnCode = -1; bool isOldCard; ChangeMeterChangChun changemeter = new ChangeMeterChangChun(); PortModal ComPt = ComClass.SetCom(port); ulong userNo = ulong.Parse(CardNO.Trim()); uint buyGasValue = uint.Parse(Gas.Trim()); uint preGasValue = uint.Parse(PresetGas.Trim()); buyGasValue += preGasValue; uint warn1 = uint.Parse(AlarmGas1.Trim()); uint warn2 = uint.Parse(AlarmGas2.Trim()); uint limitMaxGas = uint.Parse(MostGas.Trim()); string password = UserKey.Trim(); uint oldMeterBuyGasCount = uint.Parse(Times.Trim()); if (OldNew == 0) { isOldCard = true; } else { isOldCard = false; } ChangeMeterModal modal = new ChangeMeterModal(userNo, buyGasValue, warn1, warn2, limitMaxGas, password, isOldCard, oldMeterBuyGasCount); modal.Password = password; SGError TemError = changemeter.ChangeMeter(ComPt, modal); if (TemError == SGError.OK) { ReturnCode = 0; } else { ReturnCode = ReturnErrorCode(TemError); } return(ReturnCode); }
/// <summary> /// 功能:退气 /// </summary> /// <param name="port">端口号</param> /// <param name="UserKey">卡密码</param> /// <returns></returns> public int ReturnGas(Int32 port, string UserKey) //端口号,卡密码 { int ReturnCode = -1; //UserKey = ""; ClearGasChangChun clearGas = new ClearGasChangChun(); PortModal ComPt = ComClass.SetCom(port); string password = UserKey.Trim(); //MessageBox.Show(port.ToString()); SGError TemError = clearGas.ClearGas(ComPt, password.Trim()); if (TemError == SGError.OK) { ReturnCode = 0; } else { ReturnCode = ReturnErrorCode(TemError); } return(ReturnCode); }
/// <summary> /// 功能:开户 /// </summary> /// <param name="port">端口号</param> /// <param name="CardNO">卡号</param> /// <param name="Gas">气量</param> /// <param name="PresetGas">预置气量</param> /// <param name="AlarmGas1">报警气量1</param> /// <param name="AlarmGas2">报警气量2</param> /// <param name="MostGas">最多存气量</param> /// <param name="UserKey">卡密码</param> /// <returns></returns> public int OpenCard(Int32 port, string CardNO, string Gas, string PresetGas, string AlarmGas1, string AlarmGas2, string MostGas, out string UserKey) { int ReturnCode = -1; UserKey = ""; OpenAccountChangeChun openAccountChangeChun = new OpenAccountChangeChun(); PortModal ComPt = ComClass.SetCom(port); ulong userNo = ulong.Parse(CardNO.Trim()); uint buyGasValue = uint.Parse(Gas.Trim()); uint preGasValue = uint.Parse(PresetGas.Trim()); if (buyGasValue > preGasValue) { buyGasValue -= preGasValue; uint warn1 = uint.Parse(AlarmGas1.Trim()); uint warn2 = uint.Parse(AlarmGas2.Trim()); uint limitMaxGas = uint.Parse(MostGas.Trim()); OpenAccountModal modal = new OpenAccountModal(userNo, buyGasValue, warn1, warn2, limitMaxGas, false); SGError TemError = openAccountChangeChun.OpenAccount(ComPt, modal); if (TemError == SGError.OK) { ReturnCode = 0; UserKey = modal.Password; } else { ReturnCode = ReturnErrorCode(TemError); } } else { ReturnCode = 33; } return(ReturnCode); }