Пример #1
0
        public async Task <JsonResult> Search(string workFromDate, string workToDate,
                                              string freetext = "",
                                              int roleId      = 0,
                                              int page        = 1, int limit = 10)
        {
            var fromDate = string.IsNullOrWhiteSpace(workFromDate) ? DateTime.Now.AddDays(-7) : DateTimeFormat.ConvertddMMyyyyToDateTime(workFromDate);
            var toDate   = string.IsNullOrWhiteSpace(workToDate) ? DateTime.Now : DateTimeFormat.ConvertddMMyyyyToDateTime(workToDate);

            BusinessExtension.ProcessPaging(ref page, ref limit);
            freetext = string.IsNullOrWhiteSpace(freetext) ? string.Empty : freetext.Trim();
            var datas = await _rpEmployee.Gets(fromDate, toDate, roleId, freetext, page, limit, GlobalData.User.OrgId, GlobalData.User.IDUser);

            if (datas == null || !datas.Any())
            {
                return(ToJsonResponse(true, null, DataPaging.Create(null as List <EmployeeViewModel>, 0)));
            }
            var result = DataPaging.Create(datas, datas[0].TotalRecord);

            return(ToJsonResponse(true, null, result));
        }
Пример #2
0
        public async Task <(List <HosoDuyet> datas, int TotalRecord)> GetHosoDuyet(string fromDate,
                                                                                   string toDate,
                                                                                   string maHS,
                                                                                   string cmnd,
                                                                                   int loaiNgay,
                                                                                   int maNhom      = 0,
                                                                                   string freetext = null,
                                                                                   int page        = 1, int limit = 10,
                                                                                   int maThanhVien = 0)
        {
            if (!string.IsNullOrWhiteSpace(freetext) && freetext.Length > 50)
            {
                AddError("Từ khóa tìm kiếm không được nhiều hơn 50 ký tự");
                return(null, 0);
            }
            int      totalRecord = 0;
            DateTime dtFromDate = DateTime.MinValue, dtToDate = DateTime.MinValue;

            if (fromDate != "")
            {
                dtFromDate = fromDate.ConvertddMMyyyyToDateTime();
            }
            if (toDate != "")
            {
                dtToDate = toDate.ConvertddMMyyyyToDateTime();
            }
            string status = BusinessExtension.JoinTrangThai();

            totalRecord = await CountHosoDuyet(_process.User.Id, maNhom,
                                               maThanhVien, dtFromDate, dtToDate, maHS, cmnd, loaiNgay, status, freetext);

            var datas = await GetHosoDuyet(_process.User.Id, maNhom, maThanhVien,
                                           dtFromDate, dtToDate, maHS, cmnd, loaiNgay, status, page, limit, freetext);

            return(datas, totalRecord);
        }
Пример #3
0
        public async Task <JsonResult> Create([FromBody] UserCreateModel entity)
        {
            var isAdmin = GlobalData.User.UserType == (int)UserTypeEnum.Admin ? true : false;

            if (!isAdmin)
            {
                return(ToJsonResponse(false, "Bạn không có quyền"));
            }
            if (entity == null)
            {
                return(ToJsonResponse(false, "Dữ liệu không hợp lệ"));
            }
            if (string.IsNullOrWhiteSpace(entity.UserName))
            {
                return(ToJsonResponse(false, "Tên đăng nhập không được để trống"));
            }
            if (entity.UserName.Contains(" "))
            {
                return(ToJsonResponse(false, "Tên đăng nhập viết liền không dấu cách"));
            }
            if (string.IsNullOrWhiteSpace(entity.Password))
            {
                return(ToJsonResponse(false, "Mật khẩu không được để trống"));
            }
            if (entity.Password.Trim().Length < 5)
            {
                return(ToJsonResponse(false, "Mật khẩu phải có ít nhất 5 ký tự"));
            }
            if (string.IsNullOrWhiteSpace(entity.PasswordConfirm))
            {
                return(ToJsonResponse(false, "Mật khẩu xác thực không được để trống"));
            }
            if (entity.Password != entity.PasswordConfirm)
            {
                return(ToJsonResponse(false, "Mật khẩu không khớp"));
            }

            if (!string.IsNullOrWhiteSpace(entity.Email) && !BusinessExtension.IsValidEmail(entity.Email, 50))
            {
                return(ToJsonResponse(false, "Email không hợp lệ"));
            }

            var existUserName = await _rpEmployee.GetByUserName(entity.UserName.Trim(), GlobalData.User.IDUser);

            if (existUserName != null)
            {
                return(ToJsonResponse(false, "Tên đăng nhập đã tồn tại"));
            }


            if (string.IsNullOrWhiteSpace(entity.Code))
            {
                return(ToJsonResponse(false, "Mã nhân viên không được để trống", 0));
            }
            var existCode = await _rpEmployee.GetByCode(entity.Code.Trim(), GlobalData.User.IDUser);

            if (existCode != null)
            {
                return(ToJsonResponse(false, "Mã đã tồn tại", 0));
            }
            entity.UserName  = entity.UserName.Trim().ToLower();
            entity.Password  = entity.Password.Trim();
            entity.Password  = MD5.getMD5(entity.Password);
            entity.CreatedBy = GlobalData.User.IDUser;
            var result = await _rpEmployee.Create(entity);

            return(ToJsonResponse(true, null, result));
        }
Пример #4
0
        public async Task <ActionResult> Save(string hoten, string phone, string phone2, string ngayNhanDon, int hoSoCuaAi, string cmnd, int gioiTinh
                                              , int maKhuVuc, string diaChi, int courier, int sanPhamVay, string tenCuaHang, int baoHiem, int thoiHanVay,
                                              string soTienVay, string ghiChu, string birthDayStr, string cmndDayStr, string link = null, int provinceId = 0, int doitacF88Value = 0, List <int> FileRequireIds = null, int partnerType = 0)
        {
            if (!string.IsNullOrWhiteSpace(ghiChu) && ghiChu.Length > 200)
            {
                return(ToResponse(false, "Nội dung ghi chú không được lớn hơn 200"));
            }
            try
            {
                if (hoten == string.Empty)
                {
                    return(ToResponse(false, "Vui lòng nhập họ tên"));
                }
                if (phone == string.Empty)
                {
                    return(ToResponse(false, "Vui lòng nhập số điện thoại"));
                }
                if (ngayNhanDon == string.Empty)
                {
                    return(ToResponse(false, "Vui lòng nhập ngày nhận đơn"));
                }
                if (cmnd == string.Empty)
                {
                    return(ToResponse(false, "Vui lòng nhập CMND"));
                }
                if (diaChi == string.Empty)
                {
                    return(ToResponse(false, "Vui lòng nhập địa chỉ"));
                }
                if (maKhuVuc == 0)
                {
                    return(ToResponse(false, "Vui lòng chọn quận/ huyện"));
                }
                if (sanPhamVay == 0)
                {
                    return(ToResponse(false, "Vui lòng chọn sản phẩm vay"));
                }
                if (soTienVay == string.Empty)
                {
                    return(ToResponse(false, "Vui lòng nhập số tiền vay"));
                }
                if (string.IsNullOrWhiteSpace(birthDayStr))
                {
                    return(ToResponse(false, "Vui lòng nhập ngày sinh"));
                }
                if (string.IsNullOrWhiteSpace(cmndDayStr))
                {
                    return(ToResponse(false, "Vui lòng nhập ngày cấp cmnd"));
                }
                List <TaiLieuModel> lstTaiLieu = (List <TaiLieuModel>)Session["LstFileHoSo"];

                var lstLoaiTaiLieu = await _rpTailieu.GetLoaiTailieuList();

                lstLoaiTaiLieu.RemoveAll(x => x.BatBuoc == 0);
                if (lstLoaiTaiLieu != null)
                {
                    var missingNames = BusinessExtension.GetFilesMissingV2(lstLoaiTaiLieu, FileRequireIds);
                    if (!string.IsNullOrWhiteSpace(missingNames))
                    {
                        return(ToResponse(false, $"Vui lòng nhập: {missingNames}", 0));
                    }
                }
                HoSoModel hs = new HoSoModel();
                hs.ID           = (int)Session["AddNewHoSoID"];
                hs.TenKhachHang = hoten;
                hs.SDT          = phone;
                hs.SDT2         = phone2;
                if (ngayNhanDon != string.Empty)
                {
                    hs.NgayNhanDon = DateTimeFormat.ConvertddMMyyyyToDateTime(ngayNhanDon);
                }
                hs.BirthDay    = string.IsNullOrWhiteSpace(birthDayStr) ? DateTime.Now : DateTimeFormat.ConvertddMMyyyyToDateTime(birthDayStr);
                hs.CmndDay     = string.IsNullOrWhiteSpace(cmndDayStr) ? DateTime.Now : DateTimeFormat.ConvertddMMyyyyToDateTime(cmndDayStr);
                hs.HoSoCuaAi   = hoSoCuaAi;
                hs.MaNguoiTao  = GlobalData.User.IDUser;
                hs.NgayTao     = DateTime.Now;
                hs.CMND        = cmnd;
                hs.GioiTinh    = gioiTinh;
                hs.MaKhuVuc    = maKhuVuc;
                hs.DiaChi      = diaChi;
                hs.CourierCode = courier;
                hs.SanPhamVay  = sanPhamVay;
                hs.TenCuaHang  = tenCuaHang;
                hs.CoBaoHiem   = baoHiem;
                hs.HanVay      = thoiHanVay;
                if (soTienVay == string.Empty)
                {
                    soTienVay = "0";
                }
                hs.SoTienVay   = Convert.ToDecimal(soTienVay);
                hs.MaTrangThai = (int)TrangThaiHoSo.NhapLieu;
                hs.MaKetQua    = (int)KetQuaHoSo.Trong;
                int result = 0;

                if (hs.ID > 0)
                {
                    bool isCheckMaSanPham = false;
                    //// chỉnh sửa
                    if (new HoSoBLL().Luu(hs, lstTaiLieu, ref isCheckMaSanPham))
                    {
                        result = 1;
                        new HoSoDuyetXemBLL().Them(hs.ID);
                        MailCM.SendMailToAdmin(hs.ID, Request.Url.Authority);
                    }
                    else
                    {
                        if (isCheckMaSanPham)
                        {
                            return(ToResponse(false, "Mã sản phẩm đã được sử dụng bởi 1 hồ sơ khác, vui lòng chọn mã sản phẩm khác"));
                        }
                    }
                    await AddGhichu(hs.ID, ghiChu);

                    return(ToResponse(true, Resources.Global.Message_Succ, hs.ID));
                }
                else
                {
                    bool isCheckMaSanPham = false;
                    result = new HoSoBLL().Them(hs, lstTaiLieu, ref isCheckMaSanPham);
                    if (result > 0)
                    {
                        Session["AddNewHoSoID"] = result;
                        new HoSoDuyetXemBLL().Them(result);
                        MailCM.SendMailToAdmin(result, Request.Url.Authority);
                    }
                    else
                    {
                        if (isCheckMaSanPham)
                        {
                            return(ToResponse(false, "Mã sản phẩm đã được sử dụng bởi 1 hồ sơ khác, vui lòng chọn mã sản phẩm khác"));
                        }
                    }
                    await AddGhichu(result, ghiChu);
                }
                if (result > 0)
                {
                    return(ToResponse(true, Resources.Global.Message_Succ, result));
                }
                else
                {
                    return(ToResponse(false, "Không thành công, vui lòng thử lại sau"));
                }
            }
            catch (BusinessException ex)
            {
                return(ToResponse(false, ex.Message));
            }
        }
Пример #5
0
        public async Task <JsonResult> CapNhat(int id, string hoten, string phone, string phone2, string ngayNhanDon, int hoSoCuaAi, string cmnd, int gioiTinh
                                               , int maKhuVuc, string diaChi, int sanPhamVay, string tenCuaHang,
                                               int baoHiem, int thoiHanVay, string soTienVay, int trangThai,
                                               int ketQua, string ghiChu, string birthDayStr, string cmndDayStr, int courier = 0, List <int> FileRequireIds = null)
        {
            try
            {
                if (hoten == string.Empty)
                {
                    return(ToJsonResponse(false, "Vui lòng nhập họ tên"));
                }
                if (phone == string.Empty)
                {
                    return(ToJsonResponse(false, "Vui lòng nhập số điện thoại"));
                }
                if (ngayNhanDon == string.Empty)
                {
                    return(ToJsonResponse(false, "Vui lòng nhập ngày nhận đơn"));
                }
                if (cmnd == string.Empty)
                {
                    return(ToJsonResponse(false, "Vui lòng nhập CMND"));
                }
                if (diaChi == string.Empty)
                {
                    return(ToJsonResponse(false, "Vui lòng nhập địa chỉ"));
                }
                if (maKhuVuc == 0)
                {
                    return(ToJsonResponse(false, "Vui lòng chọn quận/ huyện"));
                }
                if (sanPhamVay == 0)
                {
                    return(ToJsonResponse(false, "Vui lòng chọn sản phẩm vay"));
                }
                if (soTienVay == string.Empty)
                {
                    return(ToJsonResponse(false, "Vui lòng nhập số tiền vay"));
                }
                if (string.IsNullOrWhiteSpace(birthDayStr))
                {
                    return(ToJsonResponse(false, "Vui lòng nhập ngày sinh"));
                }
                if (string.IsNullOrWhiteSpace(cmndDayStr))
                {
                    return(ToJsonResponse(false, "Vui lòng nhập ngày cấp cmnd"));
                }
                //List<TaiLieuModel> lstTaiLieu = (List<TaiLieuModel>)Session["Duyet_LstFileHoSo"];
                List <LoaiTaiLieuModel> lstLoaiTaiLieu = new LoaiTaiLieuBLL().LayDS();
                lstLoaiTaiLieu.RemoveAll(x => x.BatBuoc == 0);
                if (lstLoaiTaiLieu != null)
                {
                    var missingNames = BusinessExtension.GetFilesMissingV2(lstLoaiTaiLieu, FileRequireIds);
                    if (!string.IsNullOrWhiteSpace(missingNames))
                    {
                        return(ToJsonResponse(false, $"Vui lòng nhập: {missingNames}"));
                    }
                }

                HoSoModel hs = new HoSoModel();
                hs.ID           = id;
                hs.TenKhachHang = hoten;
                hs.SDT          = phone;
                hs.SDT2         = phone2;
                if (ngayNhanDon != string.Empty)
                {
                    hs.NgayNhanDon = DateTimeFormat.ConvertddMMyyyyToDateTime(ngayNhanDon);
                }
                hs.HoSoCuaAi      = hoSoCuaAi;
                hs.MaNguoiCapNhat = GlobalData.User.IDUser;
                hs.NgayCapNhat    = DateTime.Now;
                hs.CMND           = cmnd;
                hs.GioiTinh       = gioiTinh;
                hs.MaKhuVuc       = maKhuVuc;
                hs.DiaChi         = diaChi;
                hs.CourierCode    = courier;
                hs.SanPhamVay     = sanPhamVay;
                hs.TenCuaHang     = tenCuaHang;
                hs.CoBaoHiem      = baoHiem;
                hs.HanVay         = thoiHanVay;
                var dtBirthDayConvert = DateTimeFormat.ConvertddMMyyyyToDateTimeV2(birthDayStr);
                if (!dtBirthDayConvert.Success)
                {
                    return(ToJsonResponse(false, dtBirthDayConvert.Message));
                }
                else
                {
                    hs.BirthDay = dtBirthDayConvert.Value;
                }

                var dtCmnd = DateTimeFormat.ConvertddMMyyyyToDateTimeV2(cmndDayStr);
                if (!dtCmnd.Success)
                {
                    return(ToJsonResponse(false, dtCmnd.Message));
                }
                else
                {
                    hs.CmndDay = dtCmnd.Value;
                }

                if (soTienVay == string.Empty)
                {
                    soTienVay = "0";
                }
                hs.SoTienVay   = Convert.ToDecimal(soTienVay);
                hs.MaTrangThai = trangThai;
                hs.MaKetQua    = ketQua;
                int result = 0;
                if (hs.ID > 0)
                {
                    var hosoOld = new HoSoBLL().LayChiTiet(id);
                    if (!(hosoOld.MaTrangThai == trangThai && hosoOld.MaKetQua == ketQua))
                    {
                        new HoSoXemBLL().Them(hosoOld.ID);
                    }

                    hs.DisbursementDate = hosoOld.DisbursementDate;
                    if (hs.MaTrangThai == (int)TrangThaiHoSo.GiaiNgan)
                    {
                        hs.DisbursementDate = DateTime.Now;
                    }
                    bool isCheckMaSanPham = false;
                    //// chỉnh sửa
                    if (new HoSoBLL().CapNhatHoSo(hs, null, ref isCheckMaSanPham))
                    {
                        result = 1;
                    }
                    else
                    {
                        if (isCheckMaSanPham)
                        {
                            return(ToJsonResponse(false, "Mã sản phẩm đã được sử dụng bởi 1 hồ sơ khác, vui lòng chọn mã sản phẩm khác"));
                        }
                    }
                }

                if (result > 0)
                {
                    bool rs = new HoSoBLL().CapNhatTrangThaiHS(id, GlobalData.User.IDUser, DateTime.Now, trangThai, ketQua, ghiChu);

                    if (rs)
                    {
                        GhichuModel ghichu = new GhichuModel
                        {
                            UserId      = GlobalData.User.IDUser,
                            HosoId      = hs.ID,
                            Noidung     = ghiChu,
                            CommentTime = DateTime.Now,
                            TypeId      = (int)NoteType.Hoso
                        };

                        await _rpNote.AddNoteAsync(ghichu);

                        return(ToJsonResponse(true, Resources.Global.Message_Succ, hs.ID));
                    }
                    return(ToJsonResponse(false, "Không thành công, xin thử lại sau"));
                }
                return(ToJsonResponse(false, "Không thành công, xin thử lại sau"));
            }
            catch (Exception e)
            {
                return(ToJsonResponse(false, e.Message));
            }
        }
Пример #6
0
        public async Task <ActionResult> Save(string hoten, string phone, string phone2, string ngayNhanDon, int hoSoCuaAi, string cmnd, int gioiTinh
                                              , int maKhuVuc, string diaChi, int sanPhamVay, string tenCuaHang,
                                              bool baoHiem, int thoiHanVay, string soTienVay, int trangthai, string ghiChu,
                                              string birthDayStr, string cmndDayStr, int courier = 0, List <int> FileRequireIds = null)
        {
            string error = "";

            if (GlobalData.User.UserType == (int)UserTypeEnum.Sale ||
                trangthai == (int)TrangThaiHoSo.Nhap)
            {
                trangthai = (int)TrangThaiHoSo.NhapLieu;
            }
            try
            {
                if (hoten == string.Empty)
                {
                    return(ToJsonResponse(false, "Vui lòng nhập họ tên"));
                }
                if (phone == string.Empty)
                {
                    return(ToJsonResponse(false, "Vui lòng nhập số điện thoại"));
                }
                if (ngayNhanDon == string.Empty)
                {
                    return(ToJsonResponse(false, "Vui lòng nhập ngày nhận đơn"));
                }
                if (cmnd == string.Empty)
                {
                    return(ToJsonResponse(false, "Vui lòng nhập CMND"));
                }
                if (diaChi == string.Empty)
                {
                    return(ToJsonResponse(false, "Vui lòng nhập địa chỉ"));
                }
                if (maKhuVuc == 0)
                {
                    return(ToJsonResponse(false, "Vui lòng chọn quận/ huyện"));
                }
                else if (sanPhamVay == 0)
                {
                    return(ToJsonResponse(false, "Vui lòng chọn sản phẩm vay"));
                }
                if (soTienVay == string.Empty)
                {
                    return(ToJsonResponse(false, "Vui lòng nhập số tiền vay"));
                }
                if (string.IsNullOrWhiteSpace(birthDayStr))
                {
                    return(ToJsonResponse(false, "Vui lòng nhập ngày sinh"));
                }
                if (string.IsNullOrWhiteSpace(cmndDayStr))
                {
                    return(ToJsonResponse(false, "Vui lòng nhập ngày cấp cmnd"));
                }
                if (trangthai <= 0)
                {
                    return(ToJsonResponse(false, "Vui lòng chọn trạng thái"));
                }
                if (!string.IsNullOrWhiteSpace(ghiChu) && ghiChu.Length > 300)
                {
                    return(ToJsonResponse(false, "Nội dung ghi chú không được nhiều hơn 300 ký tự"));
                }
                try
                {
                    var lstLoaiTaiLieu = await _rpTailieu.LayDS();

                    if (lstLoaiTaiLieu == null)
                    {
                        await _rpLog.InsertLog("Update-Quanlyhoso", "lstLoaiTaiLieu = null");
                    }

                    if (lstLoaiTaiLieu != null)
                    {
                        lstLoaiTaiLieu.RemoveAll(x => x.BatBuoc == 0);
                        var missingNames = BusinessExtension.GetFilesMissingV2(lstLoaiTaiLieu, FileRequireIds);
                        if (!string.IsNullOrWhiteSpace(missingNames))
                        {
                            return(ToJsonResponse(false, $"Vui lòng nhập: {missingNames}"));
                        }
                    }
                }
                catch (Exception e)
                {
                    error = e.Dump();
                }
                if (!string.IsNullOrWhiteSpace(error))
                {
                    await _rpLog.InsertLog("Update-Quanlyhoso", error);
                }

                HoSoModel hs = new HoSoModel();
                hs.ID           = (int)Session["QL_HoSoID"];
                hs.TenKhachHang = hoten;
                hs.SDT          = phone;
                hs.SDT2         = phone2;
                if (ngayNhanDon != string.Empty)
                {
                    hs.NgayNhanDon = DateTimeFormat.ConvertddMMyyyyToDateTime(ngayNhanDon);
                }
                hs.HoSoCuaAi      = hoSoCuaAi;
                hs.MaNguoiCapNhat = GlobalData.User.IDUser;
                hs.NgayCapNhat    = DateTime.Now;
                hs.CMND           = cmnd;
                hs.GioiTinh       = gioiTinh;
                hs.MaKhuVuc       = maKhuVuc;
                hs.DiaChi         = diaChi;
                hs.CourierCode    = courier;
                hs.SanPhamVay     = sanPhamVay;
                hs.TenCuaHang     = tenCuaHang;
                hs.CoBaoHiem      = baoHiem ? 1 : 0;
                hs.MaTrangThai    = trangthai;
                hs.HanVay         = thoiHanVay;
                if (soTienVay == string.Empty)
                {
                    soTienVay = "0";
                }
                hs.SoTienVay = Convert.ToDecimal(soTienVay);
                var dtBirthDayConvert = DateTimeFormat.ConvertddMMyyyyToDateTimeV2(birthDayStr);
                if (!dtBirthDayConvert.Success)
                {
                    return(ToJsonResponse(false, dtBirthDayConvert.Message));
                }
                else
                {
                    hs.BirthDay = dtBirthDayConvert.Value;
                }

                var dtCmnd = DateTimeFormat.ConvertddMMyyyyToDateTimeV2(cmndDayStr);
                if (!dtCmnd.Success)
                {
                    return(ToJsonResponse(false, dtCmnd.Message));
                }
                else
                {
                    hs.CmndDay = dtCmnd.Value;
                }
                //hs.MaTrangThai = (int)TrangThaiHoSo.NhapLieu;
                hs.MaKetQua = (int)KetQuaHoSo.Trong;
                if (hs.ID > 0)
                {
                    var hoso = new HoSoBLL().LayChiTiet(hs.ID);
                    if (hoso == null)
                    {
                        return(ToJsonResponse(false, "Hồ sơ không tồn tại", hs.ID));
                    }
                    hs.DisbursementDate = hoso.DisbursementDate;
                    if (hs.MaTrangThai == (int)TrangThaiHoSo.GiaiNgan)
                    {
                        hs.DisbursementDate = DateTime.Now;
                    }

                    bool isCheckMaSanPham = false;
                    //// chỉnh sửa
                    if (new HoSoBLL().CapNhatHoSo(hs, null, ref isCheckMaSanPham))
                    {
                        new HoSoDuyetXemBLL().Them(hs.ID);
                    }
                    else
                    {
                        if (isCheckMaSanPham)
                        {
                            return(ToJsonResponse(false, "Mã sản phẩm đã được sử dụng bởi 1 hồ sơ khác, vui lòng chọn mã sản phẩm khác"));
                        }
                    }
                }

                await AddGhichu(hs.ID, ghiChu);

                return(ToJsonResponse(true, Resources.Global.Message_Succ, hs.ID));
            }
            catch (Exception ex)
            {
                error = error.Dump();
                await _rpLog.InsertLog("quanlyhoso", error);

                return(ToJsonResponse(false, ex.Message));
            }
        }