protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LoadDDLs(); ReportViewer1.Visible = false; ReportViewer2.Visible = false; ReportViewer3.Visible = false; ReportViewer4.Visible = false; ReportViewer5.Visible = false; ReportViewer6.Visible = false; ReportViewer7.Visible = false; } if (Request.IsAuthenticated) { if (Roles.IsUserInRole(Page.User.Identity.Name, "Pilot")) { uiRadioButtonListReports.Items[3].Attributes.Add("style", "display:none"); uiRadioButtonListReports.Items[4].Attributes.Add("style", "display:none"); uiRadioButtonListReports.Items[5].Attributes.Add("style", "display:none"); Pilot p = new Pilot(); p.GetPilotByUserName(Page.User.Identity.Name); uiDropDownListPilots.SelectedValue = p.PilotID.ToString(); uiDropDownListPilots.Enabled = false; } } }
private void BindData() { Pilot allpilots = new Pilot(); allpilots.LoadAll(); uiRadGridAllPilots.DataSource = allpilots.DefaultView; uiRadGridAllPilots.DataBind(); }
protected void uiGridViewPiolts_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView objData = (DataRowView)e.Row.DataItem; Pilot current = new Pilot(); current.LoadByPrimaryKey(Convert.ToInt32(objData["PilotID"].ToString())); Label temp = (Label)e.Row.FindControl("uiLabelName"); temp.Text = current.FirstName + " " + current.SecondName; Label temp2 = (Label)e.Row.FindControl("uiLabelStaffNo"); if (!current.IsColumnNull("StaffNo")) { temp2.Text = current.StaffNo.ToString(); } CheckBox IsPilot = (CheckBox)e.Row.FindControl("uiCheckBoxIsPilot"); if (!current.IsColumnNull("IsPilot")) IsPilot.Checked = current.IsPilot; else IsPilot.Checked = false; if (objData["PositionID"] != null) { Label pos = (Label)e.Row.FindControl("uiLabelPosition"); Position Currentpos = new Position(); Currentpos.LoadByPrimaryKey(Convert.ToInt32(objData["PositionID"].ToString())); pos.Text = Currentpos.Title; } } }
protected void uiLinkButtonGetReport_Click(object sender, EventArgs e) { Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(); GetPilotScheduleTableAdapter ta = new GetPilotScheduleTableAdapter(); rds.Name = "ScheduleDataSet"; ta.ClearBeforeFill = true; try { CultureInfo provider = CultureInfo.InvariantCulture; provider = new CultureInfo("fr-FR"); DateTime? From = null; DateTime? To = null; if (!string.IsNullOrEmpty(uiTextBoxFrom.Text)) { From = DateTime.ParseExact(uiTextBoxFrom.Text, "dd/MM/yyyy", provider); } if (!string.IsNullOrEmpty(uiTextBoxTo.Text)) { To = DateTime.ParseExact(uiTextBoxTo.Text, "dd/MM/yyyy", provider); } Pilot current = new Pilot(); current.GetPilotByUserName(Page.User.Identity.Name); if(current.RowCount > 0 ) rds.Value = ta.GetData(current.PilotID, From, To); else rds.Value = ta.GetData(0, From, To); } catch (Exception ex) { throw; } uiReportViewer.LocalReport.DataSources.Clear(); uiReportViewer.LocalReport.DataSources.Add(rds); //uiReportViewer.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("From", uiTextBoxFrom.Text)); //uiReportViewer.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("To", uiTextBoxTo.Text)); uiReportViewer.LocalReport.Refresh(); }
private void BindData() { Pilot current = new Pilot(); current.GetPilotByUserName(Page.User.Identity.Name); Pilot p = new Pilot(); DateTime? From = null; DateTime? To = null; CultureInfo provider = CultureInfo.InvariantCulture; provider = new CultureInfo("fr-FR"); if (!string.IsNullOrEmpty(uiTextBoxFrom.Text)) { From = DateTime.ParseExact(uiTextBoxFrom.Text, "dd/MM/yyyy", provider); } if (!string.IsNullOrEmpty(uiTextBoxTo.Text)) { To = DateTime.ParseExact(uiTextBoxTo.Text, "dd/MM/yyyy", provider); } if (current.RowCount > 0) p.GetPilotSchedule(current.PilotID, From, To); else p.GetPilotSchedule(0, From, To); uiGridViewSchedule.DataSource = p.DefaultView; uiGridViewSchedule.DataBind(); }
private void LoadDDLs() { Pilot Allpilots = new Pilot(); Allpilots.LoadAll(); uiDropDownListPilots.DataSource = Allpilots.DefaultView; uiDropDownListPilots.DataTextField = "ShortName"; uiDropDownListPilots.DataValueField = "PilotID"; uiDropDownListPilots.DataBind(); uiDropDownListPilots.Items.Insert(0, new ListItem("Select Pilot", "0")); }
private void BindData() { Pilot current = new Pilot(); current.LoadByPrimaryKey(Convert.ToInt32(uiDropDownListPilots.SelectedValue)); Pilot p = new Pilot(); DateTime? From = null; DateTime? To = null; CultureInfo provider = CultureInfo.InvariantCulture; provider = new CultureInfo("fr-FR"); if (!string.IsNullOrEmpty(uiTextBoxFrom.Text)) { From = DateTime.ParseExact(uiTextBoxFrom.Text, "dd/MM/yyyy", provider); } if (!string.IsNullOrEmpty(uiTextBoxTo.Text)) { To = DateTime.ParseExact(uiTextBoxTo.Text, "dd/MM/yyyy", provider); } if (current.RowCount > 0) p.GetPilotSchedule(current.PilotID, From, To); else p.GetPilotSchedule(3, From, To); uiLabelFullName.Text = current.FirstName + " " + current.SecondName; uiLabelShortName.Text = current.ShortName; uiDataListSchedule.DataSource = p.DefaultView; uiDataListSchedule.DataBind(); Header.Visible = true; totals.Visible = true; grandTotal.Visible = true; guide.Visible = true; CurrentMonthTotal.Visible = true; AverageTotals.Visible = true; uiLabelCompanyTotal.Text = Math.Floor(Companytotal.TotalHours).ToString() + ":" + Companytotal.Minutes.ToString("00"); if (Companytotal.TotalHours < 50) { DIVcompanyTotal.Attributes.Add("class", "greenI"); } else if (Companytotal.TotalHours >= 50 && Companytotal.TotalHours < 70) { DIVcompanyTotal.Attributes.Add("class", "yellowI"); } else if (Companytotal.TotalHours >= 70 && Companytotal.TotalHours < 80) { DIVcompanyTotal.Attributes.Add("class", "blueI"); } else if (Companytotal.TotalHours >= 80) { DIVcompanyTotal.Attributes.Add("class", "redI"); } uiLabelCAATotal.Text = Math.Floor(Companytotal.TotalHours).ToString() + ":" + Companytotal.Minutes.ToString("00"); if (Companytotal.TotalHours < 50) { DIVCAATotal.Attributes.Add("class", "greenI"); } else if (Companytotal.TotalHours >= 50 && Companytotal.TotalHours < 70) { DIVCAATotal.Attributes.Add("class", "yellowI"); } else if (Companytotal.TotalHours >= 70 && Companytotal.TotalHours < 80) { DIVCAATotal.Attributes.Add("class", "blueI"); } else if (Companytotal.TotalHours >= 80) { DIVCAATotal.Attributes.Add("class", "redI"); } uiLabelDutyTotal.Text = Math.Floor(DutyHoursTotal.TotalHours).ToString() + ":" + DutyHoursTotal.Minutes.ToString("00"); if (DutyHoursTotal.TotalHours < 50) { DIVDutyTotal.Attributes.Add("class", "greenI"); } else if (DutyHoursTotal.TotalHours >= 50 && DutyHoursTotal.TotalHours < 70) { DIVDutyTotal.Attributes.Add("class", "yellowI"); } else if (DutyHoursTotal.TotalHours >= 70 && DutyHoursTotal.TotalHours < 80) { DIVDutyTotal.Attributes.Add("class", "blueI"); } else if (DutyHoursTotal.TotalHours >= 80) { DIVDutyTotal.Attributes.Add("class", "redI"); } /************************************************************************************************/ DateTime FromAverage, ToAverage = new DateTime(); FromAverage = To.Value.AddDays(-28); ToAverage = To.Value; TimeSpan AverageTotal = new TimeSpan(); TimeSpan DutyAverageTotal = new TimeSpan(); /***********current month Grand Total *************/ Pilot pTotal = new Pilot(); DateTime FromTotal = new DateTime(To.Value.Year, To.Value.Month, 1); DateTime ToTotal = new DateTime(To.Value.Year, To.Value.Month, getLastDay(To.Value.Month)); pTotal.GetPilotSchedule(current.PilotID, FromTotal, ToTotal); TimeSpan TotalTime = new TimeSpan(); TimeSpan TotalTimeUpToDate = new TimeSpan(); TimeSpan DutyTotalUpToDate = new TimeSpan(); foreach (DataRow row in pTotal.DefaultView.Table.Rows) { TimeSpan currentTime = new TimeSpan(); if (row["ChoxOff"] != null && row["ChoxOn"] != null && (DateTime.Parse(row["ChoxOn"].ToString()).Subtract(DateTime.Parse(row["ChoxOff"].ToString())) != TimeSpan.Zero)) { DateTime choxon = DateTime.Parse(row["ChoxOn"].ToString()); DateTime choxoff = DateTime.Parse(row["ChoxOff"].ToString()); currentTime = choxon.Subtract(choxoff); } else { DateTime STD = DateTime.Parse(row["STD"].ToString()); DateTime STA = DateTime.Parse(row["STA"].ToString()); currentTime = STA.Subtract(STD); } if (TotalTime == TimeSpan.Zero) { TotalTime = currentTime; } else { TotalTime = TotalTime.Add(currentTime); } /* calculate total for currrent month from 1 to the ToDate */ if (Convert.ToDateTime(row["SectorDate"].ToString()) <= To.Value) { if (TotalTimeUpToDate == TimeSpan.Zero) { TotalTimeUpToDate = currentTime; } else { TotalTimeUpToDate = TotalTimeUpToDate.Add(currentTime); } if (DutyTotalUpToDate == TimeSpan.Zero) { DutyTotalUpToDate = currentTime.Add(new TimeSpan (1, 30, 0)); } else { DutyTotalUpToDate = DutyTotalUpToDate.Add(currentTime.Add(new TimeSpan (1, 30, 0))); } } /* calculate the average total for the last 4 weeks */ if (Convert.ToDateTime(row["SectorDate"].ToString()) <= ToAverage && Convert.ToDateTime(row["SectorDate"].ToString()) >= FromAverage) { if (AverageTotal == TimeSpan.Zero) { AverageTotal = currentTime; } else { AverageTotal = AverageTotal.Add(currentTime); } if (DutyAverageTotal == TimeSpan.Zero) { DutyAverageTotal = currentTime.Add(new TimeSpan (1, 30, 0)); } else { DutyAverageTotal = DutyAverageTotal.Add(currentTime.Add(new TimeSpan (1, 30, 0))); } } } uiLabelGrandTotal.Text = "<div style='float:left;width:230px'>" + From.Value.ToString("MMMM") + " Total Hours : </div><div style='float:right;width:50px'>" + Math.Floor(TotalTime.TotalHours).ToString("00") + ":" + TotalTime.Minutes.ToString("00") + "</div>"; /************************/ /***********last month Grand Total *************/ Pilot pLastTotal = new Pilot(); DateTime FromLastTotal = new DateTime((From.Value.Month != 1) ? From.Value.Year : From.Value.Year - 1, (From.Value.Month != 1) ? From.Value.Month - 1 : 12, 1); DateTime ToLastTotal = new DateTime((From.Value.Month != 1) ? From.Value.Year : From.Value.Year - 1, (From.Value.Month != 1) ? From.Value.Month - 1 : 12, getLastDay((From.Value.Month != 1) ? From.Value.Month - 1 : 12)); pLastTotal.GetPilotSchedule(current.PilotID, FromLastTotal, ToLastTotal); TimeSpan LastTotalTime = new TimeSpan(); foreach (DataRow row in pLastTotal.DefaultView.Table.Rows) { TimeSpan currentTime = new TimeSpan(); if (row["ChoxOff"] != null && row["ChoxOn"] != null && (DateTime.Parse(row["ChoxOn"].ToString()).Subtract(DateTime.Parse(row["ChoxOff"].ToString())) != TimeSpan.Zero)) { DateTime choxon = DateTime.Parse(row["ChoxOn"].ToString()); DateTime choxoff = DateTime.Parse(row["ChoxOff"].ToString()); currentTime = choxon.Subtract(choxoff); } else { DateTime STD = DateTime.Parse(row["STD"].ToString()); DateTime STA = DateTime.Parse(row["STA"].ToString()); currentTime = STA.Subtract(STD); } if (LastTotalTime == TimeSpan.Zero) { LastTotalTime = currentTime; } else { LastTotalTime = LastTotalTime.Add(currentTime); } if (Convert.ToDateTime(row["SectorDate"].ToString()) <= ToAverage && Convert.ToDateTime(row["SectorDate"].ToString()) >= FromAverage) { if (AverageTotal == TimeSpan.Zero) { AverageTotal = currentTime; } else { AverageTotal = AverageTotal.Add(currentTime); } if (DutyAverageTotal == TimeSpan.Zero) { DutyAverageTotal = currentTime.Add(new TimeSpan (1, 30, 0)); } else { DutyAverageTotal = DutyAverageTotal.Add(currentTime.Add(new TimeSpan (1, 30, 0))); } } } uiLabelLastTotal.Text = "<div style='float:left;width:230px'>" + FromLastTotal.ToString("MMMM") + " Total Hours : </div><div style='float:right;width:50px'>" + Math.Floor(LastTotalTime.TotalHours).ToString("00") + ":" + LastTotalTime.Minutes.ToString("00") + "</div>"; /************************/ //uiLabelCurrentMonth.Text = "<div style='float:left;width:230px'>" + "Current Month Total Hours : </div><div style='float:right;width:50px'>" + Math.Floor(TotalTimeUpToDate.TotalHours).ToString("00") + ":" + TotalTimeUpToDate.Minutes.ToString("00") + "</div>"; //uiLabelAverageTotal.Text = "<div style='float:left;width:230px'>" + "Last four weeks Avergae Total Hours : </div><div style='float:right;width:50px'>" + Math.Floor(AverageTotal.TotalHours / 4.0).ToString("00") + ":" + Math.Floor(AverageTotal.Minutes / 4.0).ToString("00") +"</div>"; uiLabelCurrentMCompantTotal.Text = Math.Floor(TotalTimeUpToDate.TotalHours).ToString() + ":" + TotalTimeUpToDate.Minutes.ToString("00"); uiLabelCurrentMCAATotal.Text = Math.Floor(TotalTimeUpToDate.TotalHours).ToString() + ":" + TotalTimeUpToDate.Minutes.ToString("00"); uiLabelCurrentMDutyTotal.Text = Math.Floor(DutyTotalUpToDate.TotalHours).ToString() + ":" + DutyTotalUpToDate.Minutes.ToString("00"); uiLabelAverageCompany.Text = Math.Floor(AverageTotal.TotalHours / 4.0).ToString() + ":" + Math.Floor(AverageTotal.Minutes / 4.0 ).ToString("00"); uiLabelAverageCAA.Text = Math.Floor(AverageTotal.TotalHours / 4.0).ToString() + ":" + Math.Floor(AverageTotal.Minutes / 4.0).ToString("00"); uiLabelAverageDuty.Text = Math.Floor(DutyAverageTotal.TotalHours / 4.0).ToString() + ":" + Math.Floor(DutyAverageTotal.Minutes / 4.0).ToString("00"); }
private void LoadDDLs() { Pilot Allpilots = new Pilot(); Allpilots.GetAllPilots(); uiDropDownListPilot.DataSource = Allpilots.DefaultView; uiDropDownListPilot.DataTextField = "DisplayName"; uiDropDownListPilot.DataValueField = "PilotID"; uiDropDownListPilot.DataBind(); uiDropDownListPilot.Items.Insert(0, new ListItem("Select Pilot", "")); Pilot AllCopilots = new Pilot(); AllCopilots.GetAllCoPilots(); uiDropDownListCoPilot.DataSource = AllCopilots.DefaultView; uiDropDownListCoPilot.DataTextField = "DisplayName"; uiDropDownListCoPilot.DataValueField = "PilotID"; uiDropDownListCoPilot.DataBind(); uiDropDownListCoPilot.Items.Insert(0, new ListItem("Select Co-Pilot", "")); Crew AllCrew = new Crew(); AllCrew.LoadAll(); uiDropDownListCrew.DataSource = AllCrew.DefaultView; uiDropDownListCrew.DataTextField = "Name"; uiDropDownListCrew.DataValueField = "CrewID"; uiDropDownListCrew.DataBind(); uiDropDownListCrew.Items.Insert(0, new ListItem("Select Member", "")); AirPort AllAirports = new AirPort(); AllAirports.LoadAll(); uiDropDownListSectorFrom.DataSource = AllAirports.DefaultView; uiDropDownListSectorFrom.DataTextField = "IATACode"; uiDropDownListSectorFrom.DataValueField = "AirPortID"; uiDropDownListSectorFrom.DataBind(); uiDropDownListSectorFrom.Items.Insert(0, new ListItem("Select Airport", "0")); uiDropDownListSectorTo.DataSource = AllAirports.DefaultView; uiDropDownListSectorTo.DataTextField = "IATACode"; uiDropDownListSectorTo.DataValueField = "AirPortID"; uiDropDownListSectorTo.DataBind(); uiDropDownListSectorTo.Items.Insert(0, new ListItem("Select Airport", "0")); }
protected void uiLinkButtonGetReport_Click(object sender, EventArgs e) { ReportViewer1.LocalReport.DataSources.Clear(); ReportViewer2.LocalReport.DataSources.Clear(); ReportViewer3.LocalReport.DataSources.Clear(); ReportViewer4.LocalReport.DataSources.Clear(); ReportViewer5.LocalReport.DataSources.Clear(); ReportViewer6.LocalReport.DataSources.Clear(); ReportViewer7.LocalReport.DataSources.Clear(); Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(); Microsoft.Reporting.WebForms.ReportDataSource rds2 = new Microsoft.Reporting.WebForms.ReportDataSource(); GetPilotReportTableAdapter ta = new GetPilotReportTableAdapter(); GetPAXReportTableAdapter taP = new GetPAXReportTableAdapter(); GetFlyHoursReportTableAdapter taF = new GetFlyHoursReportTableAdapter(); GetPilotScheduleTableAdapter taS = new GetPilotScheduleTableAdapter(); CalculatePerDiemTableAdapter TPD = new CalculatePerDiemTableAdapter(); GetPerDiemLogTableAdapter TPDL = new GetPerDiemLogTableAdapter(); GetAirPlaneActualBurnOffTableAdapter APBO = new GetAirPlaneActualBurnOffTableAdapter(); GetSectorsActualBurnOffTableAdapter SBO = new GetSectorsActualBurnOffTableAdapter(); ta.ClearBeforeFill = true; taP.ClearBeforeFill = true; taF.ClearBeforeFill = true; taS.ClearBeforeFill = true; TPD.ClearBeforeFill = true; TPDL.ClearBeforeFill = true; APBO.ClearBeforeFill = true; SBO.ClearBeforeFill = true; try { DateTime? From = null; DateTime? To = null; From = uiRadDatePickerFrom.SelectedDate; To = uiRadDatePickerTo.SelectedDate; switch (uiRadioButtonListReports.SelectedValue) { case "0": rds.Name = "PilotDataSet"; rds.Value = ta.GetData(Convert.ToInt32(uiDropDownListPilots.SelectedValue), From, To); ReportViewer1.LocalReport.DataSources.Add(rds); ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("From", string.Format("{0:MM/dd/yyyy}", uiRadDatePickerFrom.SelectedDate))); ReportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("To", string.Format("{0:MM/dd/yyyy}", uiRadDatePickerTo.SelectedDate))); ReportViewer1.LocalReport.Refresh(); ReportViewer1.Visible = true; ReportViewer2.Visible = false; ReportViewer3.Visible = false; ReportViewer4.Visible = false; ReportViewer5.Visible = false; ReportViewer6.Visible = false; ReportViewer7.Visible = false; break; case "1": rds.Name = "PAXDataSet"; rds.Value = taP.GetData(From, To,Convert.ToInt32(uiDropDownListAirplane.SelectedValue)); ReportViewer3.LocalReport.DataSources.Add(rds); ReportViewer3.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("From", string.Format("{0:MM/dd/yyyy}", uiRadDatePickerFrom.SelectedDate))); ReportViewer3.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("To", string.Format("{0:MM/dd/yyyy}", uiRadDatePickerTo.SelectedDate))); ReportViewer3.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("Airplane", uiDropDownListAirplane.SelectedValue)); ReportViewer3.LocalReport.Refresh(); ReportViewer1.Visible = false; ReportViewer2.Visible = false; ReportViewer3.Visible = true; ReportViewer4.Visible = false; ReportViewer5.Visible = false; ReportViewer6.Visible = false; ReportViewer7.Visible = false; break; case "2": rds.Name = "FlyHoursDataSet"; rds.Value = taF.GetData(From, To); ReportViewer4.LocalReport.DataSources.Add(rds); ReportViewer4.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("From", string.Format("{0:MM/dd/yyyy}", uiRadDatePickerFrom.SelectedDate))); ReportViewer4.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("To", string.Format("{0:MM/dd/yyyy}", uiRadDatePickerTo.SelectedDate))); ReportViewer4.LocalReport.Refresh(); ReportViewer1.Visible = false; ReportViewer2.Visible = false; ReportViewer3.Visible = false; ReportViewer4.Visible = true; ReportViewer5.Visible = false; ReportViewer6.Visible = false; ReportViewer7.Visible = false; break; case "3": rds.Name = "ScheduleDataSet"; if(!Roles.IsUserInRole(Page.User.Identity.Name,"Pilot")) { rds.Value = taS.GetData(0,From, To); } else { Pilot p = new Pilot(); p.GetPilotByUserName(Page.User.Identity.Name); rds.Value = taS.GetData(p.PilotID, From, To); } ReportViewer5.LocalReport.DataSources.Add(rds); //ReportViewer5.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("From", string.Format("{0:MM/dd/yyyy}", uiRadDatePickerFrom.SelectedDate))); //ReportViewer5.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("To", string.Format("{0:MM/dd/yyyy}", uiRadDatePickerTo.SelectedDate))); ReportViewer5.LocalReport.Refresh(); ReportViewer1.Visible = false; ReportViewer2.Visible = false; ReportViewer3.Visible = false; ReportViewer4.Visible = false; ReportViewer5.Visible = true; ReportViewer6.Visible = false; ReportViewer7.Visible = false; break; case "4": rds.Name = "PerDiemDataSet"; rds2.Name = "PerdiemLogDataSet"; rds.Value = TPD.GetData(From, To, Convert.ToInt32(uiDropDownListPilots.SelectedValue)); rds2.Value = TPDL.GetData(From, To, Convert.ToInt32(uiDropDownListPilots.SelectedValue)); ReportViewer2.LocalReport.DataSources.Add(rds); ReportViewer2.LocalReport.DataSources.Add(rds2); ReportViewer2.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("RateParameter", uiTextBoxRate.Text)); ReportViewer2.LocalReport.Refresh(); ReportViewer1.Visible = false; ReportViewer2.Visible = true; ReportViewer3.Visible = false; ReportViewer4.Visible = false; ReportViewer5.Visible = false; ReportViewer6.Visible = false; ReportViewer7.Visible = false; break; case "5": rds.Name = "PerDiemDataSet"; rds2.Name = "PerdiemLogDataSet"; rds.Value = TPD.GetData(From, To, Convert.ToInt32(uiDropDownListPilots.SelectedValue)); rds2.Value = TPDL.GetData(From, To, Convert.ToInt32(uiDropDownListPilots.SelectedValue)); ReportViewer2.LocalReport.DataSources.Add(rds); ReportViewer2.LocalReport.DataSources.Add(rds2); ReportViewer2.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("RateParameter", uiTextBoxRate.Text)); ReportViewer2.LocalReport.Refresh(); ReportViewer1.Visible = false; ReportViewer2.Visible = true; ReportViewer3.Visible = false; ReportViewer4.Visible = false; ReportViewer5.Visible = false; ReportViewer6.Visible = false; ReportViewer7.Visible = false; break; case "6": rds.Name = "AirplaneActualBurnOffDataSet"; rds.Value = APBO.GetData(Convert.ToInt32(uiDropDownListAirplane.SelectedValue),From, To); ReportViewer6.LocalReport.DataSources.Add(rds); ReportViewer6.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("StartDate", string.Format("{0:MM/dd/yyyy}", uiRadDatePickerFrom.SelectedDate))); ReportViewer6.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("EndDate", string.Format("{0:MM/dd/yyyy}", uiRadDatePickerTo.SelectedDate))); ReportViewer6.LocalReport.Refresh(); ReportViewer1.Visible = false; ReportViewer2.Visible = false; ReportViewer3.Visible = false; ReportViewer4.Visible = false; ReportViewer5.Visible = false; ReportViewer6.Visible = true; ReportViewer7.Visible = false; break; case "7": rds.Name = "SectorActualBurnOffDataSet"; rds.Value = SBO.GetData(Convert.ToInt32(uiDropDownListFrom.SelectedValue), Convert.ToInt32(uiDropDownListTo.SelectedValue), From, To); ReportViewer7.LocalReport.DataSources.Add(rds); ReportViewer7.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("StartDate", string.Format("{0:MM/dd/yyyy}", uiRadDatePickerFrom.SelectedDate))); ReportViewer7.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("EndDate", string.Format("{0:MM/dd/yyyy}", uiRadDatePickerTo.SelectedDate))); ReportViewer7.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("FromAirPort", uiDropDownListFrom.SelectedValue)); ReportViewer7.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter("ToAirPort", uiDropDownListTo.SelectedValue)); ReportViewer7.LocalReport.Refresh(); ReportViewer1.Visible = false; ReportViewer2.Visible = false; ReportViewer3.Visible = false; ReportViewer4.Visible = false; ReportViewer5.Visible = false; ReportViewer6.Visible = false; ReportViewer7.Visible = true; break; default: break; } } catch (Exception ex) { } }
private void LoadDDLs() { Pilot Allpilots = new Pilot(); Allpilots.LoadAll(); uiDropDownListPilots.DataSource = Allpilots.DefaultView; uiDropDownListPilots.DataTextField = "ShortName"; uiDropDownListPilots.DataValueField = "PilotID"; uiDropDownListPilots.DataBind(); uiDropDownListPilots.Items.Insert(0, new ListItem("Select Pilot", "")); AirPlane AllPlanes = new AirPlane(); AllPlanes.LoadAll(); uiDropDownListAirplane.DataSource = AllPlanes.DefaultView; uiDropDownListAirplane.DataTextField = "Name"; uiDropDownListAirplane.DataValueField = "AirPlaneID"; uiDropDownListAirplane.DataBind(); uiDropDownListAirplane.Items.Insert(0, new ListItem("All", "0")); AirPort AllAirports = new AirPort(); AllAirports.LoadAll(); uiDropDownListFrom.DataSource = AllAirports.DefaultView; uiDropDownListFrom.DataTextField = "IATACode"; uiDropDownListFrom.DataValueField = "AirPortID"; uiDropDownListFrom.DataBind(); uiDropDownListFrom.Items.Insert(0, new ListItem("Select Airport", "0")); uiDropDownListTo.DataSource = AllAirports.DefaultView; uiDropDownListTo.DataTextField = "IATACode"; uiDropDownListTo.DataValueField = "AirPortID"; uiDropDownListTo.DataBind(); uiDropDownListTo.Items.Insert(0, new ListItem("Select Airport", "0")); }
private void LoadDDLs() { Pilot Allpilots = new Pilot(); Allpilots.GetAllPilots(); uiDropDownListPilot.DataSource = Allpilots.DefaultView; uiDropDownListPilot.DataTextField = "DisplayName"; uiDropDownListPilot.DataValueField = "PilotID"; uiDropDownListPilot.DataBind(); uiDropDownListPilot.Items.Insert(0, new ListItem("Select Pilot", "")); Pilot AllCopilots = new Pilot(); AllCopilots.GetAllCoPilots(); uiDropDownListCoPilot.DataSource = AllCopilots.DefaultView; uiDropDownListCoPilot.DataTextField = "DisplayName"; uiDropDownListCoPilot.DataValueField = "PilotID"; uiDropDownListCoPilot.DataBind(); uiDropDownListCoPilot.Items.Insert(0, new ListItem("Select Co-Pilot", "")); Position AllPositions = new Position(); AllPositions.LoadAll(); uiDropDownListPilotPos.DataSource = AllPositions.DefaultView; uiDropDownListPilotPos.DataTextField = "Title"; uiDropDownListPilotPos.DataValueField = "PositionID"; uiDropDownListPilotPos.DataBind(); uiDropDownListPilotPos.Items.Insert(0, new ListItem("Select Position", "")); uiDropDownListCOPos.DataSource = AllPositions.DefaultView; uiDropDownListCOPos.DataTextField = "Title"; uiDropDownListCOPos.DataValueField = "PositionID"; uiDropDownListCOPos.DataBind(); uiDropDownListCOPos.Items.Insert(0, new ListItem("Select Position", "")); Crew AllCrew = new Crew(); AllCrew.LoadAll(); uiDropDownListCrew.DataSource = AllCrew.DefaultView; uiDropDownListCrew.DataTextField = "Name"; uiDropDownListCrew.DataValueField = "CrewID"; uiDropDownListCrew.DataBind(); uiDropDownListCrew.Items.Insert(0, new ListItem("Select Member", "")); uiDropDownListCrewPos.DataSource = AllPositions.DefaultView; ; uiDropDownListCrewPos.DataTextField = "Title"; uiDropDownListCrewPos.DataValueField = "PositionID"; uiDropDownListCrewPos.DataBind(); uiDropDownListCrewPos.Items.Insert(0, new ListItem("Select Position", "")); AirPort AllAirports = new AirPort(); AllAirports.LoadAll(); uiDropDownListSectorFrom.DataSource = AllAirports.DefaultView; uiDropDownListSectorFrom.DataTextField = "IATACode"; uiDropDownListSectorFrom.DataValueField = "AirPortID"; uiDropDownListSectorFrom.DataBind(); uiDropDownListSectorFrom.Items.Insert(0, new ListItem("Select Airport", "")); uiDropDownListSectorTo.DataSource = AllAirports.DefaultView; uiDropDownListSectorTo.DataTextField = "IATACode"; uiDropDownListSectorTo.DataValueField = "AirPortID"; uiDropDownListSectorTo.DataBind(); uiDropDownListSectorTo.Items.Insert(0, new ListItem("Select Airport", "")); AirPlane Ap = new AirPlane(); Ap.LoadAll(); uiDropDownListAirCraftRegistration.DataSource = Ap.DefaultView; uiDropDownListAirCraftRegistration.DataTextField = "Name"; uiDropDownListAirCraftRegistration.DataValueField = "AirPlaneID"; uiDropDownListAirCraftRegistration.DataBind(); }
public static TimeSpan[] CalculatePilotStatus(int pilotID, string fromdate, string todate) { TimeSpan []result; Pilot current = new Pilot(); current.LoadByPrimaryKey(pilotID); Pilot p = new Pilot(); DateTime? From = null; DateTime? To = null; CultureInfo provider = CultureInfo.InvariantCulture; provider = new CultureInfo("fr-FR"); if (!string.IsNullOrEmpty(fromdate)) { From = DateTime.ParseExact(fromdate, "dd/MM/yyyy", provider); } if (!string.IsNullOrEmpty(todate)) { To = DateTime.ParseExact(todate, "dd/MM/yyyy", provider); } if (current.RowCount > 0) p.GetPilotSchedule(current.PilotID, From, To); else return null; /************************************************************************************************/ DateTime FromAverage, ToAverage = new DateTime(); FromAverage = To.Value.AddDays(-28); ToAverage = To.Value; TimeSpan AverageTotal = new TimeSpan(); //TimeSpan DutyAverageTotal = new TimeSpan(); /***********current month Grand Total *************/ Pilot pTotal = new Pilot(); DateTime FromTotal = new DateTime(To.Value.Year, To.Value.Month, 1); DateTime ToTotal = new DateTime(To.Value.Year, To.Value.Month, getLastDay(To.Value.Month)); pTotal.GetPilotSchedule(current.PilotID, FromTotal, ToTotal); TimeSpan TotalTime = new TimeSpan(); TimeSpan TotalTimeUpToDate = new TimeSpan(); //TimeSpan DutyTotalUpToDate = new TimeSpan(); foreach (DataRow row in pTotal.DefaultView.Table.Rows) { TimeSpan currentTime = new TimeSpan(); if (row["ChoxOff"] != null && row["ChoxOn"] != null && string.IsNullOrEmpty(row["ChoxOff"].ToString()) && string.IsNullOrEmpty(row["ChoxOn"].ToString()) && (DateTime.Parse(row["ChoxOn"].ToString()).Subtract(DateTime.Parse(row["ChoxOff"].ToString())) != TimeSpan.Zero)) { DateTime choxon = DateTime.Parse(row["ChoxOn"].ToString()); DateTime choxoff = DateTime.Parse(row["ChoxOff"].ToString()); currentTime = choxon.Subtract(choxoff); } else { DateTime STD = DateTime.Parse(row["STD"].ToString()); DateTime STA = DateTime.Parse(row["STA"].ToString()); currentTime = STA.Subtract(STD); } if (TotalTime == TimeSpan.Zero) { TotalTime = currentTime; } else { TotalTime = TotalTime.Add(currentTime); } /* calculate total for currrent month from 1 to the ToDate */ if (Convert.ToDateTime(row["SectorDate"].ToString()) <= To.Value) { if (TotalTimeUpToDate == TimeSpan.Zero) { TotalTimeUpToDate = currentTime; } else { TotalTimeUpToDate = TotalTimeUpToDate.Add(currentTime); } /* if (DutyTotalUpToDate == TimeSpan.Zero) { DutyTotalUpToDate = currentTime.Add(new TimeSpan(1, 30, 0)); } else { DutyTotalUpToDate = DutyTotalUpToDate.Add(currentTime.Add(new TimeSpan(1, 30, 0))); }*/ } /* calculate the average total for the last 4 weeks */ /* add times related to average of last 4 weeks period from current month */ if (Convert.ToDateTime(row["SectorDate"].ToString()) <= ToAverage && Convert.ToDateTime(row["SectorDate"].ToString()) >= FromAverage) { if (AverageTotal == TimeSpan.Zero) { AverageTotal = currentTime; } else { AverageTotal = AverageTotal.Add(currentTime); } /* if (DutyAverageTotal == TimeSpan.Zero) { DutyAverageTotal = currentTime.Add(new TimeSpan(1, 30, 0)); } else { DutyAverageTotal = DutyAverageTotal.Add(currentTime.Add(new TimeSpan(1, 30, 0))); } */ } } /************************/ /***********last month Grand Total *************/ Pilot pLastTotal = new Pilot(); DateTime FromLastTotal = new DateTime((From.Value.Month != 1) ? From.Value.Year : From.Value.Year - 1, (From.Value.Month != 1) ? From.Value.Month - 1 : 12, 1); DateTime ToLastTotal = new DateTime((From.Value.Month != 1) ? From.Value.Year : From.Value.Year - 1, (From.Value.Month != 1) ? From.Value.Month - 1 : 12, getLastDay((From.Value.Month != 1) ? From.Value.Month - 1 : 12)); pLastTotal.GetPilotSchedule(current.PilotID, FromLastTotal, ToLastTotal); TimeSpan LastTotalTime = new TimeSpan(); foreach (DataRow row in pLastTotal.DefaultView.Table.Rows) { TimeSpan currentTime = new TimeSpan(); if (row["ChoxOff"] != null && row["ChoxOn"] != null && string.IsNullOrEmpty(row["ChoxOff"].ToString()) && string.IsNullOrEmpty(row["ChoxOn"].ToString()) && (DateTime.Parse(row["ChoxOn"].ToString()).Subtract(DateTime.Parse(row["ChoxOff"].ToString())) != TimeSpan.Zero)) { DateTime choxon = DateTime.Parse(row["ChoxOn"].ToString()); DateTime choxoff = DateTime.Parse(row["ChoxOff"].ToString()); currentTime = choxon.Subtract(choxoff); } else { DateTime STD = DateTime.Parse(row["STD"].ToString()); DateTime STA = DateTime.Parse(row["STA"].ToString()); currentTime = STA.Subtract(STD); } if (LastTotalTime == TimeSpan.Zero) { LastTotalTime = currentTime; } else { LastTotalTime = LastTotalTime.Add(currentTime); } /* add times related to average of last 4 weeks period from last month */ if (Convert.ToDateTime(row["SectorDate"].ToString()) <= ToAverage && Convert.ToDateTime(row["SectorDate"].ToString()) >= FromAverage) { if (AverageTotal == TimeSpan.Zero) { AverageTotal = currentTime; } else { AverageTotal = AverageTotal.Add(currentTime); } /* if (DutyAverageTotal == TimeSpan.Zero) { DutyAverageTotal = currentTime.Add(new TimeSpan(1, 30, 0)); } else { DutyAverageTotal = DutyAverageTotal.Add(currentTime.Add(new TimeSpan(1, 30, 0))); } */ } } result = new TimeSpan[4]; result[0] = TotalTime; // current month total result[1] = LastTotalTime; // last month total result[2] = AverageTotal; // last 4 weeks average result[3] = TotalTimeUpToDate; // total for selected period return result; }
private void LoadDDLs() { Pilot Allpilots = new Pilot(); Allpilots.GetAllPilots(); uiDropDownListPilot.DataSource = Allpilots.DefaultView; uiDropDownListPilot.DataTextField = "DisplayName"; uiDropDownListPilot.DataValueField = "PilotID"; uiDropDownListPilot.DataBind(); uiDropDownListPilot.Items.Insert(0, new ListItem("Select Pilot", "")); Pilot AllCopilots = new Pilot(); AllCopilots.GetAllCoPilots(); uiDropDownListCoPilot.DataSource = AllCopilots.DefaultView; uiDropDownListCoPilot.DataTextField = "DisplayName"; uiDropDownListCoPilot.DataValueField = "PilotID"; uiDropDownListCoPilot.DataBind(); uiDropDownListCoPilot.Items.Insert(0, new ListItem("Select Co-Pilot", "")); Position AllPositions = new Position(); AllPositions.LoadAll(); uiDropDownListPilotPos.DataSource = AllPositions.DefaultView; uiDropDownListPilotPos.DataTextField= "Title"; uiDropDownListPilotPos.DataValueField = "PositionID"; uiDropDownListPilotPos.DataBind(); uiDropDownListPilotPos.Items.Insert(0, new ListItem("Select Position", "")); uiDropDownListCOPos.DataSource = AllPositions.DefaultView; uiDropDownListCOPos.DataTextField = "Title"; uiDropDownListCOPos.DataValueField = "PositionID"; uiDropDownListCOPos.DataBind(); uiDropDownListCOPos.Items.Insert(0, new ListItem("Select Position", "")); }