protected void Grid_ItemCommand(object sender, DataGridCommandEventArgs e) { if ("Edit".Equals(e.CommandName)) { int primaryKey = (int)this.Grid.DataKeys[e.Item.ItemIndex]; this.OnEdit(MajorLogic.GetByID(this.DataContext, primaryKey)); } else if ("Delete".Equals(e.CommandName)) { int primaryKey = (int)this.Grid.DataKeys[e.Item.ItemIndex]; this.OnDelete(MajorLogic.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.Major = MajorLogic.GetByID(this.DataContext, id); if (!this.IsPostBack) { this.EditControl.DataBind(this.Major); } } }
protected void SaveButton_Click(object sender, EventArgs e) { if (this.ObjectID.HasValue) { Major obj = MajorLogic.GetByID(this.DataContext, this.ObjectID.Value); obj.Name = this.NameField.Text; this.DataContext.SubmitChanges(); OnSaved(obj); } else { Major obj = MajorLogic.CreateMajor(this.DataContext, this.NameField.Text); this.DataContext.SubmitChanges(); OnSaved(obj); } }
/// <summary>Gets the Major with the specified primary key.</summary> /// <param name="id">The primary key of the Major to return.</param> /// <returns>The matching Major, if one exists, or null.</returns> public SO.Major GetMajorByID(int id) { return(SO.Major.FromDataAccessObject(MajorLogic.GetByID(id))); }
/// <summary>Gets the Major with the specified primary key.</summary> /// <param name="id">The primary key of the Major to return.</param> /// <returns>The matching Major, if one exists, or null.</returns> public SO.Major GetMajorByID(string id) { return(SO.Major.FromDataAccessObject(MajorLogic.GetByID(ParseInt("id", id)))); }