Example #1
0
        private void pb1_Click(object sender, EventArgs e)
        {
            if (clickAction != null)
            {
                clickAction();
            }
            PictureBox pb = sender as PictureBox;
            string     No = pb.Name.Substring(2, 1);

            if (No == "b")
            {
                if (txtCard.Text.Length > 0 && txtCard.Text.Length <= 18)
                {
                    txtCard.Text           = txtCard.Text.Substring(0, txtCard.Text.Length - 1);
                    txtCard.SelectionStart = txtCard.Text.Length;
                }
            }
            else if (No == "f")
            {
                //完成
                if (txtCard.Text.Length != 18)
                {
                    frmMsg frm = new frmMsg();//提示
                    frm.msgInfo = "身份证号码格式不正确!";
                    frm.ShowDialog();
                    return;
                }
                else
                {
                    try
                    {
                        var CardIdentity = new CardIdentity(txtCard.Text);
                    }
                    catch
                    {
                        frmMsg frm = new frmMsg();//提示
                        frm.msgInfo = "请输入有效的身份证号码!!";
                        frm.ShowDialog();
                        return;
                    }
                    CardId = txtCard.Text;
                    if (ProcessIdCard != null)
                    {
                        ProcessIdCard(CardId);
                    }
                }
            }
            else
            {
                if (txtCard.Text.Length < 18)
                {
                    txtCard.Text           = txtCard.Text + No;
                    txtCard.SelectionStart = txtCard.Text.Length;
                }
            }
        }
Example #2
0
        private void pb_Click(object sender, EventArgs e)
        {
            if (clickAction != null)
            {
                clickAction();
            }
            ucInput pb = sender as ucInput;
            string  No = pb.Name.Substring(2, 1);

            if (No == "b")
            {
                if (txtCard.Text.Length > 0 && txtCard.Text.Length <= 18)
                {
                    int cle = txtCard.SelectionStart;
                    if (cle < 1)
                    {
                        return;
                    }
                    if (cle == txtCard.Text.Length)
                    {
                        txtCard.Text = txtCard.Text.Substring(0, txtCard.Text.Length - 1);
                    }
                    else
                    {
                        txtCard.Text = txtCard.Text.Substring(0, cle - 1) + txtCard.Text.Substring(cle, txtCard.Text.Length - cle);
                    }
                    txtCard.SelectionStart = cle - 1;
                }
            }
            else if (No == "f")
            {
                //完成
                if (txtCard.Text.Length != 18)
                {
                    frmMsg frm = new frmMsg();//提示
                    frm.msgInfo = "身份证号码格式不正确!";
                    frm.ShowDialog();
                    return;
                }
                else
                {
                    try
                    {
                        var CardIdentity = new CardIdentity(txtCard.Text);
                    }
                    catch
                    {
                        frmMsg frm = new frmMsg();//提示
                        frm.msgInfo = "请输入有效的身份证号码!!";
                        frm.ShowDialog();
                        return;
                    }
                    CardId = txtCard.Text;
                    if (ProcessIdCard != null)
                    {
                        ProcessIdCard(CardId);
                    }
                }
            }
            else
            {
                if (No == "I")
                {
                    return;
                }
                if (txtCard.Text.Length < 18)
                {
                    var selection = txtCard.SelectionStart;
                    var up        = txtCard.Text.Substring(0, txtCard.SelectionStart);
                    var dowm      = txtCard.Text.Substring(txtCard.SelectionStart, txtCard.Text.Length - txtCard.SelectionStart);
                    txtCard.Text           = up + No + dowm;
                    txtCard.SelectionStart = selection + 1;
                }
            }
        }