在一天中多次登录和注销时,可以在VB.NET中节省注销时间吗? [英] Save logout time in VB.NET on multiple login and logout in a day?

查看:98
本文介绍了在一天中多次登录和注销时,可以在VB.NET中节省注销时间吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正确保存了登录时间.但是,在更新注销时间时,前几行中的所有值也会在注销中更新.如果在任何条件下给出ID,它甚至都无法保存

我尝试过的事情:

I have saved login time correctly. But, While updating logout time all the values from previous rows also updating in logout. If given Id in where condition it not even saving

What I have tried:

Public Function logoutpage(ByVal iEmpID As Integer) As Integer
     Try
         Dim sSql As String = ""
         sSql = " UPDATE employee.tblcheck SET " &
                  " OutTime=''" & DateTime.Now.ToString("hh:mm:ss") & "''"
         Dim ireturn As Integer = execute(sSql)
     Catch ex As Exception
     End Try
 End Function











Private Sub btnlogout_Click(sender As Object, e As EventArgs) Handles btnlogout.Click
       Dim objlogout As New Attendance
       Dim iresult As Integer = objlogout.logoutpage(0)
       Response.Redirect("LoginPage.aspx")
   End Sub

推荐答案

Public Function logoutpage(ByVal iEmpID As Integer) As Integer
        Try
            Dim sSql As String = ""
            sSql = " UPDATE employee.tblcheck SET " &
                     " OutTime=''" & DateTime.Now.ToString("hh:mm:ss") & "''"
                     & " WHERE employee.tblcheck.EmployeeId = " & iEmpID.ToString
            Dim ireturn As Integer = execute(sSql)
        Catch ex As Exception
        End Try
    End Function



您需要在WHERE子句中替换您的实际员工ID字段.



You''ll need to substitute your actual employee id field in the WHERE clause.


嗯...您的设计有问题.如果电源出现故障或PC崩溃并且没有注销该怎么办?您真的无法以这种方式进行跟踪.您的数据库设计仅允许跟踪上次登录和注销时间.您没有历史记录.

这不是代码问题.这是一个很大的设计问题,您没有一套有意义的业务规则.
Ummm...there''s a problem with your design. What if the power fails or the PC crashes and there is no logout?? You really can''t track it this way. Your database design only allows for tracking the last login and logout times. You have no historical record.

This isn''t a code problem. This is a large design problem where you don''t have a set of business rules that makes any sense.


这篇关于在一天中多次登录和注销时,可以在VB.NET中节省注销时间吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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