private void txtNewMemberCardNo_Validated(object sender, System.EventArgs e)
 {
     if (txtNewMemberCardNo.Text.Trim().Length != 8)
     {
         this.errorProvider1.SetError(txtNewMemberCardNo, "¿¨ºÅ±ØÐëÊÇ8λ£¡");
     }
     else
     {
         //this.errorProvider1.SetError(txtMemberCardNo,"");
         string strMemberCardNo = txtNewMemberCardNo.Text.Trim();
         Regex  re = new Regex(@"[0-9]");
         if (!re.IsMatch(strMemberCardNo))
         {
             this.errorProvider1.SetError(txtNewMemberCardNo, "¿¨ºÅ±ØÐëÊÇÊý×Ö£¡");
         }
         else
         {
             if (strMemberCardNo.Equals("00000"))
             {
                 this.errorProvider1.SetError(txtNewMemberCardNo, "¿¨ºÅ²»Äܶ¼ÎªÁã");
             }
             else
             {
                 //ÅжϿ¨ºÅÊÇ·ñ´æÔÚ
                 Member member = new Member();
                 member.cnvcMemberCardNo = strMemberCardNo;
                 MemberManageFacade memberManage = new MemberManageFacade();
                 Member             oldMember    = memberManage.GetMemberbyCardNo(member);
                 if (oldMember.cnvcMemberCardNo.Length > 0)
                 {
                     this.errorProvider1.SetError(txtNewMemberCardNo, "¿¨ºÅÒÑ´æÔÚ");
                 }
                 else
                 {
                     this.errorProvider1.SetError(txtNewMemberCardNo, "");
                 }
             }
         }
     }
 }
Beispiel #2
0
        public static void MemberCardNoValidated(UltraTextEditor txtMemberCardNo, ErrorProvider errorProvide, string strType)
        {
            if (txtMemberCardNo.Text.Trim().Length < 8)
            {
                errorProvide.SetError(txtMemberCardNo, "会员卡号必须是8位!");
            }
            else
            {
                string strMemberCardNo = txtMemberCardNo.Text.Trim();
                if (strMemberCardNo.Equals("00000000"))
                {
                    errorProvide.SetError(txtMemberCardNo, "会员卡号不能都为零");
                }
                else
                {
                    //判断卡号是否存在
                    if (strType == "new")
                    {
                        DataTable dtMember = Query("select * from tbMember where cnvcMemberCardNo = '" + strMemberCardNo + "'");

                        Member member = new Member();
                        member.cnvcMemberCardNo = strMemberCardNo;
                        MemberManageFacade memberManage = new MemberManageFacade();
                        Member             oldMember    = memberManage.GetMemberbyCardNo(member);
                        if (dtMember.Rows.Count > 0)
                        {
                            errorProvide.SetError(txtMemberCardNo, "会员卡号已存在");
                        }
                        else
                        {
                            errorProvide.SetError(txtMemberCardNo, "");
                        }
                    }
                    else
                    {
                        errorProvide.SetError(txtMemberCardNo, "");
                    }
                }
            }
        }