Beispiel #1
0
        ScheduleTrain openEditForm(ScheduleTrain train)
        {
            EditForm editDialog = new EditForm();

            if (train != null)
            {
                ((TextBox)editDialog.Controls["FieldDestinationStation"]).Text  = train.getDestinationStation();
                ((TextBox)editDialog.Controls["FieldNumberTrain"]).Text         = train.getNumberTrain();
                ((MaskedTextBox)editDialog.Controls["FieldDepartureTime"]).Text = train.getDepartureTime().ToString();
                ((MaskedTextBox)editDialog.Controls["FieldArrivalTime"]).Text   = train.getArrivalTime().ToString();
                ((TextBox)editDialog.Controls["FieldTravelPrice"]).Text         = train.getTravelPrice().ToString();
            }

            if (editDialog.ShowDialog(this) == DialogResult.OK)
            {
                ScheduleTrain result = new ScheduleTrain();
                result.setDestinationStation(((TextBox)editDialog.Controls["FieldDestinationStation"]).Text);
                result.setNumberTrain(((TextBox)editDialog.Controls["FieldNumberTrain"]).Text);
                result.setDepartureTime(Convert.ToDateTime(((MaskedTextBox)editDialog.Controls["FieldDepartureTime"]).Text));
                result.setArrivalTime(Convert.ToDateTime(((MaskedTextBox)editDialog.Controls["FieldArrivalTime"]).Text));
                result.setTravelPrice(Convert.ToDouble(((TextBox)editDialog.Controls["FieldTravelPrice"]).Text));
                return(result);
            }

            return(null);
        }
Beispiel #2
0
        private void setRowData(DataGridViewRow row, ScheduleTrain train)
        {
            if (row.Cells.Count == 0)
            {
                row.CreateCells(TrainDataView);
            }

            row.Cells[0].Value = train.getDestinationStation();
            row.Cells[1].Value = train.getNumberTrain();
            row.Cells[2].Value = train.getDepartureTime();
            row.Cells[3].Value = train.getArrivalTime();
            row.Cells[4].Value = train.getTravelPrice();
        }