Example #1
0
 private void FrmNhanVien_Load(object sender, EventArgs e)
 {
     try
     {
         nhanVienBindingSource.DataSource = NhanVienService.GetAll();
         //pContainer.Enabled = False
         DTO.NhanVien obj = nhanVienBindingSource.Current as DTO.NhanVien;
         if (obj == null)
         {
             if (!string.IsNullOrEmpty(obj.AnhNV))
             {
                 pic.Image = Image.FromFile(obj.AnhNV);
             }
         }
         else
         {
             pic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
             pic.Image    = Image.FromFile(obj.AnhNV);
         }
     }
     catch (Exception ex)
     {
         MetroFramework.MetroMessageBox.Show(this, ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        // 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());
        }
        // GET: KHAOSATs/Create
        public ActionResult Create()
        {
            INhanVienService      nhanVienService = new NhanVienService();
            IList <NHANVIEN>      nhanVienList    = nhanVienService.GetAll();
            List <SelectListItem> listItems       = new List <SelectListItem>();

            for (int i = 0; i < nhanVienList.Count; i++)
            {
                listItems.Add(new SelectListItem
                {
                    Text  = nhanVienList[i].TenNV,
                    Value = nhanVienList[i].MaNV.ToString()
                });
            }
            ViewBag.listItems = listItems;
            return(View());
        }
        // GET: KHAOSATs/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            IList <KHAOSAT> kHAOSAT = service.Detail(id);

            if (kHAOSAT == null)
            {
                return(HttpNotFound());
            }

            INhanVienService      nhanVienService = new NhanVienService();
            IList <NHANVIEN>      nhanVienList    = nhanVienService.GetAll();
            List <SelectListItem> listItems       = new List <SelectListItem>();

            for (int i = 0; i < nhanVienList.Count; i++)
            {
                if (kHAOSAT[0].NguoiKS == nhanVienList[i].MaNV)
                {
                    listItems.Add(new SelectListItem
                    {
                        Text     = nhanVienList[i].TenNV,
                        Value    = nhanVienList[i].MaNV.ToString(),
                        Selected = true
                    });
                }
                else
                {
                    listItems.Add(new SelectListItem
                    {
                        Text  = nhanVienList[i].TenNV,
                        Value = nhanVienList[i].MaNV.ToString()
                    });
                }
            }
            ViewBag.listItems = listItems;
            return(View(kHAOSAT[0]));
        }
        // 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]));
        }