/// <summary>
 /// Edit function
 /// </summary>
 public void EditFunction()
 {
     try
     {
         PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo();
         PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll();
         SettingsBll BllSettings = new SettingsBll();
         infoPurchaseOrderMaster.PurchaseOrderMasterId = decPurchaseOrderMasterId;
         if (CheckCancelStatus(decPurchaseOrderMasterId))
         {
             infoPurchaseOrderMaster.Cancelled = true;
         }
         else
         {
             infoPurchaseOrderMaster.Cancelled = false;
         }
         infoPurchaseOrderMaster.Date = Convert.ToDateTime(txtDate.Text);
         infoPurchaseOrderMaster.DueDate = Convert.ToDateTime(txtDueDate.Text);
         infoPurchaseOrderMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
         infoPurchaseOrderMaster.SuffixPrefixId = Convert.ToDecimal(decPurchaseSuffixPrefixId);
         infoPurchaseOrderMaster.VoucherNo = strVoucherNo;
         infoPurchaseOrderMaster.VoucherTypeId = decPurchaseVoucherId;
         infoPurchaseOrderMaster.InvoiceNo = txtOrderNo.Text;
         infoPurchaseOrderMaster.UserId = PublicVariables._decCurrentUserId;
         infoPurchaseOrderMaster.EmployeeId = PublicVariables._decCurrentUserId;//by default current userid used as current employeeid
         infoPurchaseOrderMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
         infoPurchaseOrderMaster.Narration = txtNarration.Text.Trim();
         infoPurchaseOrderMaster.exchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
         infoPurchaseOrderMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text);
         infoPurchaseOrderMaster.Extra1 = string.Empty;
         infoPurchaseOrderMaster.Extra2 = string.Empty;
         BllPurchaseOrder.PurchaseOrderMasterEdit(infoPurchaseOrderMaster);
         RemovePurchaseOrderDetails();
         EditPurchaseOrderDetails();
         Messages.UpdatedMessage();
         if (frmPurchaseOrderRegisterObj != null)
         {
             if (cbxPrintAfterSave.Checked)
             {
                 if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decPurchaseOrderMasterId);
                 }
                 else
                 {
                     Print(decPurchaseOrderMasterId);
                 }
             }
             this.Close();
             frmPurchaseOrderRegisterObj.GridFill();
         }
         if (frmPurchaseOrderReportObj != null)
         {
             if (cbxPrintAfterSave.Checked)
             {
                 if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decPurchaseOrderMasterId);
                 }
                 else
                 {
                     Print(decPurchaseOrderMasterId);
                 }
             }
             this.Close();
             frmPurchaseOrderReportObj.GridFill();
         }
         if (frmDayBookObj != null)
         {
             if (cbxPrintAfterSave.Checked)
             {
                 if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decPurchaseOrderMasterId);
                 }
                 else
                 {
                     Print(decPurchaseOrderMasterId);
                 }
             }
             this.Close();
         }
         if (objVoucherSearch != null)
         {
             if (cbxPrintAfterSave.Checked)
             {
                 if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decPurchaseOrderMasterId);
                 }
                 else
                 {
                     Print(decPurchaseOrderMasterId);
                 }
             }
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PO34:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }