/// <summary>
 /// Function to Edit
 /// </summary>
 public void EditFunction()
 {
     try
     {
         AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo();
         AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
         infoAccountLedger.LedgerName = txtCustomerName.Text.Trim();
         infoAccountLedger.MailingName = txtMailingName.Text.Trim();
         if (txtOpeningBalance.Text.Trim() != string.Empty)
         {
             infoAccountLedger.OpeningBalance = Convert.ToDecimal(txtOpeningBalance.Text.Trim());
         }
         else
         {
             infoAccountLedger.OpeningBalance = 0;
         }
         infoAccountLedger.CrOrDr = cmbDrorCr.Text.ToString();
         infoAccountLedger.BankAccountNumber = txtAccountNo.Text.Trim();
         infoAccountLedger.BranchName = txtBranchName.Text.Trim();
         infoAccountLedger.BranchCode = txtBranchCode.Text.Trim();
         infoAccountLedger.Mobile = txtMobile.Text.Trim();
         infoAccountLedger.Address = txtAddress.Text.Trim();
         if (cmbBillbyBill.Text == "Yes")
         {
             infoAccountLedger.BillByBill = true;
         }
         else
         {
             infoAccountLedger.BillByBill = false;
         }
         if (txtCreditLimit.Text.Trim() != string.Empty)
         {
             infoAccountLedger.CreditLimit = Convert.ToDecimal(txtCreditLimit.Text.Trim());
         }
         else
         {
             infoAccountLedger.CreditLimit = 0;
         }
         if (txtCreditPeriod.Text.Trim() != string.Empty)
         {
             infoAccountLedger.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.Trim());
         }
         else
         {
             infoAccountLedger.CreditPeriod = 0;
         }
         infoAccountLedger.Cst = txtCST.Text.Trim();
         if (cmbArea.SelectedValue != null)
         {
             infoAccountLedger.AreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString());
         }
         else
         {
             infoAccountLedger.AreaId = 1m;
         }
         if(cmbRoute.SelectedValue != null)
         {
             infoAccountLedger.RouteId = Convert.ToDecimal(cmbRoute.SelectedValue.ToString());
         }
         else
         {
             infoAccountLedger.RouteId = 1m;
         }
         infoAccountLedger.MailingName = txtMailingName.Text.Trim();
         infoAccountLedger.Phone = txtphone.Text.Trim();
         infoAccountLedger.Email = txtEmail.Text.Trim();
         if (cmbPricingLevel.SelectedValue != null)
         {
             infoAccountLedger.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString());
         }
         else
         {
             infoAccountLedger.PricinglevelId = 0;
         }
         infoAccountLedger.Tin = txtTin.Text.Trim();
         infoAccountLedger.Pan = txtPan.Text.Trim();
         infoAccountLedger.Narration = txtNarration.Text.Trim();
         infoAccountLedger.LedgerId = decLedgerIdForEdit;
         infoAccountLedger.ExtraDate = PublicVariables._dtCurrentDate;
         decOpeningBlnc = infoAccountLedger.OpeningBalance;
         if (bllAccountLedger.AccountLedgerCheckExistenceForCustomer(txtCustomerName.Text.Trim(), decLedger) == false)
         {
             bllAccountLedger.AccountLedgerEditForCustomer(infoAccountLedger);
             ledgerUpdate();
             if (cmbBillbyBill.Text == "Yes")
             {
                 partyBalanceUpdate();
             }
             else
             {
                 bllAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(decLedgerIdForEdit.ToString(), 1);
             }
             Messages.UpdatedMessage();
             Clear();
         }
         else
         {
             Messages.InformationMessage("Customer name already exist");
             txtCustomerName.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Cus7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }