private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (lstReadReport.Items.Count <= 0)
                {
                    MessageBox.ShowBox("MessageID526", BMC_Icon.Information);
                    return;
                }

                using (CReportViewer cReportViewer = new CReportViewer())
                {
                    ReadLiquidationReportRecords lstReadLiqRecords = lstReadReport.SelectedItem as ReadLiquidationReportRecords;
                    if (lstReadLiqRecords == null)
                    {
                        MessageBox.ShowBox("MessageID527", BMC_Icon.Information);
                        return;
                    }

                    cReportViewer.ShowLiquidationReportForRead(null, lstReadLiqRecords.ReadId);
                    cReportViewer.SetOwner(Window.GetWindow(this));
                    cReportViewer.Show();
                }
            }

            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtAdvanceToRetailer.Text))
                {
                    MessageBox.ShowBox("MessageID370", BMC_Icon.Information);
                    return;
                }

                decimal dAdvanceToRetailer = 0.0M;
                if (!CheckForValidAdvanceToRetailValue(out dAdvanceToRetailer))
                {
                    MessageBox.ShowBox("MessageID434", BMC_Icon.Information);
                    return;
                }

                System.Windows.Forms.DialogResult dr = MessageBox.ShowBox("MessageID371", BMC_Icon.Question, BMC_Button.YesNo);

                if (dr.ToString() == "Yes")
                {
                    //Update advance retailer value
                    //UpdateAdvanceRetailer();

                    //Calculate the retailer negative net

                    //CalculateRetailerNegative();
                    //CalculateCarriedForwardAmount();

                    if (Entity.ProfitShareGroupId > 0)
                    {

                        //Sp call for profit share details
                        CommonLiquidationDataContext objCommonLiquidation = new CommonLiquidationDataContext(CommonUtilities.ExchangeConnectionString);
                        int LiquidationProfitShareResult = objCommonLiquidation.PerformLiquidationForProfitShare(null, 
                                                                                                                    _BatchNo, 
                                                                                                                    _entity.ProfitShareGroupId,
                                                                                                                    _entity.ExpenseShareGroupID,
                                                                                                                    _entity.ExpenseShareAmount,
                                                                                                                    _entity.WriteOffAmount,
                                                                                                                    _entity.PayPeriodId,
                                                                                                                    _entity.Gross,
                                                                                                                    _entity.Tickets_Expected,
                                                                                                                    _entity.Net_Percentage,
                                                                                                                    _entity.Retailer_Negative_Net,
                                                                                                                    _entity.Net_Percentage,
                                                                                                                    _entity.Tickets_Paid,
                                                                                                                    _entity.Advance_To_Retailer,
                                                                                                                    _entity.Retailer_Share,
                                                                                                                    _entity.Balance_Due,
                                                                                                                    _entity.Retailer,
                                                                                                                    _entity.RetailerShareBeforeFixedExpense,
                                                                                                                    _entity.CarriedForwardExpense,
                                                                                                                    _entity.RetailerExpenseShareAmount,
                                                                                                                    _entity.FixedExpenseAmount,
                                                                                                                    _entity.PrevCarriedForwardExpense);

                        //Report
                        MessageBox.ShowBox("MessageID488", BMC_Icon.Information);
                        //calling Audit Method
                        Audit(true,_BatchNo);
                        System.Windows.Forms.DialogResult res = MessageBox.ShowBox("MessageID491", BMC_Icon.Question, BMC_Button.YesNo);
                        if (res == System.Windows.Forms.DialogResult.Yes)
                        {
                            using (CReportViewer cReportViewer = new CReportViewer())
                            {
                                LogManager.WriteLog("Report data fetched successfully from database", LogManager.enumLogLevel.Info);
                                cReportViewer.ShowLiquidationReportForRead(_BatchNo, null);
                                cReportViewer.ShowDialog();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.ShowBox("MessageID490", BMC_Icon.Information);
                        return;
                    }
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }

        }
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtAdvanceToRetailer.Text))
                {
                    MessageBox.ShowBox("MessageID370", BMC_Icon.Information);
                    return;
                }

                decimal dAdvanceToRetailer = 0.0M;
                if (!CheckForValidAdvanceToRetailValue(out dAdvanceToRetailer))
                {
                    MessageBox.ShowBox("MessageID434", BMC_Icon.Information);
                    return;
                }

                System.Windows.Forms.DialogResult dr = MessageBox.ShowBox("MessageID371", BMC_Icon.Question, BMC_Button.YesNo);

                if (dr.ToString() == "Yes")
                {
                    //Update advance retailer value
                    //UpdateAdvanceRetailer();

                    //Calculate the retailer negative net

                    //CalculateRetailerNegative();
                    //CalculateCarriedForwardAmount();

                    if (Entity.ProfitShareGroupId > 0)
                    {
                        //Sp call for profit share details
                        CommonLiquidationDataContext objCommonLiquidation = new CommonLiquidationDataContext(CommonUtilities.ExchangeConnectionString);
                        int LiquidationProfitShareResult = objCommonLiquidation.PerformLiquidationForProfitShare(null,
                                                                                                                 _BatchNo,
                                                                                                                 _entity.ProfitShareGroupId,
                                                                                                                 _entity.ExpenseShareGroupID,
                                                                                                                 _entity.ExpenseShareAmount,
                                                                                                                 _entity.WriteOffAmount,
                                                                                                                 _entity.PayPeriodId,
                                                                                                                 _entity.Gross,
                                                                                                                 _entity.Tickets_Expected,
                                                                                                                 _entity.Net_Percentage,
                                                                                                                 _entity.Retailer_Negative_Net,
                                                                                                                 _entity.Net_Percentage,
                                                                                                                 _entity.Tickets_Paid,
                                                                                                                 _entity.Advance_To_Retailer,
                                                                                                                 _entity.Retailer_Share,
                                                                                                                 _entity.Balance_Due,
                                                                                                                 _entity.Retailer,
                                                                                                                 _entity.RetailerShareBeforeFixedExpense,
                                                                                                                 _entity.CarriedForwardExpense,
                                                                                                                 _entity.RetailerExpenseShareAmount,
                                                                                                                 _entity.FixedExpenseAmount,
                                                                                                                 _entity.PrevCarriedForwardExpense);

                        //Report
                        MessageBox.ShowBox("MessageID488", BMC_Icon.Information);
                        //calling Audit Method
                        Audit(true, _BatchNo);
                        System.Windows.Forms.DialogResult res = MessageBox.ShowBox("MessageID491", BMC_Icon.Question, BMC_Button.YesNo);
                        if (res == System.Windows.Forms.DialogResult.Yes)
                        {
                            using (CReportViewer cReportViewer = new CReportViewer())
                            {
                                LogManager.WriteLog("Report data fetched successfully from database", LogManager.enumLogLevel.Info);
                                cReportViewer.ShowLiquidationReportForRead(_BatchNo, null);
                                cReportViewer.ShowDialog();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.ShowBox("MessageID490", BMC_Icon.Information);
                        return;
                    }
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
        private void btnConfirm_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (objCommonLiquidation.ProfitShareGroupId <= 0)
                {
                    MessageBox.ShowBox("MessageID490", BMC_Icon.Information);
                    return;
                }

                if (string.IsNullOrEmpty(txtAdvanceToRetailer.Text))
                {
                    MessageBox.ShowBox("MessageID370", BMC_Icon.Information);
                    return;
                }

                decimal dAdvanceToRetailer = 0.0M;
                if (!CheckForValidAdvanceToRetailValue(out dAdvanceToRetailer))
                {
                    MessageBox.ShowBox("MessageID434", BMC_Icon.Information);
                    return;
                }

                System.Windows.Forms.DialogResult dr = MessageBox.ShowBox("MessageID371", BMC_Icon.Question, BMC_Button.YesNo);

                if (dr.ToString() == "Yes")
                {
                    //Calculate the retailer negative net

                    CalculateRetailerNegative();
                    if (oReadLiquidationConfiguration.SaveLiquidation(objCommonLiquidation) == 0)
                    {
                        MessageBox.ShowBox("MessageID488", BMC_Icon.Information);
                        Audit(true, objCommonLiquidation.Read_No);

                        System.Windows.Forms.DialogResult res = MessageBox.ShowBox("MessageID251", BMC_Icon.Question, BMC_Button.YesNo);
                        if (res == System.Windows.Forms.DialogResult.Yes)
                        {
                            using (CReportViewer cReportViewer = new CReportViewer())
                            {
                                LogManager.WriteLog("Report data fetched successfully from database", LogManager.enumLogLevel.Info);

                                cReportViewer.ShowLiquidationReportForRead(null, objCommonLiquidation.Read_No);
                                cReportViewer.SetOwner(this);
                                

                                cReportViewer.Show();
                            }
                        }
                    }

                    else
                    {
                        MessageBox.ShowBox("MessageID489", BMC_Icon.Information);
                        return;
                    }
                    this.Close();
                }
            }

            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }
        private void CreateLiquidationReport()
        {
            try
            {
                if (Settings.SGVI_Enabled)
                {
                    CreateSGVILiquidationReport();
                    return;
                }
                IReports objReports = isCommonCDOforDeclaration ? ReportsBusinessObject.CreateInstance(ExchangeConst, TicketConst) : ReportsBusinessObject.CreateInstance();

                LogManager.WriteLog("Check whether the Liquidation performed for the batch or not-Starts", LogManager.enumLogLevel.Info);
                int? iLiquidationPerformed = 0;
                int isLiquidationPerformedForBatch = objReports.CheckLiquidationPerformed(_BatchID, ref iLiquidationPerformed);

                if (isLiquidationPerformedForBatch == 0)
                {
                    MessageBox.ShowBox("MessageID891", BMC_Icon.Information);
                    return;
                }

                using (CReportViewer cReportViewer = new CReportViewer())
                {
                    LogManager.WriteLog("Launch the liquidation report", LogManager.enumLogLevel.Info);
                    cReportViewer.ShowLiquidationReportForRead(_BatchID, null);
                    cReportViewer.SetOwner(Window.GetWindow(this));
                    cReportViewer.ShowDialog();
                }

                LogManager.WriteLog("ShowLiquidationReport Successfull", LogManager.enumLogLevel.Info);
            }

            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
            }
        }