public int ReadGasCard(short com, int baud, ref string kh, ref int ql, ref decimal money, ref short cs, ref short bkcs) { short klx; //卡类型 short kzt; //卡状态(不支持该参数,输出-1) string cardNO; //用户卡号 string dqdm; //地区代码(不支持该参数,输出null) string yhh; //用户号 string tm; //表条码表号 int gas; //气量 short times; //购气次数 int ljgql; //表累计购气量 short renewTimes; //补卡次数(不支持该参数,输出-1) int ljyql; //表内累计用气量(不支持该参数,输出-1) int syql; //表内剩余气量 int bjql; //表内报警气量(不支持该参数,输出-1) int czsx; //表内充值上限(不支持该参数,输出-1) int tzed; //表内透支额度(不支持该参数,输出-1) string sqrq; //售气日期 格式:20121212 string sxrq; //单价生效日期(不支持该参数,输出null) string sxbj; //单价生效标记(不支持该参数,输出null) QwCardICLib.MWOperate4442 obj = QwCardICLib.MWOperate4442.GetInstance(); int result = obj.ReadGasCard(com, baud, null, out klx, out kzt, out cardNO, out dqdm, out yhh, out tm, out gas, out times, out ljgql, out renewTimes, out ljyql, out syql, out bjql, out czsx, out tzed, out sqrq, -1, -1, out sxrq, out sxbj); Log.Debug("read card result=" + result); if (result == 0) { kh = cardNO; ql = gas; money = 0; cs = times; bkcs = renewTimes; } return(result); }
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); } }
private void btnReadCard_Click(object sender, EventArgs e) { ComItem port = cboPort.SelectedItem as ComItem; if (port != null) { short com = Convert.ToInt16(port.PortNum); int baud = Convert.ToInt32(cboBaud.SelectedItem); short klx; //卡类型 short kzt; //卡状态(不支持该参数,输出-1) string kh; //用户卡号 string dqdm; //地区代码(不支持该参数,输出null) string yhh; //用户号 string tm; //表条码表号 int ql; //气量 short cs; //购气次数 int ljgql; //表累计购气量 short bkcs; //补卡次数(不支持该参数,输出-1) int ljyql; //表内累计用气量(不支持该参数,输出-1) int syql; //表内剩余气量 int bjql; //表内报警气量(不支持该参数,输出-1) int czsx; //表内充值上限(不支持该参数,输出-1) int tzed; //表内透支额度(不支持该参数,输出-1) string sqrq; //售气日期 格式:20121212 string sxrq; //单价生效日期(不支持该参数,输出null) string sxbj; //单价生效标记(不支持该参数,输出null) QwCardICLib.MWOperate4442 obj = QwCardICLib.MWOperate4442.GetInstance(); int result = obj.ReadGasCard(com, baud, null, out klx, out kzt, out kh, out dqdm, out yhh, out tm, out ql, out cs, out ljgql, out bkcs, out ljyql, out syql, out bjql, out czsx, out tzed, out sqrq, -1, -1, out sxrq, out sxbj); if (result == 0) { if (klx > 0) { txtCompanyCode.Text = "重庆前卫克罗姆公司"; } else { txtCompanyCode.Text = string.Empty; } switch (klx) { case 0: txtCardType.Text = "无效卡"; break; case 1: txtCardType.Text = "新卡"; break; case 2: txtCardType.Text = "开户卡"; break; case 3: txtCardType.Text = "用户卡"; break; case 4: txtCardType.Text = "工具卡"; break; default: txtCardType.Text = klx.ToString() + " 未知"; break; } txtMeterID.Text = tm; txtUserID.Text = kh; txtCardID.Text = yhh; //if (data.GetReadState()) //{ // txtReadState.Text = "表已读卡"; //} //else //{ // txtReadState.Text = "表未读卡"; //} txtBuyGasVal.Text = ql.ToString(); txtBuyGasCount.Text = cs.ToString(); txtBuyGasTime.Text = sqrq; txtBuyGasRemain.Text = syql.ToString(); txtBuyGasTotal.Text = ljgql.ToString(); //if (data.GetRepairState()) //{ // txtRepairState.Text = "是补卡"; //} //else //{ // txtRepairState.Text = "非补卡"; //} } else { ClearIcData(); lbMsg.Items.Add(DateTime.Now.ToString("MM-dd hh:mm:ss") + " 信息号:" + result.ToString()); } } else { MessageBox.Show("请选择合适的端口"); } }