Ejemplo n.º 1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            clsTrainCollection Train = new clsTrainCollection();
            //validation here
            Boolean OK = Train.ThisTrain.Valid(txtTrain.Text, txtCapacity.Text, txtActive.Text);
            //set some vars for the txt elements
            string Trains   = txtTrain.Text;
            string Capacity = txtCapacity.Text;
            string Active   = txtActive.Text;

            //if the data is OK add it to the object
            if (OK == true)
            {
                Train.ThisTrain.Train    = Trains;
                Train.ThisTrain.Capacity = Capacity;
                Train.ThisTrain.Active   = Active;
                Train.Add();
                //refresh the page
                Response.Redirect("Trains.aspx");
                lblValid.Text = "Success";
            }
            else
            {
                //report an error
                lblValid.Text = "Please try again";
            }
        }
Ejemplo n.º 2
0
        protected void btnFind_Click(object sender, EventArgs e)
        {
            string trains = txtTrain.Text;

            train = new clsTrainCollection();
            train.FilterByTrain(trains);
            GenerateTable();
        }
Ejemplo n.º 3
0
        private void DeleteRecord()
        {
            //new instance
            clsTrainCollection Record = new clsTrainCollection();

            //get the number of the Train to be deleted from the session object
            TrainID = Convert.ToInt32(Session["TrainID"]);
            //find the record
            Record.ThisTrain.Find(TrainID);
            //delete the record
            Record.Delete();
        }
Ejemplo n.º 4
0
        private void DisplayTrains()
        {
            clsTrainCollection TrainList = new clsTrainCollection();
            Int32 Index       = 0;
            Int32 RecordCount = TrainList.Count;

            while (Index < RecordCount)
            {
                Response.Write(TrainList.TrainList[Index].TrainID);
                Response.Write(TrainList.TrainList[Index].Train);
                Response.Write(TrainList.TrainList[Index].Capacity);
                //increment the index
                Index++;
            }
        }
Ejemplo n.º 5
0
        protected void btnRefresh_Click(object sender, EventArgs e)
        {
            clsTrainCollection train = new clsTrainCollection();

            GenerateTable();
        }