//购气 购气用cardnew控件 public void CSellGas() { if (PriceDate != null) { PriceDate = PriceDate.Substring(0, 10); PriceDate = PriceDate.Replace("-", ""); } if (SellDate != null) { SellDate = SellDate.Substring(0, 10); SellDate = SellDate.Replace("-", ""); } //购气次数加1 BuyTimes++; var openRen = GetSellEvent("Open").Open(0); if (openRen != 0) { GetSellEvent("Close").Close(); Error = "打开串口失败!"; MessageBox.Show(Error); return; } var pricenow = PriceNow * 100; var pricenew = PriceNew * 100; var money = Money * 100; var pricemodify = 1; //如果是无线表,需要先设置数据 if (FactoryId == 13 || FactoryId == 14 || FactoryId == 15 || FactoryId == 16) { var r = GetSellEvent("SaveWxPara").SaveWxPara(money, pricenow, pricemodify, pricenew, PriceDate); } //售气成功返回true,失败false; var sellRen = GetSellEvent("SellGas").SellGas(Gas, BuyTimes, SellDate); GetSellEvent("Close").Close(); if (sellRen) { State = State.End; OnCompleted(null); } else { State = State.Error; Error = "售气不成功!"; MessageBox.Show(Error); } }
//发卡 /* 民用发卡 * cardid:卡号 * alarm:告警气量 * constant:表常数 * amount:气量 * metertype:表型 * user_type:用户类型 * money:金额 * pricenow:当前单价 */ public bool MYInitCard(string cardid, int alarm, int constant, int amount, int metertype, int user_type, double money, double pricenow, int pricemodify, double pricenew, string pricedate, string selldate) { //日期转换格式:yyyymmdd if (PriceDate != null) { PriceDate = PriceDate.Substring(0, 10); PriceDate = PriceDate.Replace("-", ""); } if (SellDate != null) { SellDate = SellDate.Substring(0, 10); SellDate = SellDate.Replace("-", ""); } //打开串口,检查卡 var openRen = GetEvent("Open").Open(0); if (openRen != 0) { GetEvent("Close").Close(); OpenErrorTip(openRen); } //发卡,如果是无线表,需要先设置参数 if (metertype == 13 || metertype == 14 || metertype == 15 || metertype == 16) { GetEvent("SaveWxPara").SaveWxPara(money, pricenow, pricemodify, pricenew, pricedate); } //发卡 var initRen = GetEvent("Init").Init(cardid, alarm, metertype, constant, amount, user_type); GetEvent("Close").Close(); if (initRen) { State = State.End; return(true); } else { State = State.Error; Error = "发卡不成功!'"; return(false); } }
//补卡 card_id, meter_type, times, metre_con, warn_gas, pricenow, pricemodify, pricenew, pricedate, selldate public void MakeUp() { //如果是化解,不允许补购气卡 if (FactoryId == 1 || FactoryId == 2 || FactoryId == 11 || FactoryId == 12) { Error = "华捷不允许补购气卡!"; MessageBox.Show(Error); return; } var cpuselldate = SellDate; var cpupricedate = PriceDate; if (PriceDate != null) { PriceDate = PriceDate.Substring(0, 10); PriceDate = PriceDate.Replace("-", ""); } if (SellDate != null) { SellDate = SellDate.Substring(0, 10); SellDate = SellDate.Replace("-", ""); } // alert("card_id:" + card_id + ",meter_type:" + meter_type + ",times:" + times +",metre_con:" + metre_con + ",warn_gas:" + warn_gas + ",pricenow" + pricenow // + ",pricemodify:" + pricemodify + ",pricenew:" + pricenew + ",pricedate:" + pricedate); var gas = 0; var cus_type = 0; var money = 0; var openRen = GetEvent("Open").Open(0); if (openRen == 0) { GetEvent("Close").Close(); GetSellEvent("Open").Open(0); bool cardren; if (FactoryId == 13 || FactoryId == 14 || FactoryId == 15 || FactoryId == 16) { GetSellEvent("SaveWxPara").SaveWxPara(money, PriceNow, PriceModify, PriceNew, PriceDate); } if (FactoryId == 14 || FactoryId == 16) { var firstCard = CardId.Substring(0, 2); CardId = CardId.Substring(2, 10); cardren = GetSellEvent("SaveOldCard").SaveOldCard(CardId, FactoryId, gas, BuyTimes, cus_type, firstCard, Alarm, firstCard, 0, 0); } else { cardren = GetSellEvent("SaveOldCard").SaveOldCard(CardId, FactoryId, gas, BuyTimes, cus_type, MetreCon, Alarm, MetreCon, 0, 0); } GetSellEvent("Close").Close(); if (cardren) { State = State.End; OnCompleted(null); } else { State = State.Error; Error = "补卡不成功!'"; MessageBox.Show(Error); } } else if (openRen == 1) { GetEvent("Close").Close(); Error = "卡没有插入!"; MessageBox.Show(Error); } else if (openRen == 2) { GetEvent("Close").Close(); Error = "硬件连接错误:线没连接或读卡器有问题或计算机串口坏!"; MessageBox.Show(Error); } else if (openRen == 3) { GetEvent("Close").Close(); Error = "密码错误!"; MessageBox.Show(Error); } //补cpu卡 else if (openRen == 4) { var NewRemnant = 1000; var FirstAlarmV = 1000; var SecondAlamV = 2000; var xs = 1; var consumerlevel = 11; GetEvent("Close").Close(); //MakeUpCpu(card_id, FirstAlarmV, SecondAlamV, NewRemnant, consumerlevel, cus_type, pricedate, xs, cpupricedate, times, money, cpuselldate); } }