protected void uiLinkButtonAddCrew_Click(object sender, EventArgs e)
 {
     SectorCrew Member = new SectorCrew();
     if (!CrewExists(Convert.ToInt32(uiDropDownListCrew.SelectedValue)))
     {
         Member.AddNew();
         Member.SectorID = CurrentSector.SectorID;
         Member.PositionID = Convert.ToInt32(uiDropDownListCrewPos.SelectedValue);
         Member.CrewID = Convert.ToInt32(uiDropDownListCrew.SelectedValue);
         Member.Save();
     }
     BindCrew();
 }
Esempio n. 2
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;
        }