Пример #1
0
        //补卡  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);
            }
        }