예제 #1
0
        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));
            }
        }
예제 #2
0
        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);
                }
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
 /// <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)));
 }
예제 #5
0
 /// <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))));
 }