// 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()); }
public ActionResult Edit([Bind(Include = "MaHD,NgayLap,GiaThoaThuan,MaTram,ThoiHanThue,MaDT,NguoiLap,MoTa,createUser,lastupdateUser,createDate,lastupdateDate,isDeleted")] HOPDONG hOPDONG) { string nguoiLap = Request.Form["nhanVienDropList"].ToString(); string doiTac = Request.Form["doiTacDropList"].ToString(); string tramXe = Request.Form["tramXeDropList"].ToString(); if (ModelState.IsValid) { INhanVienService nhanVienService = new NhanVienService(); NHANVIEN nv = nhanVienService.Detail(Int32.Parse(nguoiLap)); IDoiTacService doiTacService = new DoiTacService(); DOITAC dtac = doiTacService.Detail(Int32.Parse(doiTac)); ITramXeService tramXeService = new TramXeService(); TRAMXE tx = tramXeService.Detail(Int32.Parse(tramXe))[0]; IList <HOPDONG> hd = service.Detail(hOPDONG.MaHD); hd[0].NgayLap = hOPDONG.NgayLap; hd[0].GiaThoaThuan = hOPDONG.GiaThoaThuan; hd[0].MaTram = Int32.Parse(tramXe); hd[0].ThoiHanThue = hOPDONG.ThoiHanThue; hd[0].MaDT = Int32.Parse(doiTac); hd[0].NguoiLap = Int32.Parse(nguoiLap); hd[0].MoTa = hOPDONG.MoTa; hd[0].NHANVIEN = nv; hd[0].DOITAC = dtac; hd[0].TRAMXE = tx; service.Update(hd[0]); return(RedirectToAction("Index")); } return(View(hOPDONG)); }
// GET: HOPDONGs/Create public ActionResult Create() { INhanVienService nhanVienService = new NhanVienService(); IList <NHANVIEN> nhanVienList = nhanVienService.GetAll(); List <SelectListItem> listNhanVien = new List <SelectListItem>(); for (int i = 0; i < nhanVienList.Count; i++) { listNhanVien.Add(new SelectListItem { Text = nhanVienList[i].TenNV, Value = nhanVienList[i].MaNV.ToString() }); } ViewBag.listNhanVien = listNhanVien; IDoiTacService doiTacService = new DoiTacService(); IList <DOITAC> doiTacList = doiTacService.GetAll(); List <SelectListItem> listDoiTac = new List <SelectListItem>(); for (int i = 0; i < doiTacList.Count; i++) { listDoiTac.Add(new SelectListItem { Text = doiTacList[i].TenDT, Value = doiTacList[i].MaDT.ToString() }); } ViewBag.listDoiTac = listDoiTac; ITramXeService tramXeService = new TramXeService(); IList <TRAMXE> tramXeList = tramXeService.GetAll(); List <SelectListItem> listTramXe = new List <SelectListItem>(); for (int i = 0; i < tramXeList.Count; i++) { listTramXe.Add(new SelectListItem { Text = tramXeList[i].TenTram, Value = tramXeList[i].MaTram.ToString() }); } ViewBag.listTramXe = listTramXe; return(View()); }
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)); }
// GET: HOPDONGs/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IList <HOPDONG> hOPDONG = service.Detail(id); if (hOPDONG == null) { return(HttpNotFound()); } INhanVienService nhanVienService = new NhanVienService(); IList <NHANVIEN> nhanVienList = nhanVienService.GetAll(); List <SelectListItem> listNhanVien = new List <SelectListItem>(); for (int i = 0; i < nhanVienList.Count; i++) { if (hOPDONG[0].NguoiLap == nhanVienList[i].MaNV) { listNhanVien.Add(new SelectListItem { Text = nhanVienList[i].TenNV, Value = nhanVienList[i].MaNV.ToString(), Selected = true }); } else { listNhanVien.Add(new SelectListItem { Text = nhanVienList[i].TenNV, Value = nhanVienList[i].MaNV.ToString() }); } } ViewBag.listNhanVien = listNhanVien; IDoiTacService doiTacService = new DoiTacService(); IList <DOITAC> doiTacList = doiTacService.GetAll(); List <SelectListItem> listDoiTac = new List <SelectListItem>(); for (int i = 0; i < doiTacList.Count; i++) { if (hOPDONG[0].MaDT == doiTacList[i].MaDT) { listDoiTac.Add(new SelectListItem { Text = doiTacList[i].TenDT, Value = doiTacList[i].MaDT.ToString(), Selected = true }); } else { listDoiTac.Add(new SelectListItem { Text = doiTacList[i].TenDT, Value = doiTacList[i].MaDT.ToString() }); } } ViewBag.listDoiTac = listDoiTac; ITramXeService tramXeService = new TramXeService(); IList <TRAMXE> tramXeList = tramXeService.GetAll(); List <SelectListItem> listTramXe = new List <SelectListItem>(); for (int i = 0; i < tramXeList.Count; i++) { if (hOPDONG[0].MaTram == tramXeList[i].MaTram) { listTramXe.Add(new SelectListItem { Text = tramXeList[i].TenTram, Value = tramXeList[i].MaTram.ToString(), Selected = true }); } else { listTramXe.Add(new SelectListItem { Text = tramXeList[i].TenTram, Value = tramXeList[i].MaTram.ToString() }); } } ViewBag.listTramXe = listTramXe; return(View(hOPDONG[0])); }