예제 #1
0
        public string DeleteQNA()
        {
            UserModel userInfo = SessionExtensionTool.GetObject <UserModel>(HttpContext.Session, "userInfo");

            string query = "";

            query = "SELECT FILE_ID, A.DOC_ID FROM OP_FILE A "
                    + "JOIN OP_BBS B "
                    + "ON A.DOC_ID=B.DOC_ID "
                    + "AND BBS_ID='" + Request.Form["bbs_id"] + "'";
            var removeFiles = _commonDao.SelectList(query);

            for (int i = 0; i < removeFiles.Count; ++i)
            {
                _fileMngTool.removeFile(removeFiles[i]["DOC_ID"]);
            }

            query = "DELETE FROM OP_BBS WHERE BBS_ID = @bbs_id:NUMBER";

            //cud 처리할 때는 트랜잭션 시작해주어야함
            using var transaction = _context.Database.BeginTransaction();

            string resultCode = "ok";

            if (_commonDao.Delete(query, Request.Form) == 0)
            {
                resultCode = "false";
            }

            transaction.Commit();

            return(resultCode);
        }
예제 #2
0
        public string DeleteTask()
        {
            UserModel userInfo = SessionExtensionTool.GetObject <UserModel>(HttpContext.Session, "userInfo");

            //cud 처리할 때는 트랜잭션 시작해주어야함
            using var transaction = _context.Database.BeginTransaction();
            string resultCode = "ok";

            string query = "";

            if (userInfo.author.Equals(_codeMngTool.getCode("AUTHOR", "PROFESSOR")))
            {
                if (!userInfo.author.Equals(_codeMngTool.getCode("AUTHOR", "PROFESSOR")))
                {
                    Response.WriteAsync("<script language=\"javascript\">alert('Invalid Author!!');</script>");
                    Response.WriteAsync("<script language=\"javascript\">window.location=\"/Task/SelectPageListTask\"</script>");
                }

                query = $"DELETE FROM OP_TASK_PRSENTR WHERE TASK_SEQ = @task_id:NUMBER";
                // 과제에 딸려 있는 제출 내역들을 먼저 삭제하고
                if (_commonDao.Delete(query, Request.Form) <= 0)
                {
                    resultCode = "false";
                }

                // 과제를 삭제한다.
                query = "DELETE FROM OP_TASK WHERE TASK_SEQ = @task_id:NUMBER";
            }
            else
            {
                query = $"DELETE FROM OP_TASK_PRSENTR WHERE REGISTER = '{userInfo.user_id}' AND TASK_SEQ = @task_id:NUMBER";
            }


            if (_commonDao.Delete(query, Request.Form) <= 0)
            {
                resultCode = "false";
            }

            if (resultCode.Equals("false"))
            {
                transaction.Rollback();
            }
            else
            {
                transaction.Commit();
            }

            return(resultCode);
        }
예제 #3
0
        public void removeFile(string docId)
        {
            string query = "SELECT FILE_ID FROM OP_FILE "
                           + "WHERE DOC_ID='" + docId + "'";

            string uploadFolder = System.IO.Directory.GetCurrentDirectory() + @"\wwwroot\upload";
            string fName;
            var    willDeleteList = _commonDao.SelectList(query);

            for (int i = 0; i < willDeleteList.Count; ++i)
            {
                if (willDeleteList[i]["FILE_ID"].Equals(""))
                {
                    continue;
                }
                fName = Path.Combine(uploadFolder, willDeleteList[i]["FILE_ID"]);
                File.Delete(fName);
            }

            query = "DELETE FROM OP_FILE"
                    + " WHERE DOC_ID='" + docId + "'";

            using var transaction2 = _context.Database.BeginTransaction();

            _commonDao.Delete(query);

            transaction2.Commit();
        }
예제 #4
0
        public int Delete()
        {
            string query = "DELETE FROM OP_CODE " +
                           "WHERE GROUP_ID=@group_id:NUMBER, " +
                           "OR GROUP_NM=@group_nm:VARCHAR2";

            int resultRowCnt = _commonDao.Delete(query);

            return(resultRowCnt);
        }
        public string DeleteRecsroom()
        {
            UserModel userInfo = SessionExtensionTool.GetObject <UserModel>(HttpContext.Session, "userInfo");

            if (!userInfo.author.Equals(_codeMngTool.getCode("AUTHOR", "PROFESSOR")))
            {
                Response.WriteAsync("<script language=\"javascript\">alert('Invalid Author!!');</script>");
                Response.WriteAsync("<script language=\"javascript\">window.location=\"/Recsroom/SelectPageListRecsroom\"</script>");
            }

            string query = "";

            query = "SELECT FILE_ID, A.DOC_ID FROM OP_FILE A "
                    + "JOIN OP_BBS B "
                    + "ON A.DOC_ID=B.DOC_ID "
                    + "AND BBS_ID='" + Request.Form["bbs_id"] + "'";
            var removeFiles = _commonDao.SelectList(query);

            for (int i = 0; i < removeFiles.Count; ++i)
            {
                _fileMngTool.removeFile(removeFiles[i]["DOC_ID"]);
            }

            query = "DELETE FROM OP_BBS WHERE BBS_ID = @bbs_id:NUMBER";

            //cud 처리할 때는 트랜잭션 시작해주어야함
            using var transaction = _context.Database.BeginTransaction();

            string resultCode = "ok";

            if (_commonDao.Delete(query, Request.Form) == 0)
            {
                resultCode = "false";
            }

            transaction.Commit();

            return(resultCode);
        }
예제 #6
0
        public IActionResult DeleteData()
        {
            using var transaction = _context.Database.BeginTransaction();


            string query = "DELETE FROM PERSONS WHERE PERSON_ID = @person_id:NUMBER";

            _commonDao.Delete(query, Request.Form);


            transaction.Commit();

            return(Redirect("Index"));
        }