/// <summary>
        /// Cleare function and Generate the voucher no based on settings
        /// </summary>
        public void Clear()
        {
            try
            {
                TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
                //SalesMasterSP spSalesMaster = new SalesMasterSP();
                SalesInvoiceBll BllSalesInvoice = new SalesInvoiceBll();
                if (isAutomatic)
                {
                    if (strVoucherNo == string.Empty)
                    {
                        strVoucherNo = "0";
                    }
                    strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(DecSalesInvoiceVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, "SalesMaster");
                    if (Convert.ToDecimal(strVoucherNo) != (BllSalesInvoice.SalesMasterVoucherMax(DecSalesInvoiceVoucherTypeId)))
                    {
                        strVoucherNo = BllSalesInvoice.SalesMasterVoucherMax(DecSalesInvoiceVoucherTypeId).ToString();
                        strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(DecSalesInvoiceVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, "SalesMaster");
                        if (BllSalesInvoice.SalesMasterVoucherMax(DecSalesInvoiceVoucherTypeId) == 0)
                        {
                            strVoucherNo = "0";
                            strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(DecSalesInvoiceVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, "SalesMaster");
                        }
                    }
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
                   // SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP();
                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(DecSalesInvoiceVoucherTypeId, dtpDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                    txtInvoiceNo.Text = strInvoiceNo;
                    txtInvoiceNo.ReadOnly = true;
                    decSalseInvoiceSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                }
                else
                {
                    txtInvoiceNo.ReadOnly = false;
                    txtInvoiceNo.Text = string.Empty;
                    strVoucherNo = string.Empty;
                    strInvoiceNo = strVoucherNo;
                }
                if (PrintAfetrSave())
                {
                    cbxPrintAfterSave.Checked = true;
                }
                else
                {
                    cbxPrintAfterSave.Checked = false;
                }
                cmbPricingLevel.SelectedIndex = 0;
                cmbSalesAccount.SelectedIndex = 0;
                cmbCashOrParty.SelectedIndex = 0;
                cmbSalesMan.SelectedIndex = 0;
                cmbSalesMode.SelectedIndex = 0;
                cmbDrorCr.SelectedIndex = 0;
                cmbCashOrbank.SelectedIndex = 0;
                cmbCurrency.Enabled = true;
                txtCustomer.Text = cmbCashOrParty.Text;
                txtTransportCompany.Text = string.Empty;
                txtVehicleNo.Text = string.Empty;
                txtNarration.Text = string.Empty;
                txtCreditPeriod.Text = "0";
                txtTotalAmount.Text = "0.00";
                txtBillDiscount.Text = "0";
                txtGrandTotal.Text = "0.00";
                lblTaxTotalAmount.Text = "0.00";
                lblLedgerTotalAmount.Text = "0.00";
                btnSave.Text = "Save";
                btnDelete.Enabled = false;
                dtpDate.MinDate = PublicVariables._dtFromDate;
                dtpDate.MaxDate = PublicVariables._dtToDate;
                dtpDate.Value = PublicVariables._dtCurrentDate;
                txtDate.Text = dtpDate.Value.ToString("dd-MMM-yyyy");
                dgvSalesInvoiceLedger.Rows.Clear();
                isFromEditMode = false;
                if (dgvSalesInvoice.DataSource != null)
                {
                    ((DataTable)dgvSalesInvoice.DataSource).Rows.Clear();
                }
                else
                {
                    dgvSalesInvoice.Rows.Clear();
                }
                gridCombofill();
                if (dgvSalesInvoiceTax.DataSource != null)
                {
                    ((DataTable)dgvSalesInvoiceTax.DataSource).Rows.Clear();
                }
                else
                {
                    dgvSalesInvoiceTax.Rows.Clear();
                }
                taxGridFill();
                if (!txtInvoiceNo.ReadOnly)
                {
                    txtInvoiceNo.Focus();
                }
                else
                {
                    txtDate.Select();
                }

                txtTotalAmount.Text = "0.00";
                txtGrandTotal.Text = "0.00";
                lblTotalQuantitydisplay.Text = "0";
            }
            catch (Exception ex)
            {
                MessageBox.Show("SI : 01" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }