/// <summary>
        /// Function to fill Datagridview
        /// </summary>
        public void GridFill()
        {
            try
            {
                List<DataTable> listDailySalaryRegister = new List<DataTable>();
                DailySalaryVoucherBll BllDailySalaryVoucherMaster = new DailySalaryVoucherBll();
                listDailySalaryRegister = BllDailySalaryVoucherMaster.DailySalaryRegisterSearch(Convert.ToDateTime(txtVoucherDateFrom.Text.ToString()), Convert.ToDateTime(txtVoucherDateTo.Text.ToString()), Convert.ToDateTime(txtSalaryDateFrom.Text.ToString()), Convert.ToDateTime(txtSalaryDateTo.Text.ToString()), txtVoucherNo.Text);
                dgvDailySalaryRegister.DataSource = listDailySalaryRegister[0];

            }
            catch (Exception ex)
            {
                MessageBox.Show("DSR2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to Save
        /// </summary>
        public void SaveFunction()
        {
            try
            {

                DailySalaryVoucherMasterInfo infoMaster = new DailySalaryVoucherMasterInfo();
                DailySalaryVoucherBll BllDailySalaryVoucherMaster = new DailySalaryVoucherBll();
                DailySalaryVoucherDetailsInfo infoDetails = new DailySalaryVoucherDetailsInfo();
                DailySalaryVoucherBll BllDailySalaryVoucher = new DailySalaryVoucherBll();

                //-------------In multi user case check whether salary is paying for the same persone--------------//
                int inCounts = dgvDailySalaryVoucher.RowCount;
                int incont = 0;
                decimal decVal = 0;
                for (int i = 0; i < inCounts; i++)
                {
                    decVal = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString());
                    if (BllDailySalaryVoucher.CheckWhetherDailySalaryAlreadyPaid(decVal, dtpSalaryDate.Value) != "0")
                    {
                        strEployeeNames = strEployeeNames + BllDailySalaryVoucher.CheckWhetherDailySalaryAlreadyPaid(decVal, dtpSalaryDate.Value) + ",";
                        foreach (char ch in strEployeeNames)
                        {
                            if (ch == ',')
                            {
                                incont++;
                            }
                        }
                        if (incont == 15)
                        {
                            incont = 0;
                            strEployeeNames = strEployeeNames + Environment.NewLine;
                        }

                    }
                }
                if (BllDailySalaryVoucher.CheckWhetherDailySalaryAlreadyPaid(decVal, dtpSalaryDate.Value) != "0")
                {

                    Messages.InformationMessage("Salary already paid for - " + " " + strEployeeNames);
                    DailySalaryVoucherDetailsGridfill(isEditmode);
                }
                else
                {
                    if (isAutomatic)
                    {
                        infoMaster.VoucherNo = strVoucherNo;
                    }
                    else
                    {
                        infoMaster.VoucherNo = txtVoucherNo.Text.Trim();
                    }
                    infoMaster.Date = DateTime.Parse(dtpDate.Text.ToString());
                    infoMaster.SalaryDate = DateTime.Parse(dtpSalaryDate.Text.ToString());
                    infoMaster.LedgerId = Convert.ToDecimal(cmbCashorBankAccount.SelectedValue.ToString());
                    infoMaster.Narration = txtNarration.Text.Trim();
                    infoMaster.TotalAmount = Convert.ToDecimal(lblShowTotelamount.Text.ToString());
                    infoMaster.Extra1 = string.Empty; // Fields not in design//
                    infoMaster.Extra2 = string.Empty; // Fields not in design//
                    if (isAutomatic)
                    {
                        infoMaster.InvoiceNo = strInvoiceNo;
                    }
                    else
                    {
                        infoMaster.InvoiceNo = txtVoucherNo.Text.Trim();
                    }
                    infoMaster.SuffixPrefixId = decDailySuffixPrefixId;
                    infoMaster.VoucherTypeId = decDailyVoucherTypeId;
                    infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;

                    int inval = 0;
                    int inCount = dgvDailySalaryVoucher.RowCount;
                    for (int i = 0; i < inCount; i++)
                    {
                        if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == "paid")
                        {
                            inval++;
                        }

                    }
                    if (inval >= 0)
                    {
                        //-------------checks Voucher No. repeating in Multi user case----------//
                        List<DataTable> listObj = new List<DataTable>();
                        listObj = BllDailySalaryVoucherMaster.DailySalaryVoucherMasterAddWithIdentity(infoMaster, isAutomatic);
                        foreach (DataRow dr in listObj[0].Rows)
                        {
                            decMasterId = Convert.ToDecimal(dr.ItemArray[0].ToString());
                            strUpdatedVoucherNo = dr.ItemArray[1].ToString();
                            strUpdatedInvoiceNo = dr.ItemArray[2].ToString();
                        }
                        if (!isAutomatic)
                        {
                            strVoucherNo = txtVoucherNo.Text;
                        }
                        if (isAutomatic)
                        {
                            if (Convert.ToDecimal(strUpdatedVoucherNo) != Convert.ToDecimal(strVoucherNo))
                            {
                                Messages.InformationMessage("Voucher number changed from  " + strInvoiceNo + "  to  " + strUpdatedInvoiceNo);
                                strVoucherNo = strUpdatedVoucherNo.ToString();
                                strInvoiceNo = strUpdatedInvoiceNo;
                            }
                        }
                        //-------------------------------------//
                        LedgerPosting(Convert.ToDecimal(cmbCashorBankAccount.SelectedValue.ToString()));

                        infoDetails.DailySalaryVocherMasterId = decMasterId;
                        infoDetails.Extra1 = string.Empty;// Fields not in design//
                        infoDetails.Extra2 = string.Empty;// Fields not in design//
                        int inRowCount = dgvDailySalaryVoucher.RowCount;
                        for (int i = 0; i < inRowCount; i++)
                        {

                            if (dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString() != string.Empty)
                            {
                                infoDetails.EmployeeId = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString());
                            }
                            if (dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString() != string.Empty)
                            {
                                infoDetails.Wage = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString());

                            }
                            if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() != string.Empty)
                            {
                                infoDetails.Status = dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString();

                            }

                            if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == "paid" && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() == string.Empty)
                            {
                                infoDetails.DailySalaryVocherMasterId = decMasterId;
                                BllDailySalaryVoucher.DailySalaryVoucherDetailsAdd(infoDetails);
                            }
                        }
                        Messages.SavedMessage();
                        DailySalaryVoucherDetailsGridfill(isEditmode);
                        Clear();

                    }
                    else
                    {
                        strVoucherNo = BllDailySalaryVoucherMaster.DailySalaryVoucherMasterGetMax(decDailyVoucherTypeId);
                        Messages.InformationMessage("Can't save without atleast one employee");
                        Clear();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to call Save Or Edit
        /// </summary>
        public void SaveorEdit()
        {
            try
            {
                DailySalaryVoucherBll BllDailySalaryVoucherMaster = new DailySalaryVoucherBll();
                if (txtVoucherNo.Text == string.Empty)
                {
                    Messages.InformationMessage("Enter voucher number");
                    txtVoucherNo.Focus();

                }
                else if (dtpDate.Value.ToString() == string.Empty)
                {
                    Messages.InformationMessage("Select voucher date");
                    dtpDate.Focus();
                }

                else if (dtpSalaryDate.Value.ToString() == string.Empty)
                {
                    Messages.InformationMessage("Select salary date");
                    txtSalaryDate.Focus();

                }
                else if (cmbCashorBankAccount.Text == string.Empty)
                {
                    Messages.InformationMessage("Select cash or bank account");
                    cmbCashorBankAccount.Focus();
                }
                else if (dgvDailySalaryVoucher.Rows.Count == 0)
                {
                    Messages.InformationMessage("Cant Save without atleast one employee");
                }
                else
                {

                    if (isEditmode == false)
                    {
                        if (PublicVariables.isMessageAdd)
                        {
                            if (Messages.SaveMessage())
                            {
                                if (!isAutomatic)
                                {
                                    if (BllDailySalaryVoucherMaster.DailySalaryVoucherCheckExistence(txtVoucherNo.Text.Trim(), decDailyVoucherTypeId, 0) == false)
                                    {
                                        SaveFunction();
                                    }
                                    else
                                    {
                                        Messages.InformationMessage("Voucher number already exist");
                                        txtVoucherNo.Focus();
                                    }
                                }
                                else
                                {
                                    SaveFunction();
                                }
                            }

                            //else
                            //{
                            //    if (!isAutomatic)
                            //    {
                            //        if (spMaster.DailySalaryVoucherCheckExistence(txtVoucherNo.Text.Trim(), decDailyVoucherTypeId, 0) == false)
                            //        {
                            //            SaveFunction();
                            //        }
                            //        else
                            //        {
                            //            Messages.InformationMessage("Voucher number already exist");
                            //            txtVoucherNo.Focus();
                            //        }
                            //    }
                            //    else
                            //    {
                            //        SaveFunction();
                            //    }
                            //}

                        }
                        else
                        {
                            if (!isAutomatic)
                            {
                                if (BllDailySalaryVoucherMaster.DailySalaryVoucherCheckExistence(txtVoucherNo.Text.Trim(), decDailyVoucherTypeId, 0) == false)
                                {
                                    SaveFunction();
                                }
                                else
                                {
                                    Messages.InformationMessage("Voucher number already exist");
                                    txtVoucherNo.Focus();
                                }
                            }
                            else
                            {
                                SaveFunction();
                            }
                        }

                    }
                    else
                    {

                        if (isEditmode)
                        {
                            if (PublicVariables.isMessageEdit)
                            {
                                if (Messages.UpdateMessage())
                                {
                                    if (!isAutomatic)
                                    {
                                        if (BllDailySalaryVoucherMaster.DailySalaryVoucherCheckExistence(txtVoucherNo.Text.Trim(), decDailyVoucherTypeId, 0) == false)
                                        {
                                            EditFunction();
                                        }
                                        else
                                        {
                                            Messages.InformationMessage("Voucher number already exist");
                                            txtVoucherNo.Focus();
                                        }
                                    }
                                    else
                                    {
                                        EditFunction();
                                    }
                                }
                            }
                            else
                            {
                                if (!isAutomatic)
                                {
                                    if (BllDailySalaryVoucherMaster.DailySalaryVoucherCheckExistence(txtVoucherNo.Text.Trim(), decDailyVoucherTypeId, 0) == false)
                                    {
                                        EditFunction();
                                    }
                                    else
                                    {
                                        Messages.InformationMessage("Voucher number already exist");
                                        txtVoucherNo.Focus();
                                    }
                                }
                                else
                                {
                                    EditFunction();
                                }
                            }
                        }

                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function for Edit
        /// </summary>
        public void EditFunction()
        {
            try
            {
                DailySalaryVoucherMasterInfo infoMaster = new DailySalaryVoucherMasterInfo();
                DailySalaryVoucherBll BllDailySalaryVoucherMaster = new DailySalaryVoucherBll();
                DailySalaryVoucherDetailsInfo infoDetails = new DailySalaryVoucherDetailsInfo();
                DailySalaryVoucherBll BllDailySalaryVoucher = new DailySalaryVoucherBll();

                LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();

                infoMaster.DailySalaryVoucehrMasterId = decMasterIdforEdit;
                infoMaster.Date = Convert.ToDateTime(dtpDate.Value.ToString());
                infoMaster.LedgerId = Convert.ToDecimal(cmbCashorBankAccount.SelectedValue.ToString());
                infoMaster.Narration = txtNarration.Text;
                infoMaster.TotalAmount = Convert.ToDecimal(lblShowTotelamount.Text.ToString());
                if (isAutomatic)
                {
                    infoMaster.VoucherNo = strVoucherNo;
                }
                else
                {
                    infoMaster.VoucherNo = txtVoucherNo.Text.Trim();
                }

                if (isAutomatic)
                {
                    infoMaster.InvoiceNo = strInvoiceNo;
                }
                else
                {
                    infoMaster.InvoiceNo = txtVoucherNo.Text.Trim();
                }
                infoMaster.Extra1 = string.Empty;
                infoMaster.Extra2 = string.Empty;
                infoMaster.SuffixPrefixId = decDailySuffixPrefixId;
                infoMaster.VoucherTypeId = decDailyVoucherTypeId;
                infoMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                infoMaster.SalaryDate = Convert.ToDateTime(dtpSalaryDate.Text.ToString());
                infoDetails.Extra1 = string.Empty;// Fields not in design//
                infoDetails.Extra2 = string.Empty;// Fields not in design//
                BllDailySalaryVoucherMaster.DailySalaryVoucherMasterEdit(infoMaster);
                int inRowCount = dgvDailySalaryVoucher.RowCount;
                for (int i = 0; i < inRowCount; i++)
                {
                    if (dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString() != string.Empty)
                    {
                        infoDetails.EmployeeId = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtEmployeeId"].Value.ToString());
                    }
                    if (dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString() != string.Empty)
                    {
                        infoDetails.Wage = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["txtWage"].Value.ToString());
                    }
                    if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value != null && dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() != string.Empty)
                    {
                        infoDetails.Status = dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString();
                    }

                    if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == string.Empty && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() != string.Empty)
                    {
                        decimal DailySalaryVoucherDetailsId = Convert.ToDecimal(dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtdailySalaryVoucherDetailsId"].Value.ToString());
                        BllDailySalaryVoucher.DailySalaryVoucherDetailsDelete(DailySalaryVoucherDetailsId);

                        LedgerUpdate();

                    }
                    if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == "paid" && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() == string.Empty)
                    {
                        infoDetails.DailySalaryVocherMasterId = decMasterIdforEdit;
                        BllDailySalaryVoucher.DailySalaryVoucherDetailsAdd(infoDetails);
                        //spMaster.DailySalaryVoucherMasterEdit(infoMaster);
                        LedgerUpdate();

                    }
                    if (dgvDailySalaryVoucher.Rows[i].Cells["cmbStatus"].Value.ToString() == string.Empty && dgvDailySalaryVoucher.Rows[i].Cells["dgvtxtDailySalaryVocherMasterId"].Value.ToString() == string.Empty)
                    {
                        BllDailySalaryVoucherMaster.DailySalaryVoucherMasterEdit(infoMaster);
                        LedgerUpdate();

                    }
                }
                if (BllDailySalaryVoucher.DailySalaryVoucherDetailsCount(decMasterIdforEdit) == 0)
                {
                    BllDailySalaryVoucherMaster.DailySalaryVoucherMasterDelete(decMasterIdforEdit);
                }
                Messages.UpdatedMessage();
                Clear();
                if (frmDailySalaryRegisterobj != null)
                {

                    this.Close();
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to fill controls for updation
        /// </summary>
        public void fillFunction()
        {
            try
            {
                DailySalaryVoucherBll BllDailySalaryVoucherMaster = new DailySalaryVoucherBll();
                DailySalaryVoucherMasterInfo InfoMaster = new DailySalaryVoucherMasterInfo();
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                InfoMaster = BllDailySalaryVoucherMaster.DailySalaryVoucherViewFromRegister(decMasterIdforEdit);

                strVoucherNoforEdit = InfoMaster.VoucherNo;
                strVoucherNo = InfoMaster.VoucherNo;
                txtVoucherNo.Text = InfoMaster.InvoiceNo;
                strInvoiceNo = InfoMaster.InvoiceNo;
                dtpDate.Text = InfoMaster.Date.ToString();
                dtpSalaryDate.Text = InfoMaster.SalaryDate.ToString();
                lblShowTotelamount.Text = Math.Round(Convert.ToDecimal(InfoMaster.TotalAmount.ToString("0.00000")), PublicVariables._inNoOfDecimalPlaces).ToString();
                txtNarration.Text = InfoMaster.Narration;
                decDailySuffixPrefixId = InfoMaster.SuffixPrefixId;
                decDailyVoucherTypeId = InfoMaster.VoucherTypeId;
                cmbCashorBankAccount.SelectedValue = InfoMaster.LedgerId.ToString();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decDailyVoucherTypeId);
                if (isAutomatic)
                {
                    txtVoucherNo.Enabled = false;
                }
                else
                {
                    txtVoucherNo.Enabled = true;
                }

                dtpSalaryDate.Enabled = false;
                txtSalaryDate.Enabled = false;
                DailySalaryVoucherDetailsGridfill(isEditmode);
            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function for Delete
        /// </summary>
        public void DeleteFunction()
        {
            try
            {
                DailySalaryVoucherBll BllDailySalaryVoucherMaster = new DailySalaryVoucherBll();
                DailySalaryVoucherBll BllDailySalaryVoucher = new DailySalaryVoucherBll();

                LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();

                if (PublicVariables.isMessageDelete)
                {
                    if (Messages.DeleteMessage())
                    {
                        BllDailySalaryVoucherMaster.DailySalaryVoucherMasterDelete(decMasterIdforEdit);
                        BllDailySalaryVoucher.DailySalaryVoucherDetailsDeleteUsingMasterId(decMasterIdforEdit);
                        BllLedgerPosting.LedgerPostDelete(txtVoucherNo.Text, decDailyVoucherTypeId);
                        Messages.DeletedMessage();
                        Clear();
                        DailySalaryVoucherDetailsGridfill(isEditmode);
                    }
                }
                else
                {
                    BllDailySalaryVoucherMaster.DailySalaryVoucherMasterDelete(decMasterIdforEdit);
                    BllDailySalaryVoucher.DailySalaryVoucherDetailsDeleteUsingMasterId(decMasterIdforEdit);
                    BllLedgerPosting.LedgerPostDelete(txtVoucherNo.Text, decDailyVoucherTypeId);
                    Messages.DeletedMessage();
                    Clear();
                    DailySalaryVoucherDetailsGridfill(isEditmode);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV13:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 /// <param name="isEditmode"></param>
 public void DailySalaryVoucherDetailsGridfill(bool @isEditmode)
 {
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         DailySalaryVoucherBll BllDailySalaryVoucherDetails = new DailySalaryVoucherBll();
         listObj = BllDailySalaryVoucherDetails.DailySalaryVoucherDetailsGridViewAll(dtpSalaryDate.Value.ToString(), isEditmode, strVoucherNoforEdit);
         dgvDailySalaryVoucher.DataSource = listObj[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show("DSV2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to Fill Cash Or Bank Combobox
 /// </summary>
 public void DailySalaryVoucherCashorBankComboFill()
 {
     try
     {
         DailySalaryVoucherBll BllDailySalaryVoucherMaster = new DailySalaryVoucherBll();
         List<DataTable> listDailySalaryVoucherMaster = new List<DataTable>();
         listDailySalaryVoucherMaster = BllDailySalaryVoucherMaster.DailySalaryVoucherCashOrBankLedgersComboFill();
         cmbCashorBankAccount.DataSource = listDailySalaryVoucherMaster[0];
         cmbCashorBankAccount.ValueMember = "ledgerId";
         cmbCashorBankAccount.DisplayMember = "ledgerName";
         cmbCashorBankAccount.SelectedIndex = -1;
     }
     catch (Exception ex)
     {
         MessageBox.Show("DSV1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Date vakidation and fills Datagridview
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtSalaryDate_Leave(object sender, EventArgs e)
        {
            DailySalaryVoucherBll BllDailySalaryVoucher = new DailySalaryVoucherBll();
            try
            {
                DateValidation obj = new DateValidation();
                obj.DateValidationFunction(txtSalaryDate);
                if (txtSalaryDate.Text == string.Empty)
                {
                    txtSalaryDate.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
                }
                //---for change date in Date time picker----//
                string strdate = txtSalaryDate.Text;
                dtpSalaryDate.Value = Convert.ToDateTime(strdate.ToString());

                List<DataTable> listObj = new List<DataTable>();

                listObj = BllDailySalaryVoucher.DailySalaryVoucherDetailsGridViewAll(txtSalaryDate.Text.ToString(), isEditmode, strVoucherNoforEdit);
                dgvDailySalaryVoucher.DataSource = listObj[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV30:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to generate Voucher number as per settings
        /// </summary>
        public void VoucherNumberGeneration()
        {
            try
            {
                TransactionsGeneralFillBll TransactionsGeneralFillobj = new TransactionsGeneralFillBll();
                DailySalaryVoucherBll BllDailySalaryVoucherMaster = new DailySalaryVoucherBll();
                //--------------------------Automatic Generation------------------------//
                if (strVoucherNo == string.Empty)
                {

                    strVoucherNo = "0";
                }
                strVoucherNo = TransactionsGeneralFillobj.VoucherNumberAutomaicGeneration(decDailyVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName);
                if (Convert.ToDecimal(strVoucherNo) != BllDailySalaryVoucherMaster.SalaryVoucherMasterGetMaxPlusOne(decDailyVoucherTypeId))
                {
                    strVoucherNo = BllDailySalaryVoucherMaster.SalaryVoucherMasterGetMaxPlusOne(decDailyVoucherTypeId).ToString();
                    strVoucherNo = TransactionsGeneralFillobj.VoucherNumberAutomaicGeneration(decDailyVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName);
                    if (BllDailySalaryVoucherMaster.DailySalaryVoucherMasterGetMax(decDailyVoucherTypeId) == "0")
                    {
                        strVoucherNo = "0";
                        strVoucherNo = TransactionsGeneralFillobj.VoucherNumberAutomaicGeneration(decDailyVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName);
                    }
                }
                //---------------------------------------------------------------------------------//
                if (isAutomatic)
                {
                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decDailyVoucherTypeId, dtpDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                    txtVoucherNo.Text = strInvoiceNo;
                    txtVoucherNo.ReadOnly = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }