/// <summary>
        /// Function to determine whether to call SaveFunction or EditFunction function 
        /// </summary>
        public void SaveOrEditFunction()
        {
            try
            {
                //DebitNoteMasterSP spDebitNoteMaster = new DebitNoteMasterSP();
                DebitNoteBll bllDebitNote = new DebitNoteBll();
                    if (!isEditMode)
                    {
                        if (txtVoucherNo.Text.Trim() != string.Empty)
                        {

                            if (!isAutomatic)
                            {
                                strInvoiceNo = txtVoucherNo.Text.Trim();
                                if (!bllDebitNote.DebitNoteVoucherCheckExistance(strInvoiceNo, decDebitNoteVoucherTypeId, 0))
                                {
                                    SaveFunction();
                                }
                                else
                                {
                                    Messages.InformationMessage("Voucher number already exist");
                                }
                            }
                            else
                            {
                                SaveFunction();
                            }
                        }
                        else
                        {
                            Messages.InformationMessage("Enter voucherNo");
                            txtVoucherNo.Focus();
                        }
                    }
                    else
                    {
                        if (txtVoucherNo.Text.Trim() != string.Empty)
                        {
                            if (!isAutomatic)
                            {
                                strInvoiceNo = txtVoucherNo.Text.Trim();
                                if (!bllDebitNote.DebitNoteVoucherCheckExistance(strInvoiceNo, decDebitNoteVoucherTypeId, decDebitNoteMasterIdForEdit))
                                {
                                    EditFunction(decDebitNoteMasterIdForEdit);
                                }
                                else
                                {
                                    Messages.InformationMessage("Voucher number already exist");
                                }
                            }
                            else
                            {
                                EditFunction(decDebitNoteMasterIdForEdit);
                            }
                        }
                        else
                        {
                            Messages.InformationMessage("Enter voucherNo");
                        }
                    }

            }
            catch (Exception ex)
            {
                MessageBox.Show("DRNT21:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }