예제 #1
0
 def saveUpdate(self, evt):
     judge = 1
     '''保存修改后的信息'''
     password = self.password.GetValue().strip()  # 获得修改后的值
     confirmpd = self.confirmpd.GetValue().strip()
     name = self.XingMing.GetValue().strip()
     certNo = self.certNo.GetValue().strip()
     gender = self.gender
     #
     birthday = self.birth.GetValue()
     birthday_time = self.datetime_to_str(str(birthday))
     #
     job = self.data_translate(self.job.GetValue(), 1)  # 职业
     graduschool = self.data_translate(self.school.GetValue(), 2)
     degree = self.data_translate(self.degreeType.GetValue(), 3)
     danwei = self.data_translate(self.danwei.GetValue(), 4)
     #
     zhicheng = self.zhicheng.GetValue()
     shoujihao = self.phone.GetValue().strip()
     qq = self.QQ.GetValue().strip()
     email = self.email.GetValue().strip()
     # 判断注册时输入的格式是否正确
     password_test = re.search(r"^[a-zA-Z0-9]{4,10}$", password)  # 密码
     true_name = re.search(r"^[\u4E00-\u9FA5]{2,4}$", name)  # 姓名
     shenfenzheng = re.search(
         r"^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$", certNo)  # 身份证号
     if name == "":
         warn = wx.MessageDialog(self,
                                 message="姓名不能为空!!!",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     elif true_name == None:
         # 消息对话框
         warn = wx.MessageDialog(self,
                                 message="真实姓名填写有误",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     elif certNo == "":
         warn = wx.MessageDialog(self,
                                 message="身份证号不能为空!!!",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     elif shenfenzheng == None:
         # 消息对话框
         warn = wx.MessageDialog(self,
                                 message="身份证输入不合法",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     elif password == "":
         # 消息对话框
         warn = wx.MessageDialog(self,
                                 message="登录密码不能为空!!!",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     elif password_test == None:
         # 消息对话框
         warn = wx.MessageDialog(self,
                                 message="密码不能含有非法字符,长度在4-10之间",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     elif confirmpd == "":
         # 消息对话框
         warn = wx.MessageDialog(self,
                                 message="确认密码不能为空!!!",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     elif password != confirmpd:
         # 消息对话框
         warn = wx.MessageDialog(self,
                                 message="两次密码不同,请重新输入",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     if shoujihao != '':
         phone = re.search(r"^1[3-9]\d{9}$", shoujihao)  # 验证手机号
         if phone == None:
             warn = wx.MessageDialog(self,
                                     message="手机号码不正确,请重新输入",
                                     caption="温馨提示",
                                     style=wx.OK | wx.ICON_INFORMATION)
             warn.ShowModal()  # 提示错误
             warn.Destroy()
             judge = 0
     if qq != '':
         QQ = re.search(r"^[1-9][0-9]{4,11}$", qq)  # 验证QQ号
         if QQ == None:
             warn = wx.MessageDialog(self,
                                     message="QQ号不正确,例如843278021",
                                     caption="温馨提示",
                                     style=wx.OK | wx.ICON_INFORMATION)
             warn.ShowModal()  # 提示错误
             warn.Destroy()
             judge = 0
     if email != '':
         email_test = re.search(r"^\w+@\w+(\.[a-zA-Z]{2,3}){1,2}$",
                                email)  # 验证邮箱
         if email_test == None:
             warn = wx.MessageDialog(self,
                                     message="Email格式不正确,例如[email protected]",
                                     caption="温馨提示",
                                     style=wx.OK | wx.ICON_INFORMATION)
             warn.ShowModal()  # 提示错误
             warn.Destroy()
             judge = 0
     if password != "" and name != "" and certNo != "" and judge == 1:
         print("开始将修改后的数据保存到数据库中")
         applicant = UserInfo('', password, name, certNo, gender,
                              birthday_time, job[0][0], graduschool[0][0],
                              degree[0][0], danwei[0][0], zhicheng,
                              shoujihao, qq, email)
         try:
             param_2 = (applicant.getpassword(),
                        applicant.getApplicantName(),
                        applicant.getApplicantID(), applicant.getgender(),
                        applicant.getbirthday(), applicant.getprofession(),
                        applicant.getgraduationschool(),
                        applicant.getdegree(), applicant.getdepartment(),
                        applicant.getzhicheng(),
                        applicant.getCellPhoneNumber(), applicant.getQQ(),
                        applicant.getzhicheng(), applicant.getemail(),
                        applicant.getApplicantID())
             sql_2 = "update user_info set Password=%s, TrueName=%s, IDCard=%s, Gender=%s, Birthday=%s, " \
                     "Job=%s,School=%s, Degree=%s, Unit=%s, Title=%s, Phone=%s , QQ=%s, Title=%s, Email=%s" \
                     " where IDCard=%s"
             self.dbhelper.UpdateData(sql_2, param_2)
             # 对话框
             warn = wx.MessageDialog(self,
                                     message="提交成功",
                                     caption="温馨提示",
                                     style=wx.OK | wx.ICON_INFORMATION)
             warn.ShowModal()  # 提示
             warn.Destroy()
         except Exception as e:
             print("查询记录失败:", e)
예제 #2
0
    def savePatent(self, evt):
        judge = 1
        '''第一步:获取text中文本;第二步,连接数据库;第三步插入并获得主键;第四步添加到系统中'''
        password = self.password.GetValue().strip()
        confirmpd = self.confirmpd.GetValue().strip()
        name = self.XingMing.GetValue().strip()
        certNo = self.certNo.GetValue().strip()
        gender = self.gender
        #
        birthday = self.birth.GetValue()
        birthday_time = self.datetime_to_str(str(birthday))
        #
        job = self.data_translate(self.job.GetValue(), 1)  # 职业
        graduschool = self.data_translate(self.school.GetValue(), 2)  # 毕业学校
        degree = self.data_translate(self.degreeType.GetValue(), 3)  # 学历/学位
        danwei = self.data_translate(self.danwei.GetValue(), 4)  # 单位
        #
        zhicheng = self.zhicheng.GetValue().strip()
        shoujihao = self.phone.GetValue().strip()
        qq = self.QQ.GetValue().strip()
        email = self.Email.GetValue().strip()
        print('电子邮箱', email)
        #
        userState = self.data_translate(self.user_state, 5)
        userClass = self.data_translate(self.user_class, 6)
        # 判断注册时输入的格式是否正确
        true_name = re.search(r"^[\u4E00-\u9FA5]{2,4}$", name)  # 姓名
        password_test = re.search(r"^[a-zA-Z0-9]{4,10}$", password)  # 密码
        shenfenzheng = re.search(
            r"^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$", certNo)  # 身份证号
        if name == "":
            warn = wx.MessageDialog(self,
                                    message="姓名不能为空!!!",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        elif true_name == None:
            # 消息对话框
            warn = wx.MessageDialog(self,
                                    message="真实姓名填写有误",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        elif certNo == "":
            warn = wx.MessageDialog(self,
                                    message="身份证号不能为空!!!",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        elif shenfenzheng == None:
            # 消息对话框
            warn = wx.MessageDialog(self,
                                    message="身份证输入不合法",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        elif password == "":
            # 消息对话框
            warn = wx.MessageDialog(self,
                                    message="登录密码不能为空!!!",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        elif password_test == None:
            # 消息对话框
            warn = wx.MessageDialog(self,
                                    message="密码不能含有非法字符,长度在4-10之间",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        elif confirmpd == "":
            # 消息对话框
            warn = wx.MessageDialog(self,
                                    message="确认密码不能为空!!!",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        elif password != confirmpd:
            # 消息对话框
            warn = wx.MessageDialog(self,
                                    message="两次密码不同,请重新输入",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        #
        if shoujihao != "":
            phone = re.search(r"^1[3-9]\d{9}$", shoujihao)  # 验证手机号
            if phone == None:
                warn = wx.MessageDialog(self,
                                        message="手机号码不正确,请重新输入",
                                        caption="温馨提示",
                                        style=wx.OK | wx.ICON_INFORMATION)
                warn.ShowModal()  # 提示错误
                warn.Destroy()
                judge = 0
        if qq != "":
            QQ = re.search(r"^[1-9][0-9]{4,11}$", qq)  # 验证QQ号
            if QQ == None:
                judge = 0
                warn = wx.MessageDialog(self,
                                        message="QQ号不正确,例如843278021",
                                        caption="温馨提示",
                                        style=wx.OK | wx.ICON_INFORMATION)
                warn.ShowModal()  # 提示错误
                warn.Destroy()
        if email != "":
            email_test = re.search(
                r"^[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?$",
                email)  # 验证邮箱
            if email_test == None:
                judge = 0
                warn = wx.MessageDialog(self,
                                        message="Email格式不正确,例如[email protected]",
                                        caption="温馨提示",
                                        style=wx.OK | wx.ICON_INFORMATION)
                warn.ShowModal()  # 提示错误
                warn.Destroy()

        if password != "" and name != "" and certNo != "" and judge == 1:
            print('进来了')
            # 对Applicant进行实例化
            user = UserInfo('', password, name, certNo, gender, birthday_time,
                            job[0][0], graduschool[0][0], degree[0][0],
                            danwei[0][0], zhicheng, shoujihao, qq, email)
            # 判断是否能找到相同身份证号
            try:
                param_1 = (certNo, )
                sql_1 = "select IDCard from user_info where IDCard=%s"
                i = self.dbhelper.SelectRecord(sql_1, param_1)
                print(i)
                if i != ():
                    print(i)
                    if i[0][0] == certNo:
                        warn = wx.MessageDialog(self,
                                                message="身份证号已存在,请重新输入",
                                                caption="温馨提示",
                                                style=wx.OK
                                                | wx.ICON_INFORMATION)
                        warn.ShowModal()  # 提示
                        warn.Destroy()
                else:
                    print("开始将用户注册信息插入到数据库中")
                    # 进行数据库的插入
                    try:
                        param_2 = (userClass[0][0], user.getpassword(),
                                   user.getApplicantName(),
                                   user.getApplicantID(), user.getgender(),
                                   user.getbirthday(), user.getprofession(),
                                   user.getgraduationschool(),
                                   user.getdegree(), user.getdepartment(),
                                   user.getzhicheng(),
                                   user.getCellPhoneNumber(), user.getQQ(),
                                   user.getemail(), userState[0][0])
                        sql_2 = "insert into user_info(UserCategory,Password,TrueName,IDCard, Gender, Birthday, Job, School,\
                                              Degree, Unit, Title, Phone, QQ, Email, UserStatus) \
                                        values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"

                        self.dbhelper.AddRecord(sql_2, param_2)
                        warn = wx.MessageDialog(self,
                                                message="注册成功",
                                                caption="温馨提示",
                                                style=wx.OK
                                                | wx.ICON_INFORMATION)
                        warn.ShowModal()  # 提示
                        warn.Destroy()
                        self.parent.notebook.DeleteAllPages()
                        self.parent._mgr.Update()
                        self.parent.register_state = 0
                    except Exception as e:
                        print("添加记录失败:", e)
            except Exception as e:
                print("查询记录失败:", e)