Ejemplo n.º 1
0
        private void MonitorICCardReader()
        {
            this.UIDoCircleTask(() =>
            {
                _CurrentICNo = _icAPI.LoadIC();
                if (_CurrentICNo != "0")
                {
                    oldmanInfo = Data.OldMans.SingleOrDefault(item => item.ICNo == _CurrentICNo);
                    if (oldmanInfo != null)
                    {
                        _icAPI.Beep();
                        if (oldmanInfoSlim == null)
                        {
                            oldmanInfoSlim          = new ucOldManInfoSlim();
                            oldmanInfoSlim.Location = new Point(0, 0);
                            splitContainer1.Panel1.Controls.Add(oldmanInfoSlim);
                        }
                        oldmanInfoSlim.LoadOldManInfo(oldmanInfo);
                        oldmanInfoSlim.Hide();

                        if (oldmanInfoShow == null)
                        {
                            oldmanInfoShow          = new ucOldManInfoShow();
                            oldmanInfoShow.Location = new Point(0, 0);
                            splitContainer1.Panel1.Controls.Add(oldmanInfoShow);
                        }
                        oldmanInfoShow.LoadOldManInfo(oldmanInfo);
                        oldmanInfoShow.Show();
                        splitContainer1.Panel2.Enabled = true;

                        if (physicalExaminationShow != null)
                        {
                            physicalExaminationShow.Hide();
                        }
                        if (orderInfoShow != null)
                        {
                            orderInfoShow.Hide();
                        }
                        if (courseInfoShow != null)
                        {
                            courseInfoShow.Hide();
                        }
                        if (accountShow != null)
                        {
                            accountShow.Hide();
                        }
                    }
                }
            }, 700, () =>
            {
                return(isStop);
            }, () =>
            {
                if (_icAPI.IcDev < 0)
                {
                    _icAPI.InitIC();
                }
                return(_icAPI.IcDev < 0);
            });
        }
Ejemplo n.º 2
0
 public void LoadOldManInfo(OldManInfo oldmanInfo)
 {
     lblOldManName.Text             = oldmanInfo.OldManName;
     lblGender.Text                 = oldmanInfo.GenderName;
     pbHeadPortrait.BackgroundImage = lblGender.Text == "男" ? Properties.Resources.oldman_m : Properties.Resources.oldman_f;
     lblAge.Text     = "(" + oldmanInfo.Age + "岁)";
     lblIDNo.Text    = "ID " + oldmanInfo.IDNo.Substring(0, oldmanInfo.IDNo.Length - 6) + "******";
     lblAddress.Text = oldmanInfo.Address;
 }
Ejemplo n.º 3
0
        private void LoadOldManInfoUI(OldManInfo oldmanInfo)
        {
            _OldManId                      = oldmanInfo.OldManId;
            lblOldManName.Text             = oldmanInfo.OldManName;
            lblGender.Text                 = oldmanInfo.GenderName;
            pbHeadPortrait.BackgroundImage = lblGender.Text == "男" ? Properties.Resources.oldman_m : Properties.Resources.oldman_f;
            lblAge.Text                    = "(" + oldmanInfo.Age + "岁)";
            lblIDNo.Text                   = "ID " + oldmanInfo.IDNo.Substring(0, oldmanInfo.IDNo.Length - 6) + "******";
            lblICNo.Text                   = "IC " + _CurrentICNo;
            lblAddress.Text                = oldmanInfo.Address;

            GetOrderInfo(_OldManId);
        }
Ejemplo n.º 4
0
        private void MonitorICCardReader()
        {
            this.UIDoCircleTask(() =>
            {
                _CurrentICNo = _icAPI.LoadIC();
                //Common.DebugLog("-----block _CurrentICNo:" + _CurrentICNo + " lblICNo:" + lblICNo.Text);
                if (("IC " + _CurrentICNo) != lblICNo.Text)
                {
                    if (_icAPI.AuthenticationKey(0))
                    {
                        _icAPI.Beep();

                        string read1 = _icAPI.ReadIC16Byte(1);
                        string read2 = _icAPI.ReadIC16Byte(2);

                        if ((read1 + read2) == "")
                        {
                            //空卡
                            lblTip.Text = "该卡未使用或已挂失!";
                            ClearOldManInfoUI();
                        }
                        else
                        {
                            //通过卡匹配老人
                            OldManInfo oldmanInfo = Data.OldMans.SingleOrDefault(item => item.IDNo == (read1 + read2) && item.ICNo == _CurrentICNo);
                            if (oldmanInfo != null)
                            {
                                lblTip.Text = "IC " + _CurrentICNo;
                                LoadOldManInfoUI(oldmanInfo);
                            }
                            else
                            {
                                lblTip.Text = "卡信息无效!";
                                ClearOldManInfoUI();
                            }
                        }
                    }
                }
                else
                {
                    if (_CurrentICNo == "0")
                    {
                        lblTip.Text = "请刷卡";
                    }
                }
            }, 700, () =>
            {
                return(isStop);
            });
        }
