Exemplo n.º 1
0
        public int FormatGasCard(short com, int baud, string kmm, string kh, string dqdm)
        {
            QwCardICLib.MWOperate4442 obj = QwCardICLib.MWOperate4442.GetInstance();
            int result = obj.FormatGasCard(com, baud, kmm, -1, kh, dqdm);

            return(result);
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        private void btnClearCard_Click(object sender, EventArgs e)
        {
            ComItem port = cboPort.SelectedItem as ComItem;

            if (port != null)
            {
                try
                {
                    short com  = Convert.ToInt16(port.PortNum);
                    int   baud = Convert.ToInt32(cboBaud.SelectedItem);

                    string kmm  = null;                     //卡密码(不使用)
                    short  klx  = -1;                       //卡类型(不使用)
                    string kh   = txtUserID.Text.Trim();    //用户卡号
                    string dqdm = null;                     //地区代码(不使用)

                    QwCardICLib.MWOperate4442 obj = QwCardICLib.MWOperate4442.GetInstance();
                    int result = obj.FormatGasCard(com, baud, kmm, klx, kh, dqdm);
                    if (result == 0)
                    {
                        lbMsg.Items.Add(DateTime.Now.ToString("MM-dd hh:mm:ss") + "销卡成功");
                    }
                    else
                    {
                        lbMsg.Items.Add(DateTime.Now.ToString("MM-dd hh:mm:ss") + "  信息号:" + result.ToString());
                    }
                    ClearIcData();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("请选择合适的端口");
            }
        }