/// <summary>
        /// To Save Settlement Of Accounts
        /// </summary>
        /// <param name="settlementOfAcct"></param>
        /// <returns></returns>
        public int SaveSettlementOfAccounts(SettlementOfAccountsDTO settlementOfAcct)
        {
            settlementofaccount settlementOfAcctEntity = new settlementofaccount();

            using (TransactionScope transactionScope = new TransactionScope())
            {
                AutoMapper.Mapper.Map(settlementOfAcct, settlementOfAcctEntity);

                ESalesUnityContainer.Container.Resolve<IGenericRepository<settlementofaccount>>().Save(settlementOfAcctEntity);

                BookingService bookingService = new BookingService();
                BookingDTO bookingDetail = bookingService.GetBookingDetailByBookingId(settlementOfAcct.Account_Booking_Id, true);

                //Set money receipt issued status flag to true and save booking details in database
                bookingDetail.Booking_AccountSettled = true;
                bookingDetail.Booking_AccountSettledDate = DateTime.Now.Date;   // Added by ansharma on 26-Sep-2012

                bookingService.SaveAndUpdateBookingDetail(bookingDetail);

                transactionScope.Complete();
            }

            //return value
            return settlementOfAcctEntity.Account_Id;
        }
        /// <summary>
        /// Get Settlement Of Accounts By accountId
        /// </summary>
        /// <param name="accountId">Int32:accountId</param>
        /// <returns></returns>
        public SettlementOfAccountsDTO GetSettlementOfAccountsById(int accountId)
        {
            SettlementOfAccountsDTO settlementOfAcct = new SettlementOfAccountsDTO();

            AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<settlementofaccount>>()
                .GetSingle(item => item.Account_Id == accountId && item.Account_IsDeleted == false), settlementOfAcct);

            //return value
            return settlementOfAcct;
        }
    private void SetReportParameters(SettlementOfAccountsDTO settlementOfAcct, ReportViewer reportViewer)
    {
        string truckRegNo = string.Empty;
        decimal grossAmount = settlementOfAcct.Account_Quantity *  settlementOfAcct.booking.Booking_MaterialType_HandlingRate;
        decimal serviceTaxOnAmount = (grossAmount * settlementOfAcct.booking.Booking_MaterialType_ServiceTax) / 100;
        decimal educationCessOnAmount = (serviceTaxOnAmount * settlementOfAcct.booking.Booking_MaterialType_EducationCess) / 100;
        decimal higherEducationCessOnAmount = (serviceTaxOnAmount * settlementOfAcct.booking.Booking_MaterialType_HigherEducationCess) / 100;
        decimal netAmount = grossAmount + serviceTaxOnAmount + educationCessOnAmount + higherEducationCessOnAmount;
        
        ReportParameter SNo = new ReportParameter("SNo", settlementOfAcct.booking.Booking_Agent_AgentShortName + "/" + settlementOfAcct.Account_Id);
        ReportParameter Date = new ReportParameter("Date", Convert.ToDateTime(settlementOfAcct.Account_CreatedDate).ToString());
        ReportParameter CustName = new ReportParameter("CustName", settlementOfAcct.booking.Booking_Cust_UnitName);
        ReportParameter Address = new ReportParameter("Address", settlementOfAcct.booking.Booking_Cust_UnitAddress);
        ReportParameter District = new ReportParameter("District", settlementOfAcct.booking.Booking_Cust_District_Name);
        ReportParameter State = new ReportParameter("State", settlementOfAcct.booking.Booking_Cust_State_Name);
        ReportParameter MatTypeName = new ReportParameter("MatTypeName", settlementOfAcct.booking.Booking_MaterialType_MaterialName);
        ReportParameter Quantity = new ReportParameter("Quantity", Convert.ToString(settlementOfAcct.Account_Quantity));
        ReportParameter Rate = new ReportParameter("Rate", Convert.ToString(settlementOfAcct.booking.Booking_MaterialType_HandlingRate));
        ReportParameter Amount = new ReportParameter("Amount", Convert.ToString(String.Format("{0:F2}", grossAmount)));

        if (settlementOfAcct.booking.Booking_TruckType == true)
        {
            truckRegNo = settlementOfAcct.booking.Booking_StandaloneTruck_RegNo;            
        }
        else
        {
            truckRegNo = settlementOfAcct.booking.Booking_Truck_RegNo;
        }

        ReportParameter TruckNo = new ReportParameter("TruckNo", truckRegNo);
        ReportParameter InvoiceNo = new ReportParameter("InvoiceNo", settlementOfAcct.Account_InvoiceNumber);
        ReportParameter ServiceTax = new ReportParameter("ServiceTax", Convert.ToString(String.Format("{0:F2}", settlementOfAcct.booking.Booking_MaterialType_ServiceTax)));
        ReportParameter EducationCess = new ReportParameter("EducationCess", Convert.ToString(String.Format("{0:F2}", settlementOfAcct.booking.Booking_MaterialType_EducationCess)));
        ReportParameter HigherEducationCess = new ReportParameter("HigherEducationCess", Convert.ToString(String.Format("{0:F2}", settlementOfAcct.booking.Booking_MaterialType_HigherEducationCess)));

        CurrencyConvertor currenyInWords = new CurrencyConvertor();
        string amountInWords = currenyInWords.Convertor(Convert.ToString(String.Format("{0:F2}", netAmount)));
        ReportParameter RupeesInWords = new ReportParameter("RupeesInWords", amountInWords);
        ReportParameter TotalAmount = new ReportParameter("TotalAmount", Convert.ToString(String.Format("{0:F2}",netAmount)));

        ReportParameter ServiceTaxAmt = new ReportParameter("ServiceTaxAmt", Convert.ToString(String.Format("{0:F2}", serviceTaxOnAmount)));
        ReportParameter EducationCessAmt = new ReportParameter("EducationCessAmt", Convert.ToString(String.Format("{0:F2}", educationCessOnAmount)));
        ReportParameter HigherEducationCessAmt = new ReportParameter("HigherEducationCessAmt", Convert.ToString(String.Format("{0:F2}", higherEducationCessOnAmount)));

        reportViewer.LocalReport.SetParameters(new ReportParameter[] {SNo, Date, CustName, Address, District, State, 
            MatTypeName, Quantity, Rate, Amount, TruckNo, InvoiceNo, ServiceTax, EducationCess, HigherEducationCess, 
            RupeesInWords, TotalAmount, ServiceTaxAmt, EducationCessAmt, HigherEducationCessAmt});
    }
        public SettlementOfAccountsDTO GetLastSettlementOfAccountsByTruckNo(string truckNo)
        {
            SettlementOfAccountsDTO settlementOfAcct = new SettlementOfAccountsDTO();
            List<settlementofaccount> lstSettlementOfAcctDetail = ESalesUnityContainer.Container.Resolve<IGenericRepository<settlementofaccount>>()
                .GetQuery().Where(item => item.booking.truckdetail.Truck_RegNo == truckNo || item.booking.standalonetruck.StandaloneTruck_RegNo == truckNo).OrderByDescending(F => F.Account_CreatedDate).ToList();

            if (lstSettlementOfAcctDetail.Count > 0)
            {
                AutoMapper.Mapper.Map(lstSettlementOfAcctDetail[0], settlementOfAcct);
            }
            return settlementOfAcct;
        }
 /// <summary>
 /// Initialize DTO propeties with page values
 /// </summary>
 private SettlementOfAccountsDTO InitializeSettlementDTO()
 {
     SettlementOfAccountsDTO settlementOfAcct = new SettlementOfAccountsDTO();
     settlementOfAcct.Account_Booking_Id = Convert.ToInt32(ViewState[Globals.StateMgmtVariables.BOOKINGID]);
     settlementOfAcct.Account_Quantity = Convert.ToDecimal(txtQuantity.Text.Trim());
     settlementOfAcct.Account_CFormNo = txtCFormNo.Text.Trim();
     settlementOfAcct.Account_FormDNumber = txtFormDNo.Text.Trim();
     settlementOfAcct.Account_HGNumber = txtHologramNumber.Text.Trim();
     settlementOfAcct.Account_InvoiceNumber = txtInvoiceNo.Text.Trim();
     settlementOfAcct.Account_RoadPermitNo = txtRoadPermitNo.Text.Trim();
     settlementOfAcct.Account_GatePassNo = txtGatePassNo.Text.Trim();
     settlementOfAcct.Account_AdvanceReceived = Convert.ToDecimal(txtBlockedAmount.Text);
     settlementOfAcct.Account_TiscoRate = Convert.ToDecimal(txtTiscoRate.Text);
     settlementOfAcct.Account_HandlingServiceTax = Convert.ToDecimal(txtHndServiceTax.Text);
     settlementOfAcct.Account_HandlingRate = Convert.ToDecimal(txtHandlingRate.Text);
     settlementOfAcct.Account_HandlingECess = Convert.ToDecimal(txtHndEducationCess.Text);
     settlementOfAcct.Account_HandlingHECess = Convert.ToDecimal(txtHndHigherEducationCess.Text);
     settlementOfAcct.Account_TotalAmount = Convert.ToDecimal(txtTotalAmount.Text);
     settlementOfAcct.Account_Balance = Convert.ToDecimal(txtBalanceBlockedAmount.Text);
     settlementOfAcct.Account_CreatedBy = base.GetCurrentUserId();
     settlementOfAcct.Account_CreatedDate = DateTime.Now;
     settlementOfAcct.Account_Form27CId = Convert.ToInt32(ViewState["form27ID"]);
     return settlementOfAcct;
 }