public ActionResult Create(HoanVay hoanvay)
        {
            hoanvay.KhoanVay = db.KhoanVay.Find(hoanvay.idKhoanVay);
            try
            {
                if (ModelState.IsValid)
                {   //them hoanvay vao database
                    db.HoanVay.Add(hoanvay);
                    db.SaveChanges();
                    //thong bao thanh cong ra man hinh
                    TempData["Message"] = "Thêm mới hoàn vay thành công";
                }
            }
            catch
            {    //neu thong tin bi trung hay loi thi hien ra thong bao loi
                TempData["Message"] = "Thêm mới hoàn vay không thành công";
            }

            if (hoanvay.KhoanVay != null)
            {   //tro lai man hinh index cua hoanvay co id=NV_id
                return(RedirectToAction("Index", new { NV_id = hoanvay.KhoanVay.idNhanVienVayMuon }));
            }
            else
            {
                return(View(hoanvay));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Create(dmLoaiTangGiam dmloaitanggiam)
        {
            if (ModelState.IsValid)
            {
                db.dmLoaiTangGiam.Add(dmloaitanggiam);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dmloaitanggiam));
        }
        public ActionResult Create(dmLaiSuatTruyThu dmlaisuattruythu)
        {
            if (ModelState.IsValid)
            {
                db.dmLaiSuatTruyThu.Add(dmlaisuattruythu);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(dmlaisuattruythu));
        }
        public ActionResult Create(dmLoaiDieuChinh dmloaidieuchinh)
        {
            if (ModelState.IsValid)
            {
                db.dmLoaiDieuChinh.Add(dmloaidieuchinh);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.idLoaiTangGiam = new SelectList(db.dmLoaiTangGiam, "id", "Ma", dmloaidieuchinh);
            return(View(dmloaidieuchinh));
        }
        public ActionResult Create(dmTyLeDongBHXH dmtyledongbhxh)
        {
            if (ModelState.IsValid)
            {
                db.dmTyLeDongBHXH.Add(dmtyledongbhxh);
                db.SaveChanges();
                TempData["Message"] = "Thêm mới thành công";
                return(RedirectToAction("Index", "dmTyLeDongBH"));
            }

            return(View(dmtyledongbhxh));
        }
        public ActionResult Create(dmMucLuongToiThieuVung dmmucluongtoithieuvung)
        {
            if (ModelState.IsValid)
            {
                db.dmMucLuongToiThieuVung.Add(dmmucluongtoithieuvung);
                db.SaveChanges();
                TempData["Message"] = "Thêm mới thành công";
                return(RedirectToAction("Index2", "dmMucLuongToiThieuVung"));
            }

            return(View(dmmucluongtoithieuvung));
        }
Ejemplo n.º 7
0
        public ActionResult Create(dmNoiKCB dmNoiKCBs)
        {
            if (ModelState.IsValid)
            {
                db.dmNoiKCB.Add(dmNoiKCBs);
                db.SaveChanges();
                TempData["Message"] = "Thêm mới thành công";
                return(RedirectToAction("Index", "dmNoiKCB"));
            }

            return(View(dmNoiKCBs));
        }
Ejemplo n.º 8
0
        public ActionResult Create(nvbhQuaTrinhBHXH nvbhquatrinhbhxh)
        {
            if (ModelState.IsValid)
            {
                db.nvbhQuaTrinhBHXH.Add(nvbhquatrinhbhxh);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.idNVBHXH = new SelectList(db.nvbhNhanVienBHXH, "id", "HoVaTen", nvbhquatrinhbhxh.idNVBHXH);
            return(View(nvbhquatrinhbhxh));
        }
Ejemplo n.º 9
0
        public ActionResult Create(TapTin model)
        {
            string kv;
            var    sochungtu = TempData["sochungtu"].ToString();

            kv = sochungtu;
            var mucdich = (from m in db.KhoanVay
                           where m.SoChungTu == kv
                           select m.idMucDichSuDung).First();
            var tengiay = from h in db.dmGiayTo
                          where h.idMucDichSuDung == (int)mucdich
                          select new SelectListItem {
                Value = h.TenGiayTo, Text = h.TenGiayTo
            };

            ViewBag.tengiay = tengiay;
            int idkv  = (from h in db.KhoanVay where h.SoChungTu == sochungtu select h.id).First();
            var file1 = Request.Files[0];

            if (db.TapTin.FirstOrDefault(nv => (nv.tepDinhKem == file1.FileName)) != null)
            {
                TempData["Message"] = "File đã tồn tại"; return(Redirect("../taptin/Create?kv=" + sochungtu));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    using (var scope = new TransactionScope())
                    {
                        db.TapTin.Add(model);
                        db.SaveChanges();
                        try
                        {
                            if (!String.IsNullOrEmpty(model.tepDinhKem))
                            {
                                var file = Request.Files[0];
                                model.tepDinhKem = file.FileName;
                                db.SaveChanges();
                                Upload(file);
                            }
                            scope.Complete();
                            return(Redirect("../khoanvay/details?id=" + idkv));
                        }
                        catch (Exception e)
                        {
                            ModelState.AddModelError("tepDinhKem", e.Message);
                        }
                    }
                }
            }
            return(View());
        }
Ejemplo n.º 10
0
        public ActionResult Create(nvbhLaiTruyThuBH nvbhlaitruythubh)
        {
            if (ModelState.IsValid)
            {
                db.nvbhLaiTruyThuBH.Add(nvbhlaitruythubh);
                db.SaveChanges();
                return(RedirectToAction("Index2"));
            }

            ViewBag.iddmLaiSuatTruyThu        = new SelectList(db.dmLaiSuatTruyThu, "id", "id", nvbhlaitruythubh.iddmLaiSuatTruyThu);
            ViewBag.iddmMucLuongToiThieuChung = new SelectList(db.dmMucLuongToiThieuChung, "id", "GhiChu", nvbhlaitruythubh.iddmMucLuongToiThieuChung);
            ViewBag.iddmTyLeDongBHXH          = new SelectList(db.dmTyLeDongBHXH, "id", "DoanhNghiepBHXH", nvbhlaitruythubh.iddmTyLeDongBHXH);
            ViewBag.idnvbhNhanVienBHXH        = new SelectList(db.nvbhNhanVienBHXH, "id", "HoVaTen", nvbhlaitruythubh.idnvbhNhanVienBHXH);

            return(View(nvbhlaitruythubh));
        }
Ejemplo n.º 11
0
        public ActionResult Create(nvbhDanhSachDieuChinhTangGiam nvbhdanhsachdieuchinhchucdanh)
        {
            if (ModelState.IsValid)
            {
                db.nvbhDanhSachDieuChinhTangGiam.Add(nvbhdanhsachdieuchinhchucdanh);
                db.SaveChanges();
                TempData["Message"] = "Thêm thành công";
                return(RedirectToAction("Index2"));
            }
            else
            {
                TempData["Message"] = "Thêm không thành công";
                return(RedirectToAction("Index2"));
            }

            return(View(nvbhdanhsachdieuchinhchucdanh));
        }
        //
        // GET: /dmMucDichSuDung/

        public ActionResult Index()
        {
            var model = (from MD in db.dmMucDichSuDung
                         orderby MD.stt
                         select MD).ToList();

            for (int i = 0, c = 1; i < model.Count; i++, c++)
            {
                if (model[i].stt != c)
                {
                    model[i].stt             = c;
                    db.Entry(model[i]).State = EntityState.Modified;
                }
            }
            db.SaveChanges();

            return(View(db.dmMucDichSuDung.ToList()));
        }
        //
        // GET: /dmGiayTo/

        public ActionResult Index()
        {
            var model = (from GT in db.dmGiayTo
                         orderby GT.stt
                         select GT).ToList();

            for (int i = 0, c = 1; i < model.Count; i++, c++)
            {
                if (model[i].stt != c)
                {
                    model[i].stt             = c;
                    db.Entry(model[i]).State = EntityState.Modified;
                }
            }
            db.SaveChanges();

            return(View(db.dmGiayTo.ToList()));
            //var dmgiaytoes = db.dmGiayTo.Include(d => d.MucDichSuDung);
            //return View(dmgiaytoes.ToList());
        }
Ejemplo n.º 14
0
 public ActionResult Create(NhanVienVayMuon nhanvienvaymuon)
 {   //kt null cac truong khi tao nv
     UpdateModel(ModelState, nhanvienvaymuon);
     try
     {
         if (ModelState.IsValid)
         {   //them nv vao bang nhanvienvaymuon
             db.NhanVienVayMuon.Add(nhanvienvaymuon);
             db.SaveChanges();
             TempData["Message"] = "Thêm mới nhân viên vay mượn thành công";
             //chuyen huong ve trang index cua nhanvienvaymuon
             return(RedirectToAction("index"));
         }
     }
     catch (Exception e)
     {
         TempData["Message"] = "Thêm mới nhân viên vay mượn không thành công";
     }
     return(View(nhanvienvaymuon));
 }
Ejemplo n.º 15
0
        public ActionResult Details(FormCollection m)
        {
            int i         = 0;
            var someValue = TempData["ID_KV"];

            if (ModelState.IsValid)
            {
                //lay gia tri cua checkbox
                string[] a  = m.Get("item.TrangThai").Replace("true,false", "true").Split(',');
                var      id = m.GetValues("item.id");
                //luu gia tri checkbox xong database
                for (i = 0; i < id.Count(); i++)
                {
                    HoSoVayMuon hs = db.HoSoVayMuon.Find(Convert.ToInt32(id[i]));
                    hs.TrangThai = Convert.ToBoolean(a[i]);
                }
                db.SaveChanges();
                //chuyen huong den index cua khoanvay co NV_id = someValue
                return(RedirectToAction("Index", new { NV_id = someValue }));
            }
            return(View(m));
        }
Ejemplo n.º 16
0
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         HoanVay hoanvay = db.HoanVay.Find(id);
         //int nvid = hoanvay.KhoanVay.idNhanVienVayMuon;
         db.HoanVay.Remove(hoanvay);
         db.SaveChanges();
         TempData["Message"] = "Xóa khoản vay thành công";
     }
     catch (Exception e)
     {
         TempData["Message"] = "Xóa khoản vay không thành công";
     }
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 17
0
        public ActionResult Create(nvbhDanhSachDieuChinhTangGiam nvbhdanhsachdieuchinhtanggiam)
        {
            if (ModelState.IsValid)
            {
                int maxId1 = (from c in db.nvbhDanhSachDieuChinhTangGiam select c.MoiNhat).Max();
                db.nvbhDanhSachDieuChinhTangGiam.Add(nvbhdanhsachdieuchinhtanggiam);
                nvbhdanhsachdieuchinhtanggiam.MoiNhat = maxId1 + 1;
                db.SaveChanges();
                TempData["Message"] = "Thêm thành công";
                return(RedirectToAction("Index2"));
            }
            else
            {
                TempData["Message"] = "Thêm không thành công";
                return(RedirectToAction("Index2"));
            }

            return(View(nvbhdanhsachdieuchinhtanggiam));
        }
Ejemplo n.º 18
0
        public ActionResult Create(nvbhNhanVienBHXH nvbhnhanvienbhxh)
        {
            string manv = nvbhnhanvienbhxh.MANV;

            using (var nv = new HRM.Databases.Models.HRMDBEntities())
            {
                try
                {
                    if (db.nvbhNhanVienBHXH.FirstOrDefault(dsma => (dsma.MANV == manv)) != null)
                    {
                        TempData["Message"] = "Nhân viên này đã tồn tại";
                        return(RedirectToAction("Index2", "NhanVienBHXH", new { dv = db.nvbhNhanVienBHXH.FirstOrDefault().Donvi_id }));
                    }
                    else
                    {
                        if (ModelState.IsValid)
                        {
                            //lay cac thong tin cua nhan vien trong db cua HRM0
                            int idnv = (from h in nv.NhanVien
                                        where h.MaNV == manv
                                        select h.id).First();

                            var thongtinnv = (from nhanvien in nv.nvSoYeuLyLich
                                              where nhanvien.NV_id == idnv
                                              select nhanvien).First();
                            string gioitinh = (from gt in nv.dmGioiTinh
                                               where thongtinnv.GioiTinh_id == gt.id
                                               select gt.maGioiTinh).First();

                            string diachi = (from dc in nv.nvDiaChiNha
                                             where thongtinnv.HoKhauThuongTru_id == dc.id
                                             select dc.DiaChi).First();

                            //

                            DateTime ngaysinh = Convert.ToDateTime(thongtinnv.NgaySinh);
                            nvbhnhanvienbhxh.HoVaTen  = thongtinnv.HoVaTen;
                            nvbhnhanvienbhxh.DiaChiTT = diachi;
                            nvbhnhanvienbhxh.ChucDanh = thongtinnv.ChucVuHienTai;
                            nvbhnhanvienbhxh.NgaySinh = ngaysinh;
                            if (gioitinh == "F")
                            {
                                nvbhnhanvienbhxh.Nu = true;
                            }
                            else
                            {
                                nvbhnhanvienbhxh.Nu = false;
                            }



                            db.nvbhNhanVienBHXH.Add(nvbhnhanvienbhxh);
                            db.SaveChanges();
                            TempData["Message"] = "Thêm mới nhân viên BHXH thành công";
                            return(RedirectToAction("Index2", "NhanVienBHXH"));
                        }
                    }
                }
                catch (Exception e)
                {
                    TempData["Message"] = "Thêm mới nhân viên BHXH không thành công";
                }
            }
            return(View(nvbhnhanvienbhxh));
        }