Ejemplo n.º 5
0
        private void btnMakeCard_Click(object sender, EventArgs e)
        {
            _icAPI.Beep();
            int sector = 0;

            if (_icAPI.AuthenticationKey(sector))
            {
                int address = 1;

                string read1 = _icAPI.ReadIC16Byte(address);
                string read2 = _icAPI.ReadIC16Byte(address + 1);
                string raw   = read1 + read2;
                int    ret0  = _icAPI.WriteIC(address, _IDNo);
                if (ret0 == 0)
                {
                    HttpAdapter.postSyncAsJSON(SettingsVar.DataExchangePoint + "/Pam/PamService/PAMakeCard", new { OldManId = _OldManId.ToGuid(), OperatedBy = Data.UserId, ICNo = _CurrentICNo }.ToStringObjectDictionary(), new { PACode = SettingsVar.BindingPACode, ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) =>
                    {
                        if ((bool)ret.Success)
                        {
                            MessageBoxAdapter.ShowInfo("制卡成功");
                            lblTip.Text           = "制卡成功";
                            OldManInfo oldmanInfo = Data.OldMans.SingleOrDefault(item => item.OldManId == _OldManId);
                            if (oldmanInfo != null)
                            {
                                oldmanInfo.ICNo = _CurrentICNo;
                                lblICNo.Text    = _CurrentICNo;
                            }
                            isStop            = true;
                            this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        }
                        else
                        {
                            ret0 = _icAPI.WriteIC(address, raw);
                            MessageBoxAdapter.ShowError((string)ret.ErrorMessage);
                        }
                    });
                }
                else
                {
                    MessageBoxAdapter.ShowError("写入卡失败" + ret0.ToString());
                }
            }
            else
            {
                MessageBoxAdapter.ShowError("验证密码失败");
            }
        }
Ejemplo n.º 6
0
        public void LoadInfo(API icApi, string oldmanId)
        {
            _icAPI = icApi;
            OldManInfo oldmanInfo = Data.OldMans.SingleOrDefault(item => item.OldManId == oldmanId);

            if (oldmanInfo != null)
            {
                _OldManId                      = oldmanInfo.OldManId;
                lblOldManName.Text             = oldmanInfo.OldManName;
                lblGender.Text                 = oldmanInfo.GenderName;
                pbHeadPortrait.BackgroundImage = lblGender.Text == "男" ? Properties.Resources.oldman_m : Properties.Resources.oldman_f;
                lblAge.Text                    = "(" + oldmanInfo.Age + "岁)";
                _IDNo           = oldmanInfo.IDNo;
                lblIDNo.Text    = "ID " + oldmanInfo.IDNo.Substring(0, oldmanInfo.IDNo.Length - 6) + "******";
                lblICNo.Text    = "IC " + oldmanInfo.ICNo;
                lblAddress.Text = oldmanInfo.Address;
            }
        }
Ejemplo n.º 7
0
        private void BuildControls()
        {
            this.UIDoStepTasks(new List <Func <bool> >()
            {
                () => {
                    xTab.TabPages.Clear();
                    return(true);
                },
                () => {
                    #region 数据源
                    dataSource.Clear();
                    dataSource.AddRange(Data.OldMans);
                    return(true);

                    #endregion
                },
                () => {
                    #region 构建UI
                    //计算页数
                    int needCreateTabPageCount = 1 + dataSource.Count / 20;
                    int padding   = 15;
                    int indexPage = 0;

                    int indexOfOldMan = 0;
                    int x, y          = 0;
                    do
                    {
                        int currentPageSize = pageSize;
                        xTab.TabPages.Add(indexPage.ToString());
                        needCreateTabPageCount--;
                        if (needCreateTabPageCount == 0)
                        {
                            currentPageSize = dataSource.Count % pageSize;
                        }

                        TabPage tb   = xTab.TabPages[indexPage];
                        tb.BackColor = Color.FromArgb(129, 61, 222);
                        int i        = 0;
                        for (indexOfOldMan = indexPage * pageSize + i; i < currentPageSize; i++)
                        {
                            OldManInfo oldman = dataSource[indexOfOldMan];


                            x = i % 4;
                            y = i / 4;

                            ucOldManCard card = new ucOldManCard();

                            card.BackColor = string.IsNullOrEmpty(oldman.ICNo) ? Color.Silver : Color.FromArgb(255, 192, 192);
                            card.Location  = new Point(padding * (x + 1) + x * card.Size.Width, padding * (y + 1) + y * card.Size.Height);

                            card.ClickLabel.Text = oldman.OldManName;
                            card.ClickLabel.Tag  = oldman.OldManId;

                            tb.Controls.Add(card);


                            indexOfOldMan++;
                        }

                        indexPage++;
                    } while (needCreateTabPageCount > 0);
                    #endregion
                    return(true);
                },
                () => {
                    lblPageNo.Text             = "1";
                    lblPageAll.Text            = "/ " + (dataSource.Count / pageSize + 1).ToString();
                    xSlideTab                  = new SlideableTabControl(xTab);
                    xSlideTab.SlidePageEamless = true;

                    return(true);
                },
                () => {
                    #region 绑定卡片点击事件
                    ThreadAdapter.DoOnceTask(() =>
                    {
                        foreach (TabPage page in xTab.TabPages)
                        {
                            Common.DebugLog(page.Text + ":" + page.Controls.Count);
                            foreach (ucOldManCard card in page.Controls)
                            {
                                card.ClickLabel.Click += new EventHandler((o, de) =>
                                {
                                    API icAPI = new API();
                                    icAPI.InitIC();
                                    if (icAPI.IcDev < 0)
                                    {
                                        MessageBoxAdapter.ShowError("初始化IC读卡设备失败,请确认是否已连接IC读卡设备");
                                        return;
                                    }
                                    frmCardView frm = new frmCardView();
                                    frm.LoadInfo(icAPI, (string)(o as Control).Tag);
                                    DialogResult result = frm.ShowDialog();
                                    if (result == System.Windows.Forms.DialogResult.OK)
                                    {
                                        (o as Control).Parent.BackColor = Color.FromArgb(255, 192, 192);
                                    }
                                    icAPI.ExitIC();
                                });
                            }
                        }
                    });
                    return(true);

                    #endregion
                }
            }, 0);
        }