예제 #1
0
        public async Task <IActionResult> PutCoures([FromRoute] string id, [FromBody] Coures c)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            if (id != c.CourseId)
            {
                return(BadRequest());
            }
            _database.Entry(c).State = EntityState.Modified;
            try
            {
                await _database.SaveChangesAsync();
            }
            catch (Exception)
            {
                if (!CouresExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
        public async Task <IActionResult> PostCoures([FromBody] Coures c)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            _database.Coures.Add(c);

            try
            {
                await _database.SaveChangesAsync();
            }

            catch (Exception)
            {
                if (CouresExists(c.CourseId))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }
            return(CreatedAtAction("GetCoures", new { id = c.CourseId }, c));
        }
예제 #3
0
        private void Btn_Click(object sender, EventArgs e)
        {
            Button     t  = (Button)sender;
            Coures     c  = new Coures();
            BLL_Coures bc = new BLL_Coures();

            bname.Text = t.Text;
            bid.Text   = t.ID;
        }
예제 #4
0
 public Coures getCouresByID(string couresID)
 {
     using (ISession session = getSession())
     {
         Coures c = (Coures)session.Get(typeof(Coures), couresID);
         c.ProfessionID = c.Profession.Id;
         c.FacultyID    = c.Profession.Faculty.Id;
         return(c);
     }
 }
        public int total(Coures c)
        {
            string sql = "select count(*) from CourseDetails where C_ID=@id";

            SqlParameter[] par =
            {
                new SqlParameter("@id", c.C_ID),
            };
            return(Convert.ToInt32(SQLHelper.ExecuteScalar(sql, System.Data.CommandType.Text, par)));
        }
        // 删除单词包
        public int DeleteCoures(Coures cr)
        {
            string sql = "delete from Coures where C_ID=@a and C_NAME=@b";

            SqlParameter[] par = new SqlParameter[] {
                new SqlParameter("@a", cr.C_ID),
                new SqlParameter("@b", cr.C_NAME)
            };
            return(SQLHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text, par));
        }
        //修改单词包
        public int UpdateCoures(Coures cr)
        {
            string sql = @"update Coures set C_NAME=@b where C_ID=@a";

            SqlParameter[] par =
            {
                new SqlParameter("@a", cr.C_ID),
                new SqlParameter("@b", cr.C_NAME),
            };
            return(SQLHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text, par));
        }
예제 #8
0
파일: Coures_Dal.cs 프로젝트: yyl7727/bcz
        /// <summary>
        /// 查询单词包id
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public object QueryCourseID(Coures c)
        {
            string sqlTest =
                @"select C_ID from Coures where C_NAME=@name";

            SqlParameter[] par =
            {
                new SqlParameter("@name", c.C_NAME)
            };
            return(SQLHelper.ExecuteScalar(sqlTest, CommandType.Text, par));
        }
        //添加单词包
        public int AddCoures(Coures cr)
        {
            string sql = "insert into Coures values(@a,@b,@c)";

            SqlParameter[] par =
            {
                new SqlParameter("@a", cr.C_NAME),
                new SqlParameter("@b", cr.CCT_ID),
                new SqlParameter("@c", cr.C_RELEASEDATE),
            };
            return(SQLHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text, par));
        }
예제 #10
0
파일: Coures_Dal.cs 프로젝트: yyl7727/bcz
        /// <summary>
        /// 添加单词包
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public int AddCourses(Coures c)
        {
            string sql = "insert into coures(C_NAME,CCT_ID,C_RELEASEDATE,C_VOCABULARY) values(@name,@type,@releasedate,@vocabulary)";

            SqlParameter[] par = new SqlParameter[4]
            {
                new SqlParameter("@name", c.C_NAME),
                new SqlParameter("@type", c.CCT_ID),
                new SqlParameter("@releasedate", c.C_RELEASEDATE),
                new SqlParameter("@vocabulary", c.C_vocabulary)
            };
            return(SQLHelper.ExecuteNonQuery(sql, CommandType.Text, par));
        }
예제 #11
0
 private void getCouresByID()
 {
     try
     {
         string        CouresID = context.Request.Form.Get("CouresID");
         CouresService cs       = new CouresService();
         Coures        coures   = cs.getCouresByID(CouresID);
         String        json     = JsonConvert.SerializeObject(coures);
         context.Response.Write(json);
     }
     catch (Exception e)
     {
         context.Response.Write("0");
     }
 }
예제 #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Coures        c  = new Coures();
            BLL_Coures    bc = new BLL_Coures();
            List <Coures> lc = bc.SeleteCoures();

            for (int i = 0; i < bc.SeleteCoures().Count; i++)
            {
                Button btn = new Button();
                btn.Width    = 100;
                btn.Height   = 100;
                btn.ID       = Convert.ToString(lc[i].C_ID);
                btn.CssClass = "book btn btn-info";
                btn.Text     = lc[i].C_NAME;
                btn.Click   += Btn_Click;
                panel.Controls.Add(btn);
            }
        }
예제 #13
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         Coures c = new Coures();
         if (textBox3.Text == null)
         {
             MessageBox.Show("单词包名称不能为空");
             return;
         }
         else if (textBox4.Text == null)
         {
             MessageBox.Show("单词本英语个数不能为空");
             return;
         }
         else
         {
             CourseContentType cct = new CourseContentType();
             cct.CCT_NAME = comboBox1.Text.Trim();
             CourseContentType_Bll cct_b = new CourseContentType_Bll();
             int id = Convert.ToInt32(cct_b.QueryCourseContTypeID(cct));
             c.C_NAME        = textBox3.Text.Trim();
             c.CCT_ID        = id;
             c.C_vocabulary  = Convert.ToInt32(textBox4.Text.ToString());
             c.C_RELEASEDATE = DateTime.Now.ToString();
         }
         Coures_Bll cb = new Coures_Bll();
         int        i  = cb.AddCourses(c);
         if (i > 0)
         {
             MessageBox.Show("添加成功!");
         }
         else
         {
             MessageBox.Show("添加失败!");
         }
     }
     catch
     {
         MessageBox.Show("出现异常");
         Close();
     }
 }
예제 #14
0
파일: Coures_Dal.cs 프로젝트: yyl7727/bcz
        /// <summary>
        /// 显示所有单词包
        /// </summary>
        /// <returns></returns>
        public List <Coures> QueryCouresAll()
        {
            string        sql  = "select * from coures";
            List <Coures> list = new List <Coures>();
            SqlDataReader msdr = SQLHelper.ExecuteReader(sql, CommandType.Text, null);

            if (msdr.HasRows)
            {
                while (msdr.Read())
                {
                    Coures c = new Coures();
                    c.CCT_ID       = int.Parse(msdr["C_ID"].ToString());
                    c.C_NAME       = msdr["C_NAME"].ToString();
                    c.C_vocabulary = int.Parse(msdr["C_vocabulary"].ToString());
                    list.Add(c);
                }
            }
            msdr.Close();
            return(list);
        }
예제 #15
0
 private void saveCoures()
 {
     try
     {
         string            professionID = context.Request.Form.Get("profession");
         DepartmentService ds           = new DepartmentService();
         Profession        profession   = ds.getProfessionByID(professionID);
         if (profession != null)
         {
             Coures c = new Coures();
             setValue(c, context);
             c.Profession = profession;
             ds.save(c);
             context.Response.Write("1");
         }
     }
     catch (Exception e) {
         context.Response.Write("0");
     }
 }
예제 #16
0
        /// <summary>
        /// 根据单词包id获取指定单词包
        /// </summary>
        /// <param name="cID"></param>
        /// <returns></returns>
        public Coures GetCourse(int cID)
        {
            string sql = "select * from Coures where C_ID=@C_ID";

            SqlParameter[] p =
            {
                new SqlParameter("@C_ID", cID)
            };
            SqlDataReader sdr    = SQLHelper.ExecuteReader(sql, CommandType.Text, p);
            Coures        course = new Coures();

            while (sdr.Read())
            {
                course.C_ID          = Convert.ToInt32(sdr["C_ID"]);
                course.C_NAME        = sdr["C_NAME"].ToString();
                course.CCT_ID        = Convert.ToInt32(sdr["CCT_ID"]);
                course.C_RELEASEDATE = sdr["C_RELEASEDATE"].ToString();
                course.C_vocabulary  = Convert.ToInt32(sdr["C_vocabulary"]);
            }
            return(course);
        }
        private void saveCoures()
        {
            try
            {
                string ProfessionID = context.Request.Form.Get("Profession");
                string FacultyID    = context.Request.Form.Get("Faculty");

                DepartmentService ds         = new DepartmentService();
                Profession        profession = ds.getProfessionByID(ProfessionID);
                Faculty           faculty    = ds.getFacultyByID(FacultyID);
                if (profession != null && faculty != null)
                {
                    ISet <Coures> couresSet = new HashedSet <Coures>();
                    string[]      couresArr = context.Request.Form.GetValues("Coures");
                    CouresService cs        = new CouresService();
                    foreach (string c in couresArr)
                    {
                        Coures coures = cs.getCouresByID(c);
                        if (coures != null)
                        {
                            couresSet.Add(coures);
                        }
                    }

                    ExamPlan p = new ExamPlan();
                    setValue(p, context);
                    p.Profession = profession;
                    p.Faculty    = faculty;
                    p.CouresSet  = couresSet;
                    PlanService ps = new PlanService();
                    ps.save(p);
                    context.Response.Write("1");
                }
            }
            catch (Exception e)
            {
                context.Response.Write("0");
            }
        }
        //查询所有单词包
        public List <Coures> SeleteCoures()
        {
            string        sql = "select * from Coures";
            List <Coures> lc  = new List <Coures>();
            SqlDataReader sdr = SQLHelper.ExecuteReader(sql, System.Data.CommandType.Text, null);

            if (sdr.HasRows)
            {
                while (sdr.Read())
                {
                    Coures cr = new Coures();
                    cr.C_ID          = Convert.ToInt32(sdr["C_ID"].ToString());
                    cr.C_NAME        = sdr["C_NAME"].ToString();
                    cr.CCT_ID        = Convert.ToInt32(sdr["CCT_ID"].ToString());
                    cr.C_RELEASEDATE = Convert.ToDateTime(sdr["C_RELEASEDATE"].ToString());
                    cr.C_VOCABULARY  = Convert.ToDouble(sdr["C_VOCABULARY"].ToString());
                    lc.Add(cr);
                }
            }
            sdr.Close();
            return(lc);
        }
 protected void del_Click(object sender, EventArgs e)
 {
     try
     {
         Coures cs = new Coures();
         cs.C_ID   = Convert.ToInt32(wbid.Text);
         cs.C_NAME = wbname.Text;
         BLL_Coures del = new BLL_Coures();
         del.DeleteCoures(cs);
         if (del.DeleteCoures(cs) > 0)
         {
             Response.Write(@"<script>alert('删除成功!');location.reload();</script>");
         }
         else
         {
             Response.Write(@"<script>alert('删除失败!');history.go(-1);</script>");
         }
     }
     catch
     {
         Response.Write(@"<script>alert('删除失败!'); history.go(-1);</script>");
     }
 }
        public List <Coures> select(int id)
        {
            string        sql = "select * from Coures where C_ID=@ID";
            Coures        cr  = new Coures();
            List <Coures> lc  = new List <Coures>();

            SqlParameter[] par =
            {
                new SqlParameter("@ID", id),
            };
            SqlDataReader sdr = SQLHelper.ExecuteReader(sql, System.Data.CommandType.Text, par);

            while (sdr.Read())
            {
                cr.C_ID          = Convert.ToInt32(sdr["C_ID"].ToString());
                cr.C_NAME        = sdr["C_NAME"].ToString();
                cr.CCT_ID        = Convert.ToInt32(sdr["CCT_ID"].ToString());
                cr.C_RELEASEDATE = Convert.ToDateTime(sdr["C_RELEASEDATE"].ToString());
                cr.C_VOCABULARY  = Convert.ToDouble(sdr["C_VOCABULARY"].ToString());
                lc.Add(cr);
            }
            sdr.Close();
            return(lc);
        }
예제 #21
0
 protected void save_Click(object sender, EventArgs e)
 {
     try
     {
         Coures cs = new Coures();
         cs.C_NAME        = wbname.Text;
         cs.CCT_ID        = wbtype.SelectedIndex;
         cs.C_RELEASEDATE = DateTime.Now;
         BLL_Coures save = new BLL_Coures();
         save.AddCoures(cs);
         if (save.AddCoures(cs) > 0)
         {
             Response.Write(@"<script>alert('保存成功!'); </script>");
         }
         else
         {
             Response.Write(@"<script>alert('保存失败!');history.go(-1);</script>");
         }
     }
     catch
     {
         Response.Write(@"<script>alert('保存失败!'); history.go(-1);</script>");
     }
 }
예제 #22
0
        //种子方法
        protected override void Seed(CodeFirstDamo.CodeFirstModels.CourseContext context)
        {
            context.Database.ExecuteSqlCommand("delete Coures");
            context.Database.ExecuteSqlCommand("delete departents");
            //初始化学院数据
            var d1 = new Departent()
            {
                Name        = "电子信息工程",
                SortCode    = "001",
                Description = "第一大学院"
            };
            var d2 = new Departent()
            {
                Name        = "电子信息工程",
                SortCode    = "002",
                Description = "第二大学院"
            };
            var d3 = new Departent()
            {
                Name        = "电子信息工程",
                SortCode    = "003",
                Description = "第三大学院"
            };
            var d4 = new Departent()
            {
                Name        = "电子信息工程",
                SortCode    = "004",
                Description = "第四大学院"
            };

            context.Departments.Add(d1);
            context.Departments.Add(d2);
            context.Departments.Add(d3);
            context.Departments.Add(d4);
            context.SaveChanges();

            var c1 = new Coures()
            {
                Title      = "C#程序设计",
                Credit     = 7,
                Department = context.Departments.SingleOrDefault(x => x.Name == "电子信息工程学院")
            };
            var c2 = new Coures()
            {
                Title      = "Min开发与实战",
                Credit     = 7,
                Department = context.Departments.SingleOrDefault(x => x.Name == "电子信息工程学院")
            };
            var c3 = new Coures()
            {
                Title      = "web应用开发",
                Credit     = 7,
                Department = context.Departments.SingleOrDefault(x => x.Name == "电子信息工程学院")
            };
            var c4 = new Coures()
            {
                Title      = "工业制图",
                Credit     = 4,
                Department = context.Departments.SingleOrDefault(x => x.Name == "机电工程学院")
            };
            var c5 = new Coures()
            {
                Title      = "发动机检测",
                Credit     = 6,
                Department = context.Departments.SingleOrDefault(x => x.Name == "汽车工程学院")
            };
            var c6 = new Coures()
            {
                Title      = "网络音效",
                Credit     = 6,
                Department = context.Departments.SingleOrDefault(x => x.Name == "财经与物流学院")
            };

            context.Coures.Add(c1);
            context.Coures.Add(c2);
            context.Coures.Add(c3);
            context.Coures.Add(c4);
            context.Coures.Add(c5);
            context.Coures.Add(c6);
            context.SaveChanges();

            var s1 = new Student()
            {
                StudentName = "肖文斌",
                Sex         = true,
                Class       = "17软件技术一班",
                phone       = "18877213447"
            };
            var s2 = new Student()
            {
                StudentName = "黄武建",
                Sex         = true,
                Class       = "17软件技术一班",
                phone       = "18877213447"
            };
            var s3 = new Student()
            {
                StudentName = "黄学明",
                Sex         = true,
                Class       = "17软件技术一班",
                phone       = "18877213447"
            };
            var s4 = new Student()
            {
                StudentName = "施扬恩",
                Sex         = true,
                Class       = "17软件技术一班",
                phone       = "18877213447"
            };

            context.Student.Add(s1);
            context.Student.Add(s2);
            context.Student.Add(s3);
            context.Student.Add(s4);

            context.SaveChanges();
        }
예제 #23
0
 public void update(Coures coures)
 {
     Session.Update(coures);
     Session.Flush();
 }
예제 #24
0
 public int DeleteCoures(Coures c)
 {
     return(dc.DeleteCoures(c));
 }
예제 #25
0
 public int UpdateCoures(Coures c)
 {
     return(dc.UpdateCoures(c));
 }
예제 #26
0
 public int AddCoures(Coures c)
 {
     return(dc.AddCoures(c));
 }
예제 #27
0
 /// <summary>
 /// 根据单词包名字查询id
 /// </summary>
 /// <param name="c"></param>
 /// <returns></returns>
 public object QueryCouresID(Coures c)
 {
     return(DALCourses.QueryCourseID(c));
 }
예제 #28
0
 /// <summary>
 /// 增加单词包
 /// </summary>
 /// <param name="l"></param>
 /// <returns></returns>
 public int AddCourses(Coures l)
 {
     return(DALCourses.AddCourses(l));
 }
 public int total(Coures c)
 {
     return(dd.total(c));
 }
예제 #30
0
파일: DC_Add.cs 프로젝트: yyl7727/bcz
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         if (comboBox1.Text == null)
         {
             MessageBox.Show("单词包类型不为空");
             return;
         }
         if (textBox2.Text == null)
         {
             MessageBox.Show("单词名称不可为空");
             return;
         }
         if (textBox3.Text == null)
         {
             MessageBox.Show("单词音标不可为空");
             return;
         }
         if (textBox4.Text == null)
         {
             MessageBox.Show("单词释义不可为空");
             return;
         }
         if (textBox5.Text == null)
         {
             MessageBox.Show("英文例句不可为空");
             return;
         }
         if (textBox6.Text == null)
         {
             MessageBox.Show("中文例句不可为空");
             return;
         }
         if (pictureBox1.Image == null)
         {
             MessageBox.Show("请选择单词正确图片");
             return;
         }
         if (pictureBox2.Image == null)
         {
             MessageBox.Show("请选择单词错误图片1");
             return;
         }
         if (pictureBox3.Image == null)
         {
             MessageBox.Show("请选择单词错误图片2");
             return;
         }
         if (pictureBox4.Image == null)
         {
             MessageBox.Show("请选择单词错误图片3");
             return;
         }
         else
         {
             Coures c = new Coures();
             c.C_NAME = comboBox1.Text.Trim();
             Coures_Bll cb = new Coures_Bll();
             int        id = Convert.ToInt32(cb.QueryCouresID(c));
             cd.C_ID       = id;
             cd.CD_NAME    = textBox2.Text.Trim();
             cd.CD_YINBIAO = textBox3.Text.Trim();
             cd.CD_Mean    = textBox4.Text.Trim();
             cd.CD_SENEng  = textBox5.Text.Trim();
             cd.CD_SENChi  = textBox6.Text.Trim();
             cd.CD_VIDEO   = textBox7.Text.Trim();
         }
         CourseDetail_Bll cdb = new CourseDetail_Bll();
         int i = cdb.AddCoursesDetails(cd);
         if (i > 0)
         {
             MessageBox.Show("添加成功");
         }
         else
         {
             MessageBox.Show("添加失败");
         }
     }
     catch
     {
         MessageBox.Show("添加异常");
     }
 }