如何检测或检查数据库中的值 [英] How to detect or check value in database

查看:64
本文介绍了如何检测或检查数据库中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好...
我真的需要你的帮助.
我有具有4个复选框和4个文本框的Exitpass系统,当用户外出办公室时,警卫会勾选该复选框,日期时间将从计算机日期时间中检索,但是现在我的问题是我无法通过数据库检查该列是否具有是否有价值.
在我的代码中,一旦我单击它,将保存当前时间,但是再次单击同一复选框,它将更新日期时间,它应该提示错误,提示此工作人员已经外出!". >
以下是我的安全代码:

Hi guys...
I really need your favor..
i have exitpass system which have 4 checkbox and 4 textbox, when user go out from office, the guard will tick the checkbox,the datetime will be retrieve from computer datetime, but now my problem is i cannot check thru database either the column is have value or not.
In my code, once i click it will save the current time, but is tick again with the same checkbox it will update the datetime, it should prompt up error said that "This staff have been go out!! "..

Below is my peace of code:

If CheckBox1.Checked = True Then
                           If ExitTimeOut1 = "" Then
                               'MsgBox("This record - " & Empno & " already have been " & ExitTimeOut1 & ". Please choose other records.", MsgBoxStyle.Critical)
                               TextBox4.Enabled = False
                               TextBox5.Enabled = False
                               TextBox6.Enabled = False
                               CheckBox2.Enabled = False
                               CheckBox3.Enabled = False
                               CheckBox4.Enabled = False
                               GridViewExcel.Enabled = False
                               Alert("This record - " & Empno & " already have been " & ExitTimeOut1 & ". Please choose other records.")
                               'result = Convert.ToString(ExitTimeOut1)
                           Else
                               MyComm2.CommandText = "update ExitPassDetails set ExitTimeOut1 = '" & ExitTimeOut1 & "' where ExitID = '" & id & "' "
                               sqlconnect2.Open()
                               Dim result2 As Data.SqlClient.SqlDataReader = MyComm2.ExecuteReader(Data.CommandBehavior.CloseConnection)
                               result2.Read()
                               'Dim MyMessage = "This record - " & Empno & " already Out."
                               'ShowMessage(MyMessage, Page)
                               'MsgBox(id & " - " & Empno & " Successfully.")
                               Alert("This record - " & Empno & " already out " & ExitTimeOut1 & ".")
                               'lblMsg.Text = "This record - " & Empno & " already Out."
                               sqlconnect2.Close()
                           End If
                       End If
                       If CheckBox2.Checked = True Then
                           If ExitTimeIn1 = "" Then
                               ' MsgBox("This record - " & Empno & " already have been " & ExitTimeIn1 & ". Please choose other records.", MsgBoxStyle.Critical)
                               TextBox3.Enabled = False
                               TextBox4.Enabled = False
                               TextBox6.Enabled = False
                               CheckBox1.Enabled = False
                               CheckBox3.Enabled = False
                               CheckBox4.Enabled = False
                               GridViewExcel.Enabled = False
                               Alert("This record - " & Empno & " already have been " & ExitTimeIn1 & ". Please choose other records.")
                           Else
                               MyComm2.CommandText = "update ExitPassDetails set ExitTimeIn1 = '" & ExitTimeIn1 & "' where ExitID = '" & id & "' "
                               sqlconnect2.Open()
                               Dim result2 As Data.SqlClient.SqlDataReader = MyComm2.ExecuteReader(Data.CommandBehavior.CloseConnection)
                               result2.Read()
                               'Dim MyMessage = "This record - " & Empno & " Already In."
                               'ShowMessage(MyMessage, Page)
                               ' MsgBox(id & " - " & Empno & " Successfully.")
                               Alert("This record - " & Empno & " already in " & ExitTimeIn1 & ".")
                               sqlconnect2.Close()
                           End If
                       End If
                      
                       End If

推荐答案

您可以进行AJAX调用或回发,以检查数据库中的值.如果您的客户说英语,则您的消息中不应显示此工作人员已经外出!".应该说此工作人员不在办公室"或类似名称.
You can make an AJAX call or do a postback, to check a value in the database. Your message should not say "This staff have been go out!! ", if your client speaks English. It should say ''This staff member is not in the office'' or similar.


只是偶然发现了这一点,并在将我的头撞在砖墙上数小时之后.终于解决了! !..
感谢您的帮助.
Just stumbled across this and after many hours of banging my head against a brick wall..finally solved!!..
Thanks for those help..


似乎您应该尝试

这篇关于如何检测或检查数据库中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