Beispiel #1
0
        public static CuaHangUpdateModel LayCuaHangUpdateTheoIDCuaHang(int maCuaHang)
        {
            CuaHangUpdateModel result = null;

            using (var context = new TIT_Entities())
            {
                result = (from ch in context.CuaHangs
                          where ch.MaCuaHang == maCuaHang
                          select new CuaHangUpdateModel()
                {
                    MaCuaHang = ch.MaCuaHang,
                    TenCuaHang = ch.TenCuaHang,
                    DiaChi = ch.DiaChi,
                    DienThoai = "Không có",
                    NgayTao = ch.NgayTao,
                    NguoiTao = ch.NguoiTao,
                    QuyTienMat = ch.QuyTienMat.HasValue ? ch.QuyTienMat.Value : 0,
                    VonDauTu = ch.VonDauTu.HasValue ? ch.VonDauTu.Value : 0,
                    Latitude = ch.Latitude.HasValue ? ch.Latitude.Value : 0,
                    Longitude = ch.Longitude.HasValue ? ch.Longitude.Value : 0,
                    TinhTrang = ch.TinhTrang == 1 ? true : false,
                    TKQuanLy = ch.QuanLyCuaHang
                }).FirstOrDefault();
            }

            return(result);
        }
Beispiel #2
0
        public static BaoCaoCuaHangTempViewModel LayBaoCaoCuaHang(int cuaHang_Id)
        {
            BaoCaoCuaHangTempViewModel result;

            using (var context = new TIT_Entities())
            {
                var date = DateTime.Now.Date;
                result = (from nv in context.BaoCaoHangNgays
                          where nv.Id_CuaHang == cuaHang_Id && nv.Ngay == date
                          select new BaoCaoCuaHangTempViewModel()
                {
                    TongChi = nv.TongChi,
                    TongChiBatHo = nv.TongChiHopDongBatHo,
                    TongChiCamDo = nv.TongChiHopDongCamDo,
                    TongChiChoVay = nv.TongChiHopDongChoVay,
                    TongChiDNGD = nv.TongChiHopDongChoVayDNGD,
                    TongChiKhac = nv.TongChiKhac,
                    TongSoTienConLai = nv.SoTienVonConLai,
                    TongSoTienDauNgay = nv.SoTienVonDauNgay,
                    TongThu = nv.TongThu,
                    TongThuBatHo = nv.TongThuHopDongBatHo,
                    TongThuCamDo = nv.TongThuHopDongCamDo,
                    TongThuChoVay = nv.TongThuHopDongChoVay,
                    TongThuDNGD = nv.TongThuHopDongChoVayDNGD,
                    TongThuKhac = nv.TongThuKhac
                }).FirstOrDefault();
                if (result == null)
                {
                    return(new BaoCaoCuaHangTempViewModel());
                }
            }
            return(result);
        }
Beispiel #3
0
        public static int Insert(CuaHangAddNewModel model)
        {
            var dbModel = new CuaHang
            {
                TenCuaHang    = model.TenCuaHang,
                DiaChi        = model.DiaChi,
                Latitude      = model.Latitude,
                Longitude     = model.Longitude,
                NgayTao       = model.NgayTao,
                NguoiTao      = model.NguoiTao,
                QuyTienMat    = model.QuyTienMat,
                VonDauTu      = model.VonDauTu,
                TinhTrang     = model.TinhTrang ? 1 : 0,
                QuanLyCuaHang = model.TKQuanLy
            };

            using (var context = new TIT_Entities())
            {
                context.CuaHangs.Add(dbModel);

                try
                {
                    return(context.SaveChanges());
                }
                catch (Exception ex)
                {
                    ex.ToString();
                    //_logger.Error(ex.ToString());
                    return(-1);
                }
            }
        }
 public static List <AspNetRole> LayDanhSachPhanQuyen()
 {
     using (var context = new TIT_Entities())
     {
         return(context.AspNetRoles.ToList());
     }
 }
        public static IEnumerable <BatHo_ThongTinChiTietDongTienLaiModel> LayDanhSachDongTienLai(string maHopDong)
        {
            IEnumerable <BatHo_ThongTinChiTietDongTienLaiModel> result;

            using (var context = new TIT_Entities())
            {
                result = (from hd in context.ThongTinDongLais
                          join nv in context.AspNetUsers on hd.NhanVienThuTien equals nv.Id into gj
                          from subpet in gj.DefaultIfEmpty()
                          where hd.HopDong_Id == maHopDong
                          select new BatHo_ThongTinChiTietDongTienLaiModel()
                {
                    NgayHo = hd.NgayBatDau,
                    NgayKetThuc = hd.NgayKetThuc,
                    DaDong = hd.DaDong,
                    TienHo = hd.TienLai,
                    MaNhanVien = hd.NhanVienThuTien,
                    TenNhanVien = subpet.UserName ?? String.Empty,
                    ID = hd.Id,
                    NgayGiaoDich = hd.NgayDongLai.HasValue? hd.NgayDongLai.Value: hd.NgayBatDau
                }).ToArray();
            }

            return(result);
        }
Beispiel #6
0
 public static int CapNhatThongTinGhiChu(string id_HopDong, string ghiChu)
 {
     using (var context = new TIT_Entities())
     {
         var hd_update = context.HD_VayDuNoGiamDan.SingleOrDefault(x => x.HD_Id == id_HopDong);
         hd_update.GhiChu = ghiChu;
         try
         {
             if (context.SaveChanges() > 0)
             {
                 return(1);
             }
             else
             {
                 return(0);
             }
         }
         catch (Exception ex)
         {
             ex.ToString();
             //_logger.Error(ex.ToString());
             return(0);
         }
     }
 }
Beispiel #7
0
 public static int HenGio(string id_HopDong, DateTime ngayHen, string ghiChu)
 {
     using (var context = new TIT_Entities())
     {
         var HD = context.HD_VayDuNoGiamDan.Where(x => x.HD_Id == id_HopDong).FirstOrDefault();
         if (HD != null)
         {
             HD.TrangThaiHenGio = 1;
             HD.NgayHenGio      = ngayHen;
             HD.GhiChuHenGio    = ghiChu;
             try
             {
                 if (context.SaveChanges() > 0)
                 {
                     return(1);
                 }
                 else
                 {
                     return(0);
                 }
             }
             catch (Exception ex)
             {
                 ex.ToString();
                 //_logger.Error(ex.ToString());
             }
         }
     }
     return(0);
 }
Beispiel #8
0
        public static IEnumerable <HopDongVayDNGDGridViewModel> LayHopDongTheoIdQuanLy(string IdQuanLy)
        {
            IEnumerable <HopDongVayDNGDGridViewModel> result;

            using (var context = new TIT_Entities())
            {
                result = (from hd in context.HD_VayDuNoGiamDan
                          join kh in context.KhachHangs on hd.KhachHang_CMND equals kh.CMND
                          join ch in context.CuaHangs on hd.CuaHang_Id equals ch.MaCuaHang
                          where ch.QuanLyCuaHang == IdQuanLy && hd.TinhTrang != "Hủy hợp đồng"
                          select new HopDongVayDNGDGridViewModel
                {
                    KhachHang = new KhachHangModel()
                    {
                        TenKhachHang = kh.TenKhachHang,
                        SoDienThoai = kh.SoDienThoai1
                    },
                    HoaHong = hd.HoaHong,
                    LaiSuat = hd.LaiSuat,
                    NgayDongTienCuoiCung = hd.NgayCuoiCungDongTien.HasValue ? hd.NgayCuoiCungDongTien.Value : hd.NgayVay,
                    NgayVay = hd.NgayVay,
                    SoTien = hd.SoTienVay,
                    ThoiHanVay = hd.ThoiHanVay,
                    Id_HopDong = hd.HD_Id,
                    TinhTrang = hd.TinhTrang,
                    NgayHen = hd.NgayHenGio.HasValue ? hd.NgayHenGio.Value : DateTime.MinValue,
                    NoiDungHen = hd.GhiChuHenGio,
                    IsHenGio = hd.TrangThaiHenGio == 1 ? true : false,
                    DaDong = hd.TienLaiDaDong,
                    NgayBatDauThanhToan = hd.NgayBatDauDongLai,
                    CuaHang = ch.TenCuaHang
                }).ToArray();
            }
            return(result);
        }
Beispiel #9
0
        public override IEnumerable <CamDoGridDataModel> GetGridViewCamDoModel()
        {
            IEnumerable <CamDoGridDataModel> result;

            using (var context = new TIT_Entities())
            {
                result = (from hd in context.HD_CamDo
                          join kh in context.KhachHangs on hd.KhachHang_CMND equals kh.CMND
                          join user in context.AspNetUsers on hd.CuaHang_Id equals user.CuaHang_Id
                          where user.Id == _userId
                          select new CamDoGridDataModel
                {
                    HopDong_Id = hd.HD_CamDo_Id,
                    TenKhachHang = kh.TenKhachHang,
                    SoDienThoai = kh.SoDienThoai1,
                    NgayPhaiDongLai = hd.NgayCuoiCungDongTienLai.HasValue ? hd.NgayCuoiCungDongTienLai.Value : hd.NgayCam,
                    TinhTrang = hd.TinhTrang.ToString(),
                    NoCu = "",
                    SoTien = hd.SoTienCam,
                    TaiSan = hd.TaiSan,
                    NgayTaoHopDong = hd.NgayCam
                }).ToArray();
            }
            return(result);
        }
Beispiel #10
0
        public static IEnumerable <ThuChiGridViewModel> LayDanhSachThu(IEnumerable <CuaHangDataModel> models)
        {
            IEnumerable <ThuChiGridViewModel> result;
            var DanhSachIDCuaHang = models.Select(x => x.MaCuaHang);

            using (var context = new TIT_Entities())
            {
                DateTime today = DateTime.Now.Date;
                DateTime tmr   = DateTime.Now.Date.AddDays(1);
                result = (from tc in context.ThongTinThuChis
                          join ch in context.CuaHangs on tc.Id_CuaHang equals ch.MaCuaHang
                          join nv in context.AspNetUsers on tc.Id_NhanVien equals nv.Id
                          where DanhSachIDCuaHang.Contains(tc.Id_CuaHang) && tc.NgayTao >= today && tc.NgayTao < tmr && tc.PhieuThu == PHIEU_THU
                          select new ThuChiGridViewModel()
                {
                    KhachHang = tc.KhachHang,
                    GhiChu = tc.GhiChu,
                    LoaiPhieu = tc.LoaiPhieu,
                    SoTien = tc.SoTien,
                    Ngay = tc.NgayTao,
                    CuaHang = new CuaHangDataModel()
                    {
                        MaCuaHang = ch.MaCuaHang,
                        TenCuaHang = ch.TenCuaHang
                    },
                    NhanVien = nv.UserName
                }).ToArray();
            }
            return(result);
        }
        public static IEnumerable <HopDongBatHoGridViewModel> LayHopDongTheoIdQuanLy(string IdQuanLy)
        {
            IEnumerable <HopDongBatHoGridViewModel> result;

            using (var context = new TIT_Entities())
            {
                result = (from hd in context.HD_BatHo
                          join kh in context.KhachHangs on hd.KhachHang_CMND equals kh.CMND
                          join ch in context.CuaHangs on hd.CuaHang_Id equals ch.MaCuaHang
                          where ch.QuanLyCuaHang == IdQuanLy
                          select new HopDongBatHoGridViewModel
                {
                    KhachHang = new KhachHangModel()
                    {
                        TenKhachHang = kh.TenKhachHang,
                        SoDienThoai = kh.SoDienThoai1
                    },
                    Id_HopDong = hd.HD_BatHo_Id,
                    NgayBoc = hd.NgayBoc,
                    NgayDongTienCuoiCung = hd.NgayCuoiCungDongTien.HasValue ? hd.NgayCuoiCungDongTien.Value : hd.NgayBoc,
                    NoCu = 0,
                    TienGiaoKhach = hd.TienDuaChoKhach,
                    BatHo = hd.BatHo,
                    BocTrongVong = hd.BocTrongVong,
                    SoNgayDongTien = hd.SoNgayDongTien,
                    TinhTrang = hd.TinhTrang
                }).ToArray();
            }
            return(result);
        }
Beispiel #12
0
        public static ChoVayDNGD_CapNhatThongTinDongTienViewModel LayThongTinDongTienHopDong(string maHopDong)
        {
            ChoVayDNGD_CapNhatThongTinDongTienViewModel result = new ChoVayDNGD_CapNhatThongTinDongTienViewModel();

            using (var context = new TIT_Entities())
            {
                result.HopDongChoVay = (from hd in context.HD_VayDuNoGiamDan
                                        join kh in context.KhachHangs on hd.KhachHang_CMND equals kh.CMND
                                        where hd.HD_Id == maHopDong
                                        select new HopDongChoVayDNGDDataModel()
                {
                    Id_HopDong = hd.HD_Id,
                    GhiChu = hd.GhiChu,
                    KhachHang = new KhachHangModel()
                    {
                        TenKhachHang = kh.TenKhachHang,
                        CMND = kh.CMND,
                        DiaChi = kh.DiaChi != null ? kh.DiaChi : "",
                        HinhDaiDien = kh.HinhDaiDien != null ? kh.HinhDaiDien : "",
                        SoDienThoai = kh.SoDienThoai1
                    },
                    Lai = hd.LaiSuat,
                    NgayVay = hd.NgayVay,
                    SoTienVay = hd.SoTienVay,
                    TinhTrang = hd.TinhTrang,
                    CuaHang_Id = hd.CuaHang_Id,
                    HoaHong = hd.HoaHong,
                    NhanVien_Id = hd.NhanVien_Id,
                    ThoiHanVay = hd.ThoiHanVay,
                    NgayBatDauThanhToan = hd.NgayBatDauDongLai,
                    NgayDongLaiCuoiCung = hd.NgayCuoiCungDongTien.HasValue ? hd.NgayCuoiCungDongTien.Value : hd.NgayVay,
                    ThongTinHenGio = new ChoVayDNGD_HenGio()
                    {
                        NgayHen = hd.NgayHenGio.HasValue? hd.NgayHenGio.Value: DateTime.Now,
                        GhiChu = hd.GhiChuHenGio,
                        IsNhacHen = hd.TrangThaiHenGio == 1? true: false
                    },
                    UrlHinh1 = hd.UrlHinh1,
                    UrlHinh2 = hd.UrlHinh2,
                    UrlHinh3 = hd.UrlHinh3,
                    TongSoTienLaiDaDong = hd.TienLaiDaDong
                }).FirstOrDefault();
                result.ThongTinDongLai = new ChoVayDNGD_ThongTinDongLaiModel();
                result.ThongTinDongLai.DanhSachChiTietDongTienLai = (from dl in context.ThongTinDongLais
                                                                     where dl.HopDong_Id == maHopDong
                                                                     select new ChoVayDNGD_ThongTinChiTietDongTienLaiModel()
                {
                    ID = dl.Id,
                    NgayBatDau = dl.NgayBatDau,
                    NgayKetThuc = dl.NgayKetThuc,
                    DaDong = dl.DaDong,
                    TienKhac = dl.TienKhac.HasValue ? dl.TienKhac.Value : 0,
                    TienLai = dl.TienLai,
                    SoNgay = dl.SoNgay,
                    SoTienDaDong = dl.SoTienDaDong
                }).ToList();
            }
            return(result);
        }
Beispiel #13
0
 public static string Insert(HopDongChoVayDNGDDataModel model)
 {
     using (var context = new TIT_Entities())
     {
         var result = context.ThemHopDongDNGD(model.KhachHang.CMND, model.SoTienVay, model.HoaHong, model.Lai, model.ThoiHanVay,
                                              model.NgayVay, model.GhiChu, model.CuaHang_Id, model.NhanVien_Id, DateTime.Now, model.NgayDongLaiCuoiCung, model.TinhTrang,
                                              model.NgayBatDauThanhToan, DateTime.MinValue, "", 0, "", "", "", model.TongSoTienLaiDaDong, model.LaiThangDau, model.LaiGocMotThang);
         return(result.ToString());
     }
 }
Beispiel #14
0
        internal static int LayIdCuaHangTheoIdNhanVien(string idNhanVien)
        {
            int?result;

            using (var context = new TIT_Entities())
            {
                result = (from user in context.AspNetUsers
                          where user.Id == idNhanVien
                          select user.CuaHang_Id).SingleOrDefault();
            }
            return(result.HasValue? result.Value : -1);
        }
        public static string LayIdNguoiQuanLyTheoIdNhanVien(string idNhanVien)
        {
            string result;

            using (var context = new TIT_Entities())
            {
                result = (from user in context.AspNetUsers
                          where user.Id == idNhanVien
                          select user.ManagerId).SingleOrDefault();
            }
            return(result);
        }
Beispiel #16
0
        public static int LayCuaHangIdTheoIdNhanVien(string id_NhanVien)
        {
            int result = -1;

            using (var context = new TIT_Entities())
            {
                result = (from nv in context.AspNetUsers
                          where nv.Id == id_NhanVien
                          select nv.CuaHang_Id).FirstOrDefault().Value;
            }
            return(result);
        }
Beispiel #17
0
        public static IEnumerable <NhanVienModel> LayDanhSachNhanVienTheoIDQuanLy(string idQuanLy)
        {
            IEnumerable <NhanVienModel> result;

            using (var context = new TIT_Entities())
            {
                result = (from nv in context.AspNetUsers
                          where nv.ManagerId == idQuanLy
                          select new NhanVienModel()
                {
                    MaNhanVien = nv.Id,
                    TenNhanVien = nv.FullName
                }).ToArray();
            }
            return(result);
        }
Beispiel #18
0
        public static IEnumerable <NhanVienModel> LayDanhSachNhanVienTheoIdCuaHang(int idCuaHang)
        {
            IEnumerable <NhanVienModel> result;

            using (var context = new TIT_Entities())
            {
                result = (from nv in context.AspNetUsers
                          where nv.CuaHang_Id == idCuaHang
                          select new NhanVienModel()
                {
                    MaNhanVien = nv.Id,
                    TenNhanVien = nv.FullName
                }).ToArray();
            }
            return(result);
        }
        public static BatHo_CapNhatThongTinDongTienViewModel LayThongTinDongTienHopDong(string maHopDong)
        {
            BatHo_CapNhatThongTinDongTienViewModel result = new BatHo_CapNhatThongTinDongTienViewModel();

            using (var context = new TIT_Entities())
            {
                result.HopDongBatHo = (from hd in context.HD_BatHo
                                       join kh in context.KhachHangs on hd.KhachHang_CMND equals kh.CMND
                                       where hd.HD_BatHo_Id == maHopDong
                                       select new HopDongBatHoDataModel()
                {
                    HD_BatHo_Id = hd.HD_BatHo_Id,
                    GhiChu = hd.GhiChu,
                    KhachHang = new KhachHangModel()
                    {
                        TenKhachHang = kh.TenKhachHang,
                        CMND = kh.CMND,
                        DiaChi = kh.DiaChi != null ? kh.DiaChi : "",
                        HinhDaiDien = kh.HinhDaiDien != null ? kh.HinhDaiDien : "",
                        SoDienThoai = kh.SoDienThoai1
                    },
                    BatHo = hd.BatHo,
                    BocTrongVong = hd.BocTrongVong,
                    NgayBoc = hd.NgayBoc,
                    NgayDongTienCuoiCung = hd.NgayCuoiCungDongTien.HasValue? hd.NgayCuoiCungDongTien.Value: hd.NgayBoc,
                    NgayTao = hd.NgayTao,
                    NhanVien_Id = hd.NhanVien_Id,
                    SoNgayDongTien = hd.SoNgayDongTien,
                    ThuHoTruoc = hd.ThuHoTruoc,
                    CuaHang_Id = hd.CuaHang_Id,
                    TienDuaChoKhach = hd.TienDuaChoKhach,
                    TinhTrang = hd.TinhTrang
                }).FirstOrDefault();
                result.ThongTinDongLai = new BatHo_ThongTinDongLaiModel();
                result.ThongTinDongLai.DanhSachChiTietDongTienLai = (from dl in context.ThongTinDongLais
                                                                     where dl.HopDong_Id == maHopDong
                                                                     select new BatHo_ThongTinChiTietDongTienLaiModel()
                {
                    NgayHo = dl.NgayBatDau,
                    TienHo = dl.TienLai,
                    ID = dl.Id,
                    DaDong = dl.DaDong
                }).ToList();
            }
            return(result);
        }
Beispiel #20
0
        public static void CapNhatBaoCao_Thu(TIT_Entities context, int MaCuaHang, decimal SoTien)
        {
            var BaoCaoTongKet = context.BaoCaoTongKets.Where(x => x.Id_CuaHang == MaCuaHang).OrderByDescending(p => p.Ngay).FirstOrDefault();

            if (BaoCaoTongKet != null)
            {
                if (BaoCaoTongKet.Ngay == DateTime.Now.ToString("yyyy-MM-dd"))
                {
                    BaoCaoTongKet.CamDo_Thu += SoTien;
                }
                else
                {
                    var baoCao = new BaoCaoTongKetGiaoDichModel()
                    {
                        SoTienDauNgay = BaoCaoTongKet.SoTienDauNgay,
                        CamDo_Thu     = BaoCaoTongKet.CamDo_Thu,
                        CamDo_Chi     = BaoCaoTongKet.CamDo_Chi,
                        VayLai_Thu    = BaoCaoTongKet.VayLai_Thu,
                        VayLai_Chi    = BaoCaoTongKet.VayLai_Chi,
                        BatHo_Thu     = BaoCaoTongKet.BatHo_Thu,
                        BatHo_Chi     = BaoCaoTongKet.BatHo_Chi,
                        HoatDong_Thu  = BaoCaoTongKet.HoatDong_Thu,
                        HoatDong_Chi  = BaoCaoTongKet.HoatDong_Chi,
                        Ngay_ToString = BaoCaoTongKet.Ngay
                    };
                    var baoCaoHomNay = new BaoCaoTongKet()
                    {
                        Ngay          = DateTime.Now.ToString("yyyy-MM-dd"),
                        SoTienDauNgay = baoCao.SoTienCuoiNgay,
                        CamDo_Thu     = SoTien,
                        Id_CuaHang    = MaCuaHang,
                    };
                    context.BaoCaoTongKets.Add(baoCaoHomNay);
                }
            }
            else
            {
                var baoCaoHomNay = new BaoCaoTongKet()
                {
                    Ngay       = DateTime.Now.ToString("yyyy-MM-dd"),
                    CamDo_Thu  = SoTien,
                    Id_CuaHang = MaCuaHang,
                };
                context.BaoCaoTongKets.Add(baoCaoHomNay);
            }
        }
Beispiel #21
0
        public static IEnumerable <CuaHangDataModel> GetListViewCuaHangTheoAdmin()
        {
            IEnumerable <CuaHangDataModel> result;

            using (var context = new TIT_Entities())
            {
                result = (from ch in context.CuaHangs
                          select new CuaHangDataModel()
                {
                    MaCuaHang = ch.MaCuaHang,
                    TenCuaHang = ch.TenCuaHang,
                    QuyTienMat = ch.QuyTienMat.HasValue? ch.QuyTienMat.Value : 0,
                    VonDauTu = ch.VonDauTu.HasValue? ch.VonDauTu.Value: 0,
                    DiaChi = ch.DiaChi
                }).ToArray();
            }
            return(result);
        }
        public static IEnumerable <AccountViewModel> GetList()
        {
            IEnumerable <AccountViewModel> result;

            using (var context = new TIT_Entities())
            {
                result = (from user in context.AspNetUsers
                          join ur in context.AspNetUserRoles on user.Id equals ur.UserId
                          select new AccountViewModel()
                {
                    Id = user.Id,
                    UserName = user.UserName,
                    FullName = user.FullName,
                    Email = user.Email,
                    UserRole = ur.AspNetRole.Name
                }).ToArray();
            }
            return(result);
        }
        public static IEnumerable <UserWithRole> LayDanhSachBranchManager()
        {
            List <UserWithRole> result;

            using (var context = new TIT_Entities())
            {
                result = (from user in context.AspNetUsers
                          join ur in context.AspNetUserRoles on user.Id equals ur.UserId
                          join role in context.AspNetRoles on ur.RoleId equals role.Id
                          where role.Name == "BranchManager"
                          select new UserWithRole()
                {
                    UserId = user.Id,
                    RoleName = role.Name,
                    UserName = user.UserName
                }).ToList();
            }
            return(result);
        }
Beispiel #24
0
        public static IEnumerable <CuaHangDataModel> GetListViewCuaHangTheoIdNhanVien(string maNhanVien)
        {
            IEnumerable <CuaHangDataModel> result;

            using (var context = new TIT_Entities())
            {
                result = (from nv in context.AspNetUsers
                          join ch in context.CuaHangs on nv.CuaHang_Id equals ch.MaCuaHang
                          where nv.Id == maNhanVien
                          select new CuaHangDataModel()
                {
                    MaCuaHang = ch.MaCuaHang,
                    TenCuaHang = ch.TenCuaHang,
                    QuyTienMat = ch.QuyTienMat.HasValue ? ch.QuyTienMat.Value : 0,
                    VonDauTu = ch.VonDauTu.HasValue ? ch.VonDauTu.Value : 0,
                    DiaChi = ch.DiaChi
                }).ToArray();
            }
            return(result);
        }
Beispiel #25
0
        public static IEnumerable <CuaHangDataModel> GetListViewCuaHangTheoIdKeToan(string IdKeToan)
        {
            IEnumerable <CuaHangDataModel> result;

            using (var context = new TIT_Entities())
            {
                result = (from ch in context.CuaHangs
                          join user in context.AspNetUsers on IdKeToan equals user.Id
                          where ch.QuanLyCuaHang == user.ManagerId
                          select new CuaHangDataModel()
                {
                    MaCuaHang = ch.MaCuaHang,
                    TenCuaHang = ch.TenCuaHang,
                    QuyTienMat = ch.QuyTienMat.HasValue ? ch.QuyTienMat.Value : 0,
                    VonDauTu = ch.VonDauTu.HasValue ? ch.VonDauTu.Value : 0,
                    DiaChi = ch.DiaChi
                }).ToArray();
            }
            return(result);
        }
        public static IEnumerable <NhanVienViewModel> GetListByManagerId(string managerId)
        {
            IEnumerable <NhanVienViewModel> result;

            using (var context = new TIT_Entities())
            {
                result = (from user in context.AspNetUsers
                          join ch in context.CuaHangs on user.CuaHang_Id equals ch.MaCuaHang
                          where ch.QuanLyCuaHang == managerId
                          select new NhanVienViewModel()
                {
                    Id = user.Id,
                    UserName = user.UserName,
                    FullName = user.FullName,
                    Email = user.Email,
                    TenCuaHang = ch.TenCuaHang
                }).ToArray();
            }
            return(result);
        }
Beispiel #27
0
        internal IEnumerable <CamDoHistoryDataModel> GetHistoryViewModel(string id_HopDong)
        {
            IEnumerable <CamDoHistoryDataModel> result;

            using (var context = new TIT_Entities())
            {
                result = (from hd in context.LichSuThaoTacs
                          join user in context.AspNetUsers on hd.Id_NhanVienThaoTac equals user.Id
                          where hd.Id_HopDong == id_HopDong
                          select new CamDoHistoryDataModel
                {
                    Ngay = hd.NgayThaoTac,
                    GiaoDichVien = user.UserName,
                    SoTienGhiCo = hd.ThuTien == 1 ? hd.SoTien : 0,
                    SoTienGhiNo = hd.ThuTien == 0 ? hd.SoTien : 0,
                    NoiDung = hd.NoiDung
                }).ToArray();
            }
            return(result);
        }
Beispiel #28
0
        public static int CapNhatCuaHangTheoAdmin(CuaHangUpdateModel model)
        {
            using (var context = new TIT_Entities())
            {
                //update
                var item_update = context.CuaHangs.SingleOrDefault(x => x.MaCuaHang == model.MaCuaHang);
                if (item_update != null)
                {
                    item_update.DiaChi        = model.DiaChi;
                    item_update.Latitude      = model.Latitude;
                    item_update.Longitude     = model.Longitude;
                    item_update.QuyTienMat    = model.QuyTienMat;
                    item_update.TenCuaHang    = model.TenCuaHang;
                    item_update.TinhTrang     = model.TinhTrang ? 1 : 0;
                    item_update.VonDauTu      = model.VonDauTu;
                    item_update.QuanLyCuaHang = model.QuanLyCuaHang;

                    try
                    {
                        if (context.SaveChanges() > 0)
                        {
                            return(1);
                        }
                        else
                        {
                            return(0);
                        }
                    }
                    catch (Exception ex)
                    {
                        ex.ToString();
                        //_logger.Error(ex.ToString());
                        return(0);
                    }
                }
            }
            return(0);
        }
Beispiel #29
0
        public static IEnumerable <CuaHangGridViewModel> GetGridViewCuaHangTheoIdNhanVien(string MaNhanVien)
        {
            IEnumerable <CuaHangGridViewModel> result;

            using (var context = new TIT_Entities())
            {
                result = (from nv in context.AspNetUsers
                          join ch in context.CuaHangs on nv.CuaHang_Id equals ch.MaCuaHang
                          where nv.Id == MaNhanVien
                          select new CuaHangGridViewModel()
                {
                    MaCuaHang = ch.MaCuaHang,
                    TenCuaHang = ch.TenCuaHang,
                    DiaChi = ch.DiaChi,
                    DienThoai = "Không có",
                    NgayTao = ch.NgayTao,
                    NguoiTao = ch.NguoiTao,
                    QuyTienMat = ch.QuyTienMat.HasValue? ch.QuyTienMat.Value: 0,
                    VonDauTu = ch.VonDauTu.HasValue? ch.VonDauTu.Value: 0,
                    TinhTrang = ch.TinhTrang
                }).ToArray();
            }
            return(result);
        }
Beispiel #30
0
 public static int CapNhatUrl(string idHopDong, string newPath, int STT)
 {
     using (var context = new TIT_Entities())
     {
         var hopdong = context.HD_VayDuNoGiamDan.Where(x => x.HD_Id == idHopDong).FirstOrDefault();
         if (STT == 1)
         {
             hopdong.UrlHinh1 = newPath;
         }
         else if (STT == 2)
         {
             hopdong.UrlHinh2 = newPath;
         }
         else
         {
             hopdong.UrlHinh3 = newPath;
         }
         try
         {
             if (context.SaveChanges() > 0)
             {
                 return(1);
             }
             else
             {
                 return(0);
             }
         }
         catch (Exception ex)
         {
             ex.ToString();
             //_logger.Error(ex.ToString());
             return(0);
         }
     }
 }