Hi Supriya,
Thank you for your interest in Syncfusion products.
If you want to set focus to next row of same column index in child table in gridgroupingcontrol, you can use the “TableControlKeyDown” event and focus particular cell by using “MoveTo()”method and set the “GridSetCurrentCellOptions” as SetFocus. Please refer the below code,
Code:
this.gridGroupingControl1.TableControlKeyDown += new GridTableControlKeyEventHandler(gridGroupingControl1_TableControlKeyDown);
void gridGroupingControl1_TableControlKeyDown(object sender, GridTableControlKeyEventArgs e)
{
GridCurrentCell cc = e.TableControl.CurrentCell;
GridTable tablechild = this.gridGroupingControl1.GetTable("Orders");
if (tablechild.CurrentRecord != null)
{
if (e.Inner.KeyCode == Keys.Down)
{
e.TableControl.CurrentCell.MoveTo(GridRangeInfo.Cell(cc.RowIndex + 1, cc.ColIndex), GridSetCurrentCellOptions.SetFocus); // focus to next row in child table
}
}
MessageBox.Show("Table RowIndex : " + tablechild.CurrentRecord.GetRowIndex());
e.Inner.Handled = true;
}
Please let us know if you have any concern.
Regards,
Muthukumar K
Hi,Sir Solution not working properly.Please give me another solution.My Code isPublic Sub BindSyncfusionGrid(ByVal dtset1 As DataSet)Try'Dim dr As SqlDataReaderDim dttax As New DataTableDim index As IntegerIf (dtset1.Tables(0).Rows.Count > 0) Then'for adding the column Availabel RetQty in bought itemGridGroupingControl1.DataSource = NothingIf Not dtset1.Tables(0).Columns.Contains("AvailabelRetQty") Thenindex = dtset1.Tables(0).Columns("AlreadyReturnedQuantity").Ordinaldtset1.Tables(0).Columns.Add("AvailabelRetQty").SetOrdinal(index + 1)For i As Integer = 0 To dtset1.Tables(0).Rows.Count - 1Dim invqty, alretqty As Decimalinvqty = dtset1.Tables(0).Rows(i)("Qty").ToString()alretqty = dtset1.Tables(0).Rows(i)("AlreadyReturnedQuantity").ToString()dtset1.Tables(0).Rows(i)("AvailabelRetQty") = invqty - alretqtyNextEnd If'for adding the column Current RetQty in bought itemIf Not SRExists(cmbSRetNo.Text, yearfrom, yearto) ThenIf Not dtset1.Tables(0).Columns.Contains("CurrentRetQty") Thenindex = dtset1.Tables(0).Columns("AvailabelRetQty").Ordinaldtset1.Tables(0).Columns.Add("CurrentRetQty").SetOrdinal(index + 1)For i As Integer = 0 To dtset1.Tables(0).Rows.Count - 1dtset1.Tables(0).Rows(i)("CurrentRetQty") = dtset1.Tables(0).Rows(i)("AvailabelRetQty")NextEnd IfEnd If'for adding the column SetAmt in bought itemIf Not dtset1.Tables(0).Columns.Contains("SetAmt") Thenindex = dtset1.Tables(0).Columns("Amt").Ordinaldtset1.Tables(0).Columns.Add("SetAmt").SetOrdinal(index + 1)For i As Integer = 0 To dtset1.Tables(0).Rows.Count - 1dtset1.Tables(0).Rows(i)("SetAmt") = dtset1.Tables(0).Rows(i)("Amt").ToString()NextEnd If'for adding the column SetAssAmt in bought itemIf Not dtset1.Tables(0).Columns.Contains("SetAssAmt") Thenindex = dtset1.Tables(0).Columns("AssessableAmt").Ordinaldtset1.Tables(0).Columns.Add("SetAssAmt").SetOrdinal(index + 1)For i As Integer = 0 To dtset1.Tables(0).Rows.Count - 1dtset1.Tables(0).Rows(i)("SetAssAmt") = dtset1.Tables(0).Rows(i)("AssessableAmt").ToString()NextEnd If'for adding the column SetTotalTax in bought itemIf Not dtset1.Tables(0).Columns.Contains("SetTotalTax") Thenindex = dtset1.Tables(0).Columns("TotalTax").Ordinaldtset1.Tables(0).Columns.Add("SetTotalTax").SetOrdinal(index + 1)For i As Integer = 0 To dtset1.Tables(0).Rows.Count - 1dtset1.Tables(0).Rows(i)("SetTotalTax") = dtset1.Tables(0).Rows(i)("TotalTax").ToString()NextEnd If'dtset1.Tables(1).Columns.Add("SetQty")'For i As Integer = 0 To dtset1.Tables(0).Rows.Count - 1' Dim setqty, qty, sqty As Decimal' Dim itemcode As String' Dim Setdt As New DataTable' itemcode = dtset1.Tables(0).Rows(i)("ItemCode").ToString()' If isSet11(itemcode) Then' qty = dtset1.Tables(0).Rows(i)("Qty").ToString()' For j As Integer = 0 To dtset1.Tables(1).Rows.Count - 1' sqty = dtset1.Tables(1).Rows(j)("Qty").ToString()' setqty = qty * sqty' If (itemcode = dtset1.Tables(1).Rows(j)("SetsID").ToString()) Then' dtset1.Tables(1).Rows(j)("SetQty") = setqty' End If' Next' End If'Next'for adding the column Availabel RetQty in bought items of set itemIf Not dtset1.Tables(1).Columns.Contains("AvailabelRetQty") Thenindex = dtset1.Tables(1).Columns("AlreadyReturnedQuantity").Ordinaldtset1.Tables(1).Columns.Add("AvailabelRetQty").SetOrdinal(index + 1)For i As Integer = 0 To dtset1.Tables(1).Rows.Count - 1Dim invqty, alretqty As Decimalinvqty = dtset1.Tables(1).Rows(i)("Qty").ToString()alretqty = dtset1.Tables(1).Rows(i)("AlreadyReturnedQuantity").ToString()dtset1.Tables(1).Rows(i)("AvailabelRetQty") = invqty - alretqtyNextEnd If'for adding the column Current RetQty in bought items of setitemIf Not SRExists(cmbSRetNo.Text, yearfrom, yearto) ThenIf Not dtset1.Tables(1).Columns.Contains("CurrentRetQty") Thenindex = dtset1.Tables(1).Columns("AvailabelRetQty").Ordinaldtset1.Tables(1).Columns.Add("CurrentRetQty").SetOrdinal(index + 1)For i As Integer = 0 To dtset1.Tables(1).Rows.Count - 1dtset1.Tables(1).Rows(i)("CurrentRetQty") = dtset1.Tables(1).Rows(i)("AvailabelRetQty")NextEnd IfEnd If''for adding the column amt in bought items of set items'If Not dtset1.Tables(1).Columns.Contains("Amt") Then' dtset1.Tables(1).Columns.Add("Amt")' For i As Integer = 0 To dtset1.Tables(1).Rows.Count - 1' dtset1.Tables(1).Rows(i)("Amt") = 0.0' Next'End If''for adding the column Assessable amt in bought items of set items'If Not dtset1.Tables(1).Columns.Contains("AssessableAmt") Then' dtset1.Tables(1).Columns.Add("AssessableAmt")' For i As Integer = 0 To dtset1.Tables(1).Rows.Count - 1' dtset1.Tables(1).Rows(i)("AssessableAmt") = 0.0' Next'End If''for adding the column TotalTax in bought items of set itemsIf Not SRExists(cmbSRetNo.Text, yearfrom, yearto) ThenIf Not dtset1.Tables(1).Columns.Contains("TotalTax") Thendtset1.Tables(1).Columns.Add("TotalTax")For i As Integer = 0 To dtset1.Tables(1).Rows.Count - 1dtset1.Tables(1).Rows(i)("TotalTax") = 0.0NextEnd IfEnd IfDim parentToChildRelationDescriptor As New Syncfusion.Windows.Forms.Grid.Grouping.GridRelationDescriptor()GridGroupingControl1.DataSource = NothingparentToChildRelationDescriptor.ChildTableName = "SetItems"parentToChildRelationDescriptor.RelationKind = Syncfusion.Grouping.RelationKind.RelatedMasterDetailsparentToChildRelationDescriptor.RelationKeys.Add("ItemCode", "SetItem")GridGroupingControl1.TableDescriptor.Relations.Add(parentToChildRelationDescriptor)GridGroupingControl1.Engine.SourceListSet.Add("ItemMaster", dtset1.Tables(0))GridGroupingControl1.Engine.SourceListSet.Add("SetItems", dtset1.Tables(1))GridGroupingControl1.DataSource = dtset1.Tables(0)' parentToChildRelationDescriptor.ChildTableDescriptor.Columns.AddRange(New GridColumnDescriptor() {New GridColumnDescriptor("BoughtItem"), New GridColumnDescriptor("ItemName"), New GridColumnDescriptor("Qty"), New GridColumnDescriptor("AlreadyReturnedQuantity"), New GridColumnDescriptor("AvailabelRetQty"), New GridColumnDescriptor("CurrentRetQty"), New GridColumnDescriptor("Rate"), New GridColumnDescriptor("Disc"), New GridColumnDescriptor("adddisc"), New GridColumnDescriptor("Amt"), New GridColumnDescriptor("AssessableAmt"), New GridColumnDescriptor("TotalTax")})GridGroupingControl1.TableDescriptor.VisibleColumns.Remove("TaxDetails")GridGroupingControl1.TableDescriptor.VisibleColumns.Remove("SetAssAmt")GridGroupingControl1.TableDescriptor.VisibleColumns.Remove("SetAmt")GridGroupingControl1.TableDescriptor.VisibleColumns.Remove("SetTotalTax")If SRExists(cmbSRetNo.Text, yearfrom, yearto) ThenGridGroupingControl1.TableDescriptor.VisibleColumns.Remove("CurName")GridGroupingControl1.TableDescriptor.VisibleColumns.Remove("InvAmt")GridGroupingControl1.TableDescriptor.VisibleColumns.Remove("InvAssAmt")GridGroupingControl1.TableDescriptor.VisibleColumns.Remove("InvTaxDetails")GridGroupingControl1.TableDescriptor.VisibleColumns.Remove("InvTotalTax")GridGroupingControl1.TableDescriptor.VisibleColumns.Remove("TaxDetails")End If'GridGroupingControl1.TableModel.HideCols("TaxDetails") = True'GridGroupingControl1.TableModel.HideCols("SetAssAmt") = True'GridGroupingControl1.TableModel.HideCols("SetAmt") = True'GridGroupingControl1.TableModel.HideCols("SetTotalTax") = True'If SRExists(cmbSRetNo.Text, yearfrom, yearto) Then' GridGroupingControl1.TableModel.HideCols("CurName") = True'End IfGridGroupingControl1.TableDescriptor.AllowNew = FalseparentToChildRelationDescriptor.ChildTableDescriptor.AllowNew = FalseGridGroupingControl1.TableDescriptor.Columns("itmgroupcd").ReadOnly = True'GridGroupingControl1.TableDescriptor.Columns("SrNo").ReadOnly = TrueGridGroupingControl1.TableDescriptor.Columns("ItemCode").ReadOnly = TrueGridGroupingControl1.TableDescriptor.Columns("ItemName").ReadOnly = TrueGridGroupingControl1.TableDescriptor.Columns("Qty").ReadOnly = TrueGridGroupingControl1.TableDescriptor.Columns("AlreadyReturnedQuantity").ReadOnly = TrueGridGroupingControl1.TableDescriptor.Columns("Rate").ReadOnly = TrueGridGroupingControl1.TableDescriptor.Columns("Amt").ReadOnly = TrueGridGroupingControl1.TableDescriptor.Columns("AssessableAmt").ReadOnly = TrueGridGroupingControl1.TableDescriptor.Columns("Unit").ReadOnly = TrueGridGroupingControl1.TableDescriptor.Columns("TaxDetails").ReadOnly = TrueGridGroupingControl1.TableDescriptor.Columns("SetAssAmt").ReadOnly = TrueGridGroupingControl1.TableDescriptor.Columns("SetAmt").ReadOnly = TrueGridGroupingControl1.TableDescriptor.Columns("SetTotalTax").ReadOnly = TrueGridGroupingControl1.TableDescriptor.Columns("AvailabelRetQty").ReadOnly = TrueGridGroupingControl1.TableDescriptor.Columns("TotalTax").ReadOnly = TrueDim TColIndex, totcolindex As IntegerDim taxname As StringTColIndex = dtset1.Tables(0).Columns("TaxDetails").Ordinaltotcolindex = dtset1.Tables(0).Columns("TotalTax").Ordinal - 1For i As Integer = TColIndex + 1 To totcolindextaxname = dtset1.Tables(0).Columns(i).ColumnNameGridGroupingControl1.TableDescriptor.Columns(taxname).ReadOnly = TrueNext'GridGroupingControl1.TableDescriptor.Columns.If SRExists(cmbSRetNo.Text, yearfrom, yearto) ThenGridGroupingControl1.TableDescriptor.Columns("CurName").ReadOnly = TrueGridGroupingControl1.TableDescriptor.Columns("ExistingRetQty").ReadOnly = TrueEnd If'******For hiding the column taxdetail in childtableDim tbl As GridTableModel = Me.GridGroupingControl1.GetTableModel("SetItems")AddHandler tbl.QueryColWidth, AddressOf tbl_QueryColWidthIf (dtset1.Tables(1).Rows.Count > 0) Then'parentToChildRelationDescriptor.ChildTableDescriptor.Columns("SetItem").ReadOnly = TrueparentToChildRelationDescriptor.ChildTableDescriptor.Columns("BoughtItem").ReadOnly = TrueparentToChildRelationDescriptor.ChildTableDescriptor.Columns("ItemName").ReadOnly = TrueparentToChildRelationDescriptor.ChildTableDescriptor.Columns("Qty").ReadOnly = TrueparentToChildRelationDescriptor.ChildTableDescriptor.Columns("AlreadyReturnedQuantity").ReadOnly = TrueparentToChildRelationDescriptor.ChildTableDescriptor.Columns("Rate").ReadOnly = TrueparentToChildRelationDescriptor.ChildTableDescriptor.Columns("disc").ReadOnly = TrueparentToChildRelationDescriptor.ChildTableDescriptor.Columns("adddisc").ReadOnly = True'parentToChildRelationDescriptor.ChildTableDescriptor.Columns("TaxAmt").ReadOnly = TrueparentToChildRelationDescriptor.ChildTableDescriptor.Columns("Amt").ReadOnly = TrueparentToChildRelationDescriptor.ChildTableDescriptor.Columns("AssessableAmt").ReadOnly = TrueparentToChildRelationDescriptor.ChildTableDescriptor.Columns("AvailabelRetQty").ReadOnly = TrueGridGroupingControl1.TableDescriptor.VisibleColumns.Remove("TaxDetails")If (SRExists(cmbSRetNo.Text, yearfrom, yearto)) ThenparentToChildRelationDescriptor.ChildTableDescriptor.Columns("ExistingRetQty").ReadOnly = TrueparentToChildRelationDescriptor.ChildTableDescriptor.Columns("TaxDetails").ReadOnly = TrueEnd IfEnd IfElseGridGroupingControl1.DataSource = NothingEnd IfCatch ex As ExceptionMessageBox.Show(ex.Message.ToString())End TryEnd SubPrivate Sub GridGroupingControl1_TableControlCurrentCellEditingComplete(ByVal sender As System.Object, ByVal e As Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlEventArgs) Handles GridGroupingControl1.TableControlCurrentCellEditingCompleteTryDim CRowIndex, cnt, ColIndex, totcolindex, TColIndex, CRetQtyIndex, ind As IntegerDim Curretqty, AvRetQty, ExRetQty, chkRetQty, InvQty, Rate, Amt, CalAmt, AssAmt, CalAssAmt, TaxAmt, CalTaxAmt, TotDiscPer, TradeDiscountAmt, CashDiscountAmt, DiscountAmt, DiscountedAmt As DoubleDim ItemCode, taxname, colname As StringDim ItemGrpCd As String = NothingDim calformula As DoubleRowIndex = e.TableControl.CurrentCell.RowIndex()ColIndex = e.TableControl.CurrentCell.ColIndex()Dim cc1 As GridCurrentCell = e.TableControl.CurrentCellDim style1 As GridTableCellStyleInfoIdentity = Me.GridGroupingControl1.TableModel(cc1.RowIndex, cc1.ColIndex).TableCellIdentityIf (style1.TableCellType = GridTableCellType.RecordFieldCell Or style1.TableCellType = GridTableCellType.AlternateRecordFieldCell) Thencolname = style1.Column.NameEnd If' Me.GridGroupingControl1.TableDescriptor.ColIndexToField(ColIndex)TColIndex = dtset1.Tables(0).Columns("TaxDetails").Ordinal 'for Tax calculation' totcolindex = dtset1.Tables(0).Columns.Count - 1totcolindex = dtset1.Tables(0).Columns("TotalTax").Ordinal - 1DatasetIndex = RowIndex - 3'If (DatasetIndex >= 0) Then' ItemGrpCd = dtset1.Tables(0).Rows(DatasetIndex)("itmgroupcd").ToString()'End If'**************For Bought Item Calculation*************************CRetQtyIndex = dtset1.Tables(0).Columns("CurrentRetQty").OrdinalIf (colname = "CurrentRetQty") Then'If (e.TableControl.CurrentCell.ColIndex() = 9 Or e.TableControl.CurrentCell.ColIndex() = 10 And dtset1.Tables(0).Columns("CurrentRetQty").Ordinal = 7 And ItemGrpCd <> "IG011" And ItemGrpCd = "IG005") Then'If (e.TableControl.CurrentCell.ColIndex() = 9 Or e.TableControl.CurrentCell.ColIndex() = 10) ThenCurretqty = dtset1.Tables(0).Rows(DatasetIndex)("CurrentRetQty").ToString()AvRetQty = dtset1.Tables(0).Rows(DatasetIndex)("AvailabelRetQty").ToString()ItemCode = dtset1.Tables(0).Rows(DatasetIndex)("ItemCode").ToString()If Not SRExists(cmbSRetNo.Text, yearfrom, yearto) ThenIf (Curretqty > AvRetQty) ThenMessageBox.Show("Sales Return Quantity Should be Less Than Availabel Return Quantity")e.TableControl.Model(RowIndex, 9).Text = 0End IfRate = dtset1.Tables(0).Rows(DatasetIndex)("Rate").ToString()Amt = dtset1.Tables(0).Rows(DatasetIndex)("SetAmt").ToString()InvQty = dtset1.Tables(0).Rows(DatasetIndex)("Qty").ToString()ItemGrpCd = dtset1.Tables(0).Rows(DatasetIndex)("itmgroupcd").ToString()CalAmt = Curretqty * Ratedtset1.Tables(0).Rows(DatasetIndex)("Amt") = Math.Round(CalAmt, 3)AssAmt = dtset1.Tables(0).Rows(DatasetIndex)("SetAssAmt").ToString()CalAssAmt = (AssAmt / Amt) * Rate * Curretqtydtset1.Tables(0).Rows(DatasetIndex)("AssessableAmt") = Math.Round(CalAssAmt, 3)'TaxAmt = dtset1.Tables(0).Rows(DatasetIndex)("SetTotalTax").ToString()'CalTaxAmt = (TaxAmt * Curretqty) / InvQty'dtset1.Tables(0).Rows(DatasetIndex)("TotalTax") = Math.Round(CalTaxAmt, 3)'** Tax CalculationTotDiscPer = Val(txtDiscPer.Text) + Val(txtTDiscPer.Text)TradeDiscountAmt = CDbl(VB6.Format(CalAmt * ((txtTDiscPer.Text) / 100), "#0.000"))CashDiscountAmt = CDbl(VB6.Format(CalAmt * ((txtDiscPer.Text) / 100), "#0.000"))DiscountAmt = CDbl(VB6.Format(CalAmt - TradeDiscountAmt - CashDiscountAmt, "#0.000"))DiscountedAmt = CDbl(VB6.Format(CalAmt - DiscountAmt, "#0.000"))cnt = dtset1.Tables(0).Columns.CountFor i As Integer = 1 To totcolindex - TColIndexDim dtfnm, dtcal As New DataTable' Dim calformula As Doubletaxname = dtset1.Tables(0).Columns(TColIndex + i).ColumnNamequery = "select Formula from FormulaMst where TaxName like '" & taxname & "'"dtfnm = ExecuteQry(query)dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Gross Amount}", VB6.Format(CalAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Trade Discount}", VB6.Format(TradeDiscountAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Cash Discount}", VB6.Format(CashDiscountAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Discount}", VB6.Format(TradeDiscountAmt + CashDiscountAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Discounted Amount}", VB6.Format(DiscountedAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Assessable Value}", VB6.Format(CalAssAmt, "#0.000"))query = "select " & dtfnm.Rows(0)("Formula").ToString()dtcal = ExecuteQry(query)calformula = VB6.Format(dtcal.Rows(0)(0), "#0.000")dtset1.Tables(0).Rows(DatasetIndex)(taxname) = calformulaNext'***Addition of multiple taxes for bought item set to total taxDim TotalTaxAmt As Decimal = 0For i As Integer = 1 To totcolindex - TColIndexDim TempTaxAmt As Decimaltaxname = dtset1.Tables(0).Columns(TColIndex + i).ColumnNameTempTaxAmt = dtset1.Tables(0).Rows(DatasetIndex)(taxname).ToString()TotalTaxAmt = TotalTaxAmt + TempTaxAmtNextdtset1.Tables(0).Rows(DatasetIndex)("TotalTax") = Math.Round(TotalTaxAmt, 3)ElseExRetQty = dtset1.Tables(0).Rows(DatasetIndex)("ExistingRetQty").ToString()chkRetQty = AvRetQty + ExRetQtyIf (Curretqty > chkRetQty) ThenMessageBox.Show("Sales Return Quantity Should be Less Than Availabel Return Quantity + Existing Return Quantity")e.TableControl.Model(RowIndex, 10).Text = 0End IfDim dtStock As New DataTableDim StkOnDt, StkChkQty As Decimalquery = "Select StkOnDt from vw_currentstock where ItemCode='" & ItemCode & "'"dtStock = ExecuteQry(query)StkOnDt = dtStock.Rows(0)("StkOnDt").ToString()StkChkQty = Curretqty - ExRetQty + StkOnDtIf (StkChkQty >= 0) Then' MessageBox.Show("Stock Is Available")ElseMessageBox.Show("Stock Is Not Available")End IfRate = dtset1.Tables(0).Rows(DatasetIndex)("Rate").ToString()Amt = dtset1.Tables(0).Rows(DatasetIndex)("InvAmt").ToString()InvQty = dtset1.Tables(0).Rows(DatasetIndex)("Qty").ToString()'ItemGrpCd = dtset1.Tables(0).Rows(DatasetIndex)("itmgroupcd").ToString()CalAmt = Curretqty * Ratedtset1.Tables(0).Rows(DatasetIndex)("Amt") = Math.Round(CalAmt, 3)AssAmt = dtset1.Tables(0).Rows(DatasetIndex)("InvAssAmt").ToString()CalAssAmt = (AssAmt / Amt) * Rate * Curretqtydtset1.Tables(0).Rows(DatasetIndex)("AssessableAmt") = Math.Round(CalAssAmt, 3)'TaxAmt = dtset1.Tables(0).Rows(DatasetIndex)("InvTotalTax").ToString()'CalTaxAmt = (TaxAmt * Curretqty) / InvQty'dtset1.Tables(0).Rows(DatasetIndex)("TotalTax") = Math.Round(CalTaxAmt, 3)TotDiscPer = Val(txtDiscPer.Text) + Val(txtTDiscPer.Text)TradeDiscountAmt = CDbl(VB6.Format(CalAmt * ((txtTDiscPer.Text) / 100), "#0.000"))CashDiscountAmt = CDbl(VB6.Format(CalAmt * ((txtDiscPer.Text) / 100), "#0.000"))DiscountAmt = CDbl(VB6.Format(CalAmt - TradeDiscountAmt - CashDiscountAmt, "#0.000"))DiscountedAmt = CDbl(VB6.Format(CalAmt - DiscountAmt, "#0.000"))cnt = dtset1.Tables(0).Columns.CountFor i As Integer = 1 To totcolindex - TColIndexDim dtfnm, dtcal As New DataTable'Dim calformula As Doubletaxname = dtset1.Tables(0).Columns(TColIndex + i).ColumnNamequery = "select Formula from FormulaMst where TaxName like '" & taxname & "'"dtfnm = ExecuteQry(query)dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Gross Amount}", VB6.Format(CalAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Trade Discount}", VB6.Format(TradeDiscountAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Cash Discount}", VB6.Format(CashDiscountAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Discount}", VB6.Format(TradeDiscountAmt + CashDiscountAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Discounted Amount}", VB6.Format(DiscountedAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Assessable Value}", VB6.Format(CalAssAmt, "#0.000"))query = "select " & dtfnm.Rows(0)("Formula").ToString()dtcal = ExecuteQry(query)calformula = VB6.Format(dtcal.Rows(0)(0), "#0.000")dtset1.Tables(0).Rows(DatasetIndex)(taxname) = calformulaNext'***Addition of multiple taxes for bought item set to total taxDim TotalTaxAmt As Decimal = 0For i As Integer = 1 To totcolindex - TColIndexDim TempTaxAmt As Decimaltaxname = dtset1.Tables(0).Columns(TColIndex + i).ColumnNameTempTaxAmt = dtset1.Tables(0).Rows(DatasetIndex)(taxname).ToString()TotalTaxAmt = TotalTaxAmt + TempTaxAmtNextdtset1.Tables(0).Rows(DatasetIndex)("TotalTax") = Math.Round(TotalTaxAmt, 3)End IfCalculateSubTotal()CalculateAssessableAmt()CalculateTaxAmountInAccount()CalculateTotal()BindSyncfusionGrid(dtset1)GoTo abcEnd If'**************Calculation For bought item in set *************************Dim s1 As GridRangeInfoListDim SBCalAmt, SBRate, SBDisc, SBAddDisc, SBCurRetQty, SBAvQty, SBExQty, SBInvQty, SInvAmt, TaxAmtPerTax, SAssAmt, STaxAmt, RCalAmtVsInvAmt, RCalAmtVsAssAmt, RCalAmtVsTaxAmt, SBAmt, SBAssAmt, SBTaxAmt As DecimalDim SBItemCode, SItemCode, SItemGrpCd, SBItemGrpCode As StringDim el As ElementDim rec As GridRecordDim table, tablechild As GridTableDim tablecontrol As GridTableControlDim cc As GridCurrentCellDim style As GridTableCellStyleInfoDim SBCRetQtyIndex As IntegerSBCRetQtyIndex = dtset1.Tables(1).Columns("CurrentRetQty").OrdinalDim StartTaxIndex, TotalColIndex As IntegerDim childcolname As String' Dim calformula As DoubleIf (Pindex <> 0) Thenel = GridGroupingControl1.Table.GetInnerMostCurrentElement()cc = e.TableControl.CurrentCelltablechild = Me.GridGroupingControl1.GetTable("SetItems")style = tablechild.GetTableCellStyle(cc.RowIndex, cc.ColIndex)childcolname = style.TableCellIdentity.Column.NameEnd If'If (Pindex <> Nothing And ItemGrpCd <> "IG005" And dtset1.Tables(1).Columns("CurrentRetQty").Ordinal = 6 And (e.TableControl.CurrentCell.ColIndex() = 6 Or e.TableControl.CurrentCell.ColIndex() = 7)) Then'If (dtset1.Tables(1).Columns("CurrentRetQty").Ordinal = 6 And (e.TableControl.CurrentCell.ColIndex() = 6 Or e.TableControl.CurrentCell.ColIndex() = 7)) ThenIf (childcolname = "CurrentRetQty") ThenSItemCode = GridGroupingControl1.Table.Records(Pindex - 3)("ItemCode").ToString()SInvAmt = GridGroupingControl1.Table.Records(Pindex - 3)("SetAmt").ToString()SItemGrpCd = GridGroupingControl1.Table.Records(Pindex - 3)("itmgroupcd").ToString()tempsbitmfcd = SItemGrpCdSAssAmt = GridGroupingControl1.Table.Records(Pindex - 3)("SetAssAmt").ToString()'For i As Integer = TColIndex + 1 To totcolindex' taxname = dtset1.Tables(0).Columns(i).ColumnName' STaxAmt = GridGroupingControl1.Table.Records(Pindex - 3)(taxname).ToString()'Next'**Currently not used'STaxAmt = GridGroupingControl1.Table.Records(Pindex - 3)("SetTotalTax").ToString()'*****fetching tax amt from set item'For i As Integer = TColIndex + 1 To totcolindex' taxname = dtset1.Tables(0).Columns(i).ColumnName' TaxAmtPerTax = GridGroupingControl1.Table.Records(Pindex - 3)(taxname).ToString()'Next'Dim rc As Record = GridGroupingControl1.Table.CurrentRecord()'SItemCode = rc("ItemCode").ToString()'********Fetching Record from child table************el = Me.GridGroupingControl1.Table.GetInnerMostCurrentElement()If Not el Is Nothing Thentable = CType(IIf(TypeOf el.ParentTable Is GridTable, el.ParentTable, Nothing), GridTable)tablecontrol = Me.GridGroupingControl1.GetTableControl(table.TableDescriptor.Name)cc = tablecontrol.CurrentCellstyle = table.GetTableCellStyle(cc.RowIndex, cc.ColIndex)rec = CType(IIf(TypeOf el Is GridRecord, el, Nothing), GridRecord)If rec Is Nothing AndAlso TypeOf el Is GridRecordRow Thenrec = CType(IIf(TypeOf el.ParentRecord Is GridRecord, el.ParentRecord, Nothing), GridRecord)End IfSBItemCode = e.TableControl.Model(RowIndex, 1).Text'SBItemCode = el.GetRecord().GetValue("BoughtItem").ToString()'SBItemGrpCode = el.GetRecord().GetValue("ItmGroupCd").ToString()SBCurRetQty = e.TableControl.Model(RowIndex, 6).Text'SBCurRetQty = el.GetRecord().GetValue("CurrentRetQty").ToString()SBAvQty = e.TableControl.Model(RowIndex, 5).Text'SBAvQty = el.GetRecord().GetValue("AvailabelRetQty").ToString()'SBInvQty = el.GetRecord().GetValue("Qty").ToString()SBInvQty = e.TableControl.Model(RowIndex, 3).Text'SBRate = el.GetRecord().GetValue("Rate").ToString()SBRate = e.TableControl.Model(RowIndex, 7).Text'SBDisc = el.GetRecord().GetValue("disc").ToString()SBDisc = e.TableControl.Model(RowIndex, 8).Text' SBAddDisc = el.GetRecord().GetValue("adddisc").ToString()SBAddDisc = e.TableControl.Model(RowIndex, 9).TextSBCalAmt = SBRate * (1 - ((SBDisc + SBAddDisc) / 100)) * SBInvQtyIf Not SRExists(cmbSRetNo.Text, yearfrom, yearto) ThenIf (SBCurRetQty > SBAvQty) ThenMessageBox.Show("Sales Return Quantity Should be Less Than Availabel Return Quantity")e.TableControl.Model(RowIndex, 6).Text = 0End IfElseSBExQty = el.GetRecord().GetValue("ExistingRetQty").ToString()chkRetQty = SBAvQty + SBExQtyIf (SBCurRetQty > chkRetQty) ThenMessageBox.Show("Sales Return Quantity Should be Less Than Availabel Return Quantity + ExistingRetQty ")e.TableControl.Model(RowIndex, 8).Text = 0End IfDim dtStock As New DataTableDim StkOnDt, StkChkQty As Decimalquery = "Select StkOnDt from vw_currentstock where ItemCode='" & SBItemCode & "'"dtStock = ExecuteQry(query)StkOnDt = dtStock.Rows(0)("StkOnDt").ToString()StkChkQty = SBCurRetQty - SBExQty + StkOnDtIf (StkChkQty >= 0) Then' MessageBox.Show("Stock Is Available")ElseMessageBox.Show("Stock Is Not Available")End IfEnd If'**************Ratios of CalculatedAmount Vs. Invoiced AmtRCalAmtVsInvAmt = SBCalAmt / SInvAmt'*************Ratios of CalculatedAmount Vs. Assessable AmtRCalAmtVsAssAmt = SBCalAmt / SAssAmt'*************Ratios of Calculated Amount Vs. Tax AmountRCalAmtVsTaxAmt = STaxAmt * (RCalAmtVsAssAmt / SBCalAmt)'****************Amount of Bought items of SetItem'SBAmt = SBCurRetQty * ((SBCalAmt / SBInvQty) / RCalAmtVsInvAmt)SBAmt = SInvAmt * RCalAmtVsInvAmt * (SBCurRetQty / SBInvQty)'****************ASSessable Amount of Bought items of SetItem'SBAssAmt = SBCurRetQty * ((SBCalAmt / SBInvQty) / RCalAmtVsAssAmt)SBAssAmt = SAssAmt * RCalAmtVsAssAmt * (SBCurRetQty / SBInvQty)'****************Tax Amount of Bought items of SetItem' old SBTaxAmt = SBCurRetQty * RCalAmtVsTaxAmt * ((SBCalAmt / SBInvQty) / RCalAmtVsAssAmt)' new SBTaxAmt = SBAssAmt * RCalAmtVsTaxAmtIf Not SRExists(cmbSRetNo.Text, yearfrom, yearto) ThenTotDiscPer = Val(txtDiscPer.Text) + Val(txtTDiscPer.Text)TradeDiscountAmt = CDbl(VB6.Format(SBAmt * ((txtTDiscPer.Text) / 100), "#0.000"))CashDiscountAmt = CDbl(VB6.Format(SBAmt * ((txtDiscPer.Text) / 100), "#0.000"))DiscountAmt = CDbl(VB6.Format(SBAmt - TradeDiscountAmt - CashDiscountAmt, "#0.000"))DiscountedAmt = CDbl(VB6.Format(SBAmt - DiscountAmt, "#0.000"))cnt = dtset1.Tables(0).Columns.Count'StartTaxIndex = dtset1.Tables(1).Columns("AssessableAmt").OrdinalStartTaxIndex = dtset1.Tables(1).Columns("TaxDetails").OrdinalTotalColIndex = dtset1.Tables(1).Columns("TotalTax").Ordinal - 1For i As Integer = 1 To TotalColIndex - StartTaxIndexDim dtfnm, dtcal As New DataTabletaxname = dtset1.Tables(1).Columns(StartTaxIndex + i).ColumnNamequery = "select Formula from FormulaMst where TaxName like '" & taxname & "'"dtfnm = ExecuteQry(query)dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Gross Amount}", VB6.Format(SBAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Trade Discount}", VB6.Format(TradeDiscountAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Cash Discount}", VB6.Format(CashDiscountAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Discount}", VB6.Format(TradeDiscountAmt + CashDiscountAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Discounted Amount}", VB6.Format(DiscountedAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Assessable Value}", VB6.Format(SBAssAmt, "#0.000"))query = "select " & dtfnm.Rows(0)("Formula").ToString()dtcal = ExecuteQry(query)calformula = VB6.Format(dtcal.Rows(0)(0), "#0.000")'***Binding Tax amount to taxname in dtset1.tables(1)For j As Integer = 0 To dtset1.Tables(1).Rows.Count - 1If (dtset1.Tables(1).Rows(j)("BoughtItem").ToString() = SBItemCode And dtset1.Tables(1).Rows(j)("SetItem").ToString() = SItemCode) Thendtset1.Tables(1).Rows(j)(taxname) = calformulaEnd IfNextNextElseTotDiscPer = Val(txtDiscPer.Text) + Val(txtTDiscPer.Text)TradeDiscountAmt = CDbl(VB6.Format(SBAmt * ((txtTDiscPer.Text) / 100), "#0.000"))CashDiscountAmt = CDbl(VB6.Format(SBAmt * ((txtDiscPer.Text) / 100), "#0.000"))DiscountAmt = CDbl(VB6.Format(SBAmt - TradeDiscountAmt - CashDiscountAmt, "#0.000"))DiscountedAmt = CDbl(VB6.Format(SBAmt - DiscountAmt, "#0.000"))cnt = dtset1.Tables(0).Columns.CountStartTaxIndex = dtset1.Tables(1).Columns("TaxDetails").OrdinalTotalColIndex = dtset1.Tables(1).Columns("TotalTax").Ordinal - 1For i As Integer = 1 To TotalColIndex - StartTaxIndexDim dtfnm, dtcal As New DataTabletaxname = dtset1.Tables(1).Columns(StartTaxIndex + i).ColumnNamequery = "select Formula from FormulaMst where TaxName like '" & taxname & "'"dtfnm = ExecuteQry(query)dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Gross Amount}", VB6.Format(SBAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Trade Discount}", VB6.Format(TradeDiscountAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Cash Discount}", VB6.Format(CashDiscountAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Discount}", VB6.Format(TradeDiscountAmt + CashDiscountAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Discounted Amount}", VB6.Format(DiscountedAmt, "#0.000"))dtfnm.Rows(0)("Formula") = Replace(dtfnm.Rows(0)("Formula"), "{Assessable Value}", VB6.Format(SBAssAmt, "#0.000"))query = "select " & dtfnm.Rows(0)("Formula").ToString()dtcal = ExecuteQry(query)calformula = VB6.Format(dtcal.Rows(0)(0), "#0.000")'***Binding Tax amount to taxname in dtset1.tables(1)For j As Integer = 0 To dtset1.Tables(1).Rows.Count - 1If (dtset1.Tables(1).Rows(j)("BoughtItem").ToString() = SBItemCode And dtset1.Tables(1).Rows(j)("SetItem").ToString() = SItemCode) Thendtset1.Tables(1).Rows(j)(taxname) = calformulaEnd IfNextNextEnd Ifel = Me.GridGroupingControl1.Table.GetInnerMostCurrentElement()'*******Addition of child bought item Multiple Tax Amount set to TotalTax***********Dim Totaltaxamt As Decimal = 0.0For i As Integer = 1 To TotalColIndex - StartTaxIndexDim taxvalue As Decimaltaxname = dtset1.Tables(1).Columns(StartTaxIndex + i).ColumnName'taxvalue = el.GetRecord().GetValue(taxname).ToString()taxvalue = e.TableControl.Model(RowIndex, StartTaxIndex + i).TextTotaltaxamt = Totaltaxamt + taxvalueNext'***Binding amt,AssessableAmt,TotalTax in dtset1.tables(1)For i As Integer = 0 To dtset1.Tables(1).Rows.Count - 1If (dtset1.Tables(1).Rows(i)("BoughtItem").ToString() = SBItemCode And dtset1.Tables(1).Rows(i)("SetItem").ToString() = SItemCode) Thendtset1.Tables(1).Rows(i)("Amt") = Math.Round(SBAmt, 3)dtset1.Tables(1).Rows(i)("AssessableAmt") = Math.Round(SBAssAmt, 3)'dtset1.Tables(1).Rows(i)("TaxAmt") = Math.Round(SBTaxAmt, 3)dtset1.Tables(1).Rows(i)("TotalTax") = Math.Round(Totaltaxamt, 3)End IfNext'Creating datatable for specific bought items for set itemdtset1.Tables(1).AcceptChanges()Dim Caldt As New DataTableCaldt = dtset1.Tables(1).Clone()Dim dr2 As DataRow() = dtset1.Tables(1).Select("SetItem = '" & SItemCode & "'")For Each row As DataRow In dr2Caldt.ImportRow(row)Next'*******Addition of child bought item Amount set to the set item***********Dim setAmt As Decimal = 0.0'For i As Integer = 0 To dtset1.Tables(1).Rows.Count - 1' Dim samt As Decimal = dtset1.Tables(1).Rows(i)("Amt").ToString()' setAmt = setAmt + samt' dtset1.Tables(0).Rows(Pindex - 3)("Amt") = Math.Round(setAmt, 3)'NextFor i As Integer = 0 To Caldt.Rows.Count - 1Dim samt As Decimal = Caldt.Rows(i)("Amt").ToString()setAmt = setAmt + samtNextdtset1.Tables(0).Rows(Pindex - 3)("Amt") = Math.Round(setAmt, 3)'*******Addition of child bought item Assessable Amount set to the set item***********Dim setAssAmt As Decimal = 0.0'For i As Integer = 0 To dtset1.Tables(1).Rows.Count - 1' Dim AssAmount As Decimal = dtset1.Tables(1).Rows(i)("AssessableAmt").ToString()' setAssAmt = setAssAmt + AssAmount' dtset1.Tables(0).Rows(Pindex - 3)("AssessableAmt") = Math.Round(setAssAmt, 3)'NextFor i As Integer = 0 To Caldt.Rows.Count - 1Dim AssAmount As Decimal = Caldt.Rows(i)("AssessableAmt").ToString()setAssAmt = setAssAmt + AssAmountNextdtset1.Tables(0).Rows(Pindex - 3)("AssessableAmt") = Math.Round(setAssAmt, 3)'*******Addition of child bought item TotalTax set to the set item ***********Dim setTotalTax As Decimal = 0.0'For i As Integer = 0 To dtset1.Tables(1).Rows.Count - 1' Dim TaxAmount As Decimal = dtset1.Tables(1).Rows(i)("TotalTaxAmt").ToString()' setTotalTax = setTotalTax + TaxAmount' dtset1.Tables(0).Rows(Pindex - 3)("TotalTax") = Math.Round(setTotalTax, 3)'NextFor i As Integer = 0 To Caldt.Rows.Count - 1Dim TaxAmount As Decimal = Caldt.Rows(i)("TotalTax").ToString()setTotalTax = setTotalTax + TaxAmountNextdtset1.Tables(0).Rows(Pindex - 3)("TotalTax") = Math.Round(setTotalTax, 3)End IfEnd IfCalculateSubTotal()CalculateAssessableAmt()CalculateTaxAmountInAccount()CalculateTotal()BindSyncfusionGrid(dtset1)If (SItemGrpCd = "IG011") ThenMe.GridGroupingControl1.Table.Records(Pindex - 3).IsExpanded = TrueEnd IfGoTo xyzabc:xyz:Catch ex As ExceptionMessageBox.Show(ex.Message.ToString())End TryEnd Sub
Hi Supriya,
We are glad to hear that the reported issue has been resolved. Please let us know if you need any further assistance.
Regards,
Muthukumar K