public ActionResult Delete(int id = 0)
        {
            Abnormal_event abnormal_Event = abnormaleventRepository.GetByid(id);

            abnormaleventRepository.Delete(abnormal_Event);

            return(RedirectToAction("Index"));
        }
예제 #2
0
        private void EventButton_Click(object sender, RoutedEventArgs e)  //異常通報事件按鈕
        {
            Abnormal_event abnormal_Event = new Abnormal_event();
            object         content        = abnormal_Event.Content;

            abnormal_Event.Content = null;

            AddTabItem(EventLabel.Content.ToString(), content);
            CheckList.Add(EventLabel.Content.ToString());
            Selected(EventLabel.Content.ToString());
        }
        public ActionResult Edit()
        {
            #region  拉選單

            int vol = Convert.ToInt32(Session["UserID"]);

            var volunteer_no = from v in db.Volunteer_list  //志工姓名下拉選單
                               where v.Application_unit_no == vol
                               select new
            {
                v.Volunteer_no,
                v.Volunteer.Chinese_name
            };

            ViewBag.editvoluteer = new SelectList(volunteer_no, "Volunteer_no", "Chinese_name"); //後面兩個>值,顯示


            var category = from c in db.event_category  //事件類別下拉選單
                           select new
            {
                c.event_category_ID,
                c.event_category1
            };

            ViewBag.category = new SelectList(category, "event_category_ID", "event_category1");

            #endregion

            Abnormal_event abnormal_Event = abnormaleventRepository.GetByid(Convert.ToInt32(Request.Form["Abnormal_event_no"]));
            abnormal_Event.Abnormal_event_ID = Request.Form["Abnormal_event_ID"];
            abnormal_Event.Abnormal_event1   = Request.Form["Abnormal_event1"];
            abnormal_Event.Unit_descrition   = Request.Form["Unit_descrition"];
            abnormal_Event.Volunteer_no      = Convert.ToInt32(Request.Form["Volunteer_no"]);
            abnormal_Event.event_category_ID = Convert.ToInt32(Request.Form["category"]);

            var q = from s in db.Stages
                    where s.Stage1 == "駁回" && s.Stage_type == "異常事件"
                    select s.Stage_ID;

            var q1 = from s in db.Stages
                     where s.Stage1 == "新事件" && s.Stage_type == "異常事件"
                     select s.Stage_ID;

            if (abnormal_Event.Stage == q.ToList().First())
            {
                abnormal_Event.Stage             = q1.ToList().First();
                abnormal_Event.Notification_date = DateTime.Now;
            }

            abnormaleventRepository.Update(abnormal_Event);
            return(RedirectToAction("Index"));
        }
        public ActionResult Cancel(int id)
        {
            var q = from s in db.Stages
                    where s.Stage1 == "事件取消" && s.Stage_type == "異常事件"
                    select s.Stage_ID;

            Abnormal_event abnormal_Event = abnormaleventRepository.GetByid(id);

            abnormal_Event.Stage = q.ToList().First();
            abnormaleventRepository.Update(abnormal_Event);

            return(RedirectToAction("Index"));
        }
        public ActionResult Insert()
        {
            #region  拉選單
            int vol          = Convert.ToInt32(Session["UserID"]);
            var volunteer_no = from v in db.Volunteer_list   //志工姓名下拉選單

                               where v.Application_unit_no == vol
                               select new
            {
                v.Volunteer_no,
                v.Volunteer.Chinese_name
            };

            ViewBag.voluteer = new SelectList(volunteer_no, "Volunteer_no", "Chinese_name"); //後面兩個>值,顯示


            var category = from c in db.event_category      //事件類別下拉選單
                           select new
            {
                c.event_category_ID,
                c.event_category1
            };

            ViewBag.insertcategory = new SelectList(category, "event_category_ID", "event_category1");
            #endregion

            if (Request.Form.Count > 0)
            {
                Abnormal_event _abnormal_Event = new Abnormal_event();

                _abnormal_Event.Abnormal_event_ID   = Request.Form["Abnormal_event_ID"];
                _abnormal_Event.Abnormal_event1     = Request.Form["Abnormal_event"];
                _abnormal_Event.Unit_descrition     = Request.Form["Unit_description"];
                _abnormal_Event.Application_unit_no = Convert.ToInt32(Session["UserID"]);
                _abnormal_Event.Volunteer_no        = Convert.ToInt32(Request.Form["Volunteer_no"]);
                _abnormal_Event.Notification_date   = DateTime.Now;
                _abnormal_Event.event_category_ID   = Convert.ToInt32(Request.Form["category"]);
                _abnormal_Event.Supervisor_ID       = 1;

                var q = from s in db.Stages
                        where s.Stage1 == "新事件" && s.Stage_type == "異常事件"
                        select s.Stage_ID;

                _abnormal_Event.Stage = q.ToList().First();
                abnormaleventRepository.Create(_abnormal_Event);

                return(Content("<script>alert('通報成功!');window.open('" + Url.Content("~/Abnormalevent/Home") + "', '_self')</script>"));
            }
            return(View());
        }