mardi 27 septembre 2016

Cannot set UltraGrid Checkbox value to True after saving the initial data

My project contains a form which allows the entering of orders, using an UltraGrid.

One column is a checkbox style column, to represent whether or not the order has been delivered.

When the order reaches 'Stage 4 - Awaiting Goods Delivery', the user can set the column value to True, which in turn prompts a new window, to allow the user to enter the volume and value of the delivery. If the order hasn't been fully delivered, the checkbox is set back to False, and the order line turns yellow (Eg; 5 gates have been ordered, but only 3 delivered = False, but a yellow order line).

After saving the order, closing it and going back into it, I'm trying to set the Checkbox to True, to update the order to add on the rest of the delivery (the final 2 gates have been delivered), but as soon as I set it to True, it instantly becomes False again (When stepping through the following code in the CellChange method, it says the cell value is False too).

So, why can I only change the value once? After it's been saved, why can the value then not be changed again? Is it do with the fact that it's saved as False in the database?

Try
  If e.Cell.Column.ToString = "Goods_Delivered" Then
     e.Cell.Row.Update()

       If e.Cell.Value = True Then
           If IsDBNull(e.Cell.Row.Cells("Final_Delivery").Value) Then
              MsgBox("Please enter a delivery date", MsgBoxStyle.OkOnly, "Invalid Date")
                    e.Cell.Row.Cells("Goods_Delivered").Value = False
           Else
            Dim f As New dlgDelivery(e.Cell.Row, Me, e.Cell.Row.Cells("Final_Delivery").Value, con, orderNumber, e.Cell.Row.Cells("Product_Code").Value, exTotal)
                f.ShowDialog()
           End If

           e.Cell.Row.Update()

        cmdCheck_Click(sender, New EventArgs)
        cmdTotals_Click(sender, New EventArgs)

  ElseIf e.Cell.Value = False Then
      ugProducts.ActiveRow.Cells("Final_Delivery").Value = DBNull.Value
       productCode = ugProducts.ActiveRow.Cells("Product_Code").Value
       database.NotDelivered(orderNumber, productCode, con)
     Exit Sub
  Else
  End If




Aucun commentaire:

Enregistrer un commentaire