on 07-04-2014 11:21 AM
hi, every body.
i have a main form and left click on the form a new sub grid form open.
in the sub grid form i write Observations & Remarks against some items.then press the update button form close but the Observations & Remarks are not saved.
for more clarification of the scenario please see the attached screen short and the source code. My code is in vb.net.
on clicking the update button this SaveSubGrid() function invoke.
here is code:
Sub SaveSubGrid(ByVal Row As Integer)
Try
Dim initSize As Integer = v_dbdsn2.Size
Dim currSize As Integer = v_dbdsn2.Size
For i As Integer = 0 To initSize - 1
v_dbdsn2.Offset = i - (initSize - currSize)
If v_dbdsn2.GetValue("U_detailid", v_dbdsn2.Offset).Trim <> "" Then
If CInt(v_dbdsn2.GetValue("U_detailid", v_dbdsn2.Offset)) = Row Then
v_dbdsn2.RemoveRecord(v_dbdsn2.Offset)
End If
End If
currSize = v_dbdsn2.Size
Next
Dim matrix3 As SAPbouiCOM.Matrix
matrix3 = frmSubGridForm.Items.Item("sgrid").Specific
v_dbdsn3 = frmSubGridForm.DataSources.DBDataSources.Item("@QC_INWARDSGRID")
matrix3.FlushToDataSource()
Dim oEmpty As Boolean = True
If v_dbdsn2.Size = 0 Then
v_dbdsn2.InsertRecord(v_dbdsn2.Size)
End If
v_dbdsn2.Offset = 0
If v_dbdsn2.Size = 1 And Trim(v_dbdsn2.GetValue("U_detailid", v_dbdsn2.Offset)).Equals("") = True Then
oEmpty = True
Else
oEmpty = False
End If
For i As Integer = 0 To matrix3.VisualRowCount - 1
v_dbdsn3.Offset = i
If oEmpty = True Then
v_dbdsn2.Offset = v_dbdsn2.Size - 1
v_dbdsn2.SetValue("U_detailid", v_dbdsn2.Offset, Row)
v_dbdsn2.SetValue("U_pname", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_pname", i).Trim)
v_dbdsn2.SetValue("U_spec", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_spec", i).Trim)
v_dbdsn2.SetValue("U_observation", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_observation", i).Trim)
v_dbdsn2.SetValue("U_remarks", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_remarks", i).Trim)
If i <> (matrix3.VisualRowCount - 1) Then
v_dbdsn2.InsertRecord(v_dbdsn2.Size)
End If
ElseIf oEmpty = False Then
v_dbdsn2.InsertRecord(v_dbdsn2.Size)
v_dbdsn2.Offset = v_dbdsn2.Size - 1
v_dbdsn2.SetValue("U_detailid", v_dbdsn2.Offset, Row)
v_dbdsn2.SetValue("U_pname", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_pname", i).Trim)
v_dbdsn2.SetValue("U_spec", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_spec", i).Trim)
v_dbdsn2.SetValue("U_observation", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_observation", i).Trim)
v_dbdsn2.SetValue("U_remarks", v_dbdsn2.Offset, v_dbdsn3.GetValue("U_remarks", i).Trim)
End If
Next
frmSubGridForm.Close()
Catch ex As Exception
oApplication.StatusBar.SetText("Save SubGrid Method Failed:" & ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)
Finally
End Try
End Sub
Hi,
From your code I understand that you're copying the values from one datasource to another. But what's the target? what is the role of each DS?
Should v_dbdsn2 be returned back to the parent form? How do you do it?
Beni.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Beni.
in the LoadSubGrid method i initialize the data sources.
and the update or save data in the date, i also show you the table structure and the source code
Sub LoadSubGrid(ByVal Row As Integer)
Try
Dim Bool As Boolean = False
For frm As Integer = 0 To oApplication.Forms.Count - 1
If oApplication.Forms.Item(frm).UniqueID = "inspdet" Then
frmSubGridForm = oApplication.Forms.Item("inspdet")
frmSubGridForm.Visible = True
frmSubGridForm.Select()
Bool = True
Exit For
End If
Next
If Bool = False Then
Me.AddXML("InwardInspSubGrid.xml")
frmSubGridForm = oApplication.Forms.Item("inspdet")
frmSubGridForm.Select()
End If
ModalForm = True
Dim matrix2, matrix3 As SAPbouiCOM.Matrix
matrix2 = frmInwardInspection.Items.Item("i_mat").Specific
matrix3 = frmSubGridForm.Items.Item("sgrid").Specific
v_dbdsn3 = frmSubGridForm.DataSources.DBDataSources.Item("@QC_INWARDSGRID")
v_dbdsn2 = frmSubGridForm.DataSources.DBDataSources.Item("@QC_INWARDSGRID")
v_dbdsn3.Clear()
If v_dbdsn2.Size >= 1 Then
For i As Integer = 0 To v_dbdsn2.Size - 1
v_dbdsn2.Offset = i
If Trim(v_dbdsn2.GetValue("U_detailid", v_dbdsn2.Offset)).Equals("") = False Then
If CInt(v_dbdsn2.GetValue("U_detailid", v_dbdsn2.Offset)) = Row Then
v_dbdsn3.InsertRecord(v_dbdsn3.Size)
v_dbdsn3.Offset = v_dbdsn3.Size - 1
v_dbdsn3.SetValue("U_detailid", v_dbdsn3.Offset, Row)
v_dbdsn3.SetValue("U_pname", v_dbdsn3.Offset, v_dbdsn2.GetValue("U_pname", v_dbdsn2.Offset).Trim)
v_dbdsn3.SetValue("U_spec", v_dbdsn3.Offset, v_dbdsn2.GetValue("U_spec", v_dbdsn2.Offset).Trim)
v_dbdsn3.SetValue("U_observation", v_dbdsn3.Offset, v_dbdsn2.GetValue("U_observation", v_dbdsn2.Offset).Trim)
v_dbdsn3.SetValue("U_remarks", v_dbdsn3.Offset, v_dbdsn2.GetValue("U_remarks", v_dbdsn2.Offset).Trim)
End If
End If
Next
matrix3.LoadFromDataSource()
End If
If matrix3.VisualRowCount < 1 Then
Dim rs As SAPbobsCOM.Recordset = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
rs.DoQuery("Select b.U_pname,b.U_spec,c.U_observation,c.U_remarks from [@HCC_QC_LB] a,[@QC_LAYOUTDETAIL] b,[@QC_INWARDSGRID] c Where a.DocEntry = b.DocEntry and a.U_itemid='" & Trim(matrix2.Columns.Item("i_itemid").Cells.Item(Row).Specific.Value) & "'")
For i As Integer = 1 To rs.RecordCount
matrix3.AddRow()
v_dbdsn3.InsertRecord(v_dbdsn3.Size)
v_dbdsn3.Offset = v_dbdsn3.Size - 1
v_dbdsn3.SetValue("U_detailid", v_dbdsn3.Offset, Row)
v_dbdsn3.SetValue("U_pname", v_dbdsn3.Offset, Trim(rs.Fields.Item("U_pname").Value))
v_dbdsn3.SetValue("U_spec", v_dbdsn3.Offset, Trim(rs.Fields.Item("U_spec").Value))
v_dbdsn3.SetValue("U_observation", v_dbdsn3.Offset, "")
v_dbdsn3.SetValue("U_remarks", v_dbdsn3.Offset, "")
rs.MoveNext()
Next
matrix3.LoadFromDataSource()
End If
Catch ex As Exception
oApplication.StatusBar.SetText("LoadSubGrid Method Failed:" & ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning)
Finally
End Try
End Sub
Problem solved.
LoadSubGrid is the method of parent form and saveSubGrid is the method of child model form.
i use another matrix and data source to temp store the values and make same SubGrid on the parent form as on the child form and hide that grid. as i populate the grid on the child form mean while grid on the parent from is also updated.
And the values from the SubGrid on the parent table is save in the data base table.
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.