コード例 #1
0
        // GET: LOTRINHs/Create
        public ActionResult Create()
        {
            ITuyenXeService       tuyenXeService = new TuyenXeService();
            ITramXeService        tramXeService  = new TramXeService();
            IList <TUYENXE>       tuyenXeList    = tuyenXeService.GetAll();
            IList <TRAMXE>        tramXeList     = tramXeService.GetAll();
            List <SelectListItem> listItems      = new List <SelectListItem>();
            List <SelectListItem> listItems1     = new List <SelectListItem>();

            for (int i = 0; i < tuyenXeList.Count; i++)
            {
                listItems.Add(new SelectListItem
                {
                    Text  = tuyenXeList[i].DiemDi + "-" + tuyenXeList[i].DiemDen,
                    Value = tuyenXeList[i].MaTuyen.ToString()
                });
            }
            for (int i = 0; i < tramXeList.Count; i++)
            {
                listItems1.Add(new SelectListItem
                {
                    Text  = tramXeList[i].TenTram,
                    Value = tramXeList[i].MaTram.ToString()
                });
            }
            ViewBag.listItems  = listItems;
            ViewBag.listItems1 = listItems1;
            return(View());
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "MaTuyen,MaTram,ThuTu,KhoangThoiGian,createUser,lastupdateUser,createDate,lastupdateDate,isDeleted")] LOTRINH lOTRINH)
        {
            string          thuocTuyenXe   = Request.Form["tuyenXeDropList"].ToString();
            string          thuocTramXe    = Request.Form["tramXeDropList"].ToString();
            ITuyenXeService tuyenXeService = new TuyenXeService();
            IList <TUYENXE> tx             = tuyenXeService.Detail(Int32.Parse(thuocTuyenXe));
            ITramXeService  tramXeService  = new TramXeService();
            IList <TRAMXE>  txe            = tramXeService.Detail(Int32.Parse(thuocTramXe));

            if (ModelState.IsValid)
            {
                lOTRINH.isDeleted = 0;
                lOTRINH.MaTuyen   = Int32.Parse(thuocTuyenXe);
                lOTRINH.MaTram    = Int32.Parse(thuocTramXe);
                service.Add(lOTRINH);
                return(RedirectToAction("Index"));
            }

            return(View(lOTRINH));
        }