// //////////////////////////////////////////////////////////////////////// // PUBLIC CONSTRUCTOR // /// <summary> /// FillData /// </summary> public void FillData() { PrintVehicleLocationGateway printVehicleLocationGateway = new PrintVehicleLocationGateway(Data); foreach (PrintVehicleLocationTDS.PrintVehicleLocationRow vehicleRow in (PrintVehicleLocationTDS.PrintVehicleLocationDataTable)printVehicleLocationGateway.Table) { PrintVehicleLocationTDS.PrintVehicleLocationDaysRow daysRow = GetRowByUnitCodeCountryId(vehicleRow.UnitCode, vehicleRow.CountryID); if (daysRow == null) { daysRow = ((PrintVehicleLocationTDS.PrintVehicleLocationDaysDataTable)Table).NewPrintVehicleLocationDaysRow(); daysRow.UnitCode = vehicleRow.UnitCode; daysRow.CountryID = vehicleRow.CountryID; daysRow.CountryName = vehicleRow.CountryName; daysRow.Days = 1; daysRow.LastDate = vehicleRow.Date_; ((PrintVehicleLocationTDS.PrintVehicleLocationDaysDataTable)Table).AddPrintVehicleLocationDaysRow(daysRow); } else { if (daysRow.LastDate != vehicleRow.Date_) { daysRow.Days += 1; daysRow.LastDate = vehicleRow.Date_; } } } }
private void Generate() { mReport1 master = (mReport1)this.Master; // Get Data string projectTimeState = (ddlProjectTimeState.SelectedValue == "(All)") ? "%" : ddlProjectTimeState.SelectedValue; PrintVehicleLocationGateway printVehicleLocationGateway = new PrintVehicleLocationGateway(); if (ddlCountry.SelectedValue == "(All)") { if (ddlUnit.SelectedValue == "-1") { printVehicleLocationGateway.LoadByStartDateEndDateProjectTimeState(DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString()), DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString()), projectTimeState); } else { printVehicleLocationGateway.LoadByStartDateEndDateUnitIdProjectTimeState(DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString()), DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString()), int.Parse(ddlUnit.SelectedValue), projectTimeState); } } else { if (ddlUnit.SelectedValue == "-1") { printVehicleLocationGateway.LoadByStartDateEndDateProjectTimeStateCountryId(DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString()), DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString()), projectTimeState, int.Parse(ddlCountry.SelectedValue)); } else { printVehicleLocationGateway.LoadByStartDateEndDateUnitIdProjectTimeStateCountryId(DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString()), DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString()), int.Parse(ddlUnit.SelectedValue), projectTimeState, int.Parse(ddlCountry.SelectedValue)); } } // ... set properties to master page master.Data = printVehicleLocationGateway.Data; master.Table = printVehicleLocationGateway.TableName; // Get report int companyId = Convert.ToInt32(Session["companyID"]); if (printVehicleLocationGateway.Table.Rows.Count > 0) { if (master.Format == "pdf") { master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintVehicleLocationReport(); } else { master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintVehicleLocationReportExport(); } // ... set parameters to report if (master.Format == "pdf") { // ... For report // ... ... project time state if (ddlProjectTimeState.SelectedValue == "(All)") { master.SetParameter("projectTimeState", "All"); } else { master.SetParameter("projectTimeState", ddlProjectTimeState.SelectedItem.Text); } // ... ... unit if (ddlUnit.SelectedValue == "-1") { master.SetParameter("unitName", "All"); } else { int unitId = Int32.Parse(ddlUnit.SelectedValue); UnitsGateway unitsGateway = new UnitsGateway(); unitsGateway.LoadByUnitId(unitId, companyId); string unitName = "(" + unitsGateway.GetUnitCode(unitId) + ") " + unitsGateway.GetDescription(unitId); master.SetParameter("unitName", unitName); } // ... ... user int loginId = Convert.ToInt32(Session["loginID"]); LoginGateway loginGateway = new LoginGateway(); loginGateway.LoadByLoginId(loginId, companyId); string user = loginGateway.GetLastName(loginId, companyId) + " " + loginGateway.GetFirstName(loginId, companyId); master.SetParameter("User", user.Trim()); // ... ... dates master.SetParameter("dateFrom", tkrdpStartDate.SelectedDate.Value.ToShortDateString()); master.SetParameter("dateTo", tkrdpEndDate.SelectedDate.Value.ToShortDateString()); // ... ... country if (ddlCountry.SelectedValue == "2") { master.SetParameter("Country", "USA"); } else { if (ddlCountry.SelectedValue == "1") { master.SetParameter("Country", "Canada"); } else { master.SetParameter("Country", "All"); } } } } }