private void PrintDocument()
        {
            try
            {
                try
                {
                    var rows = grdDriverCommission.Rows.Where(c => c.Cells[COLS.CommissionId].Value.ToLong() > 0).ToList();



                    List <long> invoiceIds = rows.Select(c => c.Cells[COLS.CommissionId].Value.ToLong()).ToList <long>();

                    if (invoiceIds.Count > 0)
                    {
                        frmDriverCommisionTransactionReport frm = new frmDriverCommisionTransactionReport(1);

                        frm.CompanyHeader = ddlSubCompany.Text.Trim();

                        var list = General.GetQueryable <vu_DriverCommision>(a => invoiceIds.Contains(a.Id)).ToList();


                        List <Fleet_Driver> driversList = General.GetGeneralList <Fleet_Driver>(c => c.DriverTypeId == 2);

                        frmEmail frmEmail = new frmEmail(null, "", "");


                        foreach (var item in rows)
                        {
                            frm.DataSource = list.Where(c => c.Id == item.Cells[COLS.CommissionId].Value.ToLong()).OrderBy(c => c.PickupDate).ToList();


                            frm.GenerateReport();

                            ReportPrintDocument rpt = new ReportPrintDocument(frm.reportViewer1.LocalReport);
                            rpt.Print();
                            rpt.Dispose();
                        }
                    }
                }
                catch (Exception ex)
                {
                    ENUtils.ShowMessage(ex.Message);
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void PrintDocument(long TransId)
        {
            try
            {
                try
                {
                    List <GridViewRowInfo> rows = null;


                    if (TransId == 0)
                    {
                        rows = grdDriverCommission.Rows.Where(c => c.Cells["Check"].Value.ToBool() == true).ToList();
                    }
                    else
                    {
                        rows = grdDriverCommission.Rows.Where(c => c.Cells["CommissionId"].Value.ToLong() == TransId).ToList();
                    }


                    List <long> invoiceIds = new List <long>();

                    if (TransId == 0)
                    {
                        invoiceIds = rows.Select(c => c.Cells["CommissionId"].Value.ToLong()).ToList <long>();
                    }
                    else
                    {
                        invoiceIds = new List <long>();
                        invoiceIds.Add(TransId);
                    }


                    if (invoiceIds.Count > 0)
                    {
                        frmDriverCommisionTransactionExpensesReport3 frm = new frmDriverCommisionTransactionExpensesReport3(1);
                        frm.CompanyHeader = AppVars.objSubCompany.CompanyName.ToStr().Trim();

                        var list  = General.GetQueryable <vu_DriverCommisionExpenses2>(a => invoiceIds.Contains(a.Id)).ToList();
                        var list2 = General.GetQueryable <vu_FleetDriverCommissionExpense>(a => invoiceIds.Contains(a.Id)).ToList();


                        List <Fleet_Driver> driversList = General.GetGeneralList <Fleet_Driver>(c => c.DriverTypeId == 2);
                        frmEmail            frmEmail    = new frmEmail(null, "", "");


                        foreach (var item in rows)
                        {
                            frm.DataSource  = list.Where(c => c.Id == item.Cells["CommissionId"].Value.ToLong()).OrderBy(c => c.PickupDate).ToList();
                            frm.DataSource2 = list2.Where(c => c.CommissionId == item.Cells["CommissionId"].Value.ToLong()).OrderBy(c => c.Date).ToList();

                            frm.GenerateReport();

                            ReportPrintDocument rpt = new ReportPrintDocument(frm.reportViewer1.LocalReport);
                            rpt.Print();
                            rpt.Dispose();
                        }
                    }
                }
                catch (Exception ex)
                {
                    ENUtils.ShowMessage(ex.Message);
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 3
0
        private void PrintStatement()
        {
            try
            {
                if (grdDriverRentLastStatement.Rows.Where(c => c.Cells["Check"].Value.ToBool() == true).Count() > 0)
                {
                    //foreach (var item in grdDriverRentLastStatement.Rows.Where(c => c.Cells["Check"].Value.ToBool() == true))
                    //{
                    //    long Id = item.Cells[COLS.Id].Value.ToLong();
                    //    ReportPrintDocument rpt = null;
                    //    frmDriverCommisionTransactionExpensesReport3 frm = null;
                    //    if (Id > 0)
                    //    {
                    //        frm = new frmDriverCommisionTransactionExpensesReport3(1);
                    //        var list = General.GetQueryable<vu_DriverCommisionExpenses2>(a => a.Id == Id).OrderBy(c => c.PickupDate).ToList();
                    //        int count = list.Count;

                    //        frm.DataSource = list;
                    //        var list2 = General.GetQueryable<vu_FleetDriverCommissionExpense>(c => c.CommissionId == Id).OrderBy(c => c.Date).ToList();
                    //        frm.DataSource2 = list2;

                    //        frm.IsFareAndWaitingWise = this.IsFareAndWaitingWiseComm;

                    //        frm.GenerateReport();
                    //        rpt = new ReportPrintDocument(frm.reportViewer1.LocalReport);
                    //        rpt.Print();
                    //        rpt.Dispose();
                    //    }
                    //}



                    var rows = grdDriverRentLastStatement.Rows.Where(c => c.Cells["Check"].Value.ToBool() == true).ToList();

                    var list = (from a in rows.Where(c => c.Cells[COLS.Id].Value.ToInt() > 0)
                                select new
                    {
                        Id = a.Cells[COLS.Id].Value.ToInt(),
                        CompanyId = a.Cells[COLS.DriverId].Value.ToInt(),
                        Driver = a.Cells[COLS.DriverNo].Value.ToStr()
                    }).ToList();

                    frmInvoiceReport    frm = new frmInvoiceReport();
                    ReportPrintDocument rpt = null;
                    foreach (var item in list)
                    {
                        if (item.Id > 0)
                        {
                            using (TaxiDataContext db = new TaxiDataContext())
                            {
                                var listInv = db.vu_Invoices.Where(a => a.Id == item.Id).OrderBy(c => c.PickupDate).ToList();

                                frm.DataSource = listInv;

                                var Invoice = db.Invoices.Where(c => c.Id == item.Id).FirstOrDefault();
                                frm.ObjInvoice = Invoice;

                                //var Inv=
                                //frm.ObjInvoice = listInv.;
                                frm.GenerateReport();
                                rpt = new ReportPrintDocument(frm.reportViewer1.LocalReport);
                                rpt.Print();
                                rpt.Dispose();
                            }
                        }
                    }


                    //if (list.Count > 0)
                    //{
                    //    frmDriverCommisionTransactionExpensesReport4 frm = new frmDriverCommisionTransactionExpensesReport4(list, DateTime.Now.ToDate(), DateTime.Now.ToDate());
                    //    frm.ShowDialog();
                    //    frm.Dispose();
                    //}
                }
                else
                {
                    ENUtils.ShowMessage("Please select statement to Print");
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        private void PrintDocument(long TransId)
        {
            try
            {
                try
                {
                    List <GridViewRowInfo> rows = null;


                    if (TransId == 0)
                    {
                        rows = grdLister.Rows.Where(c => c.Cells["Check"].Value.ToBool() == true).ToList();
                    }
                    else
                    {
                        rows = grdLister.Rows.Where(c => c.Cells["RentId"].Value.ToLong() == TransId).ToList();
                    }


                    List <long> invoiceIds = new List <long>();

                    if (TransId == 0)
                    {
                        invoiceIds = rows.Select(c => c.Cells["RentId"].Value.ToLong()).ToList <long>();
                    }
                    else
                    {
                        invoiceIds = new List <long>();
                        invoiceIds.Add(TransId);
                    }


                    if (invoiceIds.Count > 0)
                    {
                        var list  = General.GetQueryable <vu_DriverRentExpense>(a => invoiceIds.Contains(a.Id)).ToList();
                        var list2 = General.GetQueryable <vu_FleetDriverRentExpense>(a => invoiceIds.Contains(a.Id)).ToList();


                        List <Fleet_Driver> driversList = General.GetGeneralList <Fleet_Driver>(c => c.DriverTypeId == 1);
                        //     frmEmail frmEmail = new frmEmail(null, "", "");

                        frmDriverTransactionExpensesReport3 frm = new frmDriverTransactionExpensesReport3(1);

                        foreach (var item in rows)
                        {
                            if (optFullDetail.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
                            {
                                frm.DisplayCriteriaType = "";
                            }
                            else if (optAccountJobs.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
                            {
                                frm.DisplayCriteriaType = "account_";
                            }
                            else if (optSummaryDetails.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On)
                            {
                                frm.DisplayCriteriaType = "summary_";
                            }
                            frm.DataSource    = list.Where(c => c.Id == item.Cells["RentId"].Value.ToLong()).OrderBy(c => c.PickupDate).ToList();
                            frm.DataSource2   = list2.Where(c => c.RentId == item.Cells["RentId"].Value.ToLong()).OrderBy(c => c.Date).ToList();
                            frm.ObjSubCompany = driversList.FirstOrDefault(C => C.Id == item.Cells["DriverId"].Value.ToInt()).DefaultIfEmpty().Gen_SubCompany.DefaultIfEmpty();
                            frm.CompanyHeader = frm.ObjSubCompany.CompanyName.ToStr().Trim();
                            frm.VAT           = item.Cells["VAT"].Value.ToDecimal();
                            frm.GenerateReport();

                            ReportPrintDocument rpt = new ReportPrintDocument(frm.reportViewer1.LocalReport);
                            rpt.Print();
                            rpt.Dispose();
                        }
                    }
                }
                catch (Exception ex)
                {
                    ENUtils.ShowMessage(ex.Message);
                }
            }
            catch (Exception ex)
            {
            }
        }