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

                this.OnDelete(CourseLogic.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.Course = CourseLogic.GetByID(this.DataContext, id);

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

                obj.SemesterID = int.Parse(this.SemesterField.SelectedValue);
                obj.TeacherID  = int.Parse(this.TeacherField.SelectedValue);
                obj.Number     = this.NumberField.Text;
                obj.Name       = this.NameField.Text;
                obj.Status     = (DataAccess.CourseStatus)Enum.Parse(typeof(DataAccess.CourseStatus), this.CourseStatusField.SelectedValue);

                this.DataContext.AcceptAllChanges();
                OnSaved(obj);
            }
            else
            {
                Course obj = CourseLogic.CreateCourse(this.DataContext, int.Parse(this.SemesterField.SelectedValue), int.Parse(this.TeacherField.SelectedValue), this.NumberField.Text, this.NameField.Text, (DataAccess.CourseStatus)Enum.Parse(typeof(DataAccess.CourseStatus), this.CourseStatusField.SelectedValue));

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