コード例 #1
0
ファイル: AddCourse.aspx.cs プロジェクト: hyf1120/Contoso
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Contoso.Model.Courses course = new Contoso.Model.Courses
            {
                Title        = txtTitle.Text,
                Credits      = Convert.ToInt32(txtCredit.Text),
                DepartmentId = Convert.ToInt32(txtDepartmentId.Text)
            };
            CourseService service = new CourseService();

            service.SaveCourse(course);
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var                   courseid = Convert.ToInt32(Request.QueryString["ID"]);
                CourseService         service  = new CourseService();
                Contoso.Model.Courses c        = service.GetCourseById(courseid);

                txtTitle.Text   = c.Title;
                txtCredits.Text = c.Credits.ToString();
                TxtDeptId.Text  = c.DepartmentId.ToString();
            }
        }
コード例 #3
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Contoso.Model.Courses cs = new Contoso.Model.Courses
                {
                    Id           = Convert.ToInt32(Request.QueryString["id"]),
                    Title        = txtTitle.Text,
                    Credits      = Convert.ToInt32(txtCredits.Text),
                    DepartmentId = Convert.ToInt32(TxtDeptId.Text),
                };

                CourseService service = new CourseService();
                service.UpdateCourse(cs);
            }
        }