Esempio n. 1
0
        public int WriteNewCard(short com, int baud, ref string kmm, short kzt, string kh, string dqdm, string yhh, string tm, int ql, int csql, int ccsql, short cs, int ljgql, short bkcs, int ljyql, int bjql, int czsx, int tzed, string sqrq, string cssqrq, int oldprice, int newprice, string sxrq, string sxbj)
        {
            //读出卡号,以便清卡
            short  klx;         //卡类型
            short  rkzt;        //卡状态(不支持该参数,输出-1)
            string cardNO;      //用户卡号
            string rdqdm;       //地区代码(不支持该参数,输出null)
            string ryhh;        //用户号
            string rtm;         //表条码表号
            int    gas;         //气量
            short  times;       //购气次数
            int    rljgql;      //表累计购气量
            short  renewTimes;  //补卡次数(不支持该参数,输出-1)
            int    rljyql;      //表内累计用气量(不支持该参数,输出-1)
            int    syql;        //表内剩余气量
            int    rbjql;       //表内报警气量(不支持该参数,输出-1)
            int    rczsx;       //表内充值上限(不支持该参数,输出-1)
            int    rtzed;       //表内透支额度(不支持该参数,输出-1)
            string rsqrq;       //售气日期 格式:20121212
            string rsxrq;       //单价生效日期(不支持该参数,输出null)
            string rsxbj;       //单价生效标记(不支持该参数,输出null)

            QwCardICLib.MWOperate4442 obj = QwCardICLib.MWOperate4442.GetInstance();
            int result = obj.ReadGasCard(com, baud, null, out klx, out rkzt, out cardNO, out rdqdm, out ryhh, out rtm, out gas, out times, out rljgql, out renewTimes, out rljyql, out syql, out rbjql, out rczsx, out rtzed, out rsqrq, -1, -1, out rsxrq, out rsxbj);

            Log.Debug("read card when write result=" + result);
            //是用户卡,清卡
            if (result == 0 && (klx == 2 || klx == 3))
            {
                //发卡前先格式化卡,格式化卡时,需要原卡卡号
                result = obj.FormatGasCard(com, baud, kmm, -1, cardNO, dqdm);
                Log.Debug("clear when write result=" + result);
            }
            if (kzt == 0)
            {
                //发卡
                result = obj.WriteNewCard(com, baud, kmm, -1, kzt, kh, dqdm, "1", "1", ql, cs, ljgql, bkcs, ljyql, bjql, czsx, tzed, sqrq, oldprice, newprice, sxrq, sxbj);
                Log.Debug("write card end ret=" + result);
                return(result);
            }
            else
            {
                Log.Debug("rewrite card start kh=" + kh);
                result = obj.RepairCard(com, baud, kh, "1", "1", cs, ljgql);
                Log.Debug("rewrite card end ret=" + result);
                return(result);
            }
        }
Esempio n. 2
0
        private void btnRepairCard_Click(object sender, EventArgs e)
        {
            ComItem port = cboPort.SelectedItem as ComItem;

            if (port != null)
            {
                try
                {
                    int    portNum = Convert.ToInt32(port.PortNum);
                    int    baud    = Convert.ToInt32(cboBaud.SelectedItem);
                    string userID  = txtUserID.Text.Trim();
                    string cardID  = txtCardID.Text.Trim();
                    string meterID = txtMeterID.Text.Trim();

                    int buyGasCount = int.Parse(txtBuyGasCount.Text.Trim());
                    int buyGasTotal = int.Parse(txtBuyGasTotal.Text.Trim());


                    QwCardICLib.MWOperate4442 obj = QwCardICLib.MWOperate4442.GetInstance();
                    int flag = obj.RepairCard(portNum, baud, userID, cardID, meterID, buyGasCount, buyGasTotal);
                    MessageBox.Show(flag + "");
                    //if (flag)
                    //{
                    //    ClearIcData();
                    //    lbMsg.Items.Add(DateTime.Now.ToString("MM-dd hh:mm:ss") + "补卡成功,请先插表再进行日常购气");
                    //}
                }
                catch (Exception ex)
                {
                    string str = ex.Message;
                    //QwCardICLib.QwICException icEx = ex as QwCardICLib.QwICException;
                    //if (icEx != null)
                    //{
                    //    lbMsg.Items.Add(DateTime.Now.ToString("MM-dd hh:mm:ss") + " 信息号:" + icEx.IcErrCode.ToString() + " 内容:" + icEx.IcErrMessage);
                    //}
                    //else
                    //{
                    //    MessageBox.Show(ex.Message);
                    //}
                }
            }
            else
            {
                MessageBox.Show("请选择合适的端口");
            }
        }