Beispiel #1
0
        public async Task <IActionResult> Edit(long id, [Bind("Holidayid,Name,Description,Startdate,Enddate,Createdate,Createuser,Modifydate,Modifyuser,Ownerid,Type,Remaindate")] Holiday holiday)
        {
            if (id != holiday.Holidayid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(holiday);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HolidayExists(holiday.Holidayid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["Ownerid"] = new SelectList(_context.User, "Id", "Id", holiday.Ownerid);
            return(View(holiday));
        }
Beispiel #2
0
        public async Task <IActionResult> Edit(string id, string existPw, [Bind("Id,Pw,Name,Engname,Email,Phone,Mobile,Department,Position,Excelauth,Level,Createdate,Createuser,Modifydate,Modifyuser,Organizationid")] User user)
        {
            if (id != user.Id)
            {
                return(NotFound());
            }

            if (!CheckSystemUserAsync())
            {
                return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    user.Modifydate   = DateTime.Now;
                    user.Modifyuser   = HttpContext.Session.GetString("userId");
                    user.Organization = _context.Organization.Single(x => x.Organizationid == user.Organizationid);

                    // 시스템 관리자 여부
                    if (user.Level == "2-1")
                    {
                        user.Ismaster = true;
                    }
                    else
                    {
                        user.Ismaster = false;
                    }

                    // 비밀번호 변경 여부
                    if (string.IsNullOrEmpty(user.Pw))
                    {
                        user.Pw = existPw;
                    }

                    _context.Update(user);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["Department"] = new SelectList(_context.OptionMasterDetail, "Optionid", "Optionid", user.Department);
            return(View(user));
        }
        public async Task <IActionResult> MasterEdit(long Masterid, bool IsPop, [Bind("Masterid,Name,Description,Isused,Createdate,Createuser,Modifydate,Modifyuser,Issystem,Ownerid")] OptionMaster optionMaster)
        {
            if (!CheckSystemUserAsync())
            {
                return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
            }

            if (Masterid != optionMaster.Masterid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    optionMaster.Modifydate = DateTime.Now;
                    optionMaster.Modifyuser = HttpContext.Session.GetString("userId");

                    _context.Update(optionMaster);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OptionMasterExists(optionMaster.Masterid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Close", "Home"));
            }
            return(View(optionMaster));
        }
Beispiel #4
0
        public async Task <IActionResult> MenuCreate(bool isPop, Menu mainMenu)
        {
            if (!CheckSystemUserAsync())
            {
                return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    mainMenu.Createdate = DateTime.Now;
                    mainMenu.Createuser = HttpContext.Session.GetString("userId");
                    mainMenu.Modifydate = DateTime.Now;
                    mainMenu.Modifyuser = HttpContext.Session.GetString("userId");
                    mainMenu.Isdeleted  = false;

                    if (_context.Menu.Any(e => e.Order == mainMenu.Order))
                    {
                        // 기존의 순서가 존재하면 맨 뒤로 보내기
                        Menu exist     = _context.Menu.SingleOrDefault(x => x.Order == mainMenu.Order);
                        int  menuCount = _context.Menu.Count();
                        exist.Order = menuCount + 1;
                        _context.Update(exist);
                        await _context.SaveChangesAsync();
                    }

                    _context.Add(mainMenu);
                    await _context.SaveChangesAsync();

                    return(View("Close", "Home"));
                }
                catch (Exception ex)
                {
                    // 로그
                    string dd = ex.InnerException.Message;
                    return(View("Close", "Home"));
                }
            }
            return(View("Close", "Home"));
        }
        public async Task <IActionResult> Edit(long id, [Bind("Organizationid,Name,Createdate,Memo")] Organization organization)
        {
            if (!CheckSystemUserAsync())
            {
                return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
            }

            // 수정 권한 체크
            CreaetUserAuth();
            if (_userAuth.Modify.Equals("4-3"))
            {
                return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
            }

            // 권한
            ViewData["Read"]   = _userAuth.Read;
            ViewData["Write"]  = _userAuth.Write;
            ViewData["Modify"] = _userAuth.Modify;
            ViewData["Delete"] = _userAuth.Delete;

            if (id != organization.Organizationid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(organization);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrganizationExists(organization.Organizationid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(organization));
        }
Beispiel #6
0
        public async Task <IActionResult> Edit(long id, [Bind("Productid,Name,Maker,Ownerid,Origin,Productcode,Createdate,Createuser,Modifydate,Modifyuser")] Product product)
        {
            // 수정 권한 검사
            CreaetUserAuth();
            if (_userAuth.Modify.Equals("4-3"))
            {
                return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
            }

            if (id != product.Productid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    product.Modifydate = DateTime.Now;
                    product.Modifyuser = HttpContext.Session.GetString("userId");

                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.Productid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }

            ViewData["Read"]   = _userAuth.Read;
            ViewData["Write"]  = _userAuth.Write;
            ViewData["Modify"] = _userAuth.Modify;
            ViewData["Delete"] = _userAuth.Delete;

            return(View(product));
        }
Beispiel #7
0
        public async Task <IActionResult> Edit(long id, [Bind("Accountid,Name,Phone,Fax,Homepage,Ceo,Postcode,Address,Addresscity,Addressdetail,Addresstype,Biznum,Founddate,Detail,Ownerid,Createuser,Createdate,Modifydate,Modifyuser")] Account account)
        {
            // 수정 권한 검사
            CreaetUserAuth();
            if (_userAuth.Modify.Equals("4-3"))
            {
                return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
            }

            if (id != account.Accountid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    account.Modifydate = DateTime.Now;
                    account.Modifyuser = HttpContext.Session.GetString("userId");

                    _context.Update(account);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountExists(account.Accountid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }

            ViewData["Read"]   = _userAuth.Read;
            ViewData["Write"]  = _userAuth.Write;
            ViewData["Modify"] = _userAuth.Modify;
            ViewData["Delete"] = _userAuth.Delete;

            return(View(account));
        }
Beispiel #8
0
        public async Task <IActionResult> Edit(long id, [Bind("Priceid,Productid,Prices,Cost,Currency,Createdate,Createuser,Modifydate,Modifyuser,Ownerid")] Price price)
        {
            // 수정 권한 검사
            CreaetUserAuth();
            if (_userAuth.Modify.Equals("4-3"))
            {
                return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
            }

            if (id != price.Priceid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(price);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PriceExists(price.Priceid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }

            ViewData["Productid"] = new SelectList(_context.Product, "Productid", "Createuser", price.Productid);
            ViewData["Read"]      = _userAuth.Read;
            ViewData["Write"]     = _userAuth.Write;
            ViewData["Modify"]    = _userAuth.Modify;
            ViewData["Delete"]    = _userAuth.Delete;

            return(View(price));
        }
Beispiel #9
0
        public async Task <IActionResult> Edit(long id, [Bind("Contactid,Name,Department,Accountid,Email,Phone,Mobile,Detail,Bossid,Createdate,Createuser,Modifydate,Modifyuser,Isdeleted,Ownerid")] Contact contact)
        {
            CreaetUserAuth();

            // 사용자 수정 권한 체크
            if (_userAuth.Modify.Equals("4-3"))
            {
                return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
            }

            if (id != contact.Contactid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    contact.Modifydate = DateTime.Now;
                    contact.Modifyuser = HttpContext.Session.GetString("userId");

                    _context.Update(contact);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContactExists(contact.Contactid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["Accountid"] = new SelectList(_context.Account, "Accountid", "Biznum", contact.Accountid);
            return(View(contact));
        }
        public async Task <IActionResult> Edit(long id, Appointment appointment)
        {
            // 사용자 수정 권한 체크
            CreaetUserAuth();
            if (_userAuth.Modify.Equals("4-3"))
            {
                return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
            }

            if (id != appointment.Appointmentid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    appointment.Modifydate = DateTime.Now;
                    appointment.Modifyuser = HttpContext.Session.GetString("userId");
                    //appointment.Ownerid = HttpContext.Session.GetString("userId");
                    appointment.Owner = _context.User.Single(x => x.Id == appointment.Ownerid);

                    _context.Update(appointment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AppointmentExists(appointment.Appointmentid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }

            #region 수정에 실패한 경우
            ViewData["Ownerid"] = new SelectList(_context.User, "Id", "Id", appointment.Ownerid);
            ViewData["Read"]    = _userAuth.Read;
            ViewData["Write"]   = _userAuth.Write;
            ViewData["Modify"]  = _userAuth.Modify;
            ViewData["Delete"]  = _userAuth.Delete;
            // 읽기 권한이 없으면 아예 들어가지 못하게 한다.
            if (_userAuth.Read.Equals("4-3"))
            {
                return(RedirectToAction("Error", "Home", new { errormessage = "UserauthError" }));
            }
            // 관련항목 출력 서브메뉴 리스트
            List <DDL> submenuDDL = new List <DDL>();
            foreach (var item in _context.SubMenu.Where(x => x.Ismanager == false && x.Mainmenuid != 7).ToList())
            {
                submenuDDL.Add(new DDL()
                {
                    Value = item.Id, Text = item.Name
                });
            }
            ViewBag.SubmenuList = JsonConvert.SerializeObject(submenuDDL).ToString();
            #endregion

            return(View(appointment));
        }