public ActionResult Edit(int id, int txtTiSo1, int txtTiSo2, int txtSoDiem1, int txtSoDiem2)
        {
            //CTTRANDAU ChiTiet = new CTTRANDAU();
            var cttran = db.CTTRANDAUs.Where(ct => ct.IDTD == id).ToList();
            int a = 0; int b = 0;

            for (int i = 0; i < 1; i++)
            {
                a = cttran[i].IDDOI;     //id doi 1
                b = cttran[i + 1].IDDOI; // id doi 2
            }
            CTTRANDAU ctt = db.CTTRANDAUs.Single(c => c.IDTD == id && c.IDDOI == a);

            ctt.TISO = txtTiSo1.ToString(); ctt.DIEM = txtSoDiem1;

            CTTRANDAU ctt1 = db.CTTRANDAUs.Single(c => c.IDTD == id && c.IDDOI == b);

            ctt1.TISO = txtTiSo2.ToString(); ctt1.DIEM = txtSoDiem2;

            db.SaveChanges();

            ViewBag.CTTRAN   = db.CTTRANDAUs.Where(ct => ct.IDTD == id).ToList();
            ViewBag.DOITHANG = new SelectList(db.CTTRANDAUs.Where(c => c.IDTD == id).Select(c => new { IDDOI = c.IDDOI, TENDOI = c.DOI.TENDOI }), "IDDOI", "TENDOI");
            return(View());
        }
        public ActionResult DeleteConfirmed(int id, int?idtd)
        {
            CTTRANDAU cTTRANDAU = db.CTTRANDAUs.Find(id, idtd);

            db.CTTRANDAUs.Remove(cTTRANDAU);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Create([Bind(Include = "IDDOI,IDTD,KETQUA,TISO,DIEM")] CTTRANDAU cTTRANDAU)
        {
            if (ModelState.IsValid)
            {
                db.CTTRANDAUs.Add(cTTRANDAU);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.IDDOI = new SelectList(db.DOIs, "IDDOI", "TENDOI", cTTRANDAU.IDDOI);
            ViewBag.IDTD  = new SelectList(db.TRANDAUs, "IDTD", "THOIGIANBD", cTTRANDAU.IDTD);
            return(View(cTTRANDAU));
        }
        // GET: Admin/CTTRANDAUs1/Edit/5
        //public ActionResult Edit(int? id, int? idtd)
        //{
        //    if (id == null || idtd == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    CTTRANDAU cTTRANDAU = db.CTTRANDAUs.Find(id,idtd);
        //    if (cTTRANDAU == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    ViewBag.IDDOI = new SelectList(db.DOIs, "IDDOI", "TENDOI", cTTRANDAU.IDDOI);
        //    ViewBag.IDTD = new SelectList(db.TRANDAUs, "IDTD", "THOIGIANBD", cTTRANDAU.IDTD);
        //    return View(cTTRANDAU);
        //}

        //// POST: Admin/CTTRANDAUs1/Edit/5
        //// To protect from overposting attacks, please enable the specific properties you want to bind to, for
        //// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Edit([Bind(Include = "IDDOI,IDTD,KETQUA,TISO,DIEM")] CTTRANDAU cTTRANDAU)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.Entry(cTTRANDAU).State = EntityState.Modified;
        //        db.SaveChanges();
        //        return RedirectToAction("Index");
        //    }
        //    ViewBag.IDDOI = new SelectList(db.DOIs, "IDDOI", "TENDOI", cTTRANDAU.IDDOI);
        //    ViewBag.IDTD = new SelectList(db.TRANDAUs, "IDTD", "THOIGIANBD", cTTRANDAU.IDTD);
        //    return View(cTTRANDAU);
        //}

        // GET: Admin/CTTRANDAUs1/Delete/5
        public ActionResult Delete(int?id, int?idtd)
        {
            if (id == null || idtd == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CTTRANDAU cTTRANDAU = db.CTTRANDAUs.Find(id, idtd);

            if (cTTRANDAU == null)
            {
                return(HttpNotFound());
            }
            return(View(cTTRANDAU));
        }
Exemple #5
0
        public void createcttran(int matran, int madoi1, int madoi2)
        {
            CTTRANDAU ct = new CTTRANDAU();

            ct.IDTD   = matran;
            ct.IDDOI  = madoi1;
            ct.KETQUA = null;
            ct.TISO   = null;
            CTTRANDAU ct1 = new CTTRANDAU();

            ct1.IDTD   = matran;
            ct1.IDDOI  = madoi2;
            ct1.KETQUA = null;
            ct1.TISO   = null;

            db.CTTRANDAUs.Add(ct);
            //db.SaveChanges();
            db.CTTRANDAUs.Add(ct1);
            db.SaveChanges();
        }