/// <summary>
 /// Function toprint
 /// </summary>
 public void ReportPrint()
 {
     try
     {
         RejectionOutMasterSP spRejectionOutMaster = new RejectionOutMasterSP();
         decimal decMaterialReceiptNo = 0;
         if (cmbMaterialReceiptNo.SelectedIndex != -1)
         {
             decMaterialReceiptNo = Convert.ToDecimal(cmbMaterialReceiptNo.SelectedValue.ToString());
         }
         strVoucherNo   = txtVoucherNo.Text;
         strProductCode = txtProductCode.Text;
         DataSet   dsRejectionOut = spRejectionOutMaster.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
     {
         TransactionsGeneralFill obj = new TransactionsGeneralFill();
         RejectionOutMasterSP spRejectionOut = new RejectionOutMasterSP();
         strVoucherNo = "0";
         if (strVoucherNo == string.Empty)
         {
             strVoucherNo = "0";
         }
         strVoucherNo = obj.VoucherNumberAutomaicGeneration(decRejectionOutVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
         if (Convert.ToDecimal(strVoucherNo) != spRejectionOut.RejectionOutMasterGetMaxPlusOne(decRejectionOutVoucherTypeId))
         {
             strVoucherNo = spRejectionOut.RejectionOutMasterGetMax(decRejectionOutVoucherTypeId).ToString();
             strVoucherNo = obj.VoucherNumberAutomaicGeneration(decRejectionOutVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
             if (spRejectionOut.RejectionOutMasterGetMax(decRejectionOutVoucherTypeId) == "0")
             {
                 strVoucherNo = "0";
                 strVoucherNo = obj.VoucherNumberAutomaicGeneration(decRejectionOutVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
             }
         }
         if (isAutomatic)
         {
             SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP();
             SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
             infoSuffixPrefix = spSuffisprefix.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);
     }
 }
        /// <summary>
        /// Function toprint
        /// </summary>
        public void ReportPrint()
        {
            try
            {
                RejectionOutMasterSP spRejectionOutMaster = new RejectionOutMasterSP();
                decimal decMaterialReceiptNo = 0;
                if (cmbMaterialReceiptNo.SelectedIndex != -1)
                {
                    decMaterialReceiptNo = Convert.ToDecimal(cmbMaterialReceiptNo.SelectedValue.ToString());
                }
                strVoucherNo = txtVoucherNo.Text;
                strProductCode = txtProductCode.Text;
                DataSet dsRejectionOut = spRejectionOutMaster.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>
 /// Function to fill the grid based on conditions
 /// </summary>
 public void GridFill()
 {
     try
     {
         RejectionOutMasterSP spRejectionOutMaster = new RejectionOutMasterSP();
         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;
         DataTable dtbl     = spRejectionOutMaster.RejectionOutReportFill(strinvoiceNo, strProductCode, strProductName, decLedgerId, FromDate, ToDate, decReceiptMasterId, decVoucherTypeId);
         dgvRejectionOutReport.DataSource = dtbl;
     }
     catch (Exception ex)
     {
         MessageBox.Show("ROREP07:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to fill the grid based on conditions
        /// </summary>
        public void GridFill()
        {
            try
            {

                RejectionOutMasterSP spRejectionOutMaster = new RejectionOutMasterSP();
                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;
                DataTable dtbl = spRejectionOutMaster.RejectionOutReportFill(strinvoiceNo, strProductCode, strProductName, decLedgerId, FromDate, ToDate, decReceiptMasterId, decVoucherTypeId);
                dgvRejectionOutReport.DataSource = dtbl;

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