예제 #1
0
        public ActionResult Board_List(int?cate, int?page)
        {
            string web_company_id    = "";
            string web_department_id = "";
            int    auth = 0;

            #region 언어선택
            //언어 추가

            string _language = Request["language"] ?? "korea";

            var language = new HttpCookie("language");
            language.Value = _language;
            Response.Cookies.Add(language);
            #endregion


            string search_all_type = Request["search_all_type"] ?? "";
            string search_all      = Request["search_all"] ?? "";

            ViewBag.search_all_type = search_all_type;
            ViewBag.search_all      = search_all;

            int _cate = 0;

            if (cate == null)
            {
                _cate = (from a in db.BoardMenu where a.open_yn == "Y" select a.BM_idx).FirstOrDefault();
                cate  = _cate;
            }


            //var data = db.BoardMenu.Find(id);


            BoardMenu bm = db.BoardMenu.Find(cate);
            ViewBag.BoardMenu = bm;

            var _type = (from a in db.BoardMenu where a.BM_idx == cate select a).FirstOrDefault();

            if (_type != null)
            {
                ViewBag.타입 = _type.BM_type;
            }
            else
            {
                ViewBag.타입 = "normal";
            }



            ViewBag.기본게시글 = cate;
            ViewBag.타이틀   = _type.BM_title;

            var board = new supertalentoftheworld.Models.Board();


            if (auth >= 8)
            {
                //회사별 데이터 드롭다운==============================================================================================================================================
                var category =
                    db.BoardMenu.Where(
                        a =>
                        a.BM_com == web_company_id && a.BM_type != "photo" &&
                        ((a.department_id == web_department_id || a.open_yn == "Y"))).Select(
                        a => new { a.BM_idx, a.BM_title });
                ViewBag.category = new SelectList(category.AsEnumerable(), "BM_idx", "BM_title", board.BD_BM_idx);
                //=====================================================================================================================================================================
            }
            else
            {
                //회사별 데이터 드롭다운==============================================================================================================================================
                var category =
                    db.BoardMenu.Where(
                        a =>
                        a.BM_com == web_company_id && a.BM_type != "photo" &&
                        ((a.department_id == web_department_id || a.open_yn == "Y"))).Select(
                        a => new { a.BM_idx, a.BM_title });
                ViewBag.category = new SelectList(category.AsEnumerable(), "BM_idx", "BM_title", board.BD_BM_idx);
                //=====================================================================================================================================================================
            }


            if (bm == null)
            {
                var emptyboard = new List <supertalentoftheworld.Models.Board>();


                board.BD_idx    = 0;
                board.BD_title  = "There's no writing";
                board.BD_writer = "Helper";
                board.BD_wdate  = DateTime.Now;
                board.BoardMenu = bm;
                board.BD_BM_idx = 1;
                emptyboard.Add(board);
                return(View(emptyboard));
            }
            else
            {
                #region 일반게기판

                IEnumerable <supertalentoftheworld.Models.Board> data = bm.Board.Where(a => a.BD_useable == 1 && a.BoardMenu.BM_type != "photo");

                if (!string.IsNullOrEmpty(search_all))
                {
                    if (search_all_type == "1")
                    {
                        data = data.Where(p => p.BD_title.Contains(search_all) || p.BD_content.Contains(search_all));
                    }
                    if (search_all_type == "2")
                    {
                        data = data.Where(p => p.BD_title.Contains(search_all));
                    }
                    if (search_all_type == "3")
                    {
                        data = data.Where(p => p.BD_writer.StartsWith(search_all));
                    }
                }

                //페이징 처리
                var pg = new pagination();

                pg.totalcount     = data.Any() ? data.Count() : 1;
                pg.takecount      = 10;
                pg.skipcount      = page == null ? 0 : (int)page * pg.takecount;
                pg.totalpagecount = Math.Ceiling((double)pg.totalcount / pg.takecount);
                data = data.OrderByDescending(a => a.BD_idx).Skip(pg.skipcount).Take(pg.takecount);

                ViewBag.pagination = pg;

                List <supertalentoftheworld.Models.Board> boarddata = data.ToList();
                //게시글이 없을 경우
                if (boarddata.Count() == 0)
                {
                    board.BD_idx    = 0;
                    board.BD_title  = "There's no writing";
                    board.BD_writer = "Helper";
                    board.BD_wdate  = DateTime.Now;
                    board.BoardMenu = bm;
                    board.BD_BM_idx = bm.BM_idx;
                    boarddata.Add(board);
                }
                return(View(boarddata));

                #endregion
            }
        }
예제 #2
0
        public ActionResult m_photo_list(int?cate, int?page)
        {
            string web_company_id    = Request.Cookies["web_company_id"].Value ?? "";
            string web_department_id = Request.Cookies["web_department_id"].Value ?? "";
            int    auth        = Convert.ToInt16(Request.Cookies["check_auth"].Value);
            string search_type = Request["search_type"] ?? "";

            string LoadFileUrl = ConfigurationManager.AppSettings["LoadFileUrl"];

            ViewBag.LoadFileUrl = LoadFileUrl;

            string machine_id_search = search_type;

            cate = 7;

            //int _cate = 0;

            //if (cate == null)
            //{
            //    _cate =
            //        (from a in db.BoardMenu
            //         where (a.department_id == web_department_id || a.open_yn == "Y")
            //         select a.BM_idx).FirstOrDefault();
            //    cate = _cate;
            //}

            //if (!string.IsNullOrEmpty(search_type))
            //{
            //    cate = Convert.ToInt32(search_type);

            //}
            string search_text = Request["search_text"] ?? "";
            string cate_str    = cate.ToString();

            ViewBag.search_all  = search_text;
            ViewBag.search_type = machine_id_search;
            //var data = db.BoardMenu.Find(id);

            //========================================================================================================================================================
            var Code_machine_parts =
                db.project_main.Where(p => p.mode_type == "Y" && p.use_yn != "D").OrderBy(o => o.project_name).Select(
                    c => new { 값 = c.project_id, 이름 = c.project_name });

            ViewBag.세팅 = new SelectList(Code_machine_parts.AsEnumerable(), "값", "이름");
            //========================================================================================================================================================



            BoardMenu bm = db.BoardMenu.Find(cate);

            ViewBag.BoardMenu = bm;

            string _type = (from a in db.BoardMenu where a.BM_idx == cate select a.BM_type).FirstOrDefault() ?? "photo";


            ViewBag.타입 = _type;


            var board = new BoardFile();


            if (auth >= 8)
            {
                //회사별 데이터 드롭다운==============================================================================================================================================
                var category =
                    db.BoardMenu.Where(
                        a =>
                        a.BM_com == web_company_id && a.BM_type == "photo" &&
                        ((a.department_id == web_department_id || a.open_yn == "Y"))).Select(
                        a => new { a.BM_idx, a.BM_title });
                ViewBag.category = new SelectList(category.AsEnumerable(), "BM_idx", "BM_title", board.BD_BM_idx);
                //=====================================================================================================================================================================
            }
            else
            {
                //회사별 데이터 드롭다운==============================================================================================================================================
                var category =
                    db.BoardMenu.Where(
                        a =>
                        a.BM_com == web_company_id && a.BM_type == "photo" &&
                        ((a.department_id == web_department_id || a.open_yn == "Y"))).Select(
                        a => new { a.BM_idx, a.BM_title });
                ViewBag.category = new SelectList(category.AsEnumerable(), "BM_idx", "BM_title", board.BD_BM_idx);
                //=====================================================================================================================================================================
            }


            if (bm == null)
            {
                var emptyboard = new List <BoardFile>();


                board.Board.BD_BM_idx = 0;
                board.Board.BD_title  = "게시글이 없습니다.";
                board.Board.BD_writer = "마스터";
                board.Board.BD_wdate  = DateTime.Now;
                board.BoardMenu       = bm;
                board.BD_BM_idx       = 0;
                emptyboard.Add(board);
                return(View(emptyboard));
            }
            else
            {
                #region 포토

                IQueryable <BoardFile> data =
                    (from a in db.BoardFile where a.BD_BM_idx == cate && a.BF_useable == 1 && a.BF_type == "P" select a);

                if (!string.IsNullOrEmpty(machine_id_search))
                {
                    data = data.Where(p => p.machine_id == machine_id_search);
                }

                if (!string.IsNullOrEmpty(search_text))
                {
                    data = data.Where(p => p.Board.BD_title.StartsWith(search_text) || p.Board.BD_writer == search_text);
                }



                //페이징 처리
                var pg = new pagination();

                pg.totalcount     = data.Any() ? data.Count() : 1;
                pg.takecount      = 30;
                pg.skipcount      = page == null ? 0 : (int)page * pg.takecount;
                pg.totalpagecount = Math.Ceiling((double)pg.totalcount / pg.takecount);
                data = data.OrderByDescending(a => a.BF_wdate).Skip(pg.skipcount).Take(pg.takecount);

                ViewBag.pagination = pg;
                ViewBag.cate       = cate.ToString();

                List <BoardFile> boarddata = data.ToList();

                return(View(boarddata));

                #endregion
            }
        }