Пример #1
0
        public void GetPsamCardID()
        {
            CIcRdr myRdr = new CIcRdr();

            string sPort = "";

            bHaveRd = false;
            for (int i = 1; i < 20; i++)
            {
                sPort = "Com" + i.ToString();
                if (!myRdr.ComOpen(sPort))
                {
                    continue;
                }

                //Application.DoEvents();
                if (!myRdr.Link())
                {
                    myRdr.ComClose();
                    continue;
                }

                if (!myRdr.GetPsamID())
                {
                    myRdr.ComClose();
                    continue;
                }

                bHaveRd = true;
                sRdPort = sPort;
                myRdr.ComClose();
                break;
            }
        }
Пример #2
0
        private void button_Card_Click(object sender, EventArgs e)
        {
            ((Button)sender).Enabled = false;
            CIcRdr myRdr = new CIcRdr();

            //string szErr = "";
            if (!myRdr.ComOpen(frm_Main.sRdPort))
            {
                MessageBox.Show("连接读卡器失败,请检查连接", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ((Button)sender).Enabled = true;
                button_Card.Focus();
                return;
            }

            //Application.DoEvents();
            if (!myRdr.Link())
            {
                MessageBox.Show("连接读卡器失败,请联系供应商", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                myRdr.ComClose();
                ((Button)sender).Enabled = true;
                button_Card.Focus();
                return;
            }

            //Application.DoEvents();
            string szInf;

            if (!myRdr.ReadCardInf(out szInf))
            {
                MessageBox.Show("读卡失败,请重新放卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                myRdr.ComClose();
                ((Button)sender).Enabled = true;
                button_Card.Focus();
                return;
            }
            myRdr.ComClose();

            if (szInf.Substring(0, 1).CompareTo(MyStart.gszCardFirmFirst) != 0)    //not firm card
            {
                if (szInf.Substring(0, 1).CompareTo(MyStart.gszCardYtbFirst) != 0) //not user card
                {
                    MessageBox.Show("卡号错误(既不是卖方卡,也不是结算卡),请换卡",
                                    "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ((Button)sender).Enabled = true;
                    button_Card.Focus();
                    return;
                }
                else
                {
                    textBox_Card.Text = szInf.Substring(0, 16);
                }
            }
            else
            {
                textBox_Card.Text = szInf.Substring(1, 15);
            }

            ((Button)sender).Enabled = true;
            button_Qry_Click(sender, e);
        }
Пример #3
0
        private void ReadCardNo(string szCardFlag, Button btnObj, TextBox EditObj)
        {
            CIcRdr myRdr = new CIcRdr();

            //string szErr = "";
            if (!myRdr.ComOpen(frm_Main.sRdPort))
            {
                MessageBox.Show("连接读卡器失败,请检查连接", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnObj.Focus();
                return;
            }

            //Application.DoEvents();
            if (!myRdr.Link())
            {
                MessageBox.Show("连接读卡器失败,请联系供应商", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                myRdr.ComClose();
                btnObj.Focus();
                return;
            }

            //Application.DoEvents();
            string szInf;

            if (!myRdr.ReadCardInf(out szInf))
            {
                MessageBox.Show("读卡失败,请重新放卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                myRdr.ComClose();
                btnObj.Focus();
                return;
            }

            if (szInf.Substring(0, 1).CompareTo(szCardFlag) != 0)
            {
                if (mszFlag.ToUpper() == "USER_CARD")
                {
                    MessageBox.Show("卡号错误(不是买方卡),请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (mszFlag.ToUpper() == "FIRM_CARD")
                {
                    if (szCardFlag == MyStart.gszCardYtbFirst)
                    {
                        MessageBox.Show("卡号错误(不是卖方结算卡),请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("卡号错误(不是卖方卡),请换卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                myRdr.ComClose();
                btnObj.Focus();
                return;
            }
            EditObj.Text = szInf.Substring(0, 16);//szInf.Substring(1, 15); //
            myRdr.ComClose();
        }
Пример #4
0
        private void ReadCardNo(string szType, Button objBtn, TextBox objText)
        {
            objBtn.Enabled = false;
            CIcRdr myRdr = new CIcRdr();

            //string szErr = "";
            if (!frm_Main.bHaveRd)
            {
                MessageBox.Show("没有连接读卡器,请检查。", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                objBtn.Enabled = true;
                objBtn.Focus();
                return;
            }

            if (!myRdr.ComOpen(frm_Main.sRdPort))
            {
                MessageBox.Show("连接读卡器失败,请检查连接", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                objBtn.Enabled = true;
                objBtn.Focus();
                return;
            }

            //Application.DoEvents();
            if (!myRdr.Link())
            {
                MessageBox.Show("连接读卡器失败,请联系供应商", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                myRdr.ComClose();
                objBtn.Enabled = true;
                objBtn.Focus();
                return;
            }

            //Application.DoEvents();
            string szInf;

            if (!myRdr.ReadCardInf(out szInf))
            {
                MessageBox.Show("读卡失败,请重新放卡", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                myRdr.ComClose();
                objBtn.Enabled = true;
                objBtn.Focus();
                return;
            }

            string szTypeDesc = "买方卡";

            if (szType.CompareTo(MyStart.gszCardFirmFirst) == 0)
            {
                szTypeDesc = "卖方卡";
            }
            if (szInf.Substring(0, 1).CompareTo(szType) != 0)
            {
                MessageBox.Show("卡号错误(不是" + szTypeDesc + ",卡号第一位应是" + szType + ")," + ",请换卡",
                                "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                myRdr.ComClose();
                objBtn.Enabled = true;
                objBtn.Focus();
                return;
            }
            if (szType.CompareTo(MyStart.gszCardFirmFirst) == 0)
            {
                objText.Text = szInf.Substring(1, 15);
            }
            else
            {
                objText.Text = szInf.Substring(0, 16);
            }
            myRdr.ComClose();
            objBtn.Enabled = true;
        }