/// <summary>
 ///  Function to fill AccountLedger combobox
 /// </summary>
 public void AccountLedgerComboFill()
 {
     try
     {
         List<DataTable> ListObj = new List<DataTable>();
         AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
         ListObj = bllAccountLedger.AccountLedgerViewAll();
         DataRow dr = ListObj[0].NewRow();
         dr[0] = 0;
         dr[2] = "ALL";
         ListObj[0].Rows.InsertAt(dr, 0);
         cmbAccountLedger.DataSource = ListObj[0];
         cmbAccountLedger.ValueMember = "ledgerId";
         cmbAccountLedger.DisplayMember = "ledgerName";
         cmbAccountLedger.SelectedIndex = 0;
     }
     catch (Exception ex)
     {
         MessageBox.Show("JVREP3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Account Ledger Combofill function
 /// </summary>
 public void cmbAccountNameFill()
 {
     try
     {
         isWorkLedgerIndexChange = false;
         AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
         cmbAccountLedger.DataSource = null;
         List<DataTable> ListObj= bllAccountLedger.AccountLedgerViewAll();
         cmbAccountLedger.DataSource = ListObj[0];
         cmbAccountLedger.DisplayMember = "ledgerName";
         cmbAccountLedger.ValueMember = "ledgerId";
         isWorkLedgerIndexChange = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PR2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Cell begin edit event of grid, its for removing the item from the list once its added or Selected
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvPaymentVoucher_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
 {
     try
     {
         inUpdatingRowIndexForPartyRemove = -1;
         decUpdatingLedgerForPartyremove = 0;
         List<DataTable> ListObj = new List<DataTable>();
         AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
         if (dgvPaymentVoucher.CurrentCell.ColumnIndex == dgvPaymentVoucher.Columns["dgvcmbAccountLedger"].Index)
         {
             ListObj = bllAccountLedger.AccountLedgerViewAll();
             if (ListObj[0].Rows.Count < 2)
             {
                 DataRow dr = ListObj[0].NewRow();
                 dr[0] = string.Empty;
                 dr[1] = string.Empty;
                 ListObj[0].Rows.InsertAt(dr, 0);
             }
             if (dgvPaymentVoucher.RowCount > 1)
             {
                 int inGridRowCount = dgvPaymentVoucher.RowCount;
                 for (int inI = 0; inI < inGridRowCount - 1; inI++)
                 {
                     if (inI != e.RowIndex)
                     {
                         int inTableRowcount = ListObj[0].Rows.Count;
                         for (int inJ = 0; inJ < inTableRowcount; inJ++)
                         {
                             if (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                             {
                                 if (ListObj[0].Rows[inJ]["ledgerId"].ToString() == dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString())
                                 {
                                     ListObj[0].Rows.RemoveAt(inJ);
                                     break;
                                 }
                             }
                         }
                     }
                 }
             }
             DataGridViewComboBoxCell dgvccCashOrBank = (DataGridViewComboBoxCell)dgvPaymentVoucher[dgvPaymentVoucher.Columns["dgvcmbAccountLedger"].Index, e.RowIndex];
             DataRow drow = ListObj[0].NewRow();
             drow["ledgerId"] = "0";
             drow["ledgerName"] = string.Empty;
             ListObj[0].Rows.InsertAt(drow, 0);
             dgvccCashOrBank.DataSource = ListObj[0];
             dgvccCashOrBank.ValueMember = "ledgerId";
             dgvccCashOrBank.DisplayMember = "ledgerName";
         }
         if (dgvPaymentVoucher.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbAccountLedger")
         {
             if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
             {
                 if (bllAccountLedger.AccountGroupIdCheck(dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].FormattedValue.ToString()))
                 {
                     inUpdatingRowIndexForPartyRemove = e.RowIndex;
                     decUpdatingLedgerForPartyremove = Convert.ToDecimal(dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString());
                 }
             }
         }
         if (dgvPaymentVoucher.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbDrOrCr")
         {
             if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
             {
                 if (bllAccountLedger.AccountGroupIdCheck(dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].FormattedValue.ToString()))
                 {
                     inUpdatingRowIndexForPartyRemove = e.RowIndex;
                     decUpdatingLedgerForPartyremove = Convert.ToDecimal(dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString());
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PV54:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to fill BankorCash combobox while return from Ledger creation when creating new ledger 
        /// </summary>
        /// <param name="decId"></param>
        /// <param name="str"></param>
        public void ReturnFromAccountLedgerForm(decimal decId, string str)
        {
            try
            {
                if (str == "CashOrBank")
                {
                    if (decId != 0)
                    {
                        TransactionsGeneralFillBll Obj = new TransactionsGeneralFillBll();
                        Obj.CashOrBankComboFill(cmbBankorCash, false);
                        cmbBankorCash.SelectedValue = decId.ToString();
                    }
                    cmbBankorCash.Focus();
                }
                else
                {
                    if (decId != 0)
                    {
                        int inCurrentRowIndex = dgvPaymentVoucher.CurrentRow.Index;
                        if (inCurrentRowIndex == dgvPaymentVoucher.Rows.Count - 1)
                        {
                            dgvPaymentVoucher.Rows.Add();
                        }
                        dgvPaymentVoucher.CurrentRow.HeaderCell.Value = "X";
                        dgvPaymentVoucher.CurrentRow.HeaderCell.Style.ForeColor = Color.Red;
                        List<DataTable> ListObj = new List<DataTable>();
                        AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
                        ListObj = bllAccountLedger.AccountLedgerViewAll();
                        DataGridViewComboBoxCell dgvccCashOrBank = (DataGridViewComboBoxCell)dgvPaymentVoucher[dgvPaymentVoucher.Columns["dgvcmbAccountLedger"].Index, dgvPaymentVoucher.Rows[inCurrentRowIndex].Index];
                        DataRow dr = ListObj[0].NewRow();
                        dr["ledgerId"] = "0";
                        dr["ledgerName"] = string.Empty;
                        ListObj[0].Rows.InsertAt(dr, 0);
                        dgvccCashOrBank.DataSource = ListObj[0];
                        dgvccCashOrBank.ValueMember = "ledgerId";
                        dgvccCashOrBank.DisplayMember = "ledgerName";
                        dgvPaymentVoucher.Rows[inCurrentRowIndex].Cells["dgvcmbAccountLedger"].Value = decId;
                        dgvPaymentVoucher.Rows[inCurrentRowIndex].Cells["dgvcmbAccountLedger"].Selected = true;

                    }
                }

                this.Enabled = true;
                this.BringToFront();
            }
            catch (Exception ex)
            {
                MessageBox.Show("PV29:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to add the new accountledger from accountLedger form
 /// </summary>
 /// <param name="decLedgerId"></param>
 public void CallFromAccountLedger(decimal decLedgerId)
 {
     try
     {
         if (decLedgerId != 0)
         {
             AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
             List<DataTable> ListObj = new List<DataTable>();
             ListObj = bllAccountLedger.AccountLedgerViewAll();
             DataGridViewComboBoxCell dgvccAccountLedger = (DataGridViewComboBoxCell)dgvJournalVoucher[dgvJournalVoucher.Columns["dgvcmbAccountLedger"].Index, dgvJournalVoucher.CurrentRow.Index];
             dgvccAccountLedger.DataSource = ListObj;
             dgvccAccountLedger.ValueMember = "ledgerId";
             dgvccAccountLedger.DisplayMember = "ledgerName";
             dgvJournalVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].Value = decLedgerId;
         }
         dgvJournalVoucher.Focus();
         this.Enabled = true;
         this.BringToFront();
     }
     catch (Exception ex)
     {
         MessageBox.Show("JV30:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        //From AccountLedger form
        /// <summary>
        /// Function to fill Account ledger combobox while return from Account ledger creation when creating new ledger 
        /// </summary>
        /// <param name="decId"></param>
        /// <param name="str"></param>
        public void ReturnFromAccountLedgerForm(decimal decId, string str)
        {
            try
            {
                if (str == "CashOrBank")
                {
                    if (decId != 0)
                    {
                        TransactionsGeneralFillBll Obj = new TransactionsGeneralFillBll();
                        Obj.CashOrBankComboFill(cmbCashOrBank, false);
                        cmbCashOrBank.SelectedValue = decId.ToString();
                    }
                    cmbCashOrBank.Focus();
                }
                else
                {
                    if (decId != 0)
                    {

                        List<DataTable> ListObj = new List<DataTable>();
                        AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
                        ListObj = bllAccountLedger.AccountLedgerViewAll();
                        DataGridViewComboBoxCell dgvccCashOrBank = (DataGridViewComboBoxCell)dgvReceiptVoucher[dgvReceiptVoucher.Columns["dgvcmbAccountLedger"].Index, dgvReceiptVoucher.CurrentRow.Index];
                        dgvccCashOrBank.DataSource = ListObj;
                        dgvccCashOrBank.ValueMember = "ledgerId";
                        dgvccCashOrBank.DisplayMember = "ledgerName";
                        dgvReceiptVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].Value = decId;
                    }
                }
                this.Enabled = true;
                this.BringToFront();
            }
            catch (Exception ex)
            {
                MessageBox.Show("RV29:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }