public void GenerateReport()
        {
            try
            {
                if (ddlCompany.SelectedValue == null)
                {
                    pnlCriteria.Visible = false;
                }

                reportViewer1.LocalReport.EnableExternalImages = true;

                int minRows = 8;


                Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[22];

                string address = AppVars.objSubCompany.Address;
                string telNo   = string.Empty;



                string sortCode     = AppVars.objSubCompany.SortCode.ToStr();
                string accountNo    = AppVars.objSubCompany.AccountNo.ToStr();
                string accountTitle = AppVars.objSubCompany.AccountTitle.ToStr();
                string bank         = AppVars.objSubCompany.BankName.ToStr();

                string hasBankDetails = "1";
                if (string.IsNullOrEmpty(sortCode) && string.IsNullOrEmpty(accountNo) && string.IsNullOrEmpty(accountTitle) &&
                    string.IsNullOrEmpty(bank))
                {
                    hasBankDetails = "0";
                }

                if (!string.IsNullOrEmpty(sortCode))
                {
                    sortCode = "Sort Code : " + sortCode;
                }


                if (!string.IsNullOrEmpty(bank))
                {
                    bank = "Bank : " + bank;
                }


                if (!string.IsNullOrEmpty(accountTitle))
                {
                    accountTitle = "Account Title : " + accountTitle;
                }

                //   if (!string.IsNullOrEmpty(bank))
                //       bank = "Bank : " + bank;



                string website = AppVars.objSubCompany.WebsiteUrl.ToStr();
                if (!string.IsNullOrEmpty(website))
                {
                    website += " , ";
                }

                website += "Email:" + AppVars.objSubCompany.EmailAddress.ToStr();


                string companyNumber = AppVars.objSubCompany.CompanyNumber.ToStr();
                if (!string.IsNullOrEmpty(companyNumber))
                {
                    companyNumber = "Company Number: " + companyNumber;
                }

                string vatNumber = AppVars.objSubCompany.CompanyVatNumber.ToStr();
                if (!string.IsNullOrEmpty(vatNumber))
                {
                    vatNumber = "VAT Number: " + vatNumber;
                }



                param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address);

                param[18] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Footer", AppVars.objSubCompany.WebsiteUrl.ToStr());

                param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_MobileNo", "Mobile: " + AppVars.objSubCompany.EmergencyNo.ToStr());
                param[15] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Website", website);
                param[16] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Email", "Email: " + AppVars.objSubCompany.EmailAddress.ToStr());

                param[20] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyNumber", companyNumber);
                param[21] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_VATNumber", vatNumber);


                param[7]  = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_SortCode", sortCode);
                param[9]  = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountTitle", accountTitle);
                param[10] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Bank", bank);



                List <ClsLogo> objLogo = new List <ClsLogo>();
                objLogo.Add(new ClsLogo {
                    ImageInBytes = AppVars.objSubCompany.CompanyLogo != null ? AppVars.objSubCompany.CompanyLogo.ToArray() : null
                });
                ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo);
                this.reportViewer1.LocalReport.DataSources.Add(imageDataSource);

                string path = @"File:";
                param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Path", path);
                param[6] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyHeader", AppVars.objSubCompany.CompanyName.ToStr());



                int?companyId = this.DataSource.FirstOrDefault().DefaultIfEmpty().CompanyId;

                //decimal invoiceGrandTotal = this.DataSource.FirstOrDefault().DefaultIfEmpty().InvoiceTotal.ToDecimal() + this.DataSource.FirstOrDefault().DefaultIfEmpty().AdminFees.ToDecimal();
                var data = this.DataSource.FirstOrDefault().DefaultIfEmpty();



                telNo = "Tel No. " + AppVars.objSubCompany.TelephoneNo;



                if (!string.IsNullOrEmpty(accountNo))
                {
                    accountNo = "Account No : " + accountNo;
                }



                UM_Form_Template objTemplate = General.GetObject <UM_Form_Template>(c => c.UM_Form.FormName == this.Name && c.IsDefault == true);

                if (objTemplate.TemplateName.ToStr() == "Template3")
                {
                    minRows = 4;
                }

                string className = "Taxi_AppMain.ReportDesigns." + objTemplate.TemplateName.ToStr() + "_";

                if (objTemplate.TemplateName.ToStr() == "Template4")
                {
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptCompanyInvoice3.rdlc";
                }
                else if (objTemplate.TemplateName.ToStr() == "Template5")
                {
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptCompanyInvoice.rdlc";
                }
                else if (objTemplate.TemplateName.ToStr() == "Template6")
                {
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptCompanyInvoice.rdlc";
                    telNo += Environment.NewLine + "Fax No. " + AppVars.objSubCompany.Fax + Environment.NewLine + "Email. " + AppVars.objSubCompany.EmailAddress;
                }
                else
                {
                    if (data.HasOrderNo.ToBool() && data.HasBookedBy.ToBool())
                    {
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptCompanyInvoice.rdlc";
                    }
                    else if (data.HasOrderNo.ToBool() == false && data.HasBookedBy.ToBool())
                    {
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptCompanyInvoice2.rdlc";
                    }
                    else if (data.HasOrderNo.ToBool() == false && data.HasBookedBy.ToBool() == false)
                    {
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptCompanyInvoice3.rdlc";
                    }
                    else if (data.HasOrderNo.ToBool() == true && data.HasBookedBy.ToBool() == false)
                    {
                        this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptCompanyInvoice4.rdlc";
                    }
                }

                param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", telNo);


                param[8] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountNo", accountNo);

                decimal netAmount         = this.DataSource.Sum(c => c.Charges.ToDecimal() + c.ExtraDropCharges.ToDecimal() + c.ParkingCharges.ToDecimal() + c.WaitingCharges.ToDecimal() + c.MeetAndGreetCharges.ToDecimal() + c.CongtionCharges.ToDecimal());
                decimal invoiceGrandTotal = netAmount + data.AdminFees.ToDecimal();


                string  vat            = "0";
                decimal discountAmount = 0.00m;
                decimal valueAddedTax  = 0.0m;
                if (companyId != null)
                {
                    Gen_Company objCompany = General.GetObject <Gen_Company>(c => c.Id == companyId);

                    if (objCompany != null)
                    {
                        if (objCompany.HasVat.ToBool())
                        {
                            valueAddedTax = (invoiceGrandTotal * 20) / 100;
                            vat           = "1";
                        }

                        if (objCompany.DiscountPercentage.ToDecimal() > 0)
                        {
                            discountAmount = (invoiceGrandTotal * objCompany.DiscountPercentage.ToDecimal()) / 100;
                        }
                    }
                }

                invoiceGrandTotal = (invoiceGrandTotal + valueAddedTax) - discountAmount;



                bool departmentwise = this.DataSource.FirstOrDefault().DefaultIfEmpty().DepartmentWise.ToBool();
                bool costCenterWise = this.DataSource.FirstOrDefault().DefaultIfEmpty().CostCenterWise.ToBool();

                string grandTotal = string.Format("{0:c}", invoiceGrandTotal);
                grandTotal = grandTotal.Substring(1);

                string net = string.Format("{0:c}", netAmount);
                net = net.Substring(1);


                string discount = string.Format("{0:c}", discountAmount);
                discount = discount.Substring(1);



                param[17] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Discount", discount);


                param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_InvoiceTotal", grandTotal);

                param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasVat", vat);

                param[5]  = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_VAT", valueAddedTax.ToStr());
                param[11] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasDepartment", departmentwise ? "1" : "0");

                param[12] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Net", net);

                param[13] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasCostCenter", costCenterWise ? "1" : "0");

                param[19] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasBankDetails", hasBankDetails);


                reportViewer1.LocalReport.SetParameters(param);


                int cnt = this.DataSource.Count;

                //  int minRows = 8;

                if (cnt < minRows)
                {
                    for (int i = 0; i < minRows - cnt; i++)
                    {
                        this.DataSource.Add(new vu_Invoice {
                            Id = data.Id, BookingId = data.BookingId, HasBookedBy = data.HasBookedBy, HasOrderNo = data.HasOrderNo, HasPupilNo = data.HasPupilNo
                        });
                    }
                }



                this.vuInvoiceBindingSource.DataSource = this.DataSource;

                this.reportViewer1.ZoomPercent = 100;
                this.reportViewer1.ZoomMode    = Microsoft.Reporting.WinForms.ZoomMode.Percent;
                this.reportViewer1.RefreshReport();
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
예제 #2
0
        private void btnExportPDF_Click(object sender, EventArgs e)
        {
            int?     companyId = null;
            int?     driverId  = ddl_Driver.SelectedValue.ToIntorNull();
            DateTime?fromDate  = dtpFromDate.Value.ToDateTimeorNull();
            DateTime?tillDate  = dtpTillDate.Value.ToDateTimeorNull();

            string error = string.Empty;

            if (driverId == null)
            {
                error += "Required : Driver";
            }

            if (fromDate == null)
            {
                if (string.IsNullOrEmpty(error))
                {
                    error += Environment.NewLine;
                }

                error += "Required : From Date";
            }

            if (tillDate == null)
            {
                if (string.IsNullOrEmpty(error))
                {
                    error += Environment.NewLine;
                }

                error += "Required : To Date";
            }

            if (!string.IsNullOrEmpty(error))
            {
                ENUtils.ShowMessage(error);
                return;
            }


            //if (optCreditCard.ToggleState == ToggleState.On)
            //{
            //    companyId = General.GetObject<Gen_Company>(c => c.CompanyName.ToLower() == "credit card" || c.CompanyName.ToLower() == "creditcard").DefaultIfEmpty().Id;


            //}


            rptfrmDriverStatement frm = new rptfrmDriverStatement();

            int statementType = 0;

            if (optAccount.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
            {
                statementType = eStatementType.AccountStatement;
            }
            else if (optCash.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
            {
                statementType = eStatementType.CashStatement;
            }
            else if (optBoth.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
            {
                statementType = eStatementType.Both;
            }

            //var list = General.GetQueryable<Vu_BookingBase>(c => c.BookingStatusId == Enums.BOOKINGSTATUS.DISPATCHED && c.DriverId == driverId).AsEnumerable()
            //                .Where(b => (b.PickupDateTime.ToDate() >= fromDate && b.PickupDateTime.ToDate() <= tillDate))
            //                    .OrderByDescending(c => c.PickupDateTime).ToList();

            // frm.ReportHeading = "Driver Report for Date Range :" + string.Format("{0:dd/MM/yyyy}", fromDate) + " to " + string.Format("{0:dd/MM/yyyy}", tillDate);
            frm.DatePeriod = "For the Period : " + string.Format("{0:dd/MM/yyyy}", fromDate) + " to " + string.Format("{0:dd/MM/yyyy}", tillDate);


            UM_Form_Template objTemplate = General.GetObject <UM_Form_Template>(c => c.UM_Form.FormName == "rptfrmDriverStatement" && c.IsDefault == true);


            if (objTemplate.TemplateName.ToStr() == "Template1" || objTemplate.TemplateName.ToStr() == "Template2")
            {
                frm.DataSource = GetDataSource(driverId, statementType, fromDate, tillDate, companyId);
            }
            else if (objTemplate.TemplateName.ToStr() == "Template3")
            {
                frm.DataSource2   = GetDataSource2(fromDate, tillDate, driverId, companyId, statementType);
                frm.fromDate      = fromDate;
                frm.tillDate      = tillDate;
                frm.driverId      = driverId;
                frm.companyId     = null;
                frm.statementType = statementType;
            }

            //  frm.DataSource = GetDataSource(driverId, statementType, fromDate, tillDate);
            frm.ObjDriver = General.GetObject <Fleet_Driver>(c => c.Id == driverId).DefaultIfEmpty();

            frm.GenerateReport();
            frm.ExportReport();
        }
        public void GenerateReport()
        {
            int DriverId = ddlDriver.SelectedValue.ToInt();

            int companyId = ddlCompany.SelectedValue.ToInt();

            DateTime?fromDate = dtpFromDate.Value.ToDate();
            DateTime?tillDate = dtpTillDate.Value.ToDate();

            string error = string.Empty;

            if (fromDate == null)
            {
                if (string.IsNullOrEmpty(error))
                {
                    error += Environment.NewLine;
                }
                error += "Required : From Date";
            }

            if (tillDate == null)
            {
                if (string.IsNullOrEmpty(error))
                {
                    error += Environment.NewLine;
                }
                error += "Required : To Date";
            }

            if (!string.IsNullOrEmpty(error))
            {
                ENUtils.ShowMessage(error);
                return;
            }

            //this.Period = "For the Period : " + string.Format("{0:dd/MM/yyyy}", fromDate) + " to " + string.Format("{0:dd/MM/yyyy}", tillDate);
            int paymenttype = 0;

            if (opBoth.IsChecked)
            {
                paymenttype = 0;
            }
            if (opCash.IsChecked)
            {
                paymenttype = Enums.PAYMENT_TYPES.CASH;
            }


            //     ReInitializeReportViewer();

            string reportPath = "Taxi_AppMain.ReportDesigns.";

            if (objSubCompany == null)
            {
                objSubCompany = AppVars.objSubCompany;
            }


            reportViewer1.LocalReport.EnableExternalImages = true;

            Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[4];

            string address = objSubCompany.Address;
            string telNo   = "Tel No. " + objSubCompany.TelephoneNo;

            UM_Form_Template objTemplate = General.GetObject <UM_Form_Template>(c => c.UM_Form.FormName == this.Name && c.IsDefault == true);

            string FromDate = string.Empty;
            string ToDate   = string.Empty;

            FromDate = string.Format("{0:MMMM dd,yyyy}", dtpFromDate.Value);
            ToDate   = string.Format("{0:MMMM dd,yyyy}", dtpTillDate.Value);


            //List<ClsLogo> objLogo = new List<ClsLogo>();
            //objLogo.Add(new ClsLogo { ImageInBytes = objSubCompany.CompanyLogo != null ? objSubCompany.CompanyLogo.ToArray() : null });

            //ClsLogoBindingSource.DataSource = objLogo;

            param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyName", objSubCompany.CompanyName.ToStr().Trim());
            param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_FromDate", FromDate);
            param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_ToDate", ToDate);
            param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_ReportDate", DateTime.Now.ToString());

            reportViewer1.LocalReport.SetParameters(param);

            this.reportViewer1.LocalReport.ReportEmbeddedResource = reportPath + "rptDriverCommissionDetailReport.rdlc";

            using (TaxiDataContext db = new TaxiDataContext())
            {
                this.stp_DriverCommisionDetailReportResultBindingSource.DataSource = db.stp_DriverCommisionDetailReport(fromDate, tillDate, DriverId, paymenttype, companyId).ToList();
            }

            this.reportViewer1.ZoomPercent = 100;
            this.reportViewer1.SetDisplayMode(DisplayMode.Normal);
            this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.Percent;

            this.reportViewer1.LocalReport.Refresh();
            this.reportViewer1.Refresh();
        }
        public void GenerateReport()
        {
            if (ddlCustomer.SelectedValue == null)
            {
                pnlCriteria.Visible = false;
            }

            reportViewer1.LocalReport.EnableExternalImages = true;

            Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[10];

            string address = AppVars.objSubCompany.Address;
            string telNo   = "Tel No. " + AppVars.objSubCompany.TelephoneNo;


            string sortCode     = AppVars.objSubCompany.SortCode.ToStr();
            string accountNo    = AppVars.objSubCompany.AccountNo.ToStr();
            string accountTitle = AppVars.objSubCompany.AccountTitle.ToStr();
            string bank         = AppVars.objSubCompany.BankName.ToStr();

            if (!string.IsNullOrEmpty(sortCode))
            {
                sortCode = "Sort Code : " + sortCode;
            }

            if (!string.IsNullOrEmpty(accountNo))
            {
                accountNo = "Account No : " + accountNo;
            }

            if (!string.IsNullOrEmpty(accountTitle))
            {
                accountTitle = "Account Title : " + accountTitle;
            }

            if (!string.IsNullOrEmpty(bank))
            {
                bank = "Bank : " + bank;
            }

            UM_Form_Template objTemplate = General.GetObject <UM_Form_Template>(c => c.UM_Form.FormName == this.Name && c.IsDefault == true);


            string className = "Taxi_AppMain.ReportDesigns." + objTemplate.TemplateName.ToStr() + "_";

            if (objTemplate.TemplateName.ToStr() == "Template1")
            {
                this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptCustomerInvoice.rdlc";
            }
            else if (objTemplate.TemplateName.ToStr() == "Template2")
            {
                this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptCustomerInvoice.rdlc";
            }

            param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address);
            param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", telNo);



            List <ClsLogo> objLogo = new List <ClsLogo>();

            objLogo.Add(new ClsLogo {
                ImageInBytes = AppVars.objSubCompany.CompanyLogo != null ? AppVars.objSubCompany.CompanyLogo.ToArray() : null
            });
            ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo);

            this.reportViewer1.LocalReport.DataSources.Add(imageDataSource);

            string path = @"File:";

            param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Path", path);


            //   int? companyId = this.DataSource.FirstOrDefault().DefaultIfEmpty().CompanyId;



            decimal invoiceGrandTotal = this.DataSource.FirstOrDefault().DefaultIfEmpty().InvoiceTotal.ToDecimal() + this.DataSource.FirstOrDefault().DefaultIfEmpty().AdminFees.ToDecimal();
            string  grandTotal        = string.Format("{0:c}", invoiceGrandTotal);

            grandTotal = grandTotal.Substring(1);
            param[3]   = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_InvoiceTotal", grandTotal);


            param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyHeader", AppVars.objSubCompany.CompanyName.ToStr());

            param[5] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_SortCode", sortCode);
            param[6] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountNo", accountNo);
            param[7] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountTitle", accountTitle);
            param[8] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Bank", bank);
            param[9] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Email", "Email: " + AppVars.objSubCompany.EmailAddress.ToStr());

            //string vat = "0";
            //decimal valueAddedTax = 0.0m;
            //if (companyId != null)
            //{
            //    Gen_Company objCompany = General.GetObject<Gen_Company>(c => c.Id == companyId);

            //    if (objCompany != null)
            //    {
            //        if (objCompany.HasVat.ToBool())
            //        {
            //            valueAddedTax = (invoiceGrandTotal * 20) / 100;
            //            vat = "1";

            //        }

            //    }

            //}

            // invoiceGrandTotal = invoiceGrandTotal + valueAddedTax;


            //      param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasVat", vat);

            //           param[5] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_VAT", valueAddedTax.ToStr());


            reportViewer1.LocalReport.SetParameters(param);



            this.vuInvoiceBindingSource.DataSource = this.DataSource;

            this.reportViewer1.ZoomPercent = 100;
            this.reportViewer1.ZoomMode    = Microsoft.Reporting.WinForms.ZoomMode.Percent;
            this.reportViewer1.RefreshReport();
        }
예제 #5
0
        public override void Print()
        {
            try
            {
                int?companyId = null;

                int?     driverId = ddl_Driver.SelectedValue.ToIntorNull();
                DateTime?fromDate = dtpFromDate.Value.ToDateTimeorNull();
                DateTime?tillDate = dtpTillDate.Value.ToDateTimeorNull();

                string error = string.Empty;

                if (driverId == null)
                {
                    error += "Required : Driver";
                }

                if (fromDate == null)
                {
                    if (string.IsNullOrEmpty(error))
                    {
                        error += Environment.NewLine;
                    }

                    error += "Required : From Date";
                }

                if (tillDate == null)
                {
                    if (string.IsNullOrEmpty(error))
                    {
                        error += Environment.NewLine;
                    }

                    error += "Required : To Date";
                }

                if (!string.IsNullOrEmpty(error))
                {
                    ENUtils.ShowMessage(error);
                    return;
                }

                int statementType = 0;

                //int creditCardAccountId = 0;

                //if (chkExcludeCC.Checked)
                //{
                //    creditCardAccountId = General.GetObject<Gen_Company>(c => c.CompanyName.ToUpper().Replace(" ", "").Trim() == "CREDITCARD").DefaultIfEmpty().Id;
                //}



                //if (optCreditCard.ToggleState == ToggleState.On)
                //{
                //    companyId = General.GetObject<Gen_Company>(c => c.CompanyName.ToLower() == "credit card" || c.CompanyName.ToLower() == "creditcard").DefaultIfEmpty().Id;


                //}



                rptfrmDriverStatement frm = new rptfrmDriverStatement();


                frm.objSubCompany = General.GetObject <Gen_SubCompany>(c => c.Id == ddlSubCompany.SelectedValue.ToInt());

                if (optAccount.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
                {
                    statementType = eStatementType.AccountStatement;
                }
                else if (optCash.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
                {
                    statementType = eStatementType.CashStatement;
                }

                else if (optBoth.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
                {
                    statementType = eStatementType.Both;
                }
                else if (optCreditCard.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
                {
                    statementType = eStatementType.CREDITCARD;
                }


                UM_Form_Template objTemplate = General.GetObject <UM_Form_Template>(c => c.UM_Form.FormName == "rptfrmDriverStatement" && c.IsDefault == true);


                if (objTemplate.TemplateName.ToStr() == "Template1" || objTemplate.TemplateName.ToStr() == "Template2")
                {
                    frm.DataSource = GetDataSource(driverId, statementType, fromDate, tillDate, companyId);
                }
                else if (objTemplate.TemplateName.ToStr() == "Template3")
                {
                    frm.DataSource2   = GetDataSource2(fromDate, tillDate, driverId, companyId, statementType);
                    frm.fromDate      = fromDate;
                    frm.tillDate      = tillDate;
                    frm.driverId      = driverId;
                    frm.companyId     = null;
                    frm.statementType = statementType;
                }



                frm.Rent = ChkRent.Checked == true?txtRent.Value.ToInt() : 0;


                frm.ObjDriver = General.GetObject <Fleet_Driver>(c => c.Id == driverId).DefaultIfEmpty();


                frm.DatePeriod    = "For the Period : " + string.Format("{0:dd/MM/yyyy}", fromDate) + " to " + string.Format("{0:dd/MM/yyyy}", tillDate);
                frm.StatementType = statementType;
                frm.GenerateReport();

                DockWindow doc = UI.MainMenuForm.MainMenuFrm.GetDockByName("rptfrmDriverStatement1");

                if (doc != null)
                {
                    doc.Close();
                }
                UI.MainMenuForm.MainMenuFrm.ShowForm(frm);
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        public void LoadReport()
        {
            try
            {
                if (fromDate.Value != null && fromDate.Value.Value.Year == 1753)
                {
                    fromDate.Value = null;
                }

                if (tillDate.Value != null && tillDate.Value.Value.Year == 1753)
                {
                    tillDate.Value = null;
                }

                DateTime?fromDates = fromDate.Value.ToDate();
                DateTime?tillDates = tillDate.Value.ToDate();

                string error = string.Empty;


                if (fromDates == null)
                {
                    if (string.IsNullOrEmpty(error))
                    {
                        error += Environment.NewLine;
                    }

                    error += "Required : From Date";
                }

                if (tillDates == null)
                {
                    if (string.IsNullOrEmpty(error))
                    {
                        error += Environment.NewLine;
                    }

                    error += "Required : To Date";
                }
                if (!string.IsNullOrEmpty(error))
                {
                    ENUtils.ShowMessage(error);
                    return;
                }

                TimeSpan tillTime = TimeSpan.Zero;
                TimeSpan.TryParse("23:59:59", out tillTime);

                tillDates = tillDates + tillTime;



                this.reportViewer1.LocalReport.EnableExternalImages = true;
                UM_Form_Template objTemplate = General.GetObject <UM_Form_Template>(c => c.UM_Form.FormName == this.Name && c.IsDefault == true);

                if (objTemplate == null)
                {
                    ENUtils.ShowMessage("Report Template is not defined in Settings");
                    return;
                }

                string className = "Taxi_AppMain.ReportDesigns." + objTemplate.TemplateName.ToStr() + "_";

                if (objTemplate.TemplateName.ToStr() == "Template1")
                {
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = "Taxi_AppMain.ReportDesigns." + "rptFutureJobDiarySheet.rdlc";
                }
                else if (objTemplate.TemplateName.ToStr() == "Template2")
                {
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptFutureJobDiarySheet.rdlc";
                    //rptDriverCommisionExpenses
                }


                var list = new TaxiDataContext().stp_FutureJobDiarySheet(fromDates, tillDates, ddlCompany.SelectedValue.ToInt()).ToList();

                this.stp_FutureJobDiarySheetResultBindingSource.DataSource = list;



                Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[0];
                if (objTemplate.TemplateName.ToStr() == "Template2")
                {
                    param = new Microsoft.Reporting.WinForms.ReportParameter[5];

                    string address = AppVars.objSubCompany.Address;
                    string telNo   = "Tel No. " + AppVars.objSubCompany.TelephoneNo;
                    string heading = string.Empty;
                    if (fromDates != null && tillDates != null)
                    {
                        heading = string.Format("{0:dd/MM/yy HH:mm}", fromDates) + " to " + string.Format("{0:dd/MM/yy HH:mm}", tillDates);
                    }
                    param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address);
                    param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", telNo);

                    this.ReportHeading = heading;

                    param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalJobs", list.Count.ToStr());
                    param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Heading", heading);

                    param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyHeader", AppVars.objSubCompany.CompanyName.ToStr());
                }
                //List<ClsLogo> objLogo = new List<ClsLogo>();
                //objLogo.Add(new ClsLogo { ImageInBytes = AppVars.objSubCompany.CompanyLogo != null ? AppVars.objSubCompany.CompanyLogo.ToArray() : null });
                //ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo);
                //this.reportViewer1.LocalReport.DataSources.Add(imageDataSource);
                reportViewer1.LocalReport.SetParameters(param);
                this.reportViewer1.ZoomPercent = 100;
                this.reportViewer1.ZoomMode    = Microsoft.Reporting.WinForms.ZoomMode.Percent;
                this.reportViewer1.RefreshReport();
                IsReportLoded = true;
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        private void LoadReport()
        {
            try
            {
                DateTime?StartDate = dtpFromDate.Value;
                DateTime?TillDate  = dtpTillDate.Value;
                if (TillDate != null)
                {
                    TillDate = TillDate + TimeSpan.Parse("23:59:59");
                }


                UM_Form_Template objTemplate = null;
                objTemplate = General.GetObject <UM_Form_Template>(c => c.UM_Form.FormName == this.Name && c.IsDefault == true);

                //if (objTemplate == null)
                //{
                //    ENUtils.ShowMessage("Report Template is not defined in Settings");
                //    return;
                //}



                if (objTemplate != null && objTemplate.TemplateName.ToStr() == "Template2")
                {
                    string className = "Taxi_AppMain.ReportDesigns." + objTemplate.TemplateName.ToStr() + "_";

                    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptAccountInvoiceSummary.rdlc";

                    if (chkAll.Checked)
                    {
                        using (TaxiDataContext context = new TaxiDataContext())
                        {
                            var invoiceTemp = context.Invoices.Where(w => (w.InvoiceDate >= StartDate && w.InvoiceDate <= TillDate) && w.Gen_Company != null)
                                              .Select(w => new AccountInvoiceSummaryModel
                            {
                                InviceNo           = w.InvoiceNo,
                                InvoiceDate        = w.InvoiceDate,
                                Id                 = w.Id,
                                AccountName        = w.Gen_Company.CompanyName,
                                TotalInvoice       = w.InvoiceTotal,
                                TotalJobs          = w.Invoice_Charges.Where(x => x.InvoiceId == w.Id).Count(),
                                VAT                = w.Gen_Company.HasVat == true ? (w.InvoiceTotal * 20) / 100 : 0.00m,
                                TotalDriverCharges = w.Invoice_Charges.Where(x => x.InvoiceId == w.Id).Sum(x => (x.Booking.FareRate + x.Booking.CongtionCharges + x.Booking.MeetAndGreetCharges)),
                                Margin             = (w.InvoiceTotal) - (w.Invoice_Charges.Where(x => x.InvoiceId == w.Id).Sum(x => (x.Booking.FareRate + x.Booking.CongtionCharges + x.Booking.MeetAndGreetCharges)))
                            }).OrderByDescending(w => w.InvoiceDate).ToList();
                            this.AccountInvoiceSummaryModelBindingSource.DataSource = invoiceTemp;
                        }
                    }
                    else
                    {
                        using (TaxiDataContext context = new TaxiDataContext())
                        {
                            var invoiceTemp = context.Invoices.Where(w => (w.InvoiceDate >= StartDate && w.InvoiceDate <= TillDate) && w.Gen_Company != null && w.CompanyId == ddlCompany.SelectedValue.ToInt())
                                              .Select(w => new AccountInvoiceSummaryModel
                            {
                                InviceNo           = w.InvoiceNo,
                                InvoiceDate        = w.InvoiceDate,
                                Id                 = w.Id,
                                AccountName        = w.Gen_Company.CompanyName,
                                TotalInvoice       = w.InvoiceTotal,
                                TotalJobs          = w.Invoice_Charges.Where(x => x.InvoiceId == w.Id).Count(),
                                VAT                = w.Gen_Company.HasVat == true ? (w.InvoiceTotal * 20) / 100 : 0.00m,   //.Where(x => x.InvoiceId == w.Id).Sum(x => (x.Booking.CompanyPrice + x.Booking.ParkingCharges + x.Booking.WaitingCharges)) * 20) / 100 : 0.00m,
                                TotalDriverCharges = w.Invoice_Charges.Where(x => x.InvoiceId == w.Id).Sum(x => (x.Booking.FareRate + x.Booking.CongtionCharges + x.Booking.MeetAndGreetCharges)),
                                Margin             = (w.InvoiceTotal) - (w.Invoice_Charges.Where(x => x.InvoiceId == w.Id).Sum(x => (x.Booking.FareRate + x.Booking.CongtionCharges + x.Booking.MeetAndGreetCharges)))
                            }).OrderByDescending(w => w.InvoiceDate).ToList();
                            this.AccountInvoiceSummaryModelBindingSource.DataSource = invoiceTemp;
                        }
                        IsLoaded = true;
                    }
                }
                else
                {
                    if (chkAll.Checked)
                    {
                        using (TaxiDataContext context = new TaxiDataContext())
                        {
                            var invoiceTemp = context.Invoices.Where(w => (w.InvoiceDate >= StartDate && w.InvoiceDate <= TillDate) && w.Gen_Company != null)
                                              .Select(w => new AccountInvoiceSummaryModel
                            {
                                InviceNo    = w.InvoiceNo,
                                InvoiceDate = w.InvoiceDate,
                                Id          = w.Id,
                                AccountCode = w.Gen_Company.CompanyCode,
                                AccountName = w.Gen_Company.CompanyName,
                                TotalJobs   = w.Invoice_Charges.Where(x => x.InvoiceId == w.Id).Count(),
                                TotalAmount = w.Invoice_Charges.Where(x => x.InvoiceId == w.Id).Sum(x => (x.Booking.CompanyPrice + x.Booking.ParkingCharges + x.Booking.WaitingCharges)),
                                VAT         = w.Gen_Company.HasVat == true ? (w.Invoice_Charges.Where(x => x.InvoiceId == w.Id).Sum(x => (x.Booking.CompanyPrice + x.Booking.ParkingCharges + x.Booking.WaitingCharges)) * 20) / 100 : 0.00m,
                            }).OrderByDescending(w => w.InvoiceDate).ToList();
                            this.AccountInvoiceSummaryModelBindingSource.DataSource = invoiceTemp;
                        }
                    }
                    else
                    {
                        using (TaxiDataContext context = new TaxiDataContext())
                        {
                            var invoiceTemp = context.Invoices.Where(w => (w.InvoiceDate >= StartDate && w.InvoiceDate <= TillDate) && w.Gen_Company != null && w.CompanyId == ddlCompany.SelectedValue.ToInt())
                                              .Select(w => new AccountInvoiceSummaryModel
                            {
                                InviceNo    = w.InvoiceNo,
                                InvoiceDate = w.InvoiceDate,
                                Id          = w.Id,
                                AccountCode = w.Gen_Company.CompanyCode,
                                AccountName = w.Gen_Company.CompanyName,
                                TotalJobs   = w.Invoice_Charges.Where(x => x.InvoiceId == w.Id).Count(),
                                TotalAmount = w.Invoice_Charges.Where(x => x.InvoiceId == w.Id).Sum(x => (x.Booking.CompanyPrice + x.Booking.ParkingCharges + x.Booking.WaitingCharges)),
                                VAT         = w.Gen_Company.HasVat == true ? (w.Invoice_Charges.Where(x => x.InvoiceId == w.Id).Sum(x => (x.Booking.CompanyPrice + x.Booking.ParkingCharges + x.Booking.WaitingCharges)) * 20) / 100 : 0.00m,
                            }).OrderByDescending(w => w.InvoiceDate).ToList();

                            this.AccountInvoiceSummaryModelBindingSource.DataSource = invoiceTemp;
                        }
                        IsLoaded = true;
                    }
                }

                Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[3];
                param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Period", "Period: " + StartDate.Value.ToString("dd/MM/yyyy") + " - " + TillDate.Value.ToString("dd/MM/yyyy"));
                param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyName", AppVars.objSubCompany.CompanyName);
                param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", AppVars.objSubCompany.Address);
                reportViewer1.LocalReport.SetParameters(param);

                List <ClsLogo> objLogo = new List <ClsLogo>();
                objLogo.Add(new ClsLogo {
                    ImageInBytes = AppVars.objSubCompany.CompanyLogo != null ? AppVars.objSubCompany.CompanyLogo.ToArray() : null
                });
                ReportDataSource imageDataSource = new ReportDataSource("DSLogo", objLogo);
                this.reportViewer1.LocalReport.DataSources.Add(imageDataSource);
                this.reportViewer1.SetDisplayMode(DisplayMode.Normal);
                this.reportViewer1.ZoomPercent = 100;
                this.reportViewer1.ZoomMode    = Microsoft.Reporting.WinForms.ZoomMode.Percent;
                reportViewer1.RefreshReport();
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        public void GenerateReport()
        {
            try
            {
                int?     companyId = null;
                int?     driverId  = ddl_Driver.SelectedValue.ToIntorNull();
                DateTime?fromDate  = dtpFromDate.Value.ToDateTimeorNull();
                DateTime?tillDate  = dtpTillDate.Value.ToDateTimeorNull();

                string error = string.Empty;

                if (driverId == null)
                {
                    error += "Required : Driver";
                }

                if (fromDate == null)
                {
                    if (string.IsNullOrEmpty(error))
                    {
                        error += Environment.NewLine;
                    }

                    error += "Required : From Date";
                }

                if (tillDate == null)
                {
                    if (string.IsNullOrEmpty(error))
                    {
                        error += Environment.NewLine;
                    }

                    error += "Required : To Date";
                }

                if (!string.IsNullOrEmpty(error))
                {
                    ENUtils.ShowMessage(error);
                    return;
                }


                if (optCreditCard.ToggleState == ToggleState.On)
                {
                    companyId = General.GetObject <Gen_Company>(c => c.CompanyName.ToLower() == "credit card" || c.CompanyName.ToLower() == "creditcard").DefaultIfEmpty().Id;
                }



                int statementType = 0;
                if (optAccount.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On || optCreditCard.ToggleState == ToggleState.On)
                {
                    statementType = eStatementType.AccountStatement;
                }
                else if (optCash.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
                {
                    statementType = eStatementType.CashStatement;
                }
                else if (optBoth.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
                {
                    statementType = eStatementType.Both;
                }
                StatementType = statementType;
                //var list = General.GetQueryable<Vu_BookingBase>(c => c.BookingStatusId == Enums.BOOKINGSTATUS.DISPATCHED && c.DriverId == driverId).AsEnumerable()
                //                .Where(b => (b.PickupDateTime.ToDate() >= fromDate && b.PickupDateTime.ToDate() <= tillDate))
                //                    .OrderByDescending(c => c.PickupDateTime).ToList();

                // frm.ReportHeading = "Driver Report for Date Range :" + string.Format("{0:dd/MM/yyyy}", fromDate) + " to " + string.Format("{0:dd/MM/yyyy}", tillDate);
                if (ChkRent.Checked == true)
                {
                    Rent = txtRent.Value.ToInt();
                }
                else
                {
                    Rent = 0;
                }
                DatePeriod = "For the Period : " + string.Format("{0:dd/MM/yyyy}", fromDate) + " to " + string.Format("{0:dd/MM/yyyy}", tillDate);
                ObjDriver  = General.GetObject <Fleet_Driver>(c => c.Id == driverId).DefaultIfEmpty();

                this.DataSource = GetDataSource(driverId, statementType, fromDate, tillDate, companyId);
                Microsoft.Reporting.WinForms.ReportParameter[] param = null;

                UM_Form_Template objTemplate = General.GetObject <UM_Form_Template>(c => c.UM_Form.FormName == "rptfrmDriverStatement" && c.IsDefault == true);


                string className = "Taxi_AppMain.ReportDesigns." + objTemplate.TemplateName.ToStr() + "_";

                if (objTemplate.TemplateName.ToStr() == "Template1")
                {
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc";
                    param = new Microsoft.Reporting.WinForms.ReportParameter[19];
                }
                else if (objTemplate.TemplateName.ToStr() == "Template2")
                {
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc";
                    param = new Microsoft.Reporting.WinForms.ReportParameter[19];
                }
                else if (objTemplate.TemplateName.ToStr() == "Template3")
                {
                    GenerateReport3();
                    return;
                    //  this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc";
                    //  param = new Microsoft.Reporting.WinForms.ReportParameter[26];
                }

                reportViewer1.LocalReport.EnableExternalImages = true;



                string address = AppVars.objSubCompany.Address;
                string telNo   = "Tel No. " + AppVars.objSubCompany.TelephoneNo;

                param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address);
                param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", telNo);



                List <ClsLogo> objLogo = new List <ClsLogo>();
                objLogo.Add(new ClsLogo {
                    ImageInBytes = AppVars.objSubCompany.CompanyLogo != null ? AppVars.objSubCompany.CompanyLogo.ToArray() : null
                });
                ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo);
                this.reportViewer1.LocalReport.DataSources.Add(imageDataSource);

                string path = @"File:";
                param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Path", path);
                param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Period", this.DatePeriod);


                // Summary Calculations
                decimal JobsSum   = this.DataSource.Sum(c => c.TotalCharges.ToDecimal());
                int     jobsCnt   = this.DataSource.Count;
                string  jobsTotal = string.Format("{0:c}", JobsSum);
                jobsTotal = jobsTotal.Substring(1);
                jobsTotal = jobsTotal.Insert(0, "£ ");
                decimal zeroValue = 0.00m;
                string  zeroStr   = string.Format("{0:c}", zeroValue);
                zeroStr = zeroStr.Substring(1);
                zeroStr = zeroStr.Insert(0, "£ ");



                decimal totalCashAccountAmount = this.DataSource.Where(c => c.CompanyId != null && c.AccountTypeId.ToInt() == Enums.ACCOUNT_TYPE.CASH &&
                                                                       c.DriverCommissionType.ToStr() == "Amount").Sum(c => c.DriverCommission.ToDecimal());

                string totalCashAccountAmountStr = string.Format("{0:c}", totalCashAccountAmount);
                totalCashAccountAmountStr = totalCashAccountAmountStr.Substring(1);
                totalCashAccountAmountStr = totalCashAccountAmountStr.Insert(0, "£ ");

                string  totalAccountBookings        = this.DataSource.Count(c => c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.ACCOUNT).ToStr();
                decimal totalAccountCharges         = this.DataSource.Where(c => c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.ACCOUNT).Sum(c => c.TotalCharges.ToDecimal());
                string  totalAccountBookingsCharges = string.Format("{0:c}", totalAccountCharges).Substring(1);
                totalAccountBookingsCharges = totalAccountBookingsCharges.Insert(0, "£ ");

                string totalCashBooking        = this.DataSource.Count(c => c.CompanyId == null || (c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.CASH)).ToStr();
                string totalCashBookingCharges = string.Format("{0:c}", this.DataSource.Where(c => c.CompanyId == null || (c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.CASH))
                                                               .Sum(c => c.TotalCharges.ToDecimal()));
                totalCashBookingCharges = totalCashBookingCharges.Substring(1);
                totalCashBookingCharges = totalCashBookingCharges.Insert(0, "£ ");

                decimal driverMonthlyRent = 0;

                if (Rent > 0)
                {
                    driverMonthlyRent = (Rent).ToDecimal() + totalCashAccountAmount;
                }
                else
                {
                    driverMonthlyRent = ObjDriver.DriverMonthlyRent.ToDecimal() + totalCashAccountAmount;
                }


                string driverMonthlyRentRate = string.Format("{0:c}", driverMonthlyRent);
                driverMonthlyRentRate = driverMonthlyRentRate.Substring(1);
                driverMonthlyRentRate = driverMonthlyRentRate.Insert(0, "£ ");


                decimal driverOwed     = totalAccountCharges - driverMonthlyRent;
                string  driverOwedRate = "£ " + string.Format("{0:#.00}", driverOwed);


                if (StatementType == 2)
                {
                    driverMonthlyRentRate = "£ 0.00";

                    driverOwedRate = jobsTotal;
                }

                //UM_Form_Template objTemplate = General.GetObject<UM_Form_Template>(c => c.UM_Form.FormName == this.Name && c.IsDefault == true);


                //string className = "Taxi_AppMain.ReportDesigns." + objTemplate.TemplateName.ToStr() + "_";

                //if (objTemplate.TemplateName.ToStr() == "Template1")
                //{
                //    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc";

                //}
                //else if (objTemplate.TemplateName.ToStr() == "Template2")
                //{
                //    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc";
                //}
                //else if (objTemplate.TemplateName.ToStr() == "Template3")
                //{
                //    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc";
                //}



                param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_JobsTotal", jobsTotal);

                param[5] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AdditionsQuantity", totalAccountBookings.ToStr() + " account booking");
                param[6] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AdditionsAccountsGross", totalAccountBookingsCharges);
                param[7] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AdditionsAccountsGrossTotal", totalAccountBookingsCharges);



                param[8]  = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DeductionsCashQuantity", totalCashBooking + " cash booking");
                param[9]  = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DeductionsCashGross", totalCashBookingCharges);
                param[10] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DeductionsCashGrossTotal", totalCashBookingCharges);

                param[11] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalAdditions", totalAccountBookingsCharges);
                param[12] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalDeductions", driverMonthlyRentRate);
                param[13] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_OverallTotal", jobsTotal);
                param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BalanceBFD", zeroStr);



                param[15] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DriverOwed", driverOwedRate.ToStr());


                param[16] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_JobsCnt", jobsCnt.ToStr());
                param[17] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_StatementType", this.StatementType.ToStr());

                param[18] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalCommissionAmount", totalCashAccountAmountStr.ToStr());

                //param[19] = new Microsoft.Reporting.WinForms.ReportParameter("Report_RentWise", (Rent).ToStr());
                //


                reportViewer1.LocalReport.SetParameters(param);

                // this.vuBookingBaseBindingSource.DataSource =DataSource;
                //  this.vuBookingBaseBindingSource.DataSource = this.DataSource;
                // this.vuBookingBaseBindingSource.DataSource = this.DataSource;

                this.Vu_BookingBaseBindingSource.DataSource = this.DataSource;
                this.reportViewer1.ZoomPercent = 100;
                this.reportViewer1.ZoomMode    = Microsoft.Reporting.WinForms.ZoomMode.Percent;
                this.reportViewer1.RefreshReport();
            }

            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        public void GenerateReport()
        {
            try
            {
                Microsoft.Reporting.WinForms.ReportParameter[] param = null;

                UM_Form_Template objTemplate = General.GetObject <UM_Form_Template>(c => c.UM_Form.FormName == this.Name && c.IsDefault == true);


                string className = "Taxi_AppMain.ReportDesigns." + objTemplate.TemplateName.ToStr() + "_";

                if (objTemplate.TemplateName.ToStr() == "Template1")
                {
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc";
                    param = new Microsoft.Reporting.WinForms.ReportParameter[19];
                }
                else if (objTemplate.TemplateName.ToStr() == "Template2")
                {
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc";
                    param = new Microsoft.Reporting.WinForms.ReportParameter[19];
                }
                else if (objTemplate.TemplateName.ToStr() == "Template3" || objTemplate.TemplateName.ToStr() == "Template4")
                {
                    GenerateReport3(objTemplate.TemplateName.ToStr().Trim());
                    return;
                    //  this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc";
                    //  param = new Microsoft.Reporting.WinForms.ReportParameter[26];
                }

                reportViewer1.LocalReport.EnableExternalImages = true;



                if (objSubCompany == null)
                {
                    objSubCompany = AppVars.objSubCompany;
                }


                string address = objSubCompany.Address;
                string telNo   = "Tel No. " + objSubCompany.TelephoneNo;

                param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address);
                param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", telNo);



                List <ClsLogo> objLogo = new List <ClsLogo>();
                objLogo.Add(new ClsLogo {
                    ImageInBytes = objSubCompany.CompanyLogo != null ? objSubCompany.CompanyLogo.ToArray() : null
                });
                ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo);
                this.reportViewer1.LocalReport.DataSources.Add(imageDataSource);

                string path = @"File:";
                param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Path", path);
                param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Period", this.DatePeriod);


                // Summary Calculations
                decimal JobsSum   = this.DataSource.Sum(c => c.TotalCharges.ToDecimal());
                int     jobsCnt   = this.DataSource.Count;
                string  jobsTotal = string.Format("{0:c}", JobsSum);
                jobsTotal = jobsTotal.Substring(1);
                jobsTotal = jobsTotal.Insert(0, "£ ");
                decimal zeroValue = 0.00m;
                string  zeroStr   = string.Format("{0:c}", zeroValue);
                zeroStr = zeroStr.Substring(1);
                zeroStr = zeroStr.Insert(0, "£ ");



                decimal totalCashAccountAmount = this.DataSource.Where(c => c.CompanyId != null && c.AccountTypeId.ToInt() == Enums.ACCOUNT_TYPE.CASH &&
                                                                       c.DriverCommissionType.ToStr() == "Amount").Sum(c => c.DriverCommission.ToDecimal());

                string totalCashAccountAmountStr = string.Format("{0:c}", totalCashAccountAmount);
                totalCashAccountAmountStr = totalCashAccountAmountStr.Substring(1);
                totalCashAccountAmountStr = totalCashAccountAmountStr.Insert(0, "£ ");

                string  totalAccountBookings        = this.DataSource.Count(c => c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.ACCOUNT).ToStr();
                decimal totalAccountCharges         = this.DataSource.Where(c => c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.ACCOUNT).Sum(c => c.TotalCharges.ToDecimal());
                string  totalAccountBookingsCharges = string.Format("{0:c}", totalAccountCharges).Substring(1);
                totalAccountBookingsCharges = totalAccountBookingsCharges.Insert(0, "£ ");

                string totalCashBooking        = this.DataSource.Count(c => c.CompanyId == null || (c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.CASH)).ToStr();
                string totalCashBookingCharges = string.Format("{0:c}", this.DataSource.Where(c => c.CompanyId == null || (c.CompanyId != null && c.AccountTypeId == Enums.ACCOUNT_TYPE.CASH))
                                                               .Sum(c => c.TotalCharges.ToDecimal()));
                totalCashBookingCharges = totalCashBookingCharges.Substring(1);
                totalCashBookingCharges = totalCashBookingCharges.Insert(0, "£ ");

                decimal driverMonthlyRent = 0;

                if (Rent > 0)
                {
                    driverMonthlyRent = (Rent).ToDecimal() + totalCashAccountAmount;
                }
                else
                {
                    driverMonthlyRent = ObjDriver.DriverMonthlyRent.ToDecimal() + totalCashAccountAmount;
                }


                string driverMonthlyRentRate = string.Format("{0:c}", driverMonthlyRent);
                driverMonthlyRentRate = driverMonthlyRentRate.Substring(1);
                driverMonthlyRentRate = driverMonthlyRentRate.Insert(0, "£ ");


                decimal driverOwed     = totalAccountCharges - driverMonthlyRent;
                string  driverOwedRate = "£ " + string.Format("{0:#.00}", driverOwed);


                if (StatementType == 2)
                {
                    driverMonthlyRentRate = "£ 0.00";

                    driverOwedRate = jobsTotal;
                }

                //UM_Form_Template objTemplate = General.GetObject<UM_Form_Template>(c => c.UM_Form.FormName == this.Name && c.IsDefault == true);


                //string className = "Taxi_AppMain.ReportDesigns." + objTemplate.TemplateName.ToStr() + "_";

                //if (objTemplate.TemplateName.ToStr() == "Template1")
                //{
                //    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc";

                //}
                //else if (objTemplate.TemplateName.ToStr() == "Template2")
                //{
                //    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc";
                //}
                //else if (objTemplate.TemplateName.ToStr() == "Template3")
                //{
                //    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverStatement.rdlc";
                //}



                param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_JobsTotal", jobsTotal);

                param[5] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AdditionsQuantity", totalAccountBookings.ToStr() + " account booking");
                param[6] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AdditionsAccountsGross", totalAccountBookingsCharges);
                param[7] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AdditionsAccountsGrossTotal", totalAccountBookingsCharges);



                param[8]  = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DeductionsCashQuantity", totalCashBooking + " cash booking");
                param[9]  = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DeductionsCashGross", totalCashBookingCharges);
                param[10] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DeductionsCashGrossTotal", totalCashBookingCharges);

                param[11] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalAdditions", totalAccountBookingsCharges);
                param[12] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalDeductions", driverMonthlyRentRate);
                param[13] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_OverallTotal", jobsTotal);
                param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BalanceBFD", zeroStr);



                param[15] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_DriverOwed", driverOwedRate.ToStr());


                param[16] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_JobsCnt", jobsCnt.ToStr());
                param[17] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_StatementType", this.StatementType.ToStr());

                param[18] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_TotalCommissionAmount", totalCashAccountAmountStr.ToStr());

                //param[19] = new Microsoft.Reporting.WinForms.ReportParameter("Report_RentWise", (Rent).ToStr());
                //


                reportViewer1.LocalReport.SetParameters(param);


                this.Vu_BookingBaseBindingSource.DataSource = this.DataSource;
                this.reportViewer1.ZoomPercent = 100;
                this.reportViewer1.ZoomMode    = Microsoft.Reporting.WinForms.ZoomMode.Percent;
                this.reportViewer1.RefreshReport();
            }

            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        public void LoadReport()
        {
            try
            {
                if (dtpFromDate.Value != null && dtpFromDate.Value.Value.Year == 1753)
                {
                    dtpFromDate.Value = null;
                }

                if (dtpTillDate.Value != null && dtpTillDate.Value.Value.Year == 1753)
                {
                    dtpTillDate.Value = null;
                }


                int    DriverId = ddl_Driver.SelectedValue.ToInt();;
                string Error    = string.Empty;

                if (DriverId == 0)
                {
                    Error = "Requird : Driver";
                }
                UM_Form_Template objTemplate = General.GetObject <UM_Form_Template>(c => c.UM_Form.FormName == this.Name && c.IsDefault == true);
                if (objTemplate == null)
                {
                    if (string.IsNullOrEmpty(Error))
                    {
                        Error = "Requird : Report Template";
                    }
                    else
                    {
                        Error += Environment.NewLine + "Requird : Report Template";
                    }
                }


                if (!string.IsNullOrEmpty(Error))
                {
                    ENUtils.ShowMessage(Error);
                    return;
                }

                ReInitializeReportViewer();
                DateTime?fromDate = dtpFromDate.Value.ToDate();
                DateTime?tillDate = string.Format("{0:dd/MM/yyyy HH:mm}", dtpTillDate.Value.ToDate() + dtpTillTime.Value.Value.TimeOfDay).ToDateTime();



                string criteria = string.Format("{0:dd-MM-yy}", fromDate) + " to " + string.Format("{0:dd-MM-yy}", tillDate);



                string className = "Taxi_AppMain.ReportDesigns." + objTemplate.TemplateName.ToStr() + "_";

                if (objTemplate.TemplateName.ToStr() == "Template1")
                {
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverDailyJobSheet.rdlc";
                }
                else if (objTemplate.TemplateName.ToStr() == "Template2")
                {
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverDailyJobSheet.rdlc";
                }
                this.reportViewer1.RefreshReport();

                this.reportViewer1.LocalReport.EnableExternalImages = true;

                //var list = (from a in new Taxi_Model.TaxiDataContext().stp_DriverDailyJobSheet(DriverId, fromDate, tillDate)
                //            select new stp_DriverDailyJobSheetResult
                //            {
                //                StartDateTime = a.StartDateTime,
                //                clearedDateTimeBookingGroup=a.clearedDateTimeBookingGroup,
                //                FromAddress=a.FromAddress,
                //                ToAddress=a.ToAddress,
                //                noofpassengers=a.noofpassengers,
                //                noofluggages=a.noofluggages,
                //                FareRate=a.FareRate,
                //                acceptedDateTime=a.acceptedDateTime,
                //                CustomerName=a.CustomerName,
                //                BookingNo=a.BookingNo,
                //                DriverId=a.DriverId,
                //                clearedDateTime=a.clearedDateTime,
                //                Id=a.Id,
                //                DriverName=a.DriverName,
                //                groupJobId=a.groupJobId,
                //                Pickupdatetime=a.Pickupdatetime,


                //                VehicleNo=a.VehicleNo,
                //                RoomNo=a.RoomNo
                //            }).ToList();



                var list = new Taxi_Model.TaxiDataContext().stp_DriverDailyJobSheet(DriverId, fromDate, tillDate).ToList();

                var grpList = list


                              .GroupBy(argss =>
                                       new
                {
                    GrpId = argss.groupJobId
                })
                              .Select(args =>
                                      new
                {
                    GroupId = args.Key.GrpId,
                    GrpCnt  = args.Count()
                }).ToList();



                foreach (var item in grpList)
                {
                    for (int i = 0; i < 28 - item.GrpCnt; i++)
                    {
                        list.Add(new stp_DriverDailyJobSheetResult {
                            groupJobId = item.GroupId
                        });
                    }
                }

                stp_DriverDailyJobSheetResultBindingSource.DataSource = list;
                Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[4];



                string websiteUrl = AppVars.objSubCompany.WebsiteUrl.ToStr();

                websiteUrl = websiteUrl.Replace("www.", "").Trim();


                websiteUrl = websiteUrl.Replace("http://", "").Trim();



                param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_WebsiteUrl", websiteUrl);
                param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Criteria", criteria);
                param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyName", AppVars.objSubCompany.CompanyName.ToStr());
                param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyAddress", AppVars.objSubCompany.Address.ToStr());
                // param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Criteria", criteria);


                reportViewer1.LocalReport.SetParameters(param);



                this.reportViewer1.ZoomPercent = 100;
                this.reportViewer1.ZoomMode    = Microsoft.Reporting.WinForms.ZoomMode.Percent;
                this.reportViewer1.RefreshReport();
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
예제 #11
0
        public void GenerateReport()
        {
            try
            {
                //if (ddlCompany.SelectedValue == null)
                //    pnlCriteria.Visible = false;

                reportViewer1.LocalReport.EnableExternalImages = true;


                UM_Form_Template objTemplate = General.GetObject <UM_Form_Template>(c => c.UM_Form.FormName == this.Name && c.IsDefault == true);

                if (objTemplate == null)
                {
                    ENUtils.ShowMessage("Report Template is not defined in Settings");
                    return;
                }


                string className = "Taxi_AppMain.ReportDesigns." + objTemplate.TemplateName.ToStr() + "_";

                if (objTemplate.TemplateName.ToStr() == "Template1")
                {
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = "Taxi_AppMain.ReportDesigns." + "rptDriverCommisionExpenses.rdlc";
                }
                else if (objTemplate.TemplateName.ToStr() == "Template2")
                {
                    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverCommisionExpenses.rdlc";
                    //rptDriverCommisionExpenses
                }

                Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[31];


                string address = AppVars.objSubCompany.Address;
                string telNo   = string.Empty;


                string sortCode     = AppVars.objSubCompany.SortCode.ToStr();
                string accountNo    = AppVars.objSubCompany.AccountNo.ToStr();
                string accountTitle = AppVars.objSubCompany.AccountTitle.ToStr();
                string bank         = AppVars.objSubCompany.BankName.ToStr();


                string hasBankDetails = "1";
                if (string.IsNullOrEmpty(sortCode) && string.IsNullOrEmpty(accountNo) && string.IsNullOrEmpty(accountTitle) &&
                    string.IsNullOrEmpty(bank))
                {
                    hasBankDetails = "0";
                }

                if (!string.IsNullOrEmpty(sortCode))
                {
                    sortCode = "Sort Code : " + sortCode;
                }



                if (!string.IsNullOrEmpty(accountTitle))
                {
                    accountTitle = "Account Title : " + accountTitle;
                }



                string website = AppVars.objSubCompany.WebsiteUrl.ToStr();
                if (!string.IsNullOrEmpty(website))
                {
                    website += " , ";
                }

                website += "Email:" + AppVars.objSubCompany.EmailAddress.ToStr();


                string companyNumber = AppVars.objSubCompany.CompanyNumber.ToStr();
                if (!string.IsNullOrEmpty(companyNumber))
                {
                    companyNumber = "Company Number: " + companyNumber;
                }

                string vatNumber = AppVars.objSubCompany.CompanyVatNumber.ToStr();
                //if (!string.IsNullOrEmpty(vatNumber))
                //{
                //    vatNumber = vatNumber;
                //}


                param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address);

                param[18] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Footer", AppVars.objSubCompany.WebsiteUrl.ToStr());

                param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_MobileNo", "Mobile: " + AppVars.objSubCompany.EmergencyNo.ToStr());
                param[15] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Website", website);
                param[16] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Email", "Email: " + AppVars.objSubCompany.EmailAddress.ToStr());

                param[20] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyNumber", companyNumber);
                param[21] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_VATNumber", vatNumber);


                param[7]  = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_SortCode", sortCode);
                param[9]  = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountTitle", accountTitle);
                param[10] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Bank", bank);



                List <ClsLogo> objLogo = new List <ClsLogo>();
                objLogo.Add(new ClsLogo {
                    ImageInBytes = AppVars.objSubCompany.CompanyLogo != null ? AppVars.objSubCompany.CompanyLogo.ToArray() : null
                });
                ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo);
                this.reportViewer1.LocalReport.DataSources.Add(imageDataSource);

                string path = @"File:";
                param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Path", path);
                param[6] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyHeader", AppVars.objSubCompany.CompanyName.ToStr());



                int?driverId = this.DataSource.FirstOrDefault().DefaultIfEmpty().DriverId;

                var data = this.DataSource.FirstOrDefault().DefaultIfEmpty();


                telNo = "Telephone: " + AppVars.objSubCompany.TelephoneNo + ", Fax: " + AppVars.objSubCompany.Fax + ", E-mail: " + AppVars.objSubCompany.EmailAddress + ", Website:" + AppVars.objSubCompany.WebsiteUrl;

                if (!string.IsNullOrEmpty(accountNo))
                {
                    accountNo = "Account No : " + accountNo;
                }


                // string className = "Taxi_AppMain.ReportDesigns.";
                //if (IsCheck == 1)
                //{

                //    if (IsFareAndWaitingWise)
                //    {
                //        this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverCommisionTrasaction3.rdlc";

                //    }
                //    else
                //    {



                //        this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverCommisionTrasaction4.rdlc";
                //    }
                //}
                //else
                //{
                //    this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptDriverCommisionTrasaction2.rdlc";
                //}

                param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", telNo);


                param[8] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountNo", accountNo);



                string  vat            = "0";
                decimal discountAmount = 0.00m;
                decimal valueAddedTax  = 0.0m;



                string discount = string.Format("{0:c}", discountAmount);
                discount = discount.Substring(1);

                string grandTotal = "";

                param[17] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Discount", discount);


                param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_InvoiceTotal", grandTotal);

                param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasVat", vat);

                param[5]  = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_VAT", valueAddedTax.ToStr());
                param[11] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasDepartment", "0");

                param[12] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Net", "0");

                param[13] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasCostCenter", "0");

                param[19] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasBankDetails", hasBankDetails);


                string AccountBooking = string.Empty;
                string CashBooking    = string.Empty;



                Fleet_Driver obj             = General.GetObject <Fleet_Driver>(c => c.Id == driverId);
                decimal      DriverCommision = obj.DriverCommissionPerBooking.ToDecimal();



                decimal JobTotal = 0;
                if (this.IsFareAndWaitingWise)
                {
                    AccountBooking = string.Format("{0:£ #.##}", this.DataSource.Where(c => c.BookingTypeId.ToInt() == Enums.ACCOUNT_TYPE.ACCOUNT).Sum(c => c.FareRate.ToDecimal() + c.WaitingCharges.ToDecimal()));
                    CashBooking    = string.Format("{0:£ #.##}", this.DataSource.Where(c => c.BookingTypeId.ToInt() == Enums.ACCOUNT_TYPE.CASH).Sum(c => c.FareRate.ToDecimal() + c.WaitingCharges.ToDecimal()));
                    JobTotal       = this.DataSource.Sum(c => c.FareRate.Value.ToDecimal() + c.WaitingCharges.ToDecimal());
                }
                else
                {
                    AccountBooking = string.Format("{0:£ #.##}", this.DataSource.Where(c => c.BookingTypeId.ToInt() == Enums.ACCOUNT_TYPE.ACCOUNT).Sum(c => c.FareRate.ToDecimal() + c.ParkingCharges.ToDecimal() + c.WaitingCharges.ToDecimal()));
                    CashBooking    = string.Format("{0:£ #.##}", this.DataSource.Where(c => c.BookingTypeId.ToInt() == Enums.ACCOUNT_TYPE.CASH).Sum(c => c.FareRate.ToDecimal() + c.ParkingCharges.ToDecimal() + c.WaitingCharges.ToDecimal()));
                    JobTotal       = this.DataSource.Sum(c => c.FareRate.ToDecimal() + c.ParkingCharges.ToDecimal() + c.WaitingCharges.ToDecimal());
                }


                param[22] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountJobTotal", AccountBooking);
                param[23] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CashJobTotal", CashBooking);
                string BalanceType = string.Empty;
                int    DriverId    = this.DataSource.FirstOrDefault().DriverId.ToInt();
                int    Id          = this.DataSource.FirstOrDefault().Id.ToInt();;
                var    query       = General.GetObject <Fleet_DriverCommision>(c => c.DriverId == DriverId && c.Id < Id);

                string StatementDate = string.Empty;
                if (query == null)
                {
                    BalanceType   = "Initial Balance";
                    StatementDate = string.Format("{0:dd/MM}", this.DataSource.FirstOrDefault().TransDate);
                }
                else
                {
                    BalanceType   = "Balance from statement " + query.TransNo;
                    StatementDate = string.Format("{0:dd/MM}", query.TransDate);
                }

                string  Commision        = (JobTotal * DriverCommision / 100).ToStr();
                decimal AccountTotal     = (this.DataSource.Sum(c => c.AccountJobsTotal)).ToDecimal();
                decimal AccountCommision = (25 * AccountTotal / 100);
                decimal CashTotal        = (this.DataSource.Sum(c => c.CashJobsTotal)).ToDecimal();
                decimal CashCommision    = (25 * CashTotal / 100);
                decimal TotalDebit       = this.DataSource2.Sum(c => c.Debit).ToDecimal();
                decimal TotalCredit      = this.DataSource2.Sum(c => c.Credit).ToDecimal();



                //  decimal commissionTotal = this.data


                //   var objRecord=  General.GetObject<Fleet_DriverCommision>(c => c.Id == Id);


                //if (objRecord != null)
                //{

                //    commissionTotal = objRecord.CommissionTotal.ToDecimal() + objRecord.AgentFeesTotal.ToDecimal();
                //}

                if (AppVars.objPolicyConfiguration.PriceRangeWiseCommission.ToBool())
                {
                    List <Fleet_Driver_CommissionRange> listofRange = obj.Fleet_Driver_CommissionRanges.ToList();

                    if (listofRange.Count == 0)
                    {
                        listofRange = GetSystemCommissionRange();
                    }

                    Commision = Math.Round(this.DataSource
                                           .Sum(c => c.IsCommissionWise.ToBool() ? (c.DriverCommissionType == "Percent" ? ((c.TotalCharges * c.DriverCommissionOnBooking) / 100) : c.DriverCommissionOnBooking) : (((c.FareRate * listofRange.FirstOrDefault(a => c.TotalCharges >= a.FromPrice && c.FareRate <= a.ToPrice).DefaultIfEmpty().CommissionValue.ToDecimal()) / 100))).ToDecimal(), 2).ToStr();
                }


                param[24] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Commision", Commision);

                string DriverGrandTotal = "";

                if (this.DataSource != null)
                {
                    DriverGrandTotal = (this.DataSource[0].DriverCommision + this.DataSource[0].Extra + this.DataSource[0].fuel + this.DataSource[0].OldBalance).ToStr();
                }

                param[25] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_GrandTotal", DriverGrandTotal);

                int     cnt             = this.DataSource.Count;
                decimal AccountExpenses = 0.00m;
                //    decimal DropOfCharges=this.DataSource.Sum(c=>c.ExtraDropOfCharges).ToDecimal();
                //   decimal PickUpCharges=this.DataSource.Sum(c=>c.ExtraPickUpCharges).ToDecimal();
                //  AccountExpenses=(DropOfCharges+PickUpCharges);
                param[26] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_jobCount", cnt.ToStr());
                param[27] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BalanceType", BalanceType);
                param[28] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountExpenses", AccountExpenses.ToStr());
                param[29] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_StatementDate", StatementDate);
                //Report_Parameter_StatementDate

                string balance = string.Empty;

                decimal bal = this.DataSource.FirstOrDefault().DefaultIfEmpty().Balance.ToDecimal();


                if (bal >= 0)
                {
                    balance = "You are due to receive £" + string.Format("{0:f2}", bal);
                }
                else
                {
                    balance = "You are due to Pay £" + string.Format("{0:f2}", bal);

                    balance = balance.Replace("-", "").Trim();
                }


                param[30] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Balance", balance);


                //   string strCommissionTotal = string.Format("{0:f2}", commissionTotal);
                //    param[31] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CommissionTotal", strCommissionTotal);



                int minRows = 12;
                if (cnt < minRows)
                {
                    for (int i = 0; i < minRows - cnt; i++)
                    {
                        this.DataSource.Add(new vu_DriverCommisionExpense {
                            Id = data.Id, BookingId = data.BookingId,
                        });                                                                                              //, Passenger = data.Passenger, FromAddress = data.FromAddress, ToAddress = data.ToAddress });
                    }
                }
                reportViewer1.LocalReport.SetParameters(param);
                this.vu_DriverCommisionExpenseBindingSource.DataSource       = this.DataSource;
                this.vu_FleetDriverCommissionExpenseBindingSource.DataSource = this.DataSource2;


                this.reportViewer1.ZoomPercent = 100;
                this.reportViewer1.ZoomMode    = Microsoft.Reporting.WinForms.ZoomMode.Percent;
                this.reportViewer1.RefreshReport();
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        //       public void GenerateReport()
        //       {
        //           if(ddlCustomer.SelectedValue==null)
        //               pnlCriteria.Visible=false;

        //           reportViewer1.LocalReport.EnableExternalImages = true;

        //           Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[9];

        //           string address = AppVars.objPolicyConfiguration.OurCompanyAddress;
        //           string telNo ="Tel No. "+ AppVars.objSubCompany.TelephoneNo;


        //           string sortCode = AppVars.objPolicyConfiguration.OurCompanySortCode.ToStr();
        //           string accountNo = AppVars.objPolicyConfiguration.OurCompanyAccountNo.ToStr();
        //           string accountTitle = AppVars.objPolicyConfiguration.OurCompanyAccountTitle.ToStr();
        //           string bank = AppVars.objSubCompany.BankName.ToStr();

        //           if (!string.IsNullOrEmpty(sortCode))
        //               sortCode = "Sort Code : " + sortCode;

        //           if (!string.IsNullOrEmpty(accountNo))
        //               accountNo = "Account No : " + accountNo;

        //           if (!string.IsNullOrEmpty(accountTitle))
        //               accountTitle = "Account Title : " + accountTitle;

        //           if (!string.IsNullOrEmpty(bank))
        //               bank = "Bank : " + bank;


        //           param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address);
        //           param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", telNo);


        //           string filePath = AppVars.objPolicyConfiguration.OurCompanyLogoPath.ToStr();
        //           string path = @"File:"+filePath;

        //           param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Path", path);


        //        //   int? companyId = this.DataSource.FirstOrDefault().DefaultIfEmpty().CompanyId;

        //           decimal invoiceGrandTotal = this.DataSource.FirstOrDefault().DefaultIfEmpty().InvoiceTotal.ToDecimal() + this.DataSource.FirstOrDefault().DefaultIfEmpty().AdminFees.ToDecimal();
        //           string grandTotal = string.Format("{0:c}", invoiceGrandTotal);
        //           grandTotal = grandTotal.Substring(1);
        //           param[3] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_InvoiceTotal", grandTotal);


        //           param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyHeader", AppVars.objSubCompany.CompanyName.ToStr());

        //           param[5] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_SortCode", sortCode);
        //           param[6] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountNo", accountNo);
        //           param[7] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountTitle", accountTitle);
        //           param[8] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Bank", bank);


        //           //string vat = "0";
        //           //decimal valueAddedTax = 0.0m;
        //           //if (companyId != null)
        //           //{
        //           //    Gen_Company objCompany = General.GetObject<Gen_Company>(c => c.Id == companyId);

        //           //    if (objCompany != null)
        //           //    {
        //           //        if (objCompany.HasVat.ToBool())
        //           //        {
        //           //            valueAddedTax = (invoiceGrandTotal * 20) / 100;
        //           //            vat = "1";

        //           //        }

        //           //    }

        //           //}

        //          // invoiceGrandTotal = invoiceGrandTotal + valueAddedTax;


        //     //      param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasVat", vat);

        ////           param[5] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_VAT", valueAddedTax.ToStr());


        //           reportViewer1.LocalReport.SetParameters(param);



        //           this.vuInvoiceBindingSource.DataSource = this.DataSource;

        //         this.reportViewer1.ZoomPercent = 100;
        //           this.reportViewer1.ZoomMode= Microsoft.Reporting.WinForms.ZoomMode.Percent;
        //           this.reportViewer1.RefreshReport();

        //       }



        public void GenerateReport()
        {
            if (ddlCustomer.SelectedValue == null)
            {
                pnlCriteria.Visible = false;
            }

            reportViewer1.LocalReport.EnableExternalImages = true;



            string address = AppVars.objSubCompany.Address;
            string telNo   = "Tel No. " + AppVars.objSubCompany.TelephoneNo;


            string sortCode     = AppVars.objSubCompany.SortCode.ToStr();
            string accountNo    = AppVars.objSubCompany.AccountNo.ToStr();
            string accountTitle = AppVars.objSubCompany.AccountTitle.ToStr();
            string bank         = AppVars.objSubCompany.BankName.ToStr();


            string footer = string.Empty;


            if (!string.IsNullOrEmpty(sortCode))
            {
                sortCode = "Sort Code : " + sortCode;
            }

            if (!string.IsNullOrEmpty(accountNo))
            {
                accountNo = "Account No : " + accountNo;
            }

            if (!string.IsNullOrEmpty(accountTitle))
            {
                accountTitle = "Account Title : " + accountTitle;
            }

            if (!string.IsNullOrEmpty(bank))
            {
                bank = "Bank : " + bank;
            }

            UM_Form_Template objTemplate = General.GetObject <UM_Form_Template>(c => c.UM_Form.FormName == this.Name && c.IsDefault == true);

            Microsoft.Reporting.WinForms.ReportParameter[] param = new Microsoft.Reporting.WinForms.ReportParameter[10];


            string className = "Taxi_AppMain.ReportDesigns." + objTemplate.TemplateName.ToStr() + "_";

            if (objTemplate.TemplateName.ToStr() == "Template1" || objTemplate.TemplateName.ToStr() == "Template6")
            {
                this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptCustomerInvoice.rdlc";
            }
            else if (objTemplate.TemplateName.ToStr() == "Template2")
            {
                this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptCustomerInvoice.rdlc";
            }


            else if (objTemplate.TemplateName.ToStr() == "Template3" || objTemplate.TemplateName.ToStr() == "Template5")
            {
                this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptCustomerInvoice.rdlc";

                if (objTemplate.TemplateName.ToStr() == "Template5")
                {
                    param = new Microsoft.Reporting.WinForms.ReportParameter[15];
                }
                else
                {
                    param = new Microsoft.Reporting.WinForms.ReportParameter[13];
                }

                param[10] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_IBAN", "IBAN No : " + AppVars.objSubCompany.IbanNumber.ToStr());
                param[11] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BLC", "SWIFT Code : " + AppVars.objSubCompany.BlcNumber.ToStr());

                footer  = AppVars.objSubCompany.WebsiteUrl.ToStr() + " are part of " + AppVars.objSubCompany.AccountTitle;
                footer += "\r\n" + "Registered in England and Wales No. GB " + AppVars.objSubCompany.AccountNo + ", Vat Reg No. GB " + AppVars.objSubCompany.CompanyVatNumber;

                param[12] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Footer", footer);
            }
            else if (objTemplate.TemplateName.ToStr() == "Template4")
            {
                this.reportViewer1.LocalReport.ReportEmbeddedResource = className + "rptCustomerInvoice.rdlc";
                param = new Microsoft.Reporting.WinForms.ReportParameter[14];



                footer  = "If you have any queries regarding invoice, please dont hesitate to contact Accounts Team on " + AppVars.objSubCompany.EmailAddress.ToStr() + " or " + AppVars.objSubCompany.TelephoneNo.ToStr();
                footer += "\r\n" + AppVars.objSubCompany.WebsiteUrl.ToStr() + " are part of " + AppVars.objSubCompany.AccountTitle;
                footer += "\r\n" + "Registered in England and Wales No. GB " + AppVars.objSubCompany.CompanyNumber;

                param[10] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Footer", footer);
                param[11] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_IBAN", "IBAN No : " + AppVars.objSubCompany.IbanNumber.ToStr());
                param[12] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_BLC", "SWIFT Code : " + AppVars.objSubCompany.BlcNumber.ToStr());


                string companyNumber = AppVars.objSubCompany.CompanyNumber.ToStr();
                if (!string.IsNullOrEmpty(companyNumber))
                {
                    companyNumber = "Company Number: " + companyNumber;
                }

                param[13] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyNumber", companyNumber);
            }



            param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", address);
            param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", telNo);



            List <ClsLogo> objLogo = new List <ClsLogo>();

            objLogo.Add(new ClsLogo {
                ImageInBytes = AppVars.objSubCompany.CompanyLogo != null ? AppVars.objSubCompany.CompanyLogo.ToArray() : null
            });
            ReportDataSource imageDataSource = new ReportDataSource("Taxi_AppMain_Classes_ClsLogo", objLogo);

            this.reportViewer1.LocalReport.DataSources.Add(imageDataSource);

            string path = @"File:";

            param[2] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Path", path);

            //   int? companyId = this.DataSource.FirstOrDefault().DefaultIfEmpty().CompanyId;



            decimal invoiceGrandTotal = this.DataSource.FirstOrDefault().DefaultIfEmpty().InvoiceTotal.ToDecimal() + this.DataSource.FirstOrDefault().DefaultIfEmpty().AdminFees.ToDecimal();
            string  grandTotal        = string.Format("{0:c}", invoiceGrandTotal);

            grandTotal = grandTotal.Substring(1);
            param[3]   = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_InvoiceTotal", grandTotal);


            param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_CompanyHeader", AppVars.objSubCompany.CompanyName.ToStr());

            param[5] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_SortCode", sortCode);
            param[6] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountNo", accountNo);
            param[7] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_AccountTitle", accountTitle);
            param[8] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Bank", bank);
            param[9] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Email", "Email: " + AppVars.objSubCompany.EmailAddress.ToStr());


            if (objTemplate.TemplateName.ToStr() == "Template5")
            {
                param[0] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Address", AppVars.objSubCompany.Address);
                param[1] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Telephone", AppVars.objSubCompany.TelephoneNo);
                param[9] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_Email", AppVars.objSubCompany.EmailAddress.ToStr());

                param[13] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasVAT", "0");
                param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_VATAMOUNT", "0.00");

                if (this.DataSource.Any(c => c.PaymentTypeId.ToInt() == Enums.PAYMENT_TYPES.CREDIT_CARD))
                {
                    decimal vatValue = (this.DataSource.FirstOrDefault().InvoiceTotal.ToDecimal() * 20) / 100;
                    param[13] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasVAT", "1");
                    param[14] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_VATAMOUNT", vatValue.ToStr());
                }
            }

            //string vat = "0";
            //decimal valueAddedTax = 0.0m;
            //if (companyId != null)
            //{
            //    Gen_Company objCompany = General.GetObject<Gen_Company>(c => c.Id == companyId);

            //    if (objCompany != null)
            //    {
            //        if (objCompany.HasVat.ToBool())
            //        {
            //            valueAddedTax = (invoiceGrandTotal * 20) / 100;
            //            vat = "1";

            //        }

            //    }

            //}

            // invoiceGrandTotal = invoiceGrandTotal + valueAddedTax;


            //      param[4] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_HasVat", vat);

            //           param[5] = new Microsoft.Reporting.WinForms.ReportParameter("Report_Parameter_VAT", valueAddedTax.ToStr());


            reportViewer1.LocalReport.SetParameters(param);



            this.vuInvoiceBindingSource.DataSource = this.DataSource;

            this.reportViewer1.ZoomPercent = 100;
            this.reportViewer1.ZoomMode    = Microsoft.Reporting.WinForms.ZoomMode.Percent;
            this.reportViewer1.RefreshReport();
        }