Ejemplo n.º 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(TeacherLogic.GetByID(this.DataContext, primaryKey));
            }
            else if ("Delete".Equals(e.CommandName))
            {
                int primaryKey = (int)this.Grid.DataKeys[e.Item.ItemIndex];

                this.OnDelete(TeacherLogic.GetByID(this.DataContext, primaryKey));
            }
        }
Ejemplo n.º 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.Teacher = TeacherLogic.GetByID(this.DataContext, id);

                if (!this.IsPostBack)
                {
                    this.EditControl.DataBind(this.Teacher);
                }
            }
        }
Ejemplo n.º 3
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            if (this.ObjectID.HasValue)
            {
                Teacher obj = TeacherLogic.GetByID(this.DataContext, this.ObjectID.Value);

                obj.SSN       = this.SSNField.Text;
                obj.FirstName = this.FirstNameField.Text;
                obj.LastName  = this.LastNameField.Text;
                obj.Active    = this.ActiveField.Checked;

                this.DataContext.AcceptAllChanges();
                OnSaved(obj);
            }
            else
            {
                Teacher obj = TeacherLogic.CreateTeacher(this.DataContext, this.SSNField.Text, this.FirstNameField.Text, this.LastNameField.Text, this.ActiveField.Checked);

                this.DataContext.AcceptAllChanges();
                OnSaved(obj);
            }
        }
Ejemplo n.º 4
0
 /// <summary>Gets the Teacher with the specified primary key.</summary>
 /// <param name="id">The primary key of the Teacher to return.</param>
 /// <returns>The matching Teacher, if one exists, or null.</returns>
 public SO.Teacher GetTeacherByID(int id)
 {
     return(SO.Teacher.FromDataAccessObject(TeacherLogic.GetByID(id)));
 }
Ejemplo n.º 5
0
 /// <summary>Gets the Teacher with the specified primary key.</summary>
 /// <param name="id">The primary key of the Teacher to return.</param>
 /// <returns>The matching Teacher, if one exists, or null.</returns>
 public SO.Teacher GetTeacherByID(string id)
 {
     return(SO.Teacher.FromDataAccessObject(TeacherLogic.GetByID(ParseInt("id", id))));
 }