示例#1
0
 private void FillingStation()
 {
     foreach (Station s in StationDAL.GetAllStations())
     {
         cbStation.Items.Add(s.Name);
     }
 }
 private void FillingIntermediateStations()
 {
     foreach (IntermediateStation i in IntermediateStationDAL.GetAllIntermediateStations())
     {
         cbNew.Items.Add(StationDAL.GetStationByIntermediateStation(i.Id_IntermediateStation).Name);
     }
 }
示例#3
0
        private void AddStation()
        {
            if (String.IsNullOrEmpty(tbRTSurname.Text))
            {
                MessageBox.Show("Введите название станции!");
                return;
            }
            if (String.IsNullOrEmpty(tbRTName.Text))
            {
                MessageBox.Show("Введите телефон");
                return;
            }
            if (String.IsNullOrEmpty(tbRTPatronymic.Text))
            {
                MessageBox.Show("Введите ФИО начальника!");
                return;
            }
            if (String.IsNullOrEmpty(tbRTPassport.Text))
            {
                MessageBox.Show("Введите отдаленность в КМ!");
                return;
            }

            string name        = tbRTSurname.Text;
            string phoneNumber = tbRTName.Text;
            string chief       = tbRTPatronymic.Text;
            int    distance    = int.Parse(tbRTPassport.Text);

            StationDAL.Insert(name, phoneNumber, chief, distance);
            dgvRT.DataSource = StationDAL.GetAllStations();
            ClearText();
        }
 public fmAddIntermediateStation()
 {
     InitializeComponent();
     foreach (Station s in StationDAL.GetAllStations())
     {
         cbS.Items.Add(s.Name);
     }
 }
示例#5
0
 private void IntermediateStationsFilling()
 {
     foreach (IntermediateStation i in IntermediateStationDAL.GetAllIntermediateStations())
     {
         cbTicDS.Items.Add(StationDAL.GetStationByIntermediateStation(i.Id_IntermediateStation).Name);
         cbTicAS.Items.Add(StationDAL.GetStationByIntermediateStation(i.Id_IntermediateStation).Name);
     }
     cbTicDS.SelectedIndex = cbTicAS.SelectedIndex = 0;
 }
示例#6
0
        private void InsertTrainTable()
        {
            string departureStation = StationDAL.GetStationByName(cbAT1.Text).Id_Station.ToString();
            string arrivalStation   = StationDAL.GetStationByName(cbAT2.Text).Id_Station.ToString();
            string departureDate    = dtpDD.Value.ToString();
            string arrivalDate      = dtpAD.Value.ToString();
            string departureTime    = dtpDT.Value.ToString();
            string arrivalTime      = dtpAT.Value.ToString();

            TrainTableDAL.Insert(departureStation, arrivalStation, departureDate, arrivalDate, departureTime, arrivalTime);
        }
示例#7
0
 private void cbStationsFilling()
 {
     foreach (Station s in StationDAL.GetAllStations())
     {
         cbTableDS.Items.Add(s.Name);
         cbTableAS.Items.Add(s.Name);
         cbTripsAS.Items.Add(s.Name);
         cbTripsDS.Items.Add(s.Name);
     }
     cbTableDS.SelectedIndex = cbTableAS.SelectedIndex = cbTripsDS.SelectedIndex = cbTripsAS.SelectedIndex = 0;
 }
 private void SettingVisibleStations()
 {
     if (Type == TrainTableConst.DepartureStation || Type == TrainTableConst.ArrivalStation)
     {
         tbValue2.Visible = false;
         cbNewV.Visible   = true;
         foreach (Station s in StationDAL.GetAllStations())
         {
             cbNewV.Items.Add(s.Name);
         }
     }
 }
示例#9
0
        private void updateStation()
        {
            string          type      = dgvRT.SelectedCells[0].OwningColumn.Name;
            string          value     = dgvRT.SelectedCells[0].Value.ToString();
            Type            typeTable = dgvRT.SelectedCells[0].OwningRow.DataBoundItem.GetType();
            int             id        = (dgvRT.SelectedCells[0].OwningRow.DataBoundItem as Station).Id_Station;
            fmChangeValueRT f         = new fmChangeValueRT(type, value, id, typeTable);

            f.Text = dgvRT.SelectedCells[0].OwningColumn.HeaderText;
            if (f.ShowDialog() == DialogResult.OK)
            {
                MessageBox.Show("Значение изменено");
                dgvRT.DataSource = StationDAL.GetAllStations();
            }
        }
示例#10
0
        private static TrainTable GetTrainTableFromDataReader(SqlDataReader reader)
        {
            reader.Read();
            TrainTable t = new TrainTable()
            {
                Id_Table         = reader.GetInt32(0),
                DepartureStation = StationDAL.GetStationById(reader.GetInt32(1)).Name,
                ArrivalStation   = StationDAL.GetStationById(reader.GetInt32(2)).Name,
                DepartureDate    = reader.GetDateTime(3).ToShortDateString(),
                ArrivalDate      = reader.GetDateTime(4).ToShortDateString(),
                DepartureTime    = reader.GetValue(5).ToString(),
                ArrivalTime      = reader.GetValue(6).ToString()
            };

            return(t);
        }
示例#11
0
        private void AddStation()
        {
            if (!GetStation())
            {
                return;
            }
            int    idStation     = StationDAL.GetStationByName(cbStation.Text).Id_Station;
            string departureDate = dtpIS2.Text;
            string departureTime = dtpIS1.Text;
            string arrivalDate   = dtpIS4.Text;
            string arrivalTime   = dtpIS3.Text;

            IntermediateStationDAL.Insert(idStation, Id_Trip, departureDate, departureTime, arrivalDate, arrivalTime);
            MessageBox.Show("Строка добавлена");
            dgvIS.DataSource = IntermediateStationDAL.GetIntermediateStationsByTrip(Id_Trip);;
        }
        private static IntermediateStation GetIntermediateStationFromDataReader(SqlDataReader reader)
        {
            reader.Read();
            IntermediateStation t = new IntermediateStation()
            {
                Id_IntermediateStation = reader.GetInt32(0),
                Id_id_Station          = reader.GetInt32(1),
                Station       = StationDAL.GetStationById(reader.GetInt32(1)).Name,
                Id_id_Trip    = reader.GetInt32(2),
                DepartureDate = reader.GetDateTime(3).ToShortDateString(),
                ArrivalDate   = reader.GetDateTime(5).ToShortDateString(),
                DepartureTime = reader.GetValue(4).ToString(),
                ArrivalTime   = reader.GetValue(6).ToString()
            };

            return(t);
        }
示例#13
0
        private void SearchTripByStations()
        {
            int IdDepartureStation = cbTripsDS.SelectedIndex != 0?IdDepartureStation = StationDAL.GetStationByName(cbTripsDS.Text).Id_Station:0;
            int IdArrivalStation   = cbTripsAS.SelectedIndex != 0?IdArrivalStation = StationDAL.GetStationByName(cbTripsAS.Text).Id_Station:0;

            if (cbTripsDS.SelectedIndex != 0 && cbTripsAS.SelectedIndex != 0)
            {
                dgvTrips.DataSource = TripDAL.GetTripsByStations(IdDepartureStation, IdArrivalStation);
            }
            if (cbTripsAS.SelectedIndex != 0)
            {
                dgvTrips.DataSource = TripDAL.GetTripsByAStation(IdArrivalStation);
            }
            if (cbTripsDS.SelectedIndex != 0)
            {
                dgvTrips.DataSource = TripDAL.GetTripsByDStation(IdDepartureStation);
            }
        }
        private void btnChange_Click(object sender, EventArgs e)
        {
            string txt         = null;
            string Id_NewValue = null;

            if (tbValue2.Visible)
            {
                txt = tbValue2.Text;
            }
            if (cbNewV.Visible)
            {
                txt         = cbNewV.Text;
                Id_NewValue = StationDAL.GetStationByName(cbNewV.Text).Id_Station.ToString();
            }
            if (dtpChange.Visible)
            {
                txt = dtpChange.Value.ToShortDateString();
            }
            UpdateTable(Id_NewValue, txt);
        }
示例#15
0
        private static List <TrainTable> GetTrainTablesListFromDataReader(SqlDataReader reader)
        {
            List <TrainTable> result = new List <TrainTable>();

            while (reader.Read())
            {
                TrainTable t = new TrainTable()
                {
                    Id_Table         = reader.GetInt32(0),
                    DepartureStation = StationDAL.GetStationById(reader.GetInt32(1)).Name,
                    ArrivalStation   = StationDAL.GetStationById(reader.GetInt32(2)).Name,
                    DepartureDate    = reader.GetDateTime(3).ToShortDateString(),
                    ArrivalDate      = reader.GetDateTime(4).ToShortDateString(),
                    DepartureTime    = reader.GetValue(5).ToString(),
                    ArrivalTime      = reader.GetValue(6).ToString()
                };
                result.Add(t);
            }
            return(result);
        }
        private static List <IntermediateStation> GetIntermediateStationsListFromDataReader(SqlDataReader reader)
        {
            List <IntermediateStation> result = new List <IntermediateStation>();

            while (reader.Read())
            {
                IntermediateStation t = new IntermediateStation()
                {
                    Id_IntermediateStation = reader.GetInt32(0),
                    Id_id_Station          = reader.GetInt32(1),
                    Station       = StationDAL.GetStationById(reader.GetInt32(1)).Name,
                    Id_id_Trip    = reader.GetInt32(2),
                    DepartureDate = reader.GetDateTime(3).ToShortDateString(),
                    ArrivalDate   = reader.GetDateTime(5).ToShortDateString(),
                    DepartureTime = reader.GetValue(4).ToString(),
                    ArrivalTime   = reader.GetValue(6).ToString()
                };
                result.Add(t);
            }
            return(result);
        }
示例#17
0
 private void VisibleStations()
 {
     dgvRT.Columns[0].DataPropertyName = "Name";
     dgvRT.Columns[1].DataPropertyName = "PhoneNumber";
     dgvRT.Columns[2].DataPropertyName = "Chief";
     dgvRT.Columns[3].DataPropertyName = "DistanceInKM";
     dgvRT.Columns[0].Name             = "Name";
     dgvRT.Columns[1].Name             = "PhoneNumber";
     dgvRT.Columns[2].Name             = "Chief";
     dgvRT.Columns[3].Name             = "DistanceInKM";
     dgvRT.Columns[0].HeaderText       = "Название станции";
     dgvRT.Columns[1].HeaderText       = "Телефон";
     dgvRT.Columns[2].HeaderText       = "Начальник";
     dgvRT.Columns[3].HeaderText       = "Отдаленность в км";
     lbRTSurname.Text         = "Название станции";
     lbRTName.Text            = "Телефон";
     lbRTPatronymic.Text      = "Начальник";
     lbRTPassport.Text        = "Отдаленность в км";
     dgvRT.Columns[1].Visible = true;
     dgvRT.DataSource         = StationDAL.GetAllStations();
 }
示例#18
0
        private void UpdateStation(string newValue)
        {
            switch (Type)
            {
            case StationConst.PhoneNumber:
                StationDAL.UpdatePhoneNumber(newValue, Id);
                break;

            case StationConst.Name:
                StationDAL.UpdateName(newValue, Id);
                break;

            case StationConst.Chief:
                StationDAL.UpdateChief(newValue, Id);
                break;

            case StationConst.DistanceInKM:
                StationDAL.UpdateDistance(newValue, Id);
                break;
            }
        }
示例#19
0
        private static List <Ticket> GetTicketsListFromDataReader(SqlDataReader reader)
        {
            List <Ticket> result = new List <Ticket>();

            while (reader.Read())
            {
                Ticket t = new Ticket()
                {
                    Id_Ticket      = reader.GetInt32(0),
                    Passenger      = PassengerDAL.GetPassengerById(reader.GetInt32(2)).Surname.Trim(' ') + ' ' + PassengerDAL.GetPassengerById(reader.GetInt32(2)).Name[0] + '.' + PassengerDAL.GetPassengerById(reader.GetInt32(2)).Patronymic[0] + '.',
                    Id_id_Trip     = reader.GetInt32(3),
                    LandingStation = StationDAL.GetStationByIntermediateStation(reader.GetInt32(4)).Name,
                    ExitStation    = StationDAL.GetStationByIntermediateStation(reader.GetInt32(5)).Name,
                    CarriageType   = CarriageTypeDAL.GetCarriageTypeById(reader.GetInt32(6)).Type,
                    PlaseNumber    = reader.GetInt32(7),
                    Price          = reader.GetInt32(1),
                };
                result.Add(t);
            }
            return(result);
        }
示例#20
0
        private void SearchTableByStations()
        {
            int IdDepartureStation = cbTableDS.SelectedIndex != 0  ? StationDAL.GetStationByName(cbTableDS.Text).Id_Station : 0;
            int IdArrivalStation   = cbTableAS.SelectedIndex != 0 ? StationDAL.GetStationByName(cbTableAS.Text).Id_Station : 0;

            if (cbTableDS.SelectedIndex != 0 && cbTableAS.SelectedIndex != 0)
            {
                dgvTable.DataSource = TrainTableDAL.GetTrainTablesByStation(IdDepartureStation, IdArrivalStation);
                return;
            }
            if (cbTableAS.SelectedIndex != 0)
            {
                dgvTable.DataSource = TrainTableDAL.GetTrainTablesByAStation(IdArrivalStation);
                return;
            }
            if (cbTableDS.SelectedIndex != 0)
            {
                dgvTable.DataSource = TrainTableDAL.GetTrainTablesByDStation(IdDepartureStation);
                return;
            }
            dgvTable.DataSource = TrainTableDAL.GetAllTrainTables();
        }
示例#21
0
 private void DelStation(int id)
 {
     StationDAL.Delete(id);
     dgvRT.DataSource = StationDAL.GetAllStations();
 }