Ejemplo n.º 1
0
        public static Boolean CapNhatLaiQuyen(String MaQuyen, String strMaAction)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var lstQuyen = entity.PhanQuyens.Where(n => n.MaQuyen == MaQuyen);
                foreach (var q in lstQuyen)
                {
                    entity.PhanQuyens.Remove(q);
                }
                entity.SaveChanges();
                if (!string.IsNullOrEmpty(strMaAction))
                {
                    var arrMaAction = strMaAction.Split('#');
                    foreach (var action in arrMaAction)
                    {
                        var phanQuyen = new PhanQuyen();
                        phanQuyen.MaQuyen  = MaQuyen;
                        phanQuyen.MaAction = int.Parse(action);
                        entity.PhanQuyens.Add(phanQuyen);
                    }
                    entity.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 2
0
        public static Boolean TaoTaiKhoan(TaiKhoanViewModel taiKhoan)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var check = entity.TaiKhoans.SingleOrDefault(n => n.TaiKhoanNV == taiKhoan.TaiKhoanNV);
                if (check != null)
                {
                    return(false);
                }
                TaiKhoan tk = new TaiKhoan();
                tk.MaNV       = taiKhoan.MaNV;
                tk.MaQuyen    = taiKhoan.MaQuyen;
                tk.TaiKhoanNV = taiKhoan.TaiKhoanNV;
                tk.MatKhau    = taiKhoan.MatKhau;
                tk.Online     = false;
                entity.TaiKhoans.Add(tk);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 3
0
        public static Boolean CapNhatTrangThaiXeDangChay()
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var hd = entity.HopDongs.Where(n => n.MaTrangThai == "1");
                foreach (var item in hd)
                {
                    var cthd = entity.CT_HopDongs.Where(n => n.SoHopDong == item.SoHopDong);
                    foreach (var c in cthd)
                    {
                        if (c.NgayDi < DateTime.Now)
                        {
                            Xe result = entity.Xes.SingleOrDefault(n => n.MaXe == c.MaXe);
                            result.Status = "2";
                        }
                    }
                }
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 4
0
        public static Boolean CapNhatThongTinKhachHang(KhachHangViewModel khachHang)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var kh = entity.KhachHangs.SingleOrDefault(n => n.MaKH == khachHang.MaKH);
                kh.TenKH        = khachHang.TenKH;
                kh.GioiTinh     = khachHang.GioiTinh;
                kh.CMND         = khachHang.CMND;
                kh.SDT          = khachHang.SDT;
                kh.Email        = khachHang.Email;
                kh.DiaChiKH     = khachHang.DiaChiKH;
                kh.GiamGia      = khachHang.GiamGia;
                kh.TenCongTy    = khachHang.TenCongTy;
                kh.NguoiLienHe  = khachHang.NguoiLienHe;
                kh.SDTCongTy    = khachHang.SDTCongTy;
                kh.DiaChiCongTy = khachHang.DiaChiCongTy;
                kh.MaLoaiKH     = khachHang.MaLoaiKH;
                kh.GhiChu       = khachHang.GhiChu;
                kh.MaSoThue     = khachHang.MaSoThue;
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Thêm bảng giá
        /// </summary>
        /// <param BangGiaViewModel="MaBangGia"></param>
        /// <returns>Boolean</returns>
        public static Boolean ThemBangGia(BangGiaViewModel BG)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var bg = new BangGia();
                bg.MaBangGia = TuTangMaBG();
                bg.MaLoaiXe  = BG.MaLoaiXe;
                bg.MaKH      = BG.MaKH;
                bg.MaLoTrinh = BG.MaLoTrinh;
                bg.ThoiGian  = BG.ThoiGian;
                bg.SoKM      = BG.SoKM;
                bg.Gia       = BG.Gia;
                bg.Dang      = true;
                entity.BangGias.Add(bg);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 6
0
        public static Boolean CapNhatTrangThaiXeRanh(String SoHopDong)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var hd = entity.HopDongs.Where(n => n.SoHopDong == SoHopDong);
                foreach (var item in hd)
                {
                    var cthd = entity.CT_HopDongs.Where(n => n.SoHopDong == item.SoHopDong);
                    foreach (var c in cthd)
                    {
                        Xe result = entity.Xes.SingleOrDefault(n => n.MaXe == c.MaXe);
                        result.Status = "0";
                    }
                }
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 7
0
        //thêm công ty
        public static Boolean ThemCongTy(CongTiesViewModel CT)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var Ct = new CongTy();
                Ct.MaCongTy    = TuTangMaCT();
                Ct.TenCongTy   = CT.TenCongTy;
                Ct.Email       = CT.Email;
                Ct.DiaChi      = CT.DiaChi;
                Ct.SDT         = CT.SDT;
                Ct.Fax         = CT.Fax;
                Ct.NguoiLienHe = CT.NguoiLienHe;
                Ct.GhiChu      = CT.GhiChu;
                Ct.Dang        = true;
                entity.CongTies.Add(Ct);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 8
0
        ///End
        #endregion

        #region Chỉnh sửa xe

        /// <summary>
        /// Chỉnh sửa xe
        /// </summary>
        /// <param name="MaXe"></param>
        /// <returns>single</returns>
        // Begin
        public static Boolean ChinhSuaXe(XeViewModel xe)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var result = entity.Xes.SingleOrDefault(n => n.MaXe == xe.MaXe);
                result.BienSo          = xe.BienSo;
                result.Mota            = xe.MoTa;
                result.MaLoaiXe        = xe.MaLoaiXe;
                result.HinhAnh         = xe.HinhAnh;
                result.MaCongTy        = xe.MaCongTy;
                result.MaThuongHieu    = xe.MaThuongHieu;
                result.NgayDangKiem    = xe.NgayDangKiem;
                result.GhiChu          = xe.GhiChu;
                result.NgayBaoTriXe    = xe.NgayBaoTriXe;
                result.SoKm            = xe.SoKm;
                result.SoLan           = xe.SoLan;
                result.MaNV            = xe.MaNV;
                result.BaoHiemTuNguyen = xe.BaoHiemTuNguyen;
                result.BaoHiemBatBuoc  = xe.BaoHiemBatBuoc;
                result.NgayDangKi      = xe.DangKi;
                result.DangKiem        = xe.DangKiem;
                result.HopDong         = xe.HopDong;
                result.ChuXe           = xe.ChuXe;
                result.DiaChi          = xe.DiaChi;
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 9
0
        public static Boolean CapNhatPhuXeBiTrung(String PhuXe, CT_HopDongViewModel CTHDMoi)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var result = entity.CT_HopDongs.Where(n => n.PhuXe == PhuXe);
                foreach (var CTHDCu in result)
                {
                    var kq = entity.HopDongs.SingleOrDefault(n => n.SoHopDong == CTHDCu.SoHopDong && n.MaTrangThai == "0");
                    if (kq != null)
                    {
                        if (
                            (CTHDMoi.NgayDi > CTHDCu.NgayDi && CTHDMoi.NgayDi < CTHDCu.NgayVe) ||
                            (CTHDMoi.NgayVe > CTHDCu.NgayDi && CTHDMoi.NgayVe < CTHDCu.NgayVe) ||
                            (CTHDCu.NgayDi > CTHDMoi.NgayDi && CTHDCu.NgayDi < CTHDMoi.NgayVe) ||
                            (CTHDCu.NgayVe > CTHDMoi.NgayDi && CTHDCu.NgayVe < CTHDMoi.NgayVe)
                            )
                        {
                            CTHDCu.PhuXe = null;
                            break;
                        }
                    }
                }
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 10
0
        public static Boolean CapNhatTrangThaiChoThanhToan()
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var hd = entity.HopDongs.Where(n => n.MaTrangThai == "1");
                foreach (var item in hd)
                {
                    var cthd = entity.CT_HopDongs.Where(n => n.SoHopDong == item.SoHopDong);
                    foreach (var c in cthd)
                    {
                        if (c.NgayVe < DateTime.Now)
                        {
                            HopDong result = entity.HopDongs.SingleOrDefault(n => n.SoHopDong == c.SoHopDong);
                            result.MaTrangThai = "3";
                            TrangThaiQueries.CapNhatTrangThaiPhuXeRanh(c.SoHopDong);
                            TrangThaiQueries.CapNhatTrangThaiTaiXeRanh(c.SoHopDong);
                            TrangThaiQueries.CapNhatTrangThaiXeRanh(c.SoHopDong);
                        }
                    }
                }
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Thêm khach hang
        /// </summary>
        /// <param KhachHangViewModel="KH"></param>
        /// <returns>Boolean</returns>
        public static Boolean ThemKhachHang(KhachHangViewModel KH)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var KhHang = new KhachHang();
                KhHang.MaKH         = TuTangMaKH();
                KhHang.TenKH        = KH.TenKH;
                KhHang.GioiTinh     = KH.GioiTinh;
                KhHang.Email        = KH.Email;
                KhHang.CMND         = KH.CMND;
                KhHang.DiaChiKH     = KH.DiaChiKH;
                KhHang.SDT          = KH.SDT;
                KhHang.MaLoaiKH     = "LKH1";
                KhHang.TenCongTy    = KH.TenCongTy;
                KhHang.SDTCongTy    = KH.SDTCongTy;
                KhHang.GhiChu       = KH.GhiChu;
                KhHang.DiaChiCongTy = KH.DiaChiCongTy;
                KhHang.NguoiLienHe  = KH.NguoiLienHe;
                KhHang.GiamGia      = 0;
                KhHang.MaSoThue     = KH.MaSoThue;
                KhHang.Dang         = true;
                entity.KhachHangs.Add(KhHang);
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 12
0
 // chỉnh sửa thương hiệu xe
 public static Boolean ChinhSuaTH(ThuongHieuViewModel th)
 {
     var entity = new QuanLyThueXeEntities();
     try
     {
         var Th = entity.ThuongHieuXes.SingleOrDefault(n => n.MaThuongHieu == th.MaThuongHieu);
         Th.TenThuongHieu = th.TenThuongHieu;
         entity.SaveChanges();
         return true;
     }
     catch (Exception ex)
     {
         entity.Dispose();
         return false;
     }
 }
Ejemplo n.º 13
0
 //cap nhat chinh sua 1 action
 public static Boolean ChinhSuaTinhNang(LoaiActionViewModel action)
 {
     var entity = new QuanLyThueXeEntities();
     try
     {
         var result = entity.LoaiActions.SingleOrDefault(n => n.MaAction == action.MaAction);
         result.Mota = action.MoTa;
         entity.SaveChanges();
         return true;
     }
     catch (Exception ex)
     {
         entity.Dispose();
         return false;
     }
 }
Ejemplo n.º 14
0
        public static Boolean ResetPass(String taiKhoan)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                TaiKhoan tk = entity.TaiKhoans.SingleOrDefault(n => n.TaiKhoanNV == taiKhoan);
                tk.MatKhau = "123456";
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 15
0
        //cập nhật loại khách hàng
        public static Boolean ChinhSuaLoaiKH(LoaiKhachHangViewModel loaikh)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var loaiKH = entity.LoaiKhachHangs.SingleOrDefault(n => n.MaLoaiKH == loaikh.MaLoaiKH);
                loaiKH.TenLoaiKH = loaikh.TenLoaiKH;
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Xóa lộ trình
        /// </summary>
        /// <param name="MaLoTrinh"></param>
        /// <returns></returns>
        public static Boolean XoaLT(String MaLT)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var LT = entity.LoTrinhs.SingleOrDefault(n => n.MaLoTrinh == MaLT);
                LT.Dang = false;
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// cập nhật lộ trình
        /// </summary>
        /// <param name="lt"></param>
        /// <returns></returns>
        public static Boolean ChinhSua_LT(LoTrinhViewModel lt)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var LT = entity.LoTrinhs.SingleOrDefault(n => n.MaLoTrinh == lt.MaLoTrinh);
                LT.TenLoTrinh = lt.TenLoTrinh;
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 18
0
        public static Boolean ChinhSuaQuyen(QuyenViewModel quyen)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var result = entity.Quyens.SingleOrDefault(n => n.MaQuyen == quyen.MaQuyen);
                result.TenQuyen = quyen.TenQuyen;
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 19
0
        public static Boolean CapNhatMaCTy(int SoCTHopDong)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                CT_HopDong result = entity.CT_HopDongs.SingleOrDefault(n => n.SoCTHopDong == SoCTHopDong);
                result.MaCongTy = null;
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 20
0
        public static Boolean DoiMatKhau(TaiKhoanViewModel taiKhoan)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var result = entity.TaiKhoans.SingleOrDefault(n => n.TaiKhoanNV == taiKhoan.TaiKhoanNV);
                result.MatKhau = taiKhoan.MatKhau;
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Xóa công ty
        /// </summary>
        /// <param name="MaCongTy"></param>
        /// <returns></returns>
        public static Boolean XoaCty(String MaCongTy)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var CT = entity.CongTies.SingleOrDefault(n => n.MaCongTy == MaCongTy);
                CT.Dang = false;
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 22
0
        /// Xóa xe
        /// </summary>
        /// <param name="MaXe"></param>
        /// <returns></returns>
        public static Boolean XoaXe(String MaXe)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var Xe = entity.Xes.SingleOrDefault(n => n.MaXe == MaXe);
                Xe.Dang = false;
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 23
0
        public static Boolean CapNhatTrangThaiXeDangCho(String MaXe)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var result = entity.Xes.SingleOrDefault(n => n.MaXe == MaXe);
                result.Status = "1";
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Cap Nhat trang thai hoành thành của hợp đồng
        /// </summary>
        /// <param name="SoHopDong"></param>
        /// <returns></returns>
        public static Boolean CapNhatTrangThaiHoanThanh(String SoHopDong)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var result = entity.HopDongs.SingleOrDefault(n => n.SoHopDong == SoHopDong);
                result.MaTrangThai = "2";
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 25
0
        /// Xóa khách hàng
        /// </summary>
        /// <param name="MaKH"></param>
        /// <returns></returns>
        #region xóa khách hàng
        public static Boolean XoaKH(String MaKH)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var KH = entity.KhachHangs.SingleOrDefault(n => n.MaKH == MaKH);
                KH.Dang = false;
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Xóa nhân viên
        /// </summary>
        /// <param name="MaNV"></param>
        /// <returns></returns>
        public static Boolean XoaNV(String MaNV)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var NV = entity.NhanViens.SingleOrDefault(n => n.MaNV == MaNV);
                NV.Dang = false;
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 27
0
        public static Boolean CapNhatOffline(String TaiKhoanNV)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                TaiKhoan tk = entity.TaiKhoans.SingleOrDefault(n => n.TaiKhoanNV == TaiKhoanNV);
                tk.Online = false;
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 28
0
        public static Boolean CapNhatNhanVienBoChon(String MaNV)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var result = entity.NhanViens.SingleOrDefault(n => n.MaNV == MaNV);
                result.Status = "0";
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 29
0
        //cap nhat controller
        public static Boolean ChinhSuaNghiepVu(LoaiControllerViewModel controller)
        {
            var entity = new QuanLyThueXeEntities();

            try
            {
                var loaiController = entity.LoaiControllers.SingleOrDefault(n => n.MaController == controller.MaController);
                loaiController.TenController = controller.TenController;
                loaiController.Icon          = controller.Icon;
                entity.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                entity.Dispose();
                return(false);
            }
        }
Ejemplo n.º 30
0
 //thêm mới thương hiệu
 public static Boolean ThemTH(ThuongHieuViewModel th)
 {
     var entity = new QuanLyThueXeEntities();
     try
     {
         var TH = new ThuongHieuXe();
         TH.MaThuongHieu = TuTangMaTHX();
         TH.TenThuongHieu = th.TenThuongHieu;
         entity.ThuongHieuXes.Add(TH);
         entity.SaveChanges();
         return true;
     }
     catch (Exception ex)
     {
         entity.Dispose();
         return false;
     }
 }