Esempio n. 1
0
        private void button1_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 result = obj.ReturnCard(portNum, baud, "1", "12345678", "1", buyGasCount, buyGasTotal);
                    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)
                {
                    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("请选择合适的端口");
            }
        }
Esempio n. 2
0
        public int WriteGasCard(short com, int baud, ref string kmm, string kh, string dqdm, int ql, int csql, int ccsql, short cs, int ljgql, int bjql, int czsx, int tzed, string sqrq, string cssqrq, int oldprice, int newprice, string sxrq, string sxbj)
        {
            QwCardICLib.MWOperate4442 obj = QwCardICLib.MWOperate4442.GetInstance();
            Log.Debug("ql=" + ql);
            if (ql > 0)
            {
                int result = obj.WriteGasCard(com, baud, kmm, -1, kh, dqdm, ql, cs, ljgql, bjql, czsx, tzed, sqrq, oldprice, newprice, sxrq, sxbj);

                Log.Debug("write gas card result=" + result);
                return(result);
            }
            else
            {
                int result = obj.ReturnCard(com, baud, "1", kh, "1", cs, ljgql);
                Log.Debug("return gas card result=" + result);
                return(result);
            }
        }