protected void uiGridViewPiolts_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeletePiolt") { SectorPilot objData = new SectorPilot(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); objData.MarkAsDeleted(); objData.Save(); BindPilots(); } }
private void BindPilots() { /*if (CurrentFlightReport.RowCount > 0) { CurrentPilots.GetPilotByFlightID(CurrentFlightReport.ReportID); DT_CurrentPilots = CurrentPilots.DefaultView.Table; }*/ if (IsEdit && CanLoad) { CurrentPilots = new SectorPilot(); CurrentPilots.GetPilotBySectorID(CurrentSector.SectorID); InitializeDataTables(1); foreach (DataRow item in CurrentPilots.DefaultView.Table.Rows) { DataRow row = CurrentPilotsTable.NewRow(); row["ReportPilotID"] = item["ReportPilotID"]; row["SectorID"] = item["SectorID"]; row["PilotID"] = item["PilotID"]; row["PositionID"] = item["PositionID"]; CurrentPilotsTable.Rows.Add(row); } uiGridViewPiolts.DataSource = CurrentPilotsTable; } else { uiGridViewPiolts.DataSource = CurrentPilotsTable; } uiGridViewPiolts.DataBind(); }
protected void uiRadGrid_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == "EditSector") { Sector objData = new Sector(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); uiTextBoxSectorFlightNo.Text = objData.FlightNo; uiTextBoxDate.Text = objData.SectorDate.ToString("dd/MM/yyyy"); uiDropDownListSectorFrom.SelectedValue = objData.From_AirportID.ToString(); uiDropDownListSectorTo.SelectedValue = objData.To_AirportID.ToString(); CurrentSector = objData; IsEdit = true; CanLoad = true; uiPanelEdit.Visible = true; uiPanelViewAll.Visible = false; // BindSectors(); BindCrew(); BindPilots(); CanLoad = false; } else if (e.CommandName == "DeleteSector") { Sector objData = new Sector(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); if ((objData.IsColumnNull("IsReturnSector") || objData.IsReturnSector == false) && !objData.IsColumnNull("ReturnSectorID")) { Sector ReturnFlight = new Sector(); ReturnFlight.LoadByPrimaryKey(objData.ReturnSectorID); ReturnFlight.IsReturnSector = false; ReturnFlight.Save(); } SectorCrew crew = new SectorCrew(); crew.GetCrewBySectorID(objData.SectorID); SectorPilot pilots = new SectorPilot(); pilots.GetPilotBySectorID(objData.SectorID); pilots.DeleteAll(); pilots.Save(); crew.DeleteAll(); crew.Save(); objData.MarkAsDeleted(); objData.Save(); BindReportData(); } }
protected void uiLinkButtonSave_Click(object sender, EventArgs e) { if (!IsEdit) { CurrentSector = new Sector(); CurrentSector.AddNew(); } CurrentSector.AirCraft_AirPlaneID = 1; CurrentSector.FlightNo = uiTextBoxSectorFlightNo.Text; CurrentSector.SectorDate = DateTime.ParseExact(uiTextBoxDate.Text, "dd/MM/yyyy", null); CurrentSector.IsPAX = true; CurrentSector.From_AirportID = Convert.ToInt32(uiDropDownListSectorFrom.SelectedValue); CurrentSector.To_AirportID = Convert.ToInt32(uiDropDownListSectorTo.SelectedValue); CurrentSector.Save(); if (IsEdit) { SectorPilot Oldpilots = new SectorPilot(); Oldpilots.GetPilotBySectorID(CurrentSector.SectorID); Oldpilots.DeleteAll(); Oldpilots.Save(); SectorCrew OldCrew = new SectorCrew(); OldCrew.GetCrewBySectorID(CurrentSector.SectorID); OldCrew.DeleteAll(); OldCrew.Save(); } CurrentPilots = new SectorPilot(); for(int i=0 ;i< CurrentPilotsTable.Rows.Count ; i++) { CurrentPilots.AddNew(); CurrentPilots.SectorID = CurrentSector.SectorID; CurrentPilots.PilotID = Convert.ToInt32(CurrentPilotsTable.Rows[i]["PilotID"]); // CurrentPilots.PositionID = Convert.ToInt32(CurrentPilotsTable.Rows[i]["PositionID"]); } CurrentPilots.Save(); CurrentCrew = new SectorCrew(); for (int i = 0; i < CurrentCrewTable.Rows.Count; i++) { CurrentCrew.AddNew(); CurrentCrew.SectorID = CurrentSector.SectorID; CurrentCrew.CrewID = Convert.ToInt32(CurrentCrewTable.Rows[i]["CrewID"]); // CurrentCrew.PositionID = Convert.ToInt32(CurrentCrewTable.Rows[i]["PositionID"]); } CurrentCrew.Save(); if (MasterSector != null) { MasterSector.ReturnSectorID = CurrentSector.SectorID; CurrentSector.IsReturnSector = true; MasterSector.Save(); CurrentSector.Save(); } BindReportData(); uiPanelViewAll.Visible = true; uiPanelEdit.Visible = false; MasterSector = null; CurrentSector = null; CurrentCrew = null; CurrentPilots = null; CurrentCrewTable = null; CurrentPilotsTable = null; }
protected void uiRadGridFlights_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.CommandName == "EditSectorDetails") { Sector objData = new Sector(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); CurrentSector = objData; if (Roles.IsUserInRole("Operation") || Roles.IsUserInRole("Dispatcher")) { Response.Redirect("~/Operation/SectorDetails.aspx?F=" + uiRadDatePickerFrom.SelectedDate.Value.ToString("dd/MM/yyyy") + "&T=" + uiRadDatePickerTo.SelectedDate.Value.ToString("dd/MM/yyyy")); } else if (Roles.IsUserInRole("Commercial")) { Response.Redirect("~/Operation/InitiateSector.aspx?F=" + uiRadDatePickerFrom.SelectedDate.Value.ToString("dd/MM/yyyy") + "&T=" + uiRadDatePickerTo.SelectedDate.Value.ToString("dd/MM/yyyy")); } } else if (e.CommandName == "EditSectorPilots") { Sector objData = new Sector(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); CurrentSector = objData; Response.Redirect("~/Operation/SectorPilots.aspx?F=" + uiRadDatePickerFrom.SelectedDate.Value.ToString("dd/MM/yyyy") + "&T=" + uiRadDatePickerTo.SelectedDate.Value.ToString("dd/MM/yyyy")); } else if (e.CommandName == "EditSectorCrew") { Sector objData = new Sector(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); CurrentSector = objData; Response.Redirect("~/Operation/SectorCabinCrew.aspx?F=" + uiRadDatePickerFrom.SelectedDate.Value.ToString("dd/MM/yyyy") + "&T=" + uiRadDatePickerTo.SelectedDate.Value.ToString("dd/MM/yyyy")); } else if (e.CommandName == "DeleteSector") { Sector objData = new Sector(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); CurrentSector = objData; SectorCrew crew = new SectorCrew(); crew.GetCrewBySectorID(objData.SectorID); SectorPilot pilots = new SectorPilot(); pilots.GetPilotBySectorID(objData.SectorID); pilots.DeleteAll(); pilots.Save(); crew.DeleteAll(); crew.Save(); objData.MarkAsDeleted(); objData.Save(); CurrentSector = null; SearchSectors(); } else if (e.CommandName == "ViewReport") { Sector objData = new Sector(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); CurrentSector = objData; Response.Redirect("FlightReport.aspx?RID=" + e.CommandArgument.ToString()); } }
private void BindPilots() { SectorPilot pilots = new SectorPilot(); pilots.GetPilotBySectorID(CurrentSector.SectorID); uiGridViewPiolts.DataSource = pilots.DefaultView; uiGridViewPiolts.DataBind(); }
/* protected void uiButtonSaveMaster_Click(object sender, EventArgs e) { if (CurrentFlightReport != null) { Flight objData = CurrentFlightReport; //objData.FlightNo = uiTextBoxFlightNo.Text; objData.AirCraft_AirPlaneID = Convert.ToInt32(uiDropDownListAirCraftRegistration.SelectedValue); objData.ReportDate = DateTime.ParseExact(uiTextBoxDate.Text, "dd/MM/yyyy", null); objData.IsHeavy = uiCheckBoxIsHeavy.Checked; objData.Save(); } else { Flight objData = new Flight(); objData.AddNew(); //objData.FlightNo = uiTextBoxFlightNo.Text; objData.AirCraft_AirPlaneID = Convert.ToInt32(uiDropDownListAirCraftRegistration.SelectedValue); objData.ReportDate = DateTime.ParseExact(uiTextBoxDate.Text, "dd/MM/yyyy", null); objData.IsHeavy = uiCheckBoxIsHeavy.Checked; objData.Save(); CurrentFlightReport = objData; EnableDisableTabs(); } }*/ protected void uiRadGridFlights_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.CommandName == "EditSector") { Sector objData = new Sector(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); CurrentSector = objData; FillSectorData(); uiPanelEdit.Visible = true; uiPanelViewAll.Visible = false; EnableDisableTabs(); //BindSectors(); BindCrew(); BindPilots(); } else if (e.CommandName == "DeleteSector") { Sector objData = new Sector(); objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString())); SectorCrew crew = new SectorCrew(); crew.GetCrewBySectorID(objData.SectorID); SectorPilot pilots = new SectorPilot(); pilots.GetPilotBySectorID(objData.SectorID); pilots.DeleteAll(); pilots.Save(); crew.DeleteAll(); crew.Save(); //sectors.DeleteAll(); //sectors.Save(); objData.MarkAsDeleted(); objData.Save(); //BindReportData(); SearchSectors(); } else if (e.CommandName == "ViewReport") { Response.Redirect("FlightReport.aspx?RID=" + e.CommandArgument.ToString()); } }
protected void uiLinkButtonAddFlying_Click(object sender, EventArgs e) { SectorPilot Member = new SectorPilot(); if (!PilotExists(Convert.ToInt32(uiDropDownListPilot.SelectedValue))) { Member.AddNew(); Member.SectorID = CurrentSector.SectorID; Member.PositionID = Convert.ToInt32(uiDropDownListPilotPos.SelectedValue); Member.PilotID = Convert.ToInt32(uiDropDownListPilot.SelectedValue); Member.Save(); } BindPilots(); }
private bool PilotExists(int pilotID) { bool exist = false; SectorPilot Member = new SectorPilot(); Member.GetPilotBySectorID(CurrentSector.SectorID); foreach (DataRowView item in Member.DefaultView) { if (pilotID.ToString() == item["PilotID"].ToString()) { exist = true; break; } } return exist; }