/// <summary>
        /// Function to generate Voucher number as per settings
        /// </summary>
        public void VoucherNumberGeneration()
        {
            try
            {
                TransactionsGeneralFill TransactionsGeneralFillobj = new TransactionsGeneralFill();
                DailySalaryVoucherMasterSP spmaster = new DailySalaryVoucherMasterSP();
                //--------------------------Automatic Generation------------------------//
                if (strVoucherNo == string.Empty)
                {


                    strVoucherNo = "0";
                }
                strVoucherNo = TransactionsGeneralFillobj.VoucherNumberAutomaicGeneration(decDailyVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName);
                if (Convert.ToDecimal(strVoucherNo) != spmaster.SalaryVoucherMasterGetMaxPlusOne(decDailyVoucherTypeId))
                {
                    strVoucherNo = spmaster.SalaryVoucherMasterGetMaxPlusOne(decDailyVoucherTypeId).ToString();
                    strVoucherNo = TransactionsGeneralFillobj.VoucherNumberAutomaicGeneration(decDailyVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName);
                    if (spmaster.DailySalaryVoucherMasterGetMax(decDailyVoucherTypeId) == "0")
                    {
                        strVoucherNo = "0";
                        strVoucherNo = TransactionsGeneralFillobj.VoucherNumberAutomaicGeneration(decDailyVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName);
                    }
                }
                //---------------------------------------------------------------------------------//
                if (isAutomatic)
                {
                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP();
                    infoSuffixPrefix = spSuffisprefix.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);
            }
        }
        /// <summary>
        /// Function to Save
        /// </summary>
        public void SaveFunction()
        {
            try
            {

                DailySalaryVoucherMasterInfo infoMaster = new DailySalaryVoucherMasterInfo();
                DailySalaryVoucherMasterSP spMaster = new DailySalaryVoucherMasterSP();
                DailySalaryVoucherDetailsInfo infoDetails = new DailySalaryVoucherDetailsInfo();
                DailySalaryVoucherDetailsSP spDetails = new DailySalaryVoucherDetailsSP();

                //-------------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 (spDetails.CheckWhetherDailySalaryAlreadyPaid(decVal, dtpSalaryDate.Value) != "0")
                    {
                        strEployeeNames = strEployeeNames + spDetails.CheckWhetherDailySalaryAlreadyPaid(decVal, dtpSalaryDate.Value) + ",";
                        foreach (char ch in strEployeeNames)
                        {
                            if (ch == ',')
                            {
                                incont++;
                            }
                        }
                        if (incont == 15)
                        {
                            incont = 0;
                            strEployeeNames = strEployeeNames + Environment.NewLine;
                        }

                    }
                }
                if (spDetails.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----------//
                        DataTable dtbl = new DataTable();
                        dtbl = spMaster.DailySalaryVoucherMasterAddWithIdentity(infoMaster, isAutomatic);
                        foreach (DataRow dr in dtbl.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;
                                spDetails.DailySalaryVoucherDetailsAdd(infoDetails);
                            }
                        }
                        Messages.SavedMessage();
                        DailySalaryVoucherDetailsGridfill(isEditmode);
                        Clear();

                    }
                    else
                    {
                        strVoucherNo = spMaster.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);
            }
        }