如何排除某些字段进行验证? [英] How to exclude some field for verification?

查看:74
本文介绍了如何排除某些字段进行验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,其中的场景将按如下方式执行:

1.用于循环扫描gridview中的所有行。

2如果日期相同,那么它将进入开始时间和结束时间的检查。

3.如果相同,则不会启用更新到数据库。



问题是,如果我想更新具有相同日期和时间的任务(例如,任务A)。我只想更新任务A细节,但是当我点击更新按钮时,它不允许我更新,因为它具有相同的数据和时间。我怎么告诉系统忽略那部分?以下是代码:



Hi, i have the following codes in which the scenario will carried out as follow:
1. For loop which will scan through all rows in gridview.
2. If the date is same, then it will enter the checking for start time and end time.
3. If it is the same, it will not enable update into database.

The problem is, if i want to update a task(eg. Task A) which has the same date and time. I just want to update the Task A detail, but when I click on update button, it would not allow me to update as it has the same data and time. How would I tell the system to ignore that part? Below are the codes:

<pre lang="xml">For Each dr As DataGridItem In dtgTask.Items
    tempStartDate = dr.Cells.Item(3).Text
    tempStartHour = dr.Cells.Item(1).Text
    subStartHour = tempStartHour.Substring(0, 2)
    tempEndHour = dr.Cells.Item(2).Text
    subEndHour = tempEndHour.Substring(0, 2)
    tempCategory = dr.Cells.Item(5).Text


    If (String.Compare(tempStartDate, txtDateTskS.Text) = 0) Then
        If ((Me.ddlStartHour.Text.Equals(subStartHour) AndAlso Me.ddlEndHour.Text.Equals(subEndHour)) Or
            (Me.ddlStartHour.Text.Equals(subStartHour) AndAlso Integer.Parse(Me.ddlEndHour.Text) < Integer.Parse(subEndHour)) Or
            (Integer.Parse(Me.ddlStartHour.Text) > Integer.Parse(subStartHour) AndAlso Me.ddlEndHour.Text.Equals(subEndHour)) Or
            (Integer.Parse(Me.ddlStartHour.Text) > Integer.Parse(subStartHour) AndAlso Integer.Parse(Me.ddlEndHour.Text) < Integer.Parse(subEndHour)) Or
            (Integer.Parse(Me.ddlStartHour.Text) < Integer.Parse(subStartHour) AndAlso Integer.Parse(Me.ddlEndHour.Text) > Integer.Parse(subEndHour))) Then
            'Return "** " & loMsg.nUpdated & " of record(s) Updatwed successfully!!"
            isUpdate = True
        End If
    End If
Next dr

推荐答案

这篇关于如何排除某些字段进行验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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