Example #1
0
        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 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();
 }