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"; } }
protected void btnFind_Click(object sender, EventArgs e) { string trains = txtTrain.Text; train = new clsTrainCollection(); train.FilterByTrain(trains); GenerateTable(); }
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(); }
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++; } }
protected void btnRefresh_Click(object sender, EventArgs e) { clsTrainCollection train = new clsTrainCollection(); GenerateTable(); }