Esempio n. 1
0
        public ActionResult code_position(code_position doc, int?idx, int?company_idx)
        {
            ViewBag.타이틀 = "직책 코드";

            //========================================================================================================================================================
            var Code_company = db.company.Where(p => p.use_yn == "Y").OrderBy(o => o.index_order).Select(
                c => new { 값 = c.idx, 이름 = c.company_name });

            ViewBag.회사 = new SelectList(Code_company.AsEnumerable(), "값", "이름");
            //========================================================================================================================================================


            if (idx != null)
            {
                doc = db.code_position.Single(x => x.code_id == idx);
            }

            var _list = db.code_position.Include(p => p.company_idxNavigation).Where(p => p.use_yn != "N").OrderBy(o => o.index_order);

            if (company_idx != null)
            {
                _list = _list.Where(p => p.company_idx == company_idx).OrderBy(o => o.index_order);
            }


            ViewBag.리스트 = _list;

            return(View(doc));
        }
Esempio n. 2
0
        /// <summary>
        /// 코드 표준 : 직책
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="mode_type"></param>
        /// <param name="idx"></param>
        /// <returns></returns>
        public ActionResult code_position_action(code_position doc, string mode_type, int?idx, string re_url)
        {
            if (idx == null)
            {
                #region 저장
                doc.use_yn = "Y";
                db.code_position.Add(doc);
                db.SaveChanges(); // 실제로 저장


                #endregion
            }
            else
            {
                if (mode_type == "D")
                {
                    #region 사용안함
                    int _idx_ = Convert.ToInt32(idx);
                    var _data = (from a in db.code_position where a.code_id == idx select a).Single();

                    _data.use_yn = "N";

                    db.SaveChanges();


                    #endregion
                }
                else
                {
                    #region 수정

                    doc.use_yn          = "Y";
                    db.Entry(doc).State = EntityState.Modified;
                    db.SaveChanges();



                    #endregion
                }
            }

            return(Redirect(re_url));
        }