public override ActionResult Delete(int id)
        {
            BLL.ExamTable          exam      = new BLL.ExamTable();
            string                 strSql    = "select * from ExamTable where Id = '" + id + "'";
            List <Model.ExamTable> tableList = new BLL.ExamTable().DataTableToList(DbHelperSQL.Query(strSql).Tables[0]);

            if (tableList.Count != 0)
            {
                foreach (Model.ExamTable tableModel in tableList)
                {
                    string path = Server.MapPath(tableModel.Filepath);
                    bool   exi  = System.IO.File.Exists(path);
                    if (exi)
                    {
                        System.IO.File.Delete(path);
                    }
                }
            }

            if (exam.Delete(id))
            {
                return(this.Json(new { result = 1, data = "" }));
            }
            else
            {
                return(this.Json(new { result = 0, msg = "没有这条数据" }));
            }
        }
        public ActionResult Create(Model.ExamTable model)
        {
            bool result = false;

            if (!String.IsNullOrEmpty(model.Teacher) && !String.IsNullOrEmpty(model.Major))
            {
                BLL.ExamTable exam = new BLL.ExamTable();
                model.Nowstate = "未开启";
                var state = exam.Add(model);

                if (state != 0)
                {
                    result = true;
                }
            }
            if (result)
            {
                return(this.Json(new { result = 1, data = "" }));
            }
            else
            {
                return(this.Json(new { result = 0, msg = "新建失败" }));
            }
        }
Пример #3
0
        public ActionResult Clear(int id)
        {
            bool result = false;

            BLL.ExamTable          exam      = new BLL.ExamTable();
            string                 strSql    = "select * from ExamTable where Id = '" + id + "'";
            List <Model.ExamTable> tableList = new BLL.ExamTable().DataTableToList(DbHelperSQL.Query(strSql).Tables[0]);

            if (tableList.Count != 0)
            {
                foreach (Model.ExamTable tableModel in tableList)
                {
                    string path = Server.MapPath(tableModel.Filepath);
                    bool   exi  = System.IO.File.Exists(path);
                    if (exi)
                    {
                        System.IO.File.Delete(path);
                    }
                }
            }

            exam.Delete(id);

            BLL.AnswerTable          answer     = new BLL.AnswerTable();
            string                   strSql1    = "select * from AnswerTable where Exam = '" + id + "'";
            List <Model.AnswerTable> tableList1 = new BLL.AnswerTable().DataTableToList(DbHelperSQL.Query(strSql1).Tables[0]);

            if (tableList1.Count != 0)
            {
                foreach (Model.AnswerTable tableModel in tableList1)
                {
                    string path = Server.MapPath(tableModel.Filepath);
                    bool   exi  = System.IO.File.Exists(path);
                    if (exi)
                    {
                        System.IO.File.Delete(path);
                    }

                    answer.Delete(tableModel.ID);
                }
            }

            BLL.IPTable          IP         = new BLL.IPTable();
            string               strSql2    = "select * from IPTable";
            List <Model.IPTable> tableList2 = new BLL.IPTable().DataTableToList(DbHelperSQL.Query(strSql2).Tables[0]);

            if (tableList2.Count != 0)
            {
                foreach (Model.IPTable tableModel in tableList2)
                {
                    IP.Delete(tableModel.ID);
                }
            }

            result = true;

            if (result)
            {
                return(this.Json(new { result = 1, data = "" }));
            }
            else
            {
                return(this.Json(new { result = 0, msg = "没有这条数据" }));
            }
        }