public ActionResult List(FormCollection formCollection)
        {
            if (ModelState.IsValid)
            {
                //ViewBag.MaHKNH = new SelectList(db.HKNHs, "MaHKNH", "HocKy", dS_MONHOC_MO.MaHKNH);
                var MaMo_last = db.DS_MONHOC_MO.OrderByDescending(p => p.MaMo).FirstOrDefault();
                int id_MaMo   = 1001;
                if (MaMo_last == null)
                {
                    id_MaMo = 1001;
                }
                else
                {
                    id_MaMo = Int32.Parse(MaMo_last.MaMo);
                }
                //int id_num = Int32.Parse(MaMo_last.MaMo) + 1;
                //var employee = db.DS_MONHOC_MO.SingleOrDefault(p => p.MaMonHoc == id);
                string[] ids = formCollection["ID"]?.Split(new char[] { ',' });
                if (ids == null)
                {
                    ViewBag.IsNull = 1;
                    return(RedirectToAction("Index", new { id = hk }));
                }
                try
                {
                    foreach (string id in ids)
                    {
                        DS_MONHOC_MO a = new DS_MONHOC_MO()
                        {
                            MaMo     = (++id_MaMo).ToString(),
                            MaHKNH   = hk,
                            MaMonHoc = id
                        };
                        //db.DS_MONHOC_MO.Remove(employee);
                        //employee.MaMo = (Int32.Parse(employee.MaMo) + 1).ToString();
                        db.DS_MONHOC_MO.Add(a);
                        db.SaveChanges();
                    }
                }
                catch
                {
                    ViewBag.err = 1;
                    return(RedirectToAction("Create", new { @isErr = ViewBag.err }));
                }
                //db.DS_MONHOC_MO.Add(dS_MONHOC_MO);
                //db.SaveChanges();
                return(RedirectToAction("Index", new { id = hk }));
            }

            //ViewBag.MaHKNH = new SelectList(db.HKNHs, "MaHKNH", "HocKy", dS_MONHOC_MO.MaHKNH);
            //ViewBag.MaMonHoc = new SelectList(db.MONHOCs, "MaMonHoc", "TenMonHoc", dS_MONHOC_MO.MaMonHoc);
            return(View());
        }
 public ActionResult Edit([Bind(Include = "SoPhieuDK,MaMo,GhiChu")] CT_PHIEUDK cT_PHIEUDK)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cT_PHIEUDK).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.MaMo      = new SelectList(db.DS_MONHOC_MO, "MaMo", "MaHKNH", cT_PHIEUDK.MaMo);
     ViewBag.SoPhieuDK = new SelectList(db.PHIEU_DK, "SoPhieuDK", "MaSinhVien", cT_PHIEUDK.SoPhieuDK);
     return(View(cT_PHIEUDK));
 }
        public ActionResult Create([Bind(Include = "MaHKNH,MaSinhVien,SoTienConLai")] BAOCAO_SV_NOHP bAOCAO_SV_NOHP)
        {
            if (ModelState.IsValid)
            {
                db.BAOCAO_SV_NOHP.Add(bAOCAO_SV_NOHP);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaSinhVien = new SelectList(db.HKNHs, "MaHKNH", "HocKy", bAOCAO_SV_NOHP.MaSinhVien);
            ViewBag.MaSinhVien = new SelectList(db.SINHVIENs, "MaSinhVien", "HoTen", bAOCAO_SV_NOHP.MaSinhVien);
            return(View(bAOCAO_SV_NOHP));
        }
Exemplo n.º 4
0
        private void btSua_Click(object sender, EventArgs e)
        {
            using (CNPMEntities db = new CNPMEntities())
            {
                var xe = (from x in db.Xes
                          where x.Biensoxe == GetBSX
                          select x).FirstOrDefault();
                xe.Biensoxe  = txtBSX.Text;
                xe.idLoaiXe  = (int)cbbLoaiXe.SelectedValue;
                xe.TenXe     = txtTenXe.Text;
                xe.PhiXang   = txtPhiXang.Text;
                xe.PhiQuaKm  = txtPhiQuaKm.Text;
                xe.DonGia    = txtDonGia.Text;
                xe.MoTaTT    = txtMoTaTT.Text;
                xe.TrangThai = int.Parse(txtTrangThai.Text);
                db.SaveChanges();
                MessageBox.Show("Edit success", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            GetBSX = null;
            CNPMEntities context = new CNPMEntities();
            List <Xe>    xes     = context.Xes.ToList();

            BindGrid(xes);
        }
Exemplo n.º 5
0
        private void btSua_Click(object sender, EventArgs e)
        {
            using (CNPMEntities db = new CNPMEntities())
            {
                var dbhd = (from hd in db.HopDongs
                            where hd.MaHD == GetMaHD
                            select hd).FirstOrDefault();
                dbhd.MaHD         = txtSoDH.Text.ToString();
                dbhd.idXe         = (int)cbbSoXe.SelectedValue;
                dbhd.idNV         = (int)cbbMaNV.SelectedValue;
                dbhd.idKH         = (int)cbbMaKH.SelectedValue;
                dbhd.NgayHD       = DateTime.Parse(msktbNgayHD.Text.ToString());
                dbhd.TienDat      = txtTienDat.Text;
                dbhd.KhuyenMai    = txtKhuyenMai.Text.ToString();
                dbhd.NoiDungHD    = txtNoiDungHD.Text.ToString();
                dbhd.GiayToGiuLai = txtGiayTo.Text.ToString();
                db.SaveChanges();
                XtraMessageBox.Show("Edit success", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            GetMaHD = null;
            CNPMEntities   context    = new CNPMEntities();
            List <HopDong> lstHopDong = context.HopDongs.ToList();

            BindGrid(lstHopDong);
        }
Exemplo n.º 6
0
        private void btSua_Click(object sender, EventArgs e)
        {
            using (CNPMEntities db = new CNPMEntities())
            {
                var bbgn = (from bb in db.BBGNs
                            where bb.MaBBGN == GetMaBBGN
                            select bb).FirstOrDefault();


                bbgn.MaBBGN      = txtMaBBGN.Text;
                bbgn.NgayGiao    = DateTime.Parse(mskNgayGiao.Text.ToString());
                bbgn.idXe        = (int)cbbSoXe.SelectedValue;
                bbgn.idKH        = (int)cbbMaKH.SelectedValue;
                bbgn.idNV        = (int)cbbMaNV.SelectedValue;
                bbgn.KmDi        = int.Parse(txtKmDi.Text);
                bbgn.XangDi      = txtXangDi.Text;
                bbgn.TrangThaiDi = txtTTDi.Text;
                bbgn.NgayNhan    = DateTime.Parse(mskNgayNhan.Text.ToString());
                bbgn.KmVe        = int.Parse(txtKmVe.Text);
                bbgn.XangVe      = txtXangVe.Text;
                bbgn.TrangThaiVe = txtTTVe.Text;


                db.SaveChanges();
                XtraMessageBox.Show("Edit success", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            GetMaBBGN = null;

            CNPMEntities context = new CNPMEntities();
            List <BBGN>  lstBBGn = context.BBGNs.ToList();

            BindGrid(lstBBGn);
        }
Exemplo n.º 7
0
 public static bool AddLoaiXe(LoaiXe loaixe)
 {
     using (var _context = new CNPMEntities())
     {
         _context.LoaiXes.Add(loaixe);
         _context.SaveChanges();
         return(true);
     }
 }
Exemplo n.º 8
0
 public static bool AddBBGN(BBGN bbgn)
 {
     using (var _context = new CNPMEntities())
     {
         _context.BBGNs.Add(bbgn);
         _context.SaveChanges();
         return(true);
     }
 }
Exemplo n.º 9
0
        public ActionResult Create([Bind(Include = "MaKhoa,TenKhoa")] KHOA kHOA)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.KHOAs.Add(kHOA);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(kHOA));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Create", "KHOAs", new { id = 1 }));
            }
        }
Exemplo n.º 10
0
        public ActionResult Create([Bind(Include = "MaHKNH,HocKy,Nam1,Nam2,HanDongHocPhi")] HKNH hKNH)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.HKNHs.Add(hKNH);
                    db.SaveChanges();
                    return(RedirectToAction("ListHK", "DS_MONHOC_MO"));
                }

                return(View(hKNH));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Create", "HKNHs", new { id = 1 }));
            }
        }
        public ActionResult Create([Bind(Include = "MaDoiTuong,TenDoiTuong,TiLeGiamHocPhi")] DOITUONG dOITUONG)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.DOITUONGs.Add(dOITUONG);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(dOITUONG));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Create", "DOITUONGs", new { id = 1 }));
            }
        }
        public ActionResult Create([Bind(Include = "MaLoaiMon,TenLoaiMon,SoTietTC,SoTienTC")] LOAIMON lOAIMON)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.LOAIMONs.Add(lOAIMON);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(lOAIMON));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Create", "LOAIMONs", new { id = 1 }));
            }
        }
Exemplo n.º 13
0
 public static bool AddNhanVien(NhanVien nhanvien)
 {
     using (var _context = new CNPMEntities())
     {
         _context.NhanViens.Add(nhanvien);
         _context.SaveChanges();
         return(true);
     }
 }
Exemplo n.º 14
0
 public static bool AddAccount(Account a)
 {
     using (var _context = new CNPMEntities())
     {
         _context.Accounts.Add(a);
         _context.SaveChanges();
         return(true);
     }
 }
Exemplo n.º 15
0
 public static bool AddXe(Xe xe)
 {
     using (var _context = new CNPMEntities())
     {
         _context.Xes.Add(xe);
         _context.SaveChanges();
         return(true);
     }
 }
Exemplo n.º 16
0
        public ActionResult Create([Bind(Include = "MaTinh,TenTinh")] TINH tINH)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.TINHs.Add(tINH);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(tINH));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Create", "TINHs", new { id = 1 }));
            }
        }
Exemplo n.º 17
0
 public static bool AddKhachHang(KhachHang khachhang)
 {
     using (var _context = new CNPMEntities())
     {
         _context.KhachHangs.Add(khachhang);
         _context.SaveChanges();
         return(true);
     }
 }
Exemplo n.º 18
0
 public static bool AddHopDong(HopDong hopdong)
 {
     using (var _context = new CNPMEntities())
     {
         _context.HopDongs.Add(hopdong);
         _context.SaveChanges();
         return(true);
     }
 }
        public ActionResult Create([Bind(Include = "MaHuyen,TenHuyen,MaTinh,UuTien")] HUYEN hUYEN)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.HUYENs.Add(hUYEN);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.MaTinh = new SelectList(db.TINHs, "MaTinh", "TenTinh", hUYEN.MaTinh);
                return(View(hUYEN));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Create", "HUYENs", new { id = 1 }));
            }
        }
        public ActionResult Create([Bind(Include = "TenDangNhap,MatKhau,IDNhomNguoiDung")] NGUOIDUNG nGUOIDUNG)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.NGUOIDUNGs.Add(nGUOIDUNG);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.IDNhomNguoiDung = new SelectList(db.NHOMNGUOIDUNGs, "IDNhomNguoiDung", "TenNhomNguoiDung", nGUOIDUNG.IDNhomNguoiDung);
                return(View(nGUOIDUNG));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Create", "NGUOIDUNGs", new { id = 1 }));
            }
        }
        public ActionResult Create([Bind(Include = "MaMonHoc,TenMonHoc,MaLoaiMon,SoTiet")] MONHOC mONHOC)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.MONHOCs.Add(mONHOC);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.MaLoaiMon = new SelectList(db.LOAIMONs, "MaLoaiMon", "TenLoaiMon", mONHOC.MaLoaiMon);
                return(View(mONHOC));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Create", "MONHOCs", new { id = 1 }));
            }
        }
        public ActionResult Create([Bind(Include = "MaNganh,MaKhoa,TenNganh")] NGANH nGANH)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.NGANHs.Add(nGANH);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.MaKhoa = new SelectList(db.KHOAs, "MaKhoa", "TenKhoa", nGANH.MaKhoa);
                return(View(nGANH));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Create", "NGANHs", new { id = 1 }));
            }
        }
Exemplo n.º 23
0
        public ActionResult Create([Bind(Include = "MaNganh,MaMonHoc,HocKy")] CT_NGANH cT_NGANH)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.CT_NGANH.Add(cT_NGANH);
                    db.SaveChanges();
                    return(RedirectToAction("Index", "CT_NGANH", new { id = cT_NGANH.MaNganh }));
                }

                ViewBag.MaMonHoc = new SelectList(db.MONHOCs, "MaMonHoc", "TenMonHoc", cT_NGANH.MaMonHoc);
                ViewBag.MaNganh  = new SelectList(db.NGANHs, "MaNganh", "TenNganh", cT_NGANH.NGANH.TenNganh);
                return(View(cT_NGANH));
            }
            catch (Exception e)
            {
                return(RedirectToAction("Create", "CT_NGANH", new { id = 1 }));
            }
        }
Exemplo n.º 24
0
 public static bool RemoveLoaiXe(string TenLoai)
 {
     using (CNPMEntities _context = new CNPMEntities())
     {
         var dblx = (from lx in _context.LoaiXes
                     where lx.TenLoai == TenLoai
                     select lx).FirstOrDefault();
         _context.LoaiXes.Remove(dblx);
         _context.SaveChanges();
         return(true);
     }
 }
Exemplo n.º 25
0
 public static bool RemoveAccount(string a)
 {
     using (CNPMEntities _context = new CNPMEntities())
     {
         var getaccount = (from ac in _context.Accounts
                           where ac.TaiKhoan == a
                           select ac).FirstOrDefault();
         _context.Accounts.Remove(getaccount);
         _context.SaveChanges();
         return(true);
     }
 }
Exemplo n.º 26
0
 public static bool RemoveNhanVien(string MaNV)
 {
     using (CNPMEntities _context = new CNPMEntities())
     {
         var dbnv = (from nv in _context.NhanViens
                     where nv.MaNV == MaNV
                     select nv).FirstOrDefault();
         _context.NhanViens.Remove(dbnv);
         _context.SaveChanges();
         return(true);
     }
 }
Exemplo n.º 27
0
 public static bool RemoveXe(string BSX)
 {
     using (CNPMEntities _context = new CNPMEntities())
     {
         var dbxe = (from xe in _context.Xes
                     where xe.Biensoxe == BSX
                     select xe).FirstOrDefault();
         _context.Xes.Remove(dbxe);
         _context.SaveChanges();
         return(true);
     }
 }
Exemplo n.º 28
0
 public static bool RemoveKhachHang(string MaKH)
 {
     using (CNPMEntities _context = new CNPMEntities())
     {
         var dbkh = (from kh in _context.KhachHangs
                     where kh.MaKH == MaKH
                     select kh).FirstOrDefault();
         _context.KhachHangs.Remove(dbkh);
         _context.SaveChanges();
         return(true);
     }
 }
Exemplo n.º 29
0
 public static bool RemoveBBGN(string MaBBGN)
 {
     using (CNPMEntities _context = new CNPMEntities())
     {
         var dbbbgn = (from bbgn in _context.BBGNs
                       where bbgn.MaBBGN == MaBBGN
                       select bbgn).FirstOrDefault();
         _context.BBGNs.Remove(dbbbgn);
         _context.SaveChanges();
         return(true);
     }
 }
Exemplo n.º 30
0
 public static bool RemoveHopDong(string MaHD)
 {
     using (CNPMEntities _context = new CNPMEntities())
     {
         var dbhd = (from hd in _context.HopDongs
                     where hd.MaHD == MaHD
                     select hd).FirstOrDefault();
         _context.HopDongs.Remove(dbhd);
         _context.SaveChanges();
         return(true);
     }
 }