/// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         AdvancePaymentBll bllAdvancePayment = new AdvancePaymentBll();
         List<DataTable> ListObj = bllAdvancePayment.AdvancePaymentViewAllForAdvancePaymentReport(dtpFrmDate.Value, dtpToDate.Value, cmbEmployeeCode.Text, dtpSalaryMonth.Value);
         dgvAdvancePayment.DataSource = ListObj[0];
         TotalAmount();
     }
     catch (Exception ex)
     {
         MessageBox.Show("APR:1 " + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// On 'Print' button click to take print
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         if (dgvAdvancePayment.Rows.Count > 0)
         {
             DataSet ds = new DataSet();
             //CompanySP spCompany = new CompanySP();
             CompanyCreationBll bllCompanyCreation = new CompanyCreationBll();
             List<DataTable> listObjCompany = bllCompanyCreation.CompanyViewDataTable(1);
             ds.Tables.Add(listObjCompany[0]);
             AdvancePaymentBll bllAdvancePayment = new AdvancePaymentBll();
             List<DataTable> listObj = new List<DataTable>();
             listObj = bllAdvancePayment.AdvancePaymentViewAllForAdvancePaymentReport(dtpFrmDate.Value, dtpToDate.Value, cmbEmployeeCode.Text, DateTime.Parse(dtpSalaryMonth.Text.ToString()));
             ds.Tables.Add(listObj[0]);
             frmReport frmReportObj = new frmReport();
             frmReportObj.MdiParent = formMDI.MDIObj;
             frmReportObj.AdvancePaymentReportPrinting(ds);
         }
         else
         {
             Messages.InformationMessage("No data found");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("APR:8" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        public void SaveFunction()
        {
            try
            {
                AdvancePaymentBll bllAdvancePayment = new AdvancePaymentBll();
                AdvancePaymentInfo infoAdvancepayment = new AdvancePaymentInfo();
                LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
                MonthlySalaryVoucherBll BllMonthlySalary = new MonthlySalaryVoucherBll();
                if (CheckAdvanceAmount())
                {
                    if (!BllMonthlySalary.CheckSalaryAlreadyPaidOrNotForAdvancePayment(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value))
                    {
                        if (!bllAdvancePayment.CheckSalaryAlreadyPaidOrNot(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value))
                        {
                            if (isAutomatic == true)
                            {
                                infoAdvancepayment.VoucherNo = strVoucherNo;
                            }
                            else
                            {
                                infoAdvancepayment.VoucherNo = txtAdvanceVoucherNo.Text.Trim();
                            }
                            infoAdvancepayment.EmployeeId = Convert.ToDecimal(cmbEmployee.SelectedValue.ToString());
                            infoAdvancepayment.SalaryMonth = Convert.ToDateTime(dtpSalaryMonth.Text.ToString());
                            infoAdvancepayment.Chequenumber = txtCheckNo.Text.ToString();
                            infoAdvancepayment.Date = Convert.ToDateTime(txtDate.Text.ToString());
                            infoAdvancepayment.Amount = Convert.ToDecimal(txtAmount.Text.ToString());
                            if (isAutomatic)
                            {
                                infoAdvancepayment.InvoiceNo = strInvoiceNo;
                            }
                            else
                            {
                                infoAdvancepayment.InvoiceNo = txtAdvanceVoucherNo.Text.Trim();
                            }
                            infoAdvancepayment.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString());
                            infoAdvancepayment.ChequeDate = Convert.ToDateTime(txtChequeDate.Text.ToString());
                            infoAdvancepayment.Narration = txtNarration.Text.Trim();
                            infoAdvancepayment.ExtraDate = Convert.ToDateTime(DateTime.Now.ToString());
                            infoAdvancepayment.Extra1 = string.Empty;
                            infoAdvancepayment.Extra2 = string.Empty;
                            infoAdvancepayment.VoucherTypeId = decPaymentVoucherTypeId;
                            infoAdvancepayment.SuffixPrefixId = decPaymentSuffixPrefixId;
                            infoAdvancepayment.FinancialYearId = PublicVariables._decCurrentFinancialYearId;

                            if (btnAdvancePaymentSave.Text == "Save")
                            {
                                if (decAdvancePaymentsId != -1)
                                {
                                    List<DataTable> ListObj = new List<DataTable>();
                                    ListObj = bllAdvancePayment.AdvancePaymentAddWithIdentity(infoAdvancepayment, isAutomatic);
                                    foreach (DataRow dr in ListObj[0].Rows)
                                    {
                                        decAdvancePaymentId = Convert.ToDecimal(dr.ItemArray[0].ToString());
                                        strUpdatedVoucherNumber = dr.ItemArray[1].ToString();
                                        strUpdatedInvoiceNumber = dr.ItemArray[2].ToString();
                                    }
                                    if (!isAutomatic)
                                    {
                                        strVoucherNo = txtAdvanceVoucherNo.Text.Trim();
                                    }
                                    if (isAutomatic)
                                    {
                                        if (Convert.ToDecimal(strUpdatedVoucherNumber) != Convert.ToDecimal(strVoucherNo))
                                        {
                                            Messages.InformationMessage("Voucher number changed from  " + strInvoiceNo + "  to  " + strUpdatedInvoiceNumber);
                                            strVoucherNo = strUpdatedVoucherNumber.ToString();
                                            strInvoiceNo = strUpdatedInvoiceNumber;
                                        }
                                    }
                                    txtAdvanceVoucherNo.Focus();
                                }
                                LedgerPosting(Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString()), decAdvancePaymentId);
                                Messages.SavedMessage();
                                Clear();
                            }
                        }
                        else
                        {
                            Messages.InformationMessage(" Advance already paid for this month");
                            dtpSalaryMonth.Focus();
                        }
                    }
                    else
                    {
                        Messages.InformationMessage("Cant pay advance for this month,Salary already paid");
                        dtpSalaryMonth.Focus();
                    }
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("AP1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to call save or edit
        /// </summary>
        public void SaveOrEdit()
        {
            try
            {
                AdvancePaymentBll bllAdvancePayment = new AdvancePaymentBll();
                if (txtAdvanceVoucherNo.Text.Trim() == string.Empty)
                {
                    Messages.InformationMessage("Enter advance voucher no");
                    txtAdvanceVoucherNo.Focus();
                }
                else if (txtDate.Text == string.Empty)
                {
                    Messages.InformationMessage("Select date");
                }
                else if (cmbEmployee.Text == string.Empty)
                {
                    Messages.InformationMessage("Select employee");
                    cmbEmployee.Focus();
                }
                else if (txtAmount.Text.TrimEnd() == string.Empty)
                {
                    Messages.InformationMessage("Select amount");
                    txtAmount.Focus();
                }
                else if (cmbCashOrBank.Text == string.Empty)
                {
                    Messages.InformationMessage("Select Cash/Bank/ac");
                    cmbCashOrBank.Focus();
                }
                else
                {
                    if (btnAdvancePaymentSave.Text == "Save")
                    {
                        if (PublicVariables.isMessageAdd)
                        {
                            if (Messages.SaveMessage())
                            {
                                if (!isAutomatic)
                                {
                                    if (!bllAdvancePayment.AdvancePaymentCheckExistence(txtAdvanceVoucherNo.Text.Trim(), decPaymentVoucherTypeId, 0))
                                    {
                                        SaveFunction();
                                    }
                                    else
                                    {
                                        Messages.InformationMessage("Advance voucher number already exist");
                                        txtAdvanceVoucherNo.Focus();
                                    }
                                }
                                else
                                {
                                    SaveFunction();
                                }
                            }
                        }
                        else
                        {
                            if (!isAutomatic)
                            {
                                if (!bllAdvancePayment.AdvancePaymentCheckExistence(txtAdvanceVoucherNo.Text.Trim(), decPaymentVoucherTypeId, 0))
                                {
                                    SaveFunction();
                                }
                                else
                                {
                                    Messages.InformationMessage("Advance voucher number already exist");
                                    txtAdvanceVoucherNo.Focus();
                                }
                            }
                            else
                            {
                                SaveFunction();
                            }
                        }
                    }

                    else
                    {
                        if (btnAdvancePaymentSave.Text == "Update")
                        {
                            if (PublicVariables.isMessageEdit)
                            {
                                bool EditMessage = Messages.UpdateMessage();
                                if (EditMessage)
                                {
                                    if (!isAutomatic)
                                    {
                                        if (!bllAdvancePayment.AdvancePaymentCheckExistence(txtAdvanceVoucherNo.Text.Trim(), decPaymentVoucherTypeId, decAdvancePaymentEditId))
                                        {
                                            EditFunction();
                                        }
                                        else
                                        {
                                            Messages.InformationMessage("Advance voucher number already exist");
                                            txtAdvanceVoucherNo.Focus();
                                        }
                                    }
                                    else
                                    {
                                        EditFunction();
                                    }
                                }
                            }
                            else
                            {
                                if (!isAutomatic)
                                {
                                    if (!bllAdvancePayment.AdvancePaymentCheckExistence(txtAdvanceVoucherNo.Text.Trim(), decPaymentVoucherTypeId, decAdvancePaymentEditId))
                                    {
                                        EditFunction();
                                    }
                                    else
                                    {
                                        Messages.InformationMessage("Advance voucher number already exist");
                                        txtAdvanceVoucherNo.Focus();
                                    }
                                }
                                else
                                {
                                    EditFunction();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("AP4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to fill controls for update
 /// </summary>
 public void fillFunction()
 {
     try
     {
         AdvancePaymentBll bllAdvancePayment = new AdvancePaymentBll();
         AdvancePaymentInfo infoadvance = new AdvancePaymentInfo();
         VoucherTypeBll BllVoucherType = new VoucherTypeBll();
         infoadvance = bllAdvancePayment.AdvancePaymentView(decAdvancePaymentEditId);
         strVoucherNo = infoadvance.VoucherNo;
         txtAdvanceVoucherNo.Text = infoadvance.InvoiceNo;
         strInvoiceNo = infoadvance.InvoiceNo;
         cmbEmployee.SelectedValue = infoadvance.EmployeeId.ToString();
         dtpSalaryMonth.Value = Convert.ToDateTime(infoadvance.SalaryMonth.ToString());
         txtDate.Text = infoadvance.Date.ToString("dd-MMM-yyyy");
         txtChequeDate.Text = infoadvance.Date.ToString("dd-MMM-yyyy");
         cmbCashOrBank.SelectedValue = infoadvance.LedgerId.ToString();
         txtCheckNo.Text = infoadvance.Chequenumber;
         txtAmount.Text = infoadvance.Amount.ToString();
         txtNarration.Text = infoadvance.Narration;
         btnAdvancePaymentSave.Text = "Update";
         btnAdvancePaymentDelete.Enabled = true;
         decAdvancePaymentsId = decAdvancePaymentId;
         decPaymentVoucherTypeId = infoadvance.VoucherTypeId;
         decPaymentSuffixPrefixId = infoadvance.SuffixPrefixId;
         isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decPaymentVoucherTypeId);
         if (isAutomatic)
         {
             txtAdvanceVoucherNo.Enabled = false;
         }
         else
         {
             txtAdvanceVoucherNo.Enabled = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("AP8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function for Ledger Posting
        /// </summary>
        /// <param name="decLedgerPostingId"></param>
        /// <param name="decAdvancePaymentId"></param>
        public void LedgerPosting(decimal decLedgerPostingId, decimal decAdvancePaymentId)
        {
            try
            {
                AdvancePaymentBll bllAdvancePayment = new AdvancePaymentBll();
                AdvancePaymentInfo infoAdvancePayment = new AdvancePaymentInfo();
                LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
                LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
                infoLedgerPosting.VoucherTypeId = decPaymentVoucherTypeId;
                if (isAutomatic)
                {
                    infoLedgerPosting.VoucherNo = strVoucherNo;
                }
                else
                {
                    infoLedgerPosting.VoucherNo = txtAdvanceVoucherNo.Text.Trim();
                }
                infoLedgerPosting.Date = PublicVariables._dtCurrentDate;
                infoLedgerPosting.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString());
                infoLedgerPosting.DetailsId = decAdvancePaymentId;
                if (isAutomatic)
                {
                    infoLedgerPosting.InvoiceNo = strInvoiceNo;
                }
                else
                {
                    infoLedgerPosting.InvoiceNo = txtAdvanceVoucherNo.Text.Trim();
                }
                infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                infoLedgerPosting.Debit = 0;
                infoLedgerPosting.Credit = Convert.ToDecimal(txtAmount.Text.ToString());

                infoLedgerPosting.ChequeNo = string.Empty;
                infoLedgerPosting.ChequeDate = DateTime.Now;

                infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate;
                infoLedgerPosting.Extra1 = string.Empty;
                infoLedgerPosting.Extra2 = string.Empty;
                BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                infoLedgerPosting.VoucherTypeId = decPaymentVoucherTypeId;
                if (isAutomatic)
                {
                    infoLedgerPosting.VoucherNo = strVoucherNo;
                }
                else
                {
                    infoLedgerPosting.VoucherNo = txtAdvanceVoucherNo.Text.Trim();
                }
                infoLedgerPosting.Date = PublicVariables._dtCurrentDate;
                infoLedgerPosting.LedgerId = 3;
                infoLedgerPosting.DetailsId = decAdvancePaymentId;
                if (isAutomatic)
                {
                    infoLedgerPosting.InvoiceNo = strInvoiceNo;
                }
                else
                {
                    infoLedgerPosting.InvoiceNo = txtAdvanceVoucherNo.Text.Trim();
                }
                infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                infoLedgerPosting.Debit = Convert.ToDecimal(txtAmount.Text.ToString());
                infoLedgerPosting.Credit = 0;

                infoLedgerPosting.ChequeNo = string.Empty;
                infoLedgerPosting.ChequeDate = DateTime.Now;

                infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate;
                infoLedgerPosting.Extra1 = string.Empty;
                infoLedgerPosting.Extra2 = string.Empty;
                BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
            }
            catch (Exception ex)
            {
                MessageBox.Show("AP6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to edit
        /// </summary>
        public void EditFunction()
        {
            try
            {
                MonthlySalaryVoucherBll BllMonthlySalary = new MonthlySalaryVoucherBll();
                if (!BllMonthlySalary.CheckSalaryStatusForAdvancePayment(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value))
                {

                    AdvancePaymentBll bllAdvancepayment = new AdvancePaymentBll();
                    AdvancePaymentInfo infoAdvancepayment = new AdvancePaymentInfo();
                    LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();

                    if (bllAdvancepayment.CheckSalaryAlreadyPaidOrNot(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value))
                    {
                        txtAmount.ReadOnly = true;
                    }

                    infoAdvancepayment.AdvancePaymentId = (Convert.ToDecimal(decAdvancePaymentEditId.ToString()));
                    infoAdvancepayment.EmployeeId = Convert.ToDecimal(cmbEmployee.SelectedValue.ToString());
                    infoAdvancepayment.SalaryMonth = Convert.ToDateTime(dtpSalaryMonth.Text.ToString());
                    infoAdvancepayment.Chequenumber = txtCheckNo.Text.ToString();
                    infoAdvancepayment.Date = Convert.ToDateTime(txtDate.Text.ToString());
                    infoAdvancepayment.Amount = Convert.ToDecimal(txtAmount.Text.ToString());
                    if (CheckAdvanceAmount())
                    {
                        if (isAutomatic)
                        {
                            infoAdvancepayment.VoucherNo = strVoucherNo;
                        }
                        else
                        {
                            infoAdvancepayment.VoucherNo = txtAdvanceVoucherNo.Text.Trim();
                        }
                        if (isAutomatic)
                        {
                            infoAdvancepayment.InvoiceNo = strInvoiceNo;
                        }
                        else
                        {
                            infoAdvancepayment.InvoiceNo = txtAdvanceVoucherNo.Text.Trim();
                        }
                        infoAdvancepayment.LedgerId = Convert.ToDecimal(cmbCashOrBank.SelectedValue.ToString());
                        infoAdvancepayment.ChequeDate = Convert.ToDateTime(txtChequeDate.Text.ToString());
                        infoAdvancepayment.Narration = txtNarration.Text.Trim();
                        infoAdvancepayment.ExtraDate = Convert.ToDateTime(DateTime.Now.ToString());
                        infoAdvancepayment.Extra1 = string.Empty;
                        infoAdvancepayment.Extra2 = string.Empty;
                        infoAdvancepayment.VoucherTypeId = decPaymentVoucherTypeId;
                        infoAdvancepayment.SuffixPrefixId = decPaymentSuffixPrefixId;
                        infoAdvancepayment.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
                        bllAdvancepayment.AdvancePaymentEdit(infoAdvancepayment);
                        LedgerUpdate();
                        Messages.UpdatedMessage();
                        txtAdvanceVoucherNo.Focus();
                        this.Close();
                    }
                }
                else
                {
                    Messages.ReferenceExistsMessageForUpdate();
                    dtpSalaryMonth.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("AP3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to fill Employee combobox
 /// </summary>
 public void EmployeeComboFill()
 {
     try
     {
         AdvancePaymentBll spAdvancePayment = new AdvancePaymentBll();
         List<DataTable> ListObj = new List<DataTable>();
         ListObj = spAdvancePayment.AdvancePaymentEmployeeComboFill();
         cmbEmployee.DataSource = ListObj[0];
         cmbEmployee.ValueMember = "EmployeeId";
         cmbEmployee.DisplayMember = "EmployeeName";
         cmbEmployee.SelectedIndex = -1;
     }
     catch (Exception ex)
     {
         MessageBox.Show("AP12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to delete
 /// </summary>
 public void DeleteFunction()
 {
     try
     {
         MonthlySalaryVoucherBll BllMonthlySalary = new MonthlySalaryVoucherBll();
         if (!BllMonthlySalary.CheckSalaryStatusForAdvancePayment(Convert.ToDecimal(cmbEmployee.SelectedValue.ToString()), dtpSalaryMonth.Value))
         {
             AdvancePaymentInfo infoAdvancepayment = new AdvancePaymentInfo();
             AdvancePaymentBll bllAdvancePayment = new AdvancePaymentBll();
             LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
             bllAdvancePayment.AdvancePaymentDelete(Convert.ToDecimal(decAdvancePaymentEditId.ToString()));
             BllLedgerPosting.LedgerPostDelete(txtAdvanceVoucherNo.Text.Trim(), decAdvancePaymentEditId);
             Messages.DeletedMessage();
             txtAdvanceVoucherNo.Focus();
             Clear();
             this.Close();
         }
         else
         {
             Messages.ReferenceExistsMessage();
             dtpSalaryMonth.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("AP14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to check wheteher the advance amount given exceeds the limit for  that employee or not
        /// </summary>
        /// <returns></returns>
        public bool CheckAdvanceAmount()
        {
            bool Cancel = true;
            try
            {
                decimal decEmployeeId = 0;
                AdvancePaymentBll bllAdvancePayment = new AdvancePaymentBll();
                decimal decEmployeesalary = 0;
                if (cmbEmployee.SelectedValue != null)
                {
                    decEmployeeId = Convert.ToDecimal(cmbEmployee.SelectedValue.ToString());
                }
                decEmployeesalary = bllAdvancePayment.AdvancePaymentAmountchecking(decEmployeeId);

                decimal txtamountvalue = 0;
                if (txtAmount.Text != string.Empty)
                {
                    txtamountvalue = Convert.ToDecimal(txtAmount.Text.ToString());
                }
                if (txtamountvalue > decEmployeesalary)
                {
                    MessageBox.Show("Advance of this month exceeds than amount set  for  the employee", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtAmount.Focus();
                    Cancel = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("AP16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return Cancel;
        }
        /// <summary>
        /// Function to generate Voucher number as per settings
        /// </summary>
        public void VoucherNoGeneration()
        {
            TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
            AdvancePaymentBll bllAdvancePayment = new AdvancePaymentBll();
            if (strVoucherNo == string.Empty)
            {
                strVoucherNo = "0";
            }
            strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpSalaryMonth.Value, strAdvancePayment);
            if (Convert.ToDecimal(strVoucherNo) != bllAdvancePayment.AdvancePaymentGetMaxPlusOne(decPaymentVoucherTypeId))
            {
                strVoucherNo = bllAdvancePayment.AdvancePaymentGetMax(decPaymentVoucherTypeId).ToString();
                strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpSalaryMonth.Value, strAdvancePayment);
                if (bllAdvancePayment.AdvancePaymentGetMax(decPaymentVoucherTypeId) == "0")
                {
                    strVoucherNo = "0";
                    strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPaymentVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpSalaryMonth.Value, strAdvancePayment);
                }
            }
            if (isAutomatic)
            {
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decPaymentVoucherTypeId, dtpDate.Value);
                strPrefix = infoSuffixPrefix.Prefix;
                strSuffix = infoSuffixPrefix.Suffix;
                strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                txtAdvanceVoucherNo.Text = strInvoiceNo;
                txtAdvanceVoucherNo.Enabled = false;
            }
        }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void GridFill()
 {
     try
     {
         List<DataTable> ListObj = new List<DataTable>();
         AdvancePaymentBll bllAdvanceRegister = new AdvancePaymentBll();
         ListObj = bllAdvanceRegister.AdvanceRegisterSearch(txtAdvanceVoucher.Text, txtEmployeeCode.Text, txtEmployeeName.Text, dtpSalaryMonth.Text, cmbVoucherType.Text);
         dgvAdvanceRegister.DataSource = ListObj[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show("AR1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to fill cmbVoucherType combobox
        /// </summary>
        public void VoucherTypeNameComboFill()
        {
            try
            {
                AdvancePaymentBll bllAdvancePaymentSP = new AdvancePaymentBll();
                List<DataTable> ListObj = new List<DataTable>();
                ListObj = bllAdvancePaymentSP.VoucherTypeNameComboFillAdvanceRegister();
                DataRow dr = ListObj[0].NewRow();
                dr[1] = "All";
                ListObj[0].Rows.InsertAt(dr, 0);
                cmbVoucherType.DataSource = ListObj[0];
                cmbVoucherType.ValueMember = "voucherTypeId";
                cmbVoucherType.DisplayMember = "voucherTypeName";

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