Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trying to update grid
Message
From
29/01/2008 08:36:06
 
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01285828
Message ID:
01286552
Views:
12
When a user saves a line item record with a mmButtonSave, I am adding a receiver row like this:
  Private Sub btnItemSave_Click(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles btnItemSave.Click
    'Check for broken rules after save
    Dim result As mmSaveDataResult
    If result <> mmSaveDataResult.RulesBroken Then
      SaveLineItem()
    End If
  End Sub

  Private Sub SaveLineItem()
    'Set Line Item variables before setting Receiver variables
    Puritem.gcDescription = Me.txtLIDescrip.Text
    Puritem.gnItemNum = CInt(Me.txtLIItemNum.Text)
    Puritem.gnOrderQty = CInt(Me.txtLIQty.Text)
    Purrecv.gcPONum = ReqForm.gcPONum
    Purrecv.gnReqId = ReqForm.gnReqID
    Puritem.gcVendorPartNum = Me.txtLIVendPartNum.Text
    Puritem.gcMfgName = Me.txtLIManuName.Text
    Puritem.gcMfgNum = Me.txtLIManuPartNum.Text

    'If line item saved all right, save receiver row
    'If adding a line item do this
    If glItemAdding Then
      glRecvAdding = True

      'Set globals before creating Receiver record
      '  since some defaults are set by globals
      SetRecvGlobals()

      'Create new receiver row
      AddReceiverRow()

      SaveReceiver()

    Else
      'If editing do this
      Me.Save()
      UpdateReceiver()
    End If

    glItemAdding = False
    glItemSaving = False

  End Sub

  Private Sub AddReceiverRow()
   'Create new receiver record
    Me.oReceivers.NewRow(New PurRecvDefaults(Me.oReceivers.Entity.receiveid))

    'Go to last row
    Me.BindingContext(Me.oReceivers.GetCurrentDataSet(), "Pur_Recv").Position = _
        Me.oReceivers.GetCurrentDataSet().Tables("Pur_Recv").Rows.Count - 1
  End Sub

  Private Sub SaveReceiver()
    'Check for broken rules then save
    Dim result As mmSaveDataResult = oReceivers.SaveDataSet("Pur_Recv")

    'Check for broken rules after save
    If result <> mmSaveDataResult.RulesBroken Then
      Me.glRecvAdding = False
     Else
      Me.lblReqMessage.Text = "Receiver record not saved."
     End If
  End Sub
If the user makes any changes to the line item in edit mode, this has to be sent to the receiver record in the Pur_Recv table. I use a stored procedure for this:
  Private Sub UpdateReceiver()
    Dim lnRecCount As Integer
    Dim ldToday As DateTime = Now

    'Put values into Purrecv public variables
    Purrecv.gnReqId = CInt(Me.txtLIReqNum.Text)
    Purrecv.gnItemNum = CShort(Me.txtLIItemNum.Text)
    Purrecv.gcPONum = Me.txtLIPONum.Text
    Purrecv.gnOrderQty = CInt(Me.txtLIQty.Text)
    Purrecv.gcVendPartNum = Me.txtLIVendPartNum.Text
    Purrecv.gcDescrip = Me.txtLIDescrip.Text
    Purrecv.gcMfgName = Me.txtLIManuName.Text
    Purrecv.gcMfgNum = Me.txtLIManuPartNum.Text

    'Call UpdateReceiver function in Purrecv
    lnRecCount = Me.oReceivers.UpdateReceiver( _
      Purrecv.gnReqId, _
      Purrecv.gnItemNum, _
      Purrecv.gcPONum, _
      Purrecv.gnOrderQty, _
      Purrecv.gcVendPartNum, _
      Purrecv.gcDescrip, _
      Purrecv.gcMfgName, _
      Purrecv.gcMfgNum, _
      ldToday)

    If lnRecCount > 0 Then
      'This updates the grids when an update occurs?
      Me.grdListing.NavigateData(mmNavigate.Next)
      Me.grdListing.NavigateData(mmNavigate.Prior)
    Else
      MsgBox("Receive record could not be updated", MsgBoxStyle.Exclamation, "Save error")
    End If
  End Sub
The problem is that the receiver grid doesn't show the updated data, but the data has been updated in the 'Pur_Recv' table.

The grdRecvListing grid's Binding source is the Purrecv business object.

Thanks.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform