コード例 #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Contoso.Model.Department dept = new Contoso.Model.Department
            {
                Name         = txtName.Text,
                Budget       = TxtBudget.Text,
                StartDate    = Convert.ToDateTime(TxtStartDate.Text),
                InstructorId = Convert.ToInt32(TxtInstructorId.Text),
                RowVersion   = TxtRowVersion.Text
            };
            DeptService service = new DeptService();

            service.SaveDepartment(dept);
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var         deptid            = Convert.ToInt32(Request.QueryString["ID"]);
                DeptService service           = new DeptService();
                Contoso.Model.Department dept = service.GetDeptById(deptid);

                txtName.Text         = dept.Name;
                TxtBudget.Text       = dept.Budget;
                TxtStartDate.Text    = dept.StartDate.ToString();
                TxtInstructorId.Text = dept.InstructorId.ToString();
                TxtRowVersion.Text   = dept.RowVersion;
            }
        }
コード例 #3
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                Contoso.Model.Department dt = new Contoso.Model.Department
                {
                    Id           = Convert.ToInt32(Request.QueryString["id"]),
                    Name         = txtName.Text,
                    Budget       = TxtBudget.Text,
                    StartDate    = Convert.ToDateTime(TxtStartDate.Text),
                    InstructorId = Convert.ToInt32(TxtInstructorId.Text),
                    RowVersion   = TxtRowVersion.Text,
                };

                DeptService service = new DeptService();
                service.UpdateDept(dt);
            }
        }