protected void Grid_ItemCommand(object sender, DataGridCommandEventArgs e) { if ("Edit".Equals(e.CommandName)) { int primaryKey = (int)this.Grid.DataKeys[e.Item.ItemIndex]; this.OnEdit(SemesterLogic.GetByID(this.DataContext, primaryKey)); } else if ("Delete".Equals(e.CommandName)) { int primaryKey = (int)this.Grid.DataKeys[e.Item.ItemIndex]; this.OnDelete(SemesterLogic.GetByID(this.DataContext, primaryKey)); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); string idString = this.Request.QueryString["ID"]; int id; if (int.TryParse(idString, out id)) { this.Semester = SemesterLogic.GetByID(this.DataContext, id); if (!this.IsPostBack) { this.EditControl.DataBind(this.Semester); } } }
protected void SaveButton_Click(object sender, EventArgs e) { if (this.ObjectID.HasValue) { Semester obj = SemesterLogic.GetByID(this.DataContext, this.ObjectID.Value); obj.Begin = this.BeginField.SelectedDate; obj.End = this.EndField.SelectedDate; obj.Name = this.NameField.Text; this.DataContext.AcceptAllChanges(); OnSaved(obj); } else { Semester obj = SemesterLogic.CreateSemester(this.DataContext, this.BeginField.SelectedDate, this.EndField.SelectedDate, this.NameField.Text); this.DataContext.AcceptAllChanges(); OnSaved(obj); } }
/// <summary>Gets the Semester with the specified primary key.</summary> /// <param name="id">The primary key of the Semester to return.</param> /// <returns>The matching Semester, if one exists, or null.</returns> public SO.Semester GetSemesterByID(int id) { return(SO.Semester.FromDataAccessObject(SemesterLogic.GetByID(id))); }
/// <summary>Gets the Semester with the specified primary key.</summary> /// <param name="id">The primary key of the Semester to return.</param> /// <returns>The matching Semester, if one exists, or null.</returns> public SO.Semester GetSemesterByID(string id) { return(SO.Semester.FromDataAccessObject(SemesterLogic.GetByID(ParseInt("id", id)))); }