/// <summary>
 /// Function to fill additional cost grid
 /// </summary>
 public void AdditionalCostGridFill()
 {
     List<DataTable> ListObjforaccountLedger = new List<DataTable>();
     PurchaseInvoiceBll BllPurchaseInvoice = new PurchaseInvoiceBll();
     AditionalCostBll bllAdditionalCost = new AditionalCostBll();
     try
     {
         ListObjforaccountLedger = BllPurchaseInvoice.AccountLedgerViewForAdditionalCost();
         DataRow dr = ListObjforaccountLedger[0].NewRow();
         dr["ledgerName"] = string.Empty;
         dr["ledgerId"] = 0;
         ListObjforaccountLedger[0].Rows.InsertAt(dr, 0);
         dgvcmbLedger.DataSource = ListObjforaccountLedger[0];
         dgvcmbLedger.DisplayMember = "ledgerName";
         dgvcmbLedger.ValueMember = "ledgerId";
         if (decPurchaseMasterId == 0)
         {
             AdditionalCostComboFill(0);
         }
         else
         {
             List<DataTable> ListObj = new List<DataTable>();
             ListObj = bllAdditionalCost.AdditionalCostViewAllByVoucherTypeIdAndVoucherNo(decPurchaseInvoiceVoucherTypeId, strVoucherNo);
             dgvAdditionalCost.DataSource = ListObj[0];
         }
         AdditionalCostSerialNo();
     }
     catch (Exception ex)
     {
         MessageBox.Show("PI26:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill additional cost combo box
 /// </summary>
 /// <param name="inRowIndex"></param>
 public void AdditionalCostComboFill(int inRowIndex)
 {
     List<DataTable> ListObj = new List<DataTable>();
     PurchaseInvoiceBll BllPurchaseInvoice = new PurchaseInvoiceBll();
     try
     {
         ListObj = BllPurchaseInvoice.AccountLedgerViewForAdditionalCost();
         DataRow drow = ListObj[0].NewRow();
         drow["ledgerName"] = string.Empty;
         drow["ledgerId"] = 0;
         ListObj[0].Rows.InsertAt(drow, 0);
         if (dgvAdditionalCost.RowCount > 1)
         {
             foreach (DataGridViewRow dgvrow in dgvAdditionalCost.Rows)
             {
                 foreach (DataRow drow1 in ListObj[0].Rows)
                 {
                     if (dgvrow.Index != inRowIndex)
                     {
                         if (dgvrow.Cells["dgvcmbLedger"].Value != null)
                         {
                             if (drow1["ledgerId"].ToString() == dgvrow.Cells["dgvcmbLedger"].Value.ToString())
                             {
                                 ListObj[0].Rows.RemoveAt(ListObj[0].Rows.IndexOf(drow1));
                                 break;
                             }
                         }
                     }
                 }
             }
         }
         DataGridViewComboBoxCell dgvcmbLedgerCell = (DataGridViewComboBoxCell)dgvAdditionalCost.Rows[inRowIndex].Cells[dgvAdditionalCost.Columns["dgvcmbLedger"].Index];
         dgvcmbLedgerCell.DataSource = ListObj[0];
         dgvcmbLedgerCell.DisplayMember = "ledgerName";
         dgvcmbLedgerCell.ValueMember = "ledgerId";
     }
     catch (Exception ex)
     {
         MessageBox.Show("PI25:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }