/// <summary>
        /// Checking VoucherNo existance for save or update and call its curresponding function
        /// </summary>
        public void SaveOrEdit()
        {
            try
            {
                //ContraMasterSP spContraMaster = new ContraMasterSP();
                ContraVoucherDetailsBll bllContraVoucherDetails = new ContraVoucherDetailsBll();
                if (!isEditMode)
                {
                    if (PublicVariables.isMessageAdd)
                    {
                        if (Messages.SaveMessage())
                        {
                            if (!isAutomatic)
                            {
                                if (bllContraVoucherDetails.ContraVoucherCheckExistence(txtVoucherNo.Text.Trim(), DecContraVoucherTypeId, 0) == false)
                                {
                                    SaveFuction();
                                }
                                else
                                {
                                    Messages.InformationMessage("Voucher number already exist");
                                }
                            }
                            else
                            {
                                if (bllContraVoucherDetails.ContraVoucherCheckExistence(txtVoucherNo.Text.Trim(), DecContraVoucherTypeId, 0) == false)
                                {
                                    SaveFuction();
                                }
                                else
                                {
                                    Messages.InformationMessage("Voucher number already exist");
                                }

                            }
                        }
                    }
                    else
                    {
                        if (!isAutomatic)
                        {
                            if (bllContraVoucherDetails.ContraVoucherCheckExistence(txtVoucherNo.Text.Trim(), DecContraVoucherTypeId, 0) == false)
                            {
                                SaveFuction();
                            }
                            else
                            {
                                Messages.InformationMessage("Voucher number already exist");
                            }
                        }
                        else
                        {
                            SaveFuction();

                        }
                    }
                }
                else if (isEditMode)
                {

                    if (PublicVariables.isMessageEdit)
                    {
                        if (Messages.UpdateMessage())
                        {
                            if (!isAutomatic)
                            {
                                if (bllContraVoucherDetails.ContraVoucherCheckExistence(txtVoucherNo.Text.Trim(), DecContraVoucherTypeId, decMasterId) == false)
                                {
                                    EditFunction(decMasterId);
                                }
                                else
                                {
                                    Messages.InformationMessage("Voucher number already exist");
                                }
                            }
                            else
                            {
                                EditFunction(decMasterId);

                            }

                        }
                    }
                    else
                    {
                        if (!isAutomatic)
                        {
                            if (bllContraVoucherDetails.ContraVoucherCheckExistence(txtVoucherNo.Text.Trim(), DecContraVoucherTypeId, decMasterId) == false)
                            {
                                EditFunction(decMasterId);
                            }
                            else
                            {
                                Messages.InformationMessage("Voucher number already exist");
                            }
                        }
                        else
                        {
                            EditFunction(decMasterId);

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