/// <summary>
 /// Search function to fill the grid based on condition
 /// </summary>
 public void ReportSearch()
 {
     try
     {
         PDCClearanceBll BllPDCClearance = new PDCClearanceBll();
         List<DataTable> ListPDCClearnceReport = new List<DataTable>();
         ListPDCClearnceReport = BllPDCClearance.PDCClearanceReportSearch(Convert.ToDateTime(dtpFrmDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), cmbAccountLedger.Text.ToString(), cmbVoucherType.Text.ToString(), txtVoucherNo.Text.ToString());
         DGVClraranceReport.DataSource = ListPDCClearnceReport[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show("PCREP5" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// VoucherType Combofill
 /// </summary>
 public void VoucherTypeComboFill()
 {
     try
     {
         isDontExecuteVoucherType = true;
         List<DataTable> listObj = new List<DataTable>();
         PDCClearanceBll BllPdcClearance = new PDCClearanceBll();
         cmbvouchertype.DataSource = null;
         listObj = BllPdcClearance.VouchertypeComboFill();
         cmbvouchertype.DataSource = listObj[0];
         cmbvouchertype.ValueMember = "voucherTypeId";
         cmbvouchertype.DisplayMember = "voucherTypeName";
         cmbvouchertype.SelectedIndex = -1;
         isDontExecuteVoucherType = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Datagridview
 /// </summary>
 public void Search()
 {
     try
     {
         List<DataTable> ListPDCClearnceRegister = new List<DataTable>();
         PDCClearanceBll BllPDCClearance = new PDCClearanceBll();
         ListPDCClearnceRegister = BllPDCClearance.PDCClearanceRegisterSearch(Convert.ToDateTime(dtpFromDate.Value.ToString()), Convert.ToDateTime(dtpTodate.Value.ToString()), cmbAccountLedger.Text, cmbVouchertype.Text, txtCheckno.Text.Trim(), Convert.ToDecimal(cmbBank.SelectedValue), cmbStatus.Text);
         dgvClearanceSearch.DataSource = ListPDCClearnceRegister[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show("PCREG6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to call this form from frmDayBook to view details and for updation
 /// </summary>
 /// <param name="frmDayBook"></param>
 /// <param name="decMasterId"></param>
 public void callFromDayBook(frmDayBook frmDayBook, decimal decMasterId)
 {
     try
     {
         frmDayBook.Enabled = false;
         base.Show();
         isInEditMode = true;
         btnDelete.Enabled = true;
         frmDayBookObj = frmDayBook;
         decPDCClearanceEditId = decMasterId;
         PDCClearanceBll BllPdcClearance = new PDCClearanceBll();
         decMasterIdEdit = BllPdcClearance.PDCClearanceAgainstIdUnderClearanceId(decPDCClearanceEditId);
         FillFunction();
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC22:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Voucher no automatic generation, it considered the settings also
        /// </summary>
        public void VoucherNumberGeneration()
        {
            try
            {
                TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();

                PDCClearanceBll BllPdcClearance = new PDCClearanceBll();

                if (strVoucherNo == string.Empty)
                {
                    strVoucherNo = "0";
                }
                strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPDCclearanceVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, strtableName);
                if (Convert.ToDecimal(strVoucherNo) != BllPdcClearance.PDCClearanceMaxUnderVoucherTypePlusOne(decPDCclearanceVoucherTypeId))
                {
                    strVoucherNo = BllPdcClearance.PDCClearanceMaxUnderVoucherType(decPDCclearanceVoucherTypeId).ToString();
                    strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPDCclearanceVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, strtableName);
                    if (BllPdcClearance.PDCClearanceMaxUnderVoucherType(decPDCclearanceVoucherTypeId).ToString() == "0")
                    {
                        strVoucherNo = "0";
                        strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPDCclearanceVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, strtableName);
                    }
                }
                if (isAutomatic)
                {
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decPDCclearanceVoucherTypeId, dtpVoucherDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    decSufixprefixPdcpayableID = infoSuffixPrefix.SuffixprefixId;
                    strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                    txtvoucherNo.Text = strInvoiceNo;
                    lblVoucherNoManualValidator.Visible = false;
                    txtvoucherNo.ReadOnly = true;
                    txtvoucherNo.Enabled = false;
                }
                else
                {
                    txtvoucherNo.ReadOnly = false;
                    txtvoucherNo.Text = string.Empty;
                    lblVoucherNoManualValidator.Visible = true;
                    strInvoiceNo = txtvoucherNo.Text.Trim();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to call this form from frmLedgerDetails to view details and for updation
        /// </summary>
        /// <param name="frmLedgerDetails"></param>
        /// <param name="decMasterId"></param>
        public void CallFromLedgerDetails(frmLedgerDetails frmLedgerDetails, decimal decMasterId)
        {
            try
            {

                base.Show();
                frmLedgerDetailsObj = frmLedgerDetails;
                frmLedgerDetailsObj.Enabled = false;
                isInEditMode = true;
                btnDelete.Enabled = true;
                decPDCClearanceEditId = decMasterId;
                PDCClearanceBll BllPdcClearance = new PDCClearanceBll();
                decMasterIdEdit = BllPdcClearance.PDCClearanceAgainstIdUnderClearanceId(decPDCClearanceEditId);
                FillFunction();
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC15:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Save Or edit function, here checking the invalid entries
        /// </summary>
        public void SaveOrEditFunction()
        {
            try
            {
                bool isOk = true;
                if (isOk)
                    if (txtvoucherNo.Text == string.Empty)
                    {
                        Messages.InformationMessage("Enter voucher no");
                        txtvoucherNo.Focus();
                    }
                    else if (txtVoucherDate.Text == string.Empty)
                    {
                        Messages.InformationMessage("Select date");
                        txtVoucherDate.Focus();
                    }
                    else if (cmbvouchertype.SelectedValue == null)
                    {
                        Messages.InformationMessage("Select voucher type");
                        cmbvouchertype.Focus();
                    }
                    else if (cmbInvoiceNo.SelectedValue == null)
                    {
                        Messages.InformationMessage("Select against invoice no");
                        cmbInvoiceNo.Focus();
                    }
                    else if (cmbStatus.Text == string.Empty)
                    {
                        Messages.InformationMessage("Select status");
                        cmbStatus.Focus();
                    }
                    else
                    {
                        if (PublicVariables.isMessageAdd)
                        {
                            isOk = false;
                            PDCClearanceBll BllPdcClearance = new PDCClearanceBll();
                            if (!isInEditMode)
                            {
                                if (Messages.SaveMessage())
                                    if (!BllPdcClearance.PDCclearanceCheckExistence(txtvoucherNo.Text.Trim(), decPDCclearanceVoucherTypeId, 0))
                                    {
                                        SaveFunction();
                                    }
                                    else
                                    {
                                        Messages.InformationMessage("Voucher number already exist");
                                    }
                            }
                            else if (isInEditMode)
                            {
                                if (Messages.UpdateMessage())
                                {
                                    SaveFunction();
                                }
                            }
                        }
                        if (isOk)
                        {
                            if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, this.Name, btnSave.Text))
                            {
                                PDCPayableBll BllPDCPayable = new PDCPayableBll();

                                if (isInEditMode)
                                {
                                    SaveFunction();
                                }
                                else
                                {
                                    SaveFunction();
                                }
                            }
                            else
                            {
                                Messages.NoPrivillageMessage();
                            }
                        }
                    }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Ledger Posting Function, here saving the curresponding details into the ledger
        /// </summary>
        public void LedgerPostingAdd()
        {
            try
            {
                string strstatus = cmbStatus.Text.ToString();
                LedgerPostingInfo InfoPosting = new LedgerPostingInfo();
                LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
                AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
                LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
                PDCClearanceBll BllPdcClearance = new PDCClearanceBll();
                PDCPayableMasterInfo infoPDCPayable = new PDCPayableMasterInfo();
                PDCPayableBll BllPDCPayable = new PDCPayableBll();
                PDCReceivableMasterInfo infoPDCReceivable = new PDCReceivableMasterInfo();
                PDCRecivebleBll BllPDCReciveble = new PDCRecivebleBll();
                strVoucherType = BllPdcClearance.TypeOfVoucherReturnUnderVoucherName(cmbvouchertype.Text.ToString());
                if (strVoucherType == "PDC Payable")
                {
                    infoPDCPayable = BllPDCPayable.PDCPayableMasterView(Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString()));
                    infoLedgerPosting.VoucherNo = strVoucherNo;
                    infoLedgerPosting.InvoiceNo = txtvoucherNo.Text.Trim();
                    infoLedgerPosting.Date = Convert.ToDateTime(txtVoucherDate.Text.ToString());
                    infoLedgerPosting.VoucherTypeId = decPDCclearanceVoucherTypeId;
                    infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                    infoLedgerPosting.ChequeDate = Convert.ToDateTime(txtcheckdate.Text.ToString());
                    infoLedgerPosting.ChequeNo = txtcheckNo.Text.Trim();
                    infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate;
                    infoLedgerPosting.Extra1 = string.Empty;
                    infoLedgerPosting.Extra2 = string.Empty;
                    if (strstatus == "Cleared")
                    {

                        infoLedgerPosting.LedgerId = infoPDCPayable.BankId;
                        infoLedgerPosting.Debit = 0;
                        infoLedgerPosting.Credit = Convert.ToDecimal(txtAmount.Text.ToString());
                    }
                    else if (strstatus == "Bounced")
                    {
                        infoLedgerPosting.LedgerId = infoPDCPayable.LedgerId;
                        infoLedgerPosting.Debit = 0;
                        infoLedgerPosting.Credit = Convert.ToDecimal(txtAmount.Text.ToString());
                    }
                    BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                    infoLedgerPosting.VoucherTypeId = decPDCclearanceVoucherTypeId;
                    infoLedgerPosting.VoucherNo = txtvoucherNo.Text.Trim();
                    infoLedgerPosting.Date = Convert.ToDateTime(txtVoucherDate.Text.ToString());
                    infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                    infoLedgerPosting.ChequeDate = Convert.ToDateTime(txtcheckdate.Text);
                    infoLedgerPosting.ChequeNo = txtcheckNo.Text.Trim();
                    infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate;
                    infoLedgerPosting.Extra1 = string.Empty;
                    infoLedgerPosting.Extra2 = string.Empty;
                    infoLedgerPosting.VoucherNo = strVoucherNo;
                    infoLedgerPosting.InvoiceNo = txtvoucherNo.Text.Trim();
                    infoLedgerPosting.LedgerId = 6;
                    infoLedgerPosting.Debit = Convert.ToDecimal(txtAmount.Text.ToString());
                    infoLedgerPosting.Credit = 0;
                    BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                }
                else if (strVoucherType == "PDC Receivable")
                {
                    infoPDCReceivable = BllPDCReciveble.PDCReceivableMasterView(Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString()));
                    infoLedgerPosting.VoucherTypeId = decPDCclearanceVoucherTypeId;
                    infoLedgerPosting.VoucherNo = strVoucherNo;
                    infoLedgerPosting.InvoiceNo = txtvoucherNo.Text.Trim();
                    infoLedgerPosting.Date = PublicVariables._dtCurrentDate;
                    infoLedgerPosting.LedgerId = 7;
                    infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                    infoLedgerPosting.Debit = 0;
                    infoLedgerPosting.Credit = Convert.ToDecimal(txtAmount.Text.ToString());
                    infoLedgerPosting.ChequeDate = Convert.ToDateTime(txtcheckdate.Text.ToString());
                    infoLedgerPosting.ChequeNo = txtcheckNo.Text.Trim();
                    infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate;
                    infoLedgerPosting.Extra1 = string.Empty;
                    infoLedgerPosting.Extra2 = string.Empty;
                    BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                    infoLedgerPosting.VoucherTypeId = decPDCclearanceVoucherTypeId;
                    infoLedgerPosting.Date = PublicVariables._dtCurrentDate;
                    if (strstatus == "Cleared")
                    {
                        infoLedgerPosting.LedgerId = infoPDCReceivable.BankId;
                    }
                    else if (strstatus == "Bounced")
                    {
                        infoLedgerPosting.LedgerId = infoPDCReceivable.LedgerId;
                    }
                    infoLedgerPosting.VoucherNo = strVoucherNo;
                    infoLedgerPosting.InvoiceNo = txtvoucherNo.Text.Trim();
                    infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                    infoLedgerPosting.Debit = Convert.ToDecimal(txtAmount.Text.ToString());
                    infoLedgerPosting.Credit = 0;
                    infoLedgerPosting.ChequeDate = Convert.ToDateTime(txtcheckdate.Text);
                    infoLedgerPosting.ChequeNo = txtcheckNo.Text.Trim();
                    infoLedgerPosting.ExtraDate = PublicVariables._dtCurrentDate;
                    infoLedgerPosting.Extra1 = string.Empty;
                    infoLedgerPosting.Extra2 = string.Empty;
                    BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Its the function for print function
 /// </summary>
 /// <param name="decMasterId"></param>
 public void Print(decimal decMasterId)
 {
     try
     {
         DataSet dsPdcClearance = new DataSet();
         PDCClearanceBll BllPdcClearance = new PDCClearanceBll();
         dsPdcClearance = BllPdcClearance.PDCClearanceVoucherPrinting(decMasterId, 1);
         frmReport frmreport = new frmReport();
         frmreport.MdiParent = formMDI.MDIObj;
         frmreport.PDCClearancevoucherPrinting(dsPdcClearance);
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC18:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Its the fill function to update or delete
 /// </summary>
 public void FillFunction()
 {
     try
     {
         PDCClearanceMasterInfo infoPDCClearance = new PDCClearanceMasterInfo();
         PDCClearanceBll BllPdcClearance = new PDCClearanceBll();
         infoPDCClearance = BllPdcClearance.PDCClearanceMasterView(decPDCClearanceEditId);
         VoucherTypeComboFill();
         strVoucherNo = infoPDCClearance.VoucherNo;
         strInvoiceNo = infoPDCClearance.InvoiceNo;
         txtvoucherNo.Text = strInvoiceNo;
         decSufixprefixPdcpayableID = infoPDCClearance.SuffixPrefixId;
         decPDCclearanceVoucherTypeId = infoPDCClearance.VoucherTypeId;
         VoucherTypeBll BllVOucherType = new VoucherTypeBll();
         isAutomatic = BllVOucherType.CheckMethodOfVoucherNumbering(decPDCclearanceVoucherTypeId);
         if (isAutomatic)
         {
             txtvoucherNo.ReadOnly = true;
         }
         else
         {
             txtvoucherNo.ReadOnly = false;
         }
         if (infoPDCClearance.PDCClearanceMasterId != 0)
         {
             txtvoucherNo.Text = infoPDCClearance.VoucherNo;
             dtpVoucherDate.Value = infoPDCClearance.Date;
             txtVoucherDate.Text = dtpVoucherDate.Value.ToString("dd-MMM-yyyy");
             txtNarration.Text = infoPDCClearance.Narration;
             cmbvouchertype.Text = infoPDCClearance.Type;
             InvoiceNumberCombofill(cmbvouchertype.Text.ToString(), decMasterIdEdit);
             cmbStatus.Text = infoPDCClearance.Status;
             cmbInvoiceNo.SelectedValue = decMasterIdEdit;
             btnSave.Text = "Update";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Invoice no Combo fill function
 /// </summary>
 /// <param name="strVoucherType"></param>
 /// <param name="masterId"></param>
 public void InvoiceNumberCombofill(string strVoucherType, decimal masterId)
 {
     try
     {
         if (cmbvouchertype.Text != string.Empty)
         {
             if (cmbvouchertype.SelectedValue.ToString() != "System.Data.DataRowView" && cmbvouchertype.Text != "System.Data.DataRowView")
             {
                 isInvoicefill = true;
                 if (isInEditMode)
                 {
                     masterId = decMasterIdEdit;
                 }
                 List<DataTable> listObjInvoice = new List<DataTable>();
                 PDCClearanceBll BllPdcClearance = new PDCClearanceBll();
                 listObjInvoice = BllPdcClearance.InvoiceNumberCombofillUnderVoucherType(strVoucherType, masterId);
                 cmbInvoiceNo.DataSource = listObjInvoice[0];
                 if (cmbInvoiceNo.DataSource != null)
                 {
                     cmbInvoiceNo.DisplayMember = "invoiceNo";
                     cmbInvoiceNo.ValueMember = "MasterId";
                     cmbInvoiceNo.SelectedIndex = -1;
                 }
                 isInvoicefill = false;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Details fill function when user changed the invoice no. here fill thje curresponding invoice no
 /// </summary>
 public void filldetailsfunction()
 {
     try
     {
         PDCClearanceBll BllPdcClearance = new PDCClearanceBll();
         decmasterId = Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString());
         listObjDetails = BllPdcClearance.pdcclearancedetailsFill(cmbvouchertype.Text.ToString(), decmasterId);
         string strchequeNo = listObjDetails[0].Rows[0]["chequeNo"].ToString();
         decimal decAmount = Convert.ToDecimal(listObjDetails[0].Rows[0]["amount"].ToString());
         string straccountledger = listObjDetails[0].Rows[0]["ledgerName"].ToString();
         DateTime dtcheckdate = Convert.ToDateTime(listObjDetails[0].Rows[0]["checkDate"].ToString());
         string strBank = listObjDetails[0].Rows[0]["Bank"].ToString();
         strledgerId = listObjDetails[0].Rows[0]["ledgerId"].ToString();
         txtcheckNo.Text = strchequeNo;
         txtAmount.Text = decAmount.ToString();
         txtAccountLedger.Text = straccountledger;
         txtcheckdate.Text = Convert.ToString(listObjDetails[0].Rows[0]["checkDate"].ToString());
         txtBank.Text = strBank;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// delete function
        /// </summary>
        /// <param name="decpdcMasterId"></param>
        public void DeleteFunction(decimal decpdcMasterId)
        {
            try
            {
                PDCClearanceBll BllPdcClearance = new PDCClearanceBll();
                AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
                BllPdcClearance.PDCClearanceDelete(decpdcMasterId, decPDCclearanceVoucherTypeId, strVoucherNo);
                Messages.DeletedMessage();
                if (pdcClearanceRegObj != null)
                {
                    this.Close();
                    pdcClearanceRegObj.Show();
                }
                else if (pdcClearanceReportObj != null)
                {
                    this.Close();
                    pdcClearanceReportObj.Show();
                }
                else if (objVoucherSearch != null)
                {
                    this.Close();
                    objVoucherSearch.GridFill();
                }
                else if (frmLedgerDetailsObj != null)
                {
                    this.Close();
                }
                else if (frmDayBookObj != null)
                {
                    this.Close();
                }
                else
                {
                    ClearFunction();
                }

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

            }
        }
 /// <summary>
 /// Function to call this form from frmPDCClearanceReport to view details and for updation
 /// </summary>
 /// <param name="PDCClearanceReport"></param>
 /// <param name="decMasterId"></param>
 public void CallFromPDCClearanceReport(frmPDCClearanceReport PDCClearanceReport, decimal decMasterId)
 {
     try
     {
         PDCClearanceReport.Enabled = false;
         base.Show();
         isInEditMode = true;
         btnDelete.Enabled = true;
         pdcClearanceReportObj = PDCClearanceReport;
         decPDCClearanceEditId = decMasterId;
         PDCClearanceBll BllPdcClearance = new PDCClearanceBll();
         decMasterIdEdit = BllPdcClearance.PDCClearanceAgainstIdUnderClearanceId(decPDCClearanceEditId);
         FillFunction();
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC17:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill VoucherType combobox
 /// </summary>
 public void VoucherTypeComboFill()
 {
     try
     {
         isDontExecuteVoucherType = true;
         PDCClearanceBll BllPDCClearance = new PDCClearanceBll();
         List<DataTable> listObj = new List<DataTable>();
         cmbVoucherType.DataSource = null;
         listObj = BllPDCClearance.VouchertypeComboFill();
         DataRow dr = listObj[0].NewRow();
         dr["voucherTypeId"] = 0;
         dr["voucherTypeName"] = "All";
         listObj[0].Rows.InsertAt(dr, 0);
         cmbVoucherType.DataSource = listObj[0];
         cmbVoucherType.ValueMember = "voucherTypeId";
         cmbVoucherType.DisplayMember = "voucherTypeName";
         cmbVoucherType.SelectedIndex = 0;
         isDontExecuteVoucherType = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PCREP2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Save Function
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         DateValidation Objdatevalidation = new DateValidation();
         OtherDateValidationFunction ObjotherdateValidation = new OtherDateValidationFunction();
         Objdatevalidation.DateValidationFunction(txtVoucherDate);
         AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
         SettingsBll BllSettings = new SettingsBll();
         txtVoucherDate.Text = txtVoucherDate.Text.Trim();
         cmbvouchertype.Text = cmbvouchertype.Text.Trim();
         txtAmount.Text = txtAmount.Text.Trim();
         txtBank.Text = txtBank.Text.Trim();
         txtcheckdate.Text = txtcheckdate.Text.Trim();
         txtcheckNo.Text = txtcheckNo.Text.Trim();
         txtNarration.Text = txtNarration.Text.Trim();
         DataTable dtblMaster = new DataTable();
         PDCClearanceBll BllPdcClearance = new PDCClearanceBll();
         PDCClearanceMasterInfo infoPdcclearance = new PDCClearanceMasterInfo();
         infoPdcclearance.SuffixPrefixId = decSufixprefixPdcpayableID;
         infoPdcclearance.FinancialYearId = Convert.ToDecimal(PublicVariables._decCurrentFinancialYearId.ToString());
         infoPdcclearance.VoucherNo = strVoucherNo;
         infoPdcclearance.InvoiceNo = txtvoucherNo.Text;
         if (txtVoucherDate.Text != string.Empty)
             infoPdcclearance.Date = Convert.ToDateTime(txtVoucherDate.Text);
         else
             infoPdcclearance.Date = DateTime.Now;
         infoPdcclearance.LedgerId = decimal.Parse(strledgerId.ToString());
         infoPdcclearance.AgainstId = decmasterId;
         infoPdcclearance.UserId = PublicVariables._decCurrentUserId;
         infoPdcclearance.VoucherTypeId = decPDCclearanceVoucherTypeId;
         infoPdcclearance.Status = cmbStatus.Text.ToString();
         infoPdcclearance.Type = cmbvouchertype.Text.ToString();
         infoPdcclearance.ExtraDate = DateTime.Now;
         infoPdcclearance.Narration = txtNarration.Text;
         infoPdcclearance.Extra1 = string.Empty;
         infoPdcclearance.Extra2 = string.Empty;
         if (!isInEditMode)
         {
             decimal decIdentity = BllPdcClearance.PDCClearanceMasterAdd(infoPdcclearance);
             LedgerPostingAdd();
             if (cmbStatus.Text.ToString() == "Bounced")
             {
                 if (bllAccountLedger.AccountGroupIdCheck(txtAccountLedger.Text.ToString()))
                 {
                     PartyBalanceAddOrEdit();
                 }
             }
             Messages.SavedMessage();
             if (cbxPrint.Checked)
             {
                 if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decIdentity);
                 }
                 else
                 {
                     Print(decIdentity);
                 }
             }
             ClearFunction();
         }
         else
         {
             decimal decIdentity = decPDCClearanceEditId;
             infoPdcclearance.PDCClearanceMasterId = decPDCClearanceEditId;
             BllPdcClearance.PDCClearanceMasterEdit(infoPdcclearance);
             bllAccountLedger.LedgerPostingDeleteByVoucherTypeAndVoucherNo(strVoucherNo, decPDCclearanceVoucherTypeId);
             LedgerPostingAdd();
             bllAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(strVoucherNo, decPDCclearanceVoucherTypeId);
             if (cmbStatus.Text.ToString() == "Bounced")
             {
                 if (bllAccountLedger.AccountGroupIdCheck(txtAccountLedger.Text.ToString()))
                 {
                     PartyBalanceAddOrEdit();
                 }
             }
             Messages.UpdatedMessage();
             if (cbxPrint.Checked)
             {
                 if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decIdentity);
                 }
                 else
                 {
                     Print(decIdentity);
                 }
             }
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// print button click, call the print function
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         if (DGVClraranceReport.RowCount > 0)
         {
             PDCClearanceBll BllPDCClearance = new PDCClearanceBll();
             DataSet dsPDCClearance = new DataSet();
             dsPDCClearance = BllPDCClearance.PDCClearanceReportPrinting(Convert.ToDateTime(dtpFrmDate.Value.ToString()), Convert.ToDateTime(dtpToDate.Value.ToString()), cmbAccountLedger.Text.ToString(), cmbVoucherType.Text.ToString(), txtVoucherNo.Text.ToString(), 1);
             frmReport frmreport = new frmReport();
             frmreport.MdiParent = formMDI.MDIObj;
             frmreport.PDCClearanceReportPrinting(dsPDCClearance);
         }
         else
         {
             Messages.InformationMessage("No data found");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PCREP12:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Delete button click, checking the user role PrivilegeCheck and call the delete function
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         PDCClearanceBll BllPdcClearance = new PDCClearanceBll();
         if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, this.Name, btnDelete.Text))
         {
             if (PublicVariables.isMessageDelete)
             {
                 if (Messages.DeleteMessage())
                 {
                     if (isInEditMode)
                     {
                         DeleteFunction(decPDCClearanceEditId);
                         txtvoucherNo.Focus();
                     }
                 }
             }
             else
             {
                 if (isInEditMode)
                 {
                     DeleteFunction(decPDCClearanceEditId);
                     txtvoucherNo.Focus();
                 }
             }
         }
         else
         {
             Messages.NoPrivillageMessage();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC30:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }