//danh sách công ty public static List <CongTiesViewModel> LayDanhSachCongTy() { var entity = new QuanLyThueXeEntities(); try { var result = ( from c in entity.CongTies where c.Dang == true select new CongTiesViewModel() { MaCongTy = c.MaCongTy, TenCongTy = c.TenCongTy, SDT = c.SDT, DiaChi = c.DiaChi, Email = c.Email, Fax = c.Fax, GhiChu = c.GhiChu, NguoiLienHe = c.NguoiLienHe, MaSoThue = c.MaSoThue, VAT = c.VAT, STT = c.STT, }).OrderBy(n => n.STT).ToList(); return(result); } catch (Exception ex) { entity.Dispose(); return(null); } }
/// <summary> /// Ma tu dong tang cua khach hang /// </summary> /// <returns>MaKH</returns> public static String TuTangMaKH() { var entity = new QuanLyThueXeEntities(); try { String MaKH = ""; var MaKh = entity.KhachHangs.OrderByDescending(n => n.STT).FirstOrDefault(); if (MaKh == null) { MaKH = "KH1"; } else { MaKh.MaKH = MaKh.MaKH.Substring(2, MaKh.MaKH.Length - 2); int iSo = int.Parse(MaKh.MaKH); iSo++; string sSo = iSo.ToString(); MaKH = "KH" + sSo; } return(MaKH); } catch (Exception ex) { entity.Dispose(); return(null); } }
//tự tăng mã thương hiệu xe public static String TuTangMaTHX() { var entity = new QuanLyThueXeEntities(); try { String MaThuongHieu = ""; var MaThx = entity.ThuongHieuXes.OrderByDescending(n => n.STT).FirstOrDefault(); if (MaThx == null) { MaThuongHieu = "THX1"; } else { MaThx.MaThuongHieu = MaThx.MaThuongHieu.Substring(3, MaThx.MaThuongHieu.Length - 3); int iSo = int.Parse(MaThx.MaThuongHieu); iSo++; MaThuongHieu = "THX" + iSo; } return MaThuongHieu; } catch (Exception ex) { entity.Dispose(); return null; } }
/// <summary> /// thông tin chi tiết lộ trình /// </summary> /// <param name="MaLT"></param> /// <returns></returns> public static LoTrinhViewModel ChiTiet_LoTrinh(String MaLT) { var entity = new QuanLyThueXeEntities(); try { var result = ( from lt in entity.LoTrinhs where lt.MaLoTrinh == MaLT select new LoTrinhViewModel() { MaLoTrinh = lt.MaLoTrinh, TenLoTrinh = lt.TenLoTrinh, MaKH = lt.MaKH, KhachHangs = (from kh in entity.KhachHangs where lt.MaKH == kh.MaKH select new KhachHangViewModel() { MaKH = kh.MaKH, TenKH = kh.TenKH }).FirstOrDefault() }).SingleOrDefault(); return(result); } catch (Exception ex) { entity.Dispose(); return(null); } }
/// <summary> /// Lấy danh sách lộ trình đi /// </summary> /// <returns></returns> public static List <LoTrinhViewModel> LayDanhSachLoTrinh() { var entity = new QuanLyThueXeEntities(); try { var result = ( from lt in entity.LoTrinhs where lt.Dang == true select new LoTrinhViewModel() { MaLoTrinh = lt.MaLoTrinh, TenLoTrinh = lt.TenLoTrinh, MaKH = lt.MaKH, STT = lt.STT, KhachHangs = (from kh in entity.KhachHangs where lt.MaKH == kh.MaKH select new KhachHangViewModel() { MaKH = kh.MaKH, TenKH = kh.TenKH }).FirstOrDefault() }).OrderByDescending(n => n.MaLoTrinh).ToList(); return(result); } catch (Exception ex) { entity.Dispose(); return(null); } }
public static String TuTangMaPhieuThu() { var entity = new QuanLyThueXeEntities(); try { String SoPhieuThu = ""; var soPT = entity.PhieuThus.OrderByDescending(n => n.STT).FirstOrDefault(); if (soPT == null) { SoPhieuThu = "PT1"; } else { soPT.SoPhieuThu = soPT.SoPhieuThu.Substring(2, soPT.SoPhieuThu.Length - 2); int iSo = int.Parse(soPT.SoPhieuThu); iSo++; string sSo = iSo.ToString(); SoPhieuThu = "PT" + sSo; } return(SoPhieuThu); } catch (Exception ex) { entity.Dispose(); return(null); } }
//tự tăng mã loại bằng public static String TuTangMaBang() { var entity = new QuanLyThueXeEntities(); try { String MaBang = ""; var MaB = entity.LoaiBangs.OrderByDescending(n => n.MaBang).FirstOrDefault(); if (MaB == null) { MaBang = "LB1"; } else { MaB.MaBang = MaB.MaBang.Substring(2, MaB.MaBang.Length - 2); int iSo = int.Parse(MaB.MaBang); iSo++; string sSo = iSo.ToString(); MaBang = "LB" + sSo; } return(MaBang); } catch (Exception ex) { entity.Dispose(); return(null); } }
/// <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); } }
public static List <BangGiaViewModel> LayDanhSachLoaiXeMaKHVaMaLT(String MaKH, String MaLoTrinh) { var entity = new QuanLyThueXeEntities(); try { var result = ( from bg in entity.BangGias where MaKH == bg.MaKH && MaLoTrinh == bg.MaLoTrinh && bg.Dang == true select new BangGiaViewModel() { LoaiXes = ( from lx in entity.LoaiXes where lx.MaLoaiXe == bg.MaLoaiXe select new LoaiXeViewModel() { MaLoaiXe = lx.MaLoaiXe, TenLoaiXe = lx.TenLoaiXe, STT = lx.STT, Dang = lx.Dang } ).FirstOrDefault() }).OrderBy(n => n.LoaiXes.MaLoaiXe).ToList(); return(result); } catch (Exception ex) { entity.Dispose(); return(null); } }
///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); } }
/// <summary> /// Tự động tăng mã bảng giá /// </summary> /// <returns></returns> public static String TuTangMaBG() { var entity = new QuanLyThueXeEntities(); try { String MaBangGia = ""; var MaBg = entity.BangGias.OrderByDescending(n => n.STT).FirstOrDefault(); if (MaBg == null) { MaBangGia = "BG1"; } else { MaBg.MaBangGia = MaBg.MaBangGia.Substring(2, MaBg.MaBangGia.Length - 2); int iSo = int.Parse(MaBg.MaBangGia); iSo++; string sSo = iSo.ToString(); MaBangGia = "BG" + sSo; } return(MaBangGia); } catch (Exception ex) { entity.Dispose(); return(null); } }
/// <summary> /// Tự động tăng mã xe /// </summary> /// <returns>String </returns> /// Begin public static String TangMaXe() { var entity = new QuanLyThueXeEntities(); try { String MaXe = ""; var Maxe = entity.Xes.OrderByDescending(n => n.STT).FirstOrDefault(); if (Maxe == null) { MaXe = "Xe1"; } else { Maxe.MaXe = Maxe.MaXe.Substring(2, Maxe.MaXe.Length - 2); int iSo = int.Parse(Maxe.MaXe); iSo++; string sSo = iSo.ToString(); MaXe = "Xe" + sSo; } return(MaXe); } catch (Exception ex) { entity.Dispose(); return(null); } }
public static List <ChiTietChiPhiPhatSinhViewModel> LayDanhSachCTCPPhatSinhTheoSoHopDong(string SoHopDong) { var entity = new QuanLyThueXeEntities(); try { List <ChiTietChiPhiPhatSinhViewModel> chiTiet = DanhSachCPPSTheoSoHopDong(SoHopDong); var result = chiTiet .GroupBy(n => n.MaChiPhi) .Select(sl => new ChiTietChiPhiPhatSinhViewModel { SoHopDong = sl.First().SoHopDong, DonGia = sl.First().DonGia, MaChiPhi = sl.First().MaChiPhi, SoLuong = sl.Sum(n => n.SoLuong), // ChiPhiPhatSinhs = ( // from cp in entity.ChiPhiPhatSinhs // where cp.MaChiPhi == sl.First().MaChiPhi // select new ChiPhiPhatSinhViewModel() // { // MaChiPhi = cp.MaChiPhi, // PhiPhatSinh = cp.PhiPhatSinh, // TenChiPhi = cp.TenChiPhi, // MoTa = cp.Mota, // }).FirstOrDefault(), }).ToList(); return(result); } catch (Exception ex) { entity.Dispose(); return(null); } }
//chi tiết công ty public static CongTiesViewModel LayThongTinChiTietCty(String MaCT) { var entity = new QuanLyThueXeEntities(); try { var result = (from ct in entity.CongTies where ct.MaCongTy == MaCT select new CongTiesViewModel() { MaCongTy = ct.MaCongTy, TenCongTy = ct.TenCongTy, DiaChi = ct.DiaChi, SDT = ct.SDT, Fax = ct.Fax, Email = ct.Email, NguoiLienHe = ct.NguoiLienHe, GhiChu = ct.GhiChu, Dang = ct.Dang, VAT = ct.VAT, MaSoThue = ct.MaSoThue, STT = ct.STT, }).SingleOrDefault(); return(result); } catch (Exception ex) { entity.Dispose(); return(null); } }
/// <summary> /// Lấy action theo ma quyền /// </summary> public static List<LoaiActionViewModel> LayDanhSachActionTheoQuyen(string MaQuyen) { var entity = new QuanLyThueXeEntities(); try { var result = ( from action in entity.LoaiActions join pq in entity.PhanQuyens on action.MaAction equals pq.MaAction where pq.MaQuyen == MaQuyen select new LoaiActionViewModel() { MaAction = action.MaAction, MaController = action.MaController, MoTa = action.Mota, TenAction = action.TenAction, UrlAction = action.UrlAction }).ToList(); return result; } catch (Exception ex) { return null; entity.Dispose(); } }
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); } }
//thông tin chi tiết phiếu thu public static PhieuThuViewModel ChiTiet_PT(string SoPT) { var entity = new QuanLyThueXeEntities(); try { var result = ( from pt in entity.PhieuThus where pt.SoPhieuThu == SoPT select new PhieuThuViewModel() { SoPhieuThu = pt.SoPhieuThu, MaNV = pt.MaNV, LyDo = pt.LyDo, NgayThu = pt.NgayThu, SoTienThu = pt.SoTienThu, NguoiNop = pt.NguoiNop, DiaChi = pt.DiaChi, NhanViens = (from nv in entity.NhanViens where pt.MaNV == nv.MaNV select new NhanVienViewModel() { MaNV = nv.MaNV, HoTen = nv.HoTen }).FirstOrDefault() }).SingleOrDefault(); return(result); } catch (Exception ex) { entity.Dispose(); return(null); } }
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); } }
/// <summary> /// Danh sach phieu thu /// </summary> public static List <PhieuThuViewModel> DanhSachPhieuThu() { var entity = new QuanLyThueXeEntities(); try { var result = ( from pt in entity.PhieuThus select new PhieuThuViewModel() { SoPhieuThu = pt.SoPhieuThu, LyDo = pt.LyDo, NgayThu = pt.NgayThu, SoTienThu = pt.SoTienThu, MaNV = pt.NhanVien.HoTen, NguoiNop = pt.NguoiNop, DiaChi = pt.DiaChi, NhanViens = (from nv in entity.NhanViens where pt.MaNV == nv.MaNV select new NhanVienViewModel() { MaNV = nv.MaNV, HoTen = nv.HoTen }).FirstOrDefault() }).OrderBy(n => n.SoPhieuThu).ToList(); return(result); } catch (Exception ex) { entity.Dispose(); return(null); } }
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); } }
/// <summary> /// Tự động tăng mã hợp đồng /// </summary> /// <returns></returns> public static String TuDongTangSoHD() { var entity = new QuanLyThueXeEntities(); try { String SoHopDong = ""; var soHD = entity.HopDongs.OrderByDescending(n => n.STT).FirstOrDefault(); if (soHD == null || !(soHD.SoHopDong.Contains(DateTime.Now.ToString("yyyy")))) { SoHopDong = "1/" + DateTime.Now.ToString("yyyy") + "/HD-DETRA"; } else { soHD.SoHopDong = soHD.SoHopDong.Substring(0, soHD.SoHopDong.Length - 14); int iSo = int.Parse(soHD.SoHopDong); iSo++; string sSo = iSo.ToString(); SoHopDong = sSo + "/" + DateTime.Now.ToString("yyyy") + "/HD-DETRA"; } return(SoHopDong); } catch (Exception ex) { entity.Dispose(); return(null); } }
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); } }
/// <summary> /// tự tăng mã lộ trình /// </summary> /// <returns></returns> public static String TuTangMaLT() { var entity = new QuanLyThueXeEntities(); try { String MaLoTrinh = ""; var MaLt = entity.LoTrinhs.OrderByDescending(n => n.STT).FirstOrDefault(); if (MaLt == null) { MaLoTrinh = "LT1"; } else { MaLt.MaLoTrinh = MaLt.MaLoTrinh.Substring(2, MaLt.MaLoTrinh.Length - 2); int iSo = int.Parse(MaLt.MaLoTrinh); iSo++; string sSo = iSo.ToString(); MaLoTrinh = "LT" + sSo; } return(MaLoTrinh); } catch (Exception ex) { entity.Dispose(); return(null); } }
/// <summary> /// Đăng nhập /// </summary> /// <param name="TaiKhoanNV"></param> /// <param name="MatKhau"></param> /// <returns></returns> public static TaiKhoanViewModel Login(String TaiKhoanNV, String MatKhau) { var entity = new QuanLyThueXeEntities(); try { var result = ( from t in entity.TaiKhoans where t.TaiKhoanNV == TaiKhoanNV && t.MatKhau == MatKhau select new TaiKhoanViewModel() { TaiKhoanNV = t.TaiKhoanNV, MatKhau = t.MatKhau, MaNV = t.MaNV, MaQuyen = t.MaQuyen, Online = t.Online, }).FirstOrDefault(); return(result); } catch (Exception ex) { entity.Dispose(); return(null); } }
/// <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); } }
public static TaiKhoanViewModel LayThongTinTaiKhoan(String taiKhoan) { var entity = new QuanLyThueXeEntities(); try { var result = ( from tk in entity.TaiKhoans where tk.TaiKhoanNV == taiKhoan select new TaiKhoanViewModel() { MaNV = tk.MaNV, MaQuyen = tk.MaQuyen, MatKhau = tk.MatKhau, STT = tk.STT, TaiKhoanNV = tk.TaiKhoanNV, NhanViens = ( from nv in entity.NhanViens where nv.MaNV == tk.MaNV select new NhanVienViewModel() { HoTen = nv.HoTen }).FirstOrDefault(), }).SingleOrDefault(); return(result); } catch (Exception ex) { entity.Dispose(); return(null); } }
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); } }
public static List<LoaiActionViewModel> LayDanhSachTinhNang() { // Danh sach action var entity = new QuanLyThueXeEntities(); try { var result = ( from a in entity.LoaiActions where a.TenAction.Contains("Menu") select new LoaiActionViewModel() { MaAction = a.MaAction, TenAction = a.TenAction, MoTa = a.Mota, MaController = a.MaController, UrlAction = a.UrlAction }).ToList(); return result; } catch (Exception ex) { entity.Dispose(); return null; } }
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); } }
//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); } }