Пример #1
0
        public ActionResult Delete(string kind, string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (kind == "trgTable")
            {
                linkage_trigger trigger = db.linkage_trigger.Find(int.Parse(id));
                if (trigger == null)
                {
                    return(HttpNotFound());
                }
                db.linkage_trigger.Remove(trigger);

                db.SaveChanges();
            }
            else if (kind == "istrTable")
            {
                linkage_instruction instruction = db.linkage_instruction.Find(int.Parse(id));
                if (instruction == null)
                {
                    return(HttpNotFound());
                }
                db.linkage_instruction.Remove(instruction);

                db.SaveChanges();
            }

            return(RedirectToAction("Index"));
        }
Пример #2
0
        public ActionResult EditTrg(FormCollection collection)
        {
            //生成repeat
            var Mon  = collection["Mon"];
            var Tues = collection["Tues"];
            var Wed  = collection["Wed"];
            var Thur = collection["Thur"];
            var Fri  = collection["Fri"];
            var Sat  = collection["Sat"];
            var Sun  = collection["Sun"];
            //过滤 hidden false
            var repeat = "";

            if (Mon.Contains("true"))
            {
                repeat += "1";
            }
            else
            {
                repeat += "0";
            }
            if (Tues.Contains("true"))
            {
                repeat += "1";
            }
            else
            {
                repeat += "0";
            }
            if (Wed.Contains("true"))
            {
                repeat += "1";
            }
            else
            {
                repeat += "0";
            }
            if (Thur.Contains("true"))
            {
                repeat += "1";
            }
            else
            {
                repeat += "0";
            }
            if (Fri.Contains("true"))
            {
                repeat += "1";
            }
            else
            {
                repeat += "0";
            }
            if (Sat.Contains("true"))
            {
                repeat += "1";
            }
            else
            {
                repeat += "0";
            }
            if (Sun.Contains("true"))
            {
                repeat += "1";
            }
            else
            {
                repeat += "0";
            }

            linkage_trigger trg = new linkage_trigger();

            trg.id      = int.Parse(collection["id2"]);
            trg.delay   = int.Parse(collection["delay2"]);
            trg.repeat  = repeat;
            trg.trigger = collection["trigger2"];

            db.Entry <linkage_trigger>(trg).State = EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }