/// <summary>
        /// Function to fill the grid based on conditions
        /// </summary>
        public void GridFill()
        {
            try
            {

                //RejectionOutMasterSP spRejectionOutMaster = new RejectionOutMasterSP();
                RejectionOutBll bllRejectionOut = new RejectionOutBll();
                if (txtVoucherNo.Text.Trim() == string.Empty)
                {
                    strVoucherNo = string.Empty;
                }
                else
                {
                    strVoucherNo = txtVoucherNo.Text;
                }
                if (cmbCashOrParty.SelectedIndex == 0 || cmbCashOrParty.SelectedIndex == -1)
                {
                    decLedgerId = 0;
                }
                else
                {
                    decLedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
                }
                if (cmbVoucherType.SelectedIndex == 0 || cmbVoucherType.SelectedIndex == -1)
                {
                    decVoucherTypeId = 0;

                }
                else
                {
                    decVoucherTypeId = Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString());
                }
                if (cmbMaterialReceiptNo.SelectedIndex == 0 || cmbMaterialReceiptNo.SelectedIndex == -1)
                {
                    decReceiptMasterId = 0;
                }
                else
                {
                    decReceiptMasterId = Convert.ToDecimal(cmbMaterialReceiptNo.SelectedValue.ToString());

                }
                if (txtProductCode.Text.Trim() == string.Empty)
                {
                    strProductCode = string.Empty;
                }
                else
                {
                    strProductCode = txtProductCode.Text;
                }
                if (txtProductName.Text.Trim() == string.Empty)
                {
                    strProductName = string.Empty;
                }
                else
                {
                    strProductName = txtProductName.Text;
                }
                DateTime FromDate = this.dtpFromDate.Value;
                DateTime ToDate = this.dtpToDate.Value;
                List<DataTable>list = bllRejectionOut.RejectionOutReportFill(strinvoiceNo, strProductCode, strProductName, decLedgerId, FromDate, ToDate, decReceiptMasterId, decVoucherTypeId);
                dgvRejectionOutReport.DataSource = list[0];

            }
            catch (Exception ex)
            {
                MessageBox.Show("ROREP07:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to fill VoucherType combobox
 /// </summary>
 public void VoucherTypeComboFill()
 {
     try
     {
      
         RejectionOutBll bllRejectionOut = new RejectionOutBll();
         List<DataTable> list = new List<DataTable>();
         list = bllRejectionOut.VoucherTypeComboFillForRejectionOutReport();
         cmbVoucherType.DataSource = list[0];
         cmbVoucherType.ValueMember = "voucherTypeId";
         cmbVoucherType.DisplayMember = "voucherTypeName";
         cmbVoucherType.SelectedIndex = 0;
     }
     catch (Exception ex)
     {
         MessageBox.Show("ROREP05:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Funtion to check remaining  quantity with refernce to purchaseinvoice and rejectionout
 /// </summary>
 /// <returns></returns>
 public int QuantityCheckWithReference()
 {
     decimal decQtyRejectionOutAndPurchaseInvoice = 0;
     decimal decQtyMaterialReceipt = 0;
     decimal inRef = 0;
     int inF1 = 1;
     decimal decMaterialReceiptDetailsId = 0;
     MaterialReceiptBll bllMaterialReceiptMaster = new MaterialReceiptBll();
     PurchaseInvoiceBll BllPurchaseInvoice = new PurchaseInvoiceBll();
     RejectionOutBll bllRejectionOut = new RejectionOutBll();
     try
     {
         foreach (DataGridViewRow dgvrow in dgvProduct.Rows)
         {
             if (dgvrow.Cells["dgvtxtmaterialReceiptDetailsId"].Value != null)
             {
                 if (dgvrow.Cells["dgvtxtmaterialReceiptDetailsId"].Value.ToString() != "0" || dgvrow.Cells["dgvtxtmaterialReceiptDetailsId"].Value.ToString() != string.Empty)
                 {
                     decMaterialReceiptDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtmaterialReceiptDetailsId"].Value.ToString());
                     inRef = bllMaterialReceiptMaster.MaterialReceiptDetailsReferenceCheck(decMaterialReceiptDetailsId);
                     if (inRef == 1)
                     {
                         if (inF1 == 1)
                         {
                             if (dgvrow.Cells["dgvtxtQty"].Value != null)
                             {
                                 if (dgvrow.Cells["dgvtxtQty"].Value.ToString() != "0" || dgvrow.Cells["dgvtxtQty"].Value.ToString() != string.Empty)
                                 {
                                     decQtyMaterialReceipt = Convert.ToDecimal(dgvrow.Cells["dgvtxtQty"].Value.ToString());
                                     decQtyRejectionOutAndPurchaseInvoice = Math.Round(bllMaterialReceiptMaster.MaterialReceiptQuantityDetailsAgainstPurcahseInvoiceAndRejectionOut(decMaterialReceiptDetailsId), PublicVariables._inNoOfDecimalPlaces);
                                     if (decQtyMaterialReceipt >= decQtyRejectionOutAndPurchaseInvoice)
                                     {
                                         inF1 = 1;
                                     }
                                     else
                                     {
                                         inF1 = 0;
                                         Messages.InformationMessage("Quantity in row " + (dgvrow.Index + 1) + " should be greater than " + decQtyRejectionOutAndPurchaseInvoice);
                                     }
                                 }
                                 else
                                 {
                                     inF1 = 0;
                                     Messages.InformationMessage("Quantity in row " + (dgvrow.Index + 1) + " should be greater than " + decQtyRejectionOutAndPurchaseInvoice);
                                 }
                             }
                             else
                             {
                                 inF1 = 0;
                                 Messages.InformationMessage("Quantity in row " + (dgvrow.Index + 1) + " should be greater than " + decQtyRejectionOutAndPurchaseInvoice);
                             }
                         }
                     }
                     else
                     {
                         inF1 = 1;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("MR11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return inF1;
 }
        /// <summary>
        /// Function toprint
        /// </summary>
        public void ReportPrint()
        {
            try
            {
                
                RejectionOutBll bllRejectionOut = new RejectionOutBll();
                decimal decMaterialReceiptNo = 0;
                if (cmbMaterialReceiptNo.SelectedIndex != -1)
                {
                    decMaterialReceiptNo = Convert.ToDecimal(cmbMaterialReceiptNo.SelectedValue.ToString());
                }
                strVoucherNo = txtVoucherNo.Text;
                strProductCode = txtProductCode.Text;
                DataSet dsRejectionOut = bllRejectionOut.RejectionOutReportPrinting(decmaterialReceiptMasterId, 1, Convert.ToDateTime(txtFromDate.Text), Convert.ToDateTime(txtToDate.Text), Convert.ToDecimal(cmbVoucherType.SelectedValue.ToString()), strVoucherNo, Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()), strProductCode, strProductName);
                frmReport frmReport = new frmReport();
                frmReport.MdiParent = formMDI.MDIObj;
                frmReport.RejectionOutReportPrinting(dsRejectionOut);
            }
            catch (Exception ex)
            {
                MessageBox.Show("RORP03:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

        }
 /// <summary>
 /// For VoucherNumberGeneration
 /// </summary>
 public void VoucherNumberGeneration()
 {
     try
     {
         TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
         RejectionOutBll bllRejectionOut = new RejectionOutBll();
         strVoucherNo = "0";
         if (strVoucherNo == string.Empty)
         {
             strVoucherNo = "0";
         }
         strVoucherNo = obj.VoucherNumberAutomaicGeneration(decRejectionOutVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
         if (Convert.ToDecimal(strVoucherNo) != bllRejectionOut.RejectionOutMasterGetMaxPlusOne(decRejectionOutVoucherTypeId))
         {
             strVoucherNo = bllRejectionOut.RejectionOutMasterGetMax(decRejectionOutVoucherTypeId).ToString();
             strVoucherNo = obj.VoucherNumberAutomaicGeneration(decRejectionOutVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
             if (bllRejectionOut.RejectionOutMasterGetMax(decRejectionOutVoucherTypeId) == "0")
             {
                 strVoucherNo = "0";
                 strVoucherNo = obj.VoucherNumberAutomaicGeneration(decRejectionOutVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
             }
         }
         if (isAutomatic)
         {
             SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
             //SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP();
             SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
             infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decRejectionOutVoucherTypeId, dtpDate.Value);
             strPrefix = infoSuffixPrefix.Prefix;
             strSuffix = infoSuffixPrefix.Suffix;
             decRejectionOutSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
             strRejectionOutNo = strPrefix + strVoucherNo + strSuffix;
             txtRejectionOutNo.Text = strRejectionOutNo;
             txtRejectionOutNo.ReadOnly = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("RO02:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }