Ejemplo n.º 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (MessageBoxEx.Show("确认开设此课程吗?请注意填写信息", "提示~", MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return;
            }
            CourseBLL bll   = new CourseBLL();
            Course    model = new Course(); //建立数据对象

            model.Name          = txtCourseName.Text.Trim();
            model.Room_name     = txtRoomName.Text.Trim();
            model.Semester      = txtSemester.Text;
            model.Speciality_id = (int)cbSpeciality.SelectedValue;
            model.Submitter_id  = frmMain.current_user.Id;

            if (bll.AddCourse(model))
            {
                MessageBoxEx.Show("添加成功!!!");
                btnCancel_Click(sender, e); //关闭窗口
            }
            else
            {
                MessageBoxEx.Show("添加失败,请检查信息后重试");
            }
        }
        //添加课程
        private void ucBtnAdd_BtnClick(object sender, EventArgs e)
        {
            if (!Check.isCourse(textBox1.Text))
            {
                MessageBox.Show("课程号错误");
                return;
            }

            string cid   = textBox1.Text;
            string cname = textBox2.Text;

            Course course = new Course()
            {
                CID         = cid,
                CName       = cname,
                Departments = teacher.Departments,
                CTeacher    = teacher.TID
            };
            CourseBLL bll = new CourseBLL();

            if (bll.AddCourse(course))
            {
                MessageBox.Show("添加成功");
                LoadCourseInfo();
            }
            else
            {
                MessageBox.Show("添加失败");
            }
        }
 //添加、修改
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if (btnAdd.Text == "添加")
     {
         Course model = new Course();
         model.CourseName = txtCourseName.Value.Trim();
         model.Credits    = Convert.ToInt32(txtCredits.Value.Trim());
         model.Note       = txtNote.Value.Trim();
         model.TeacherId  = Convert.ToInt32(ddlTeacherId.SelectedValue);
         if (CourseBLL.IsTrue(model.CourseName))
         {
             this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('该课程名称已存在,不能重复!');</script>");
             return;
         }
         else
         {
             if (CourseBLL.AddCourse(model) > 0)
             {
                 this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加成功!');window.location.replace('CourseManage.aspx');</script>");
                 return;
             }
             else
             {
                 this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加失败!');</script>");
                 return;
             }
         }
     }
     else
     {
         Course model = CourseBLL.GetIdByCourse(Convert.ToInt32(Request.QueryString["uid"]));
         model.CourseName = txtCourseName.Value.Trim();
         model.Credits    = Convert.ToInt32(txtCredits.Value.Trim());
         model.Note       = txtNote.Value.Trim();
         model.TeacherId  = Convert.ToInt32(ddlTeacherId.SelectedValue);
         if (CourseBLL.IsTrue(model.CourseName, model.CourseId))
         {
             this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('该课程名称已存在,不能重复!');</script>");
             return;
         }
         else
         {
             if (CourseBLL.UpdateCourse(model) > 0)
             {
                 this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功!');window.location.replace('CourseManage.aspx');</script>");
                 return;
             }
             else
             {
                 this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改失败!');</script>");
                 return;
             }
         }
     }
 }
Ejemplo n.º 4
0
    protected void ButtonAdd_Click(object sender, EventArgs e)
    {
        Course course = new Course();

        course.CourseNO     = Int32.Parse(TextBoxNO.Text);
        course.CourseName   = TextBoxName.Text;
        course.CourseCredit = Int32.Parse(TextBoxCredit.Text);
        CourseBLL bll = new CourseBLL();

        bll.AddCourse(course);
    }
        public IHttpActionResult AddCourse([FromBody] DAL.Courses_Tbl newCourse)
//todo: יש לבדוק שאין לנו קוד זהה בקורסים הקימים!
        {
            if (CourseBLL.AddCourse(newCourse))
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
Ejemplo n.º 6
0
        //private Control FindControlById(Control parent, String id)
        //{
        //    foreach (Control item in parent.Controls)
        //    {
        //        if (item.ID == id) return item;
        //        Control subControl = FindControlById(item, id);
        //        if (subControl != null) return subControl;
        //    }
        //    return null;
        //}


        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            int queryString = RequestHelper.GetQueryString <int>("ID");

            CourseInfo CourseModel = new CourseInfo();

            //if (_CompanyId > 0 && TempGroupId != 1 && TempGroupId != 2)
            //{
            CourseModel.CompanyId = systemCompanyId;
            //}
            //else
            //{
            //    if (CompanyId.SelectedValue == "-1") ScriptHelper.Alert("请选择公司");
            //    CourseModel.CompanyId = Convert.ToInt32(this.CompanyId.SelectedValue);
            //}
            if (this.CateId.SelectedValue == "-1")
            {
                ScriptHelper.Alert("请选择类别");
            }
            CourseModel.CourseId   = queryString;
            CourseModel.CourseName = this.CourseName.Text;
            //CourseModel.CourseCode = this.CourseCode.Text;
            CourseModel.CateId     = Convert.ToInt32(this.CateId.SelectedValue);
            CourseModel.OrderIndex = Convert.ToInt32(this.OrderIndex.Text);

            string alertMessage = ShopLanguage.ReadLanguage("AddOK");

            if (CourseModel.CourseId == int.MinValue)
            {
                base.CheckAdminPower("AddCourse", PowerCheckType.Single);
                int id = CourseBLL.AddCourse(CourseModel);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Course"), id);
            }
            else
            {
                base.CheckAdminPower("UpdateCourse", PowerCheckType.Single);
                CourseBLL.UpdateCourse(CourseModel);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("Course"), CourseModel.CourseId);
                alertMessage = ShopLanguage.ReadLanguage("UpdateOK");
            }
            AdminBasePage.Alert(alertMessage, RequestHelper.RawUrl);
        }
Ejemplo n.º 7
0
        public ActionResult AddCourse(CourseVM courseVM, FormCollection collection)
        {
            if (!string.IsNullOrEmpty(collection["activeState"]))
            {
                string checkResp  = collection["activeState"];
                bool   checkRespB = Convert.ToBoolean(checkResp);

                if (checkRespB)
                {
                    courseVM.isActive = true;
                }
                else
                {
                    courseVM.isActive = false;
                }
            }
            else
            {
                courseVM.isActive = false;
            }

            courseBll.AddCourse(courseVM);
            return(RedirectToAction("getAllCourses", "Course", new { area = "AdminArea" }));
        }