Пример #1
0
        private void buttonGetMakeRecord_Click(object sender, EventArgs e)
        {
            string idCheck = this.textBoxWriteID.Text;

            if (idCheck == null || idCheck == string.Empty)
            {
                MessageBox.Show("id为空,请重新输入");
                return;
            }
            idCheck = "TP" + idCheck.PadLeft(7, '0');
            List <MakeCardRecordModel> makeCardList = makeCardBll.GetModelList("cardID = '" + idCheck + "' ");

            if (makeCardList == null || makeCardList.Count == 0)
            {
                MessageBox.Show("发卡记录为空");
                return;
            }
            MakeCardRecordModel record = makeCardList[0];

            if (record == null)
            {
                MessageBox.Show("发卡记录为空");
                return;
            }
            string recordInfo = string.Format("发卡记录:\n托盘号:{0}\n发卡时间:{1}\n", record.cardID, record.makedTime);

            this.richTextBoxMakeRecord.Text = recordInfo;
        }
Пример #2
0
        private void buttonDelMakeRecord_Click(object sender, EventArgs e)
        {
            string idCheck = this.textBoxWriteID.Text;

            if (idCheck == null || idCheck == string.Empty)
            {
                MessageBox.Show("id为空,请重新输入");
                return;
            }
            idCheck = "TP" + idCheck.PadLeft(7, '0');
            List <MakeCardRecordModel> makeCardList = makeCardBll.GetModelList("cardID = '" + idCheck + "' ");

            if (makeCardList == null || makeCardList.Count == 0)
            {
                MessageBox.Show("发卡记录为空");
                return;
            }
            MakeCardRecordModel record = makeCardList[0];

            if (record == null)
            {
                MessageBox.Show("发卡记录为空");
            }
            makeCardBll.Delete(record.serialNo);
            MessageBox.Show("发卡记录已删除");
        }
Пример #3
0
        //发卡
        private void buttonWriteID_Click(object sender, EventArgs e)
        {
            try
            {
                string idCheck = this.textBoxWriteIDRepeat.Text;

                if (idCheck == null || idCheck == string.Empty)
                {
                    MessageBox.Show("id为空,请重新输入");
                    return;
                }
                idCheck = "TP" + idCheck.PadLeft(7, '0');
                if (makeCardBll.Exists(idCheck))
                {
                    MessageBox.Show("该ID已经发过卡,请换一张重新发卡");
                    return;
                }
                if (this.textBoxWriteIDRepeat.Text != this.textBoxWriteID.Text)
                {
                    MessageBox.Show("两次输入不一致,请确认");
                    return;
                }
                rfidRW.ReaderID = byte.Parse(this.textBoxReaderID.Text);
                uint   rfidID    = uint.Parse(this.textBoxWriteID.Text);
                byte[] byteArray = BitConverter.GetBytes(rfidID);
                if (byteArray != null && byteArray.Count() > 0)
                {
                    this.textBoxWriteID.SelectAll();
                    if (!rfidRW.WriteSBlock(byteArray))
                    {
                        this.labelIDRWResult.Text      = "发卡失败!";
                        this.labelIDRWResult.BackColor = Color.Red;
                        MessageBox.Show("发卡失败");

                        return;
                    }
                    byte[] recvByteArray = null;
                    string readPalletID  = rfidRW.ReadPalletID(ref recvByteArray);
                    if (string.IsNullOrEmpty(readPalletID) || (readPalletID != idCheck))
                    {
                        string faildInfo = "发卡失败!发卡后回读结果不一致";
                        this.labelIDRWResult.Text      = faildInfo;
                        this.labelIDRWResult.BackColor = Color.Red;
                        MessageBox.Show(faildInfo);
                        return;
                    }
                    MakeCardRecordModel cardModel = new MakeCardRecordModel();
                    cardModel.cardID    = idCheck;
                    cardModel.makedTime = System.DateTime.Now;

                    if (makeCardBll.Add(cardModel) <= 0)
                    {
                        MessageBox.Show("发卡信息录入数据库失败");
                        return;
                    }
                    makeCardCount++;
                    this.labelMakeCardCount.Text   = "计数:" + makeCardCount.ToString();
                    this.labelIDRWResult.Text      = "发卡成功!";
                    this.labelIDRWResult.BackColor = Color.Green;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("发卡失败,错误信息:" + ex.Message);
            }
        }