コード例 #1
0
        private void btnRead_Click(object sender, System.EventArgs e)
        {
            try
            {
                cIC cicObj = new cIC(this.axMSComm1);
                if (cicObj.openPort() == true)
                {
                    string strCardNo = "";
                    string strSal    = "";
                    if (cicObj.readCard(ref strCardNo, ref strSal) == false)
                    {
                        MessageBox.Show("读卡失败,失败原因:IC卡未在感应区内或者未对该卡进行发卡操作!");
                    }
                    else
                    {
                        this.txtICNo.Text       = strCardNo;
                        this.txtLeftAmount.Text = strSal;
                    }
                    cicObj.closePort();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            string strWellNo  = "";
            string strDepName = "";

            this.getDepName(this.txtICNo.Text, ref strWellNo, ref strDepName);
            this.txtWellNo.Text  = strWellNo;
            this.txtDepName.Text = strDepName;
        }
コード例 #2
0
ファイル: frmIniCard.cs プロジェクト: wwkkww1983/yh
        private void btnIni_Click(object sender, System.EventArgs e)
        {
            cIC cicObj = null;

            cicObj = new cIC(this.axMSComm1);
            if (cicObj.openPort() == true)
            {
                string strCardNo = "";
                if (cicObj.iniCard(ref strCardNo) == false)
                {
                    MessageBox.Show("发卡失败,失败原因:IC卡未在感应区内或者已对该卡进行发卡操作!");
                }
                else
                {
                    this.txtICNo.Text = strCardNo;
                    MessageBox.Show("发卡完成!");
                    this.saveData(this.txtWellNo.Text, this.txtICNo.Text.Trim(), this.txtDepName.Text.Trim());
                }
                cicObj.closePort();
            }
        }
コード例 #3
0
        private void btnWrite_Click(object sender, System.EventArgs e)
        {
            if (this.txtICNo.Text.Trim() == "")
            {
                MessageBox.Show("请先进行读卡操作!");
                return;
            }
            if (this.txtDepName.Text.Trim() == "")
            {
                MessageBox.Show("请先对该卡进行发卡操作!");
                return;
            }
            if (this.txtLeftAmount.Text.Trim() == "")
            {
                MessageBox.Show("请先进行读卡操作!");
                return;
            }

            if (this.txtAmount.Text.Trim() == "")
            {
                MessageBox.Show("售水量不能为空!");
                return;
            }

            double dVal = Convert.ToDouble(this.txtAmount.Text);
            double dMax = 0xffffffff;

            if (dVal > dMax)
            {
                MessageBox.Show("售水量值过大!");
                return;
            }

            try
            {
                if (this.txtAmount.Text.Trim() == "")
                {
                    MessageBox.Show("售水量不能为空!");
                    return;
                }

                Double dSal = Convert.ToDouble(this.txtAmount.Text.Trim());

                cIC cicObj = new cIC(this.axMSComm1);
                if (cicObj.openPort() == true)
                {
                    string strSal = "";
                    if (cicObj.salWater(dSal.ToString(), ref strSal) == false)
                    {
                        MessageBox.Show("充值失败!");
                    }
                    else
                    {
                        this.txtLeftAmount.Text = strSal;
                        MessageBox.Show("充值完成!");
                        if (this.SaveDatas() == false)
                        {
                            MessageBox.Show("保存售水信息时失败!");
                        }
                    }
                    cicObj.closePort();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }