/// <summary>
 /// datagridview cell leave event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvPartyBalance_CellLeave(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (!IsSaveOrEsc)
         {
             PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
             if (dgvPartyBalance.CurrentCell.ColumnIndex == dgvPartyBalance.CurrentRow.Cells["dgvtxtAmount"].ColumnIndex)
             {
                 if (dgvPartyBalance.CurrentRow.Cells["dgvtxtAmount"].Value != null && dgvPartyBalance.CurrentRow.Cells["dgvtxtAmount"].Value.ToString() != string.Empty)
                 {
                     if (dgvPartyBalance.CurrentRow.Cells["dgvcmbReference"].Value != null && dgvPartyBalance.CurrentRow.Cells["dgvcmbReference"].Value.ToString() != string.Empty)
                     {
                         if (dgvPartyBalance.CurrentRow.Cells["dgvcmbReference"].Value.ToString() == "Against")
                         {
                             if (dgvPartyBalance.CurrentRow.Cells["dgvtxtPending"].Value != null && dgvPartyBalance.CurrentRow.Cells["dgvtxtPending"].Value.ToString() != string.Empty)
                             {
                                 if (dgvPartyBalance.CurrentRow.Cells["dgvtxtPending"].Value != null && dgvPartyBalance.CurrentRow.Cells["dgvtxtPending"].Value.ToString() != string.Empty)
                                 {
                                     if (Convert.ToDecimal(dgvPartyBalance.CurrentRow.Cells["dgvtxtPending"].Value.ToString()) < Convert.ToDecimal(dgvPartyBalance.CurrentRow.Cells["dgvtxtAmount"].Value.ToString()))
                                     {
                                         Messages.InformationMessage("Amount should be less than pending amount");
                                         dgvPartyBalance.CurrentRow.Cells["dgvtxtAmount"].Value = null;
                                     }
                                 }
                             }
                         }
                         else
                         {
                             decimal decAmountToCheck = Math.Round(BllPartyBalance.PartyBalanceAmountCheckForEdit(decLedgerId, decVoucherTypeId, strVoucherNo, strDebitOrCredit), PublicVariables._inNoOfDecimalPlaces);
                             if (decAmountToCheck > Convert.ToDecimal(dgvPartyBalance.CurrentRow.Cells["dgvtxtAmount"].Value.ToString()))
                             {
                                 Messages.InformationMessage("Reference Exist. You cannot enter less than " + decAmountToCheck.ToString());
                                 dgvPartyBalance.CurrentRow.Cells["dgvtxtAmount"].Value = null;
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PB:26" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }