Ejemplo n.º 1
0
        //public String ReturnUrl
        //{
        //    set
        //    {
        //        btnCancel.Visible = true;
        //        hidRetUrl.Value = value;
        //    }
        //}



        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                var cat = new Academic.DbEntities.Subjects.SubjectCategory()
                {
                    Id = CategoryId
                    ,
                    SchoolId = SchoolId
                    ,
                    CreatedDate = DateTime.Now.Date
                    ,
                    Description = txtDescription.Text
                    ,
                    IsActive = chkIsActive.Checked
                    ,
                    Name = txtName.Text
                };
                if (!(cmbCategory.SelectedValue == "" || cmbCategory.SelectedValue == "0" || cmbCategory.SelectedValue == "-1"))
                {
                    cat.ParentId = Convert.ToInt32(cmbCategory.SelectedValue);
                }

                using (var helper = new DbHelper.Subject())
                {
                    var save = helper.AddOrUpdateSubjectCategory(cat);
                    if (save != null)
                    {
                        Response.Redirect("~/Views/Course/?catId=" + save.Id);
                    }
                    else
                    {
                        lblError.Visible = true;
                    }
                }
            }
        }