Пример #1
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();
        }
Пример #2
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);
            }
        }