コード例 #1
0
        private void CardFill_Click(object sender, EventArgs e)
        {
            contextMenu.Close();
            bool   IsFillOk   = false;
            string msg        = "";
            string EmpNo      = "";
            string EmpName    = "";
            string FingerNo   = "";
            string CardNo     = "";
            int    CardCount  = 0;
            int    EmpNoCount = 0;
            int    EmpSeCount = 0;

            RFIDReaderCard.num = "";
            GetFrCardNo(ref CardNo);
            Report.DetailGrid.Recordset.First();
            while (!Report.DetailGrid.Recordset.Eof())
            {
                CardCount = Report.FieldByName("EmpCardCount").AsInteger;
                if ((Report.FieldByName("Checked").AsInteger == (int)GRSystemImage.grsiChecked))
                {
                    if (CardCount != 0)
                    {
                        EmpSeCount = EmpSeCount + 1;
                    }
                }
                else
                {
                    EmpNoCount = EmpNoCount + 1;
                }
                if (EmpNoCount == Report.DetailGrid.Recordset.RecordCount)
                {
                    MessageBoxEx.Show(Pub.GetResText(formCode, "ErrorSelectEmp", ""), Pub.GetResText(formCode, "ErrorMessage", ""));

                    return;
                }
                if (EmpSeCount == Report.DetailGrid.Recordset.RecordCount)
                {
                    MessageBoxEx.Show(Pub.GetResText(formCode, "ErrorCardFill", ""), Pub.GetResText(formCode, "ErrorMessage", ""));

                    return;
                }
                Report.DetailGrid.Recordset.Next();
            }
            string tmp = Pub.GetResText(formCode, "ErrorCannotRepeated", "");

            tmp = string.Format(tmp, Pub.GetResText(formCode, "EmpCardNo", ""));

            IsFilling = true;
            RefreshForm(false);
            int pos = Report.DetailGrid.Recordset.RecordNo;

            Report.DetailGrid.Recordset.First();


            while (!Report.DetailGrid.Recordset.Eof())
            {
                EmpNo     = Report.FieldByName("EmpNo").AsString;
                EmpName   = Report.FieldByName("EmpName").AsString;
                FingerNo  = Report.FieldByName("FingerNo").AsString;
                CardCount = Report.FieldByName("EmpCardCount").AsInteger;
                if ((CardCount == 0) && (Report.FieldByName("Checked").AsInteger == (int)GRSystemImage.grsiChecked))
                {
                    msg = Pub.GetResText(formCode, "MsgFillInfo", "");
                    msg = string.Format(msg, EmpNo, EmpName) + "    ";
                    RefreshMsg(msg);
LoopCard:
                    Application.DoEvents();
                    if (!IsFilling)
                    {
                        goto LoopEnd;
                    }
                    CardNo = "";
                    if (!Pub.CheckCardExists())
                    {
                        CardNo             = RFIDReaderCard.num;
                        RFIDReaderCard.num = "";

                        GetFrCardNo(ref CardNo);
                        if (CardNo != "")
                        {
                            goto RFIDCard;
                        }
                        else
                        {
                            lblMsg.Text = msg + Pub.GetResText(formCode, "MsgCardEmpty", "");
                        }
                        goto LoopCard;
                    }
                    if (!Pub.GetCardNo(ref CardNo))
                    {
                        lblMsg.Text = msg + Pub.GetResText(formCode, "MsgCardEmpty", "");
                        goto LoopCard;
                    }

RFIDCard:
                    if (CheckCardExists(EmpNo, CardNo))
                    {
                        lblMsg.Text = msg + " [" + CardNo + "]  " + tmp;
                        Application.DoEvents();
                        System.Threading.Thread.Sleep(500);
                        goto LoopCard;
                    }

                    if (!SaveCardToDB(FingerNo, CardNo))
                    {
                        goto LoopEnd;
                    }
                    IsFillOk    = true;
                    lblMsg.Text = msg + " [" + CardNo + "]  " + Pub.GetResText(formCode, "MsgCardSuccess", "");
LoopNoCard:
                    Application.DoEvents();
                    if (Pub.CheckCardExists())
                    {
                        goto LoopNoCard;
                    }
                    else
                    {
                        System.Threading.Thread.Sleep(1000);
                    }
                }

                Report.DetailGrid.Recordset.Next();
            }

            Report.DetailGrid.Recordset.MoveBy(pos);
LoopEnd:

            IsFilling = false;
            RefreshForm(true);
            RefreshMsg("");
            if (IsFillOk)
            {
                SystemInfo.db.UpdateEmpInfoCount(this.Text);
                ExecItemRefresh();
            }
        }