2017年10月20日 星期五

[ASP.NET]判斷要寫入的資料是否與資料表相同,若不相同才進行更新

Function IsRowModified_u(ByVal r As GridViewRow) As Boolean
        Dim Curr_OrgID As String
        Dim Curr_HomoID As String
        Dim Curr_LineNum As String
        Dim lv_RadioButtonList As String
        Dim lv_HAZARDOUS_VALUE As String
        Dim lv_REASON As String

        Curr_OrgID = CType(r.FindControl("lb_org_id"), Label).Text 'Convert.ToInt32(GridView1.DataKeys(0).Value)
        Curr_HomoID = CType(r.FindControl("lb_HOMOGENOUS_MAT_ID"), Label).Text
        Curr_LineNum = CType(r.FindControl("lb_LINE_NUM"), Label).Text

        lv_RadioButtonList = CType(r.FindControl("RadioButtonList1"), RadioButtonList).Text
        lv_HAZARDOUS_VALUE = CType(r.FindControl("tb_HAZARDOUS_VALUE"), TextBox).Text
        lv_REASON = CType(r.FindControl("tb_REASON"), TextBox).Text

        Dim row As DataRow = originalDataTable_u.[Select]([String].Format("org_id = {0} and HOMOGENOUS_MAT_ID={1} and line_num={2}", Curr_OrgID, Curr_HomoID, Curr_LineNum))(0)

        If lv_RadioButtonList.Equals(row("INCLUDE_YN").ToString()) = True And _
            lv_HAZARDOUS_VALUE.Equals(row("HAZARDOUS_VALUE").ToString()) = True And _
            lv_REASON.Equals(row("REASON").ToString()) = True Then
            Return True
        Else
            Return False
        End If

        'Return False
    End Function

沒有留言:

張貼留言