public PhieuChiBusiness()
 {
     dbContext         = new SMSEntities();
     _phieuChiRepo     = new PhieuChiRepository(dbContext);
     _nhanVienRepo     = new NhanVienRepository(dbContext);
     _nhanVienBus      = new NhanVienBusiness();
     _phieuNhapKhoRepo = new PhieuNhapKhoRepository(dbContext);
 }
Exemplo n.º 2
0
 public ChucVuBusiness()
 {
     _dbContext         = new SMSEntities();
     _chucVuRepo        = new ChucVuRepository(_dbContext);
     _nhanVienQuyenRepo = new NhanVien_QuyenRepository(_dbContext);
     _phanQuyenRepo     = new PhanQuyenRepository(_dbContext);
     _nhanVienRepo      = new NhanVienRepository(_dbContext);
 }
Exemplo n.º 3
0
 public BaoCaoBanHangBusiness()
 {
     dbContext         = new SMSEntities();
     _phieuBanHangRepo = new PhieuBanHangRepository(dbContext);
     _nhanVienRepo     = new NhanVienRepository(dbContext);
     _hangHoaRepo      = new HangHoaRepository(dbContext);
     _nhanVienBus      = new NhanVienBusiness();
 }
Exemplo n.º 4
0
 public PhieuKiemKhoBusiness()
 {
     dbContext                = new SMSEntities();
     _phieuKiemKhoRepo        = new PhieuKiemKhoRepository(dbContext);
     _nhanVienRepo            = new NhanVienRepository(dbContext);
     _hangHoaRepo             = new HangHoaRepository(dbContext);
     _chiTietPhieuKiemKhoRepo = new ChiTietPhieuKiemKhoRepository(dbContext);
     _nhanVienBus             = new NhanVienBusiness();
 }
Exemplo n.º 5
0
        /// <summary>
        /// Ham xu ly chinh, chi nhan 1 bien moi truong
        /// </summary>
        /// <param name="context">Bien moi truong</param>
        /// <returns></returns>
        public async Task <Entity.MSSQL_QLDN_QLNS.Entity.NhanVien> Execute()
        {
            Init();
            Validate();

            var repo   = new NhanVienRepository(_context);
            var result = await repo.Insert(this);

            return(result);
        }
 public HttpResponseMessage GetAll(string id)
 {
     try
     {
         return(Request.CreateResponse(HttpStatusCode.OK, NhanVienRepository.GetInstance().GetFrom(id)));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
     }
 }
 public HttpResponseMessage Update([FromBody] NhanVien obj)
 {
     try
     {
         return(Request.CreateResponse(HttpStatusCode.OK, NhanVienRepository.GetInstance().Update(obj)));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
     }
 }
        public HttpResponseMessage Sync([FromBody] SyncRequest request)
        {
            var response = new SyncResponse();

            try
            {
                int result = -1;
                switch (request.SyncType)
                {
                case 1:
                    result = NhanVienRepository.GetInstance().Add(new NhanVien()
                    {
                        MaNV        = request.Id,
                        HoTen       = request.FullName,
                        Email       = request.Email,
                        TenTaiKhoan = request.Username,
                        MatKhau     = request.Password,
                        CapPQ       = request.PermissionLevel,
                        MaCN        = request.AgencyId,
                        MaPQ        = request.PermissionId,
                    });
                    break;

                case 0:
                    result = NhanVienRepository.GetInstance().Update(new NhanVien()
                    {
                        MaNV        = request.Id,
                        HoTen       = request.FullName,
                        Email       = request.Email,
                        TenTaiKhoan = request.Username,
                        MatKhau     = request.Password,
                        CapPQ       = request.PermissionLevel,
                        MaCN        = request.AgencyId,
                        MaPQ        = request.PermissionId,
                    });
                    break;

                case -1:
                    result = NhanVienRepository.GetInstance().Delete(request.Id);
                    break;

                default:
                    response.IsError = true;
                    break;
                }
                response.IsError = result != 1;
            }
            catch
            {
                response.IsError = true;
            }
            return(Request.CreateResponse(HttpStatusCode.NoContent, response));
        }
Exemplo n.º 9
0
 public UnitOfWork(QuanLyPhongMachEntities context)
 {
     this.context     = context;
     Nhanviens        = new NhanVienRepository(context);
     Thuocs           = new ThuocRepository(context);
     VaiTroes         = new VaiTroRepository(context);
     PhieuKhams       = new PhieuKhamRepository(context);
     BenhNhans        = new BenhNhanRepository(context);
     Benhs            = new BenhRepository(context);
     ChiTietBenhs     = new ChiTietBenhRepository(context);
     ChiTietDonThuocs = new ChiTietDonThuocRepository(context);
     DonThuocs        = new DonThuocRepository(context);
     BaoCaos          = new BaoCaoRepository(context);
 }
        public HttpResponseMessage ChangeRole([FromBody] ChangeRoleRequest request)
        {
            var response = new ChangeRoleResponse();

            try
            {
                var token = Token.Get(request.Token);
                if (token == null)
                {
                    response.IsTokenTimeout = true;
                }
                else
                {
                    if (AccountBUS.CheckRole3(token.MaNV))
                    {
                        response.Data = true;
                        if (request.IsUp)
                        {
                            var temp = NhanVienRepository.GetInstance().GetUserById(token.MaNV);
                            if (temp != null)
                            {
                                token.CapPQ = 3;
                                token.MaCN  = temp.MaCN;
                            }
                            else
                            {
                                response.IsError = true;
                            }
                        }
                        else
                        {
                            token.CapPQ = 2;
                            token.MaCN  = request.AgencyId;
                        }
                    }
                }
            }
            catch
            {
                response.IsError = true;
            }
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
        public HttpResponseMessage Change([FromBody] CPassRequest request)
        {
            var response = new CPassResponse();

            if (BusinessHandler.AccountBUS.CPassValidate(request, ref response))
            {
                try
                {
                    var tokenValue = Token.Get(request.Token) as NhanVien;
                    if (tokenValue == null)
                    {
                        response.IsTokenTimeout = true;
                    }
                    else
                    {
                        var oldp   = Security.Encrypt(request.OldPassword);
                        var newp   = Security.Encrypt(request.NewPassword);
                        var result = NhanVienRepository.GetInstance().ChangePass(tokenValue.MaNV, oldp, newp);
                        if (result == 1)
                        {
                            BusinessHandler.AccountBUS.SyncPassword2ManagementServiceAsync(new ChangePasswordRequest
                            {
                                UserId  = tokenValue.MaNV,
                                NewPass = newp
                            });
                            response.Data = "Thay đổi mật khẩu thành công.";
                        }
                        else
                        {
                            response.Errors.Add("Thay đổi mật khẩu thất bại.");
                            response.IsError = true;
                        }
                    }
                }
                catch
                {
                    response.Errors.Add("Lỗi hệ thống.");
                    response.IsError = true;
                }
            }
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
Exemplo n.º 12
0
        public async Task <dynamic> Execute(ContextDto context)
        {
            try
            {
                init();
                validate();

                if (_listNhanVien != null && _listNhanVien.Count > 0)
                {
                    var repo = new NhanVienRepository(context);

                    foreach (var nhanvienModel in _listNhanVien)
                    {
                        if (nhanvienModel.NV_ID > 0)
                        {
                            var nhanvienEntity = new Entity.MSSQL_QLDN_QLNS.Entity.NhanVien();
                            nhanvienEntity.NhanVienId = nhanvienModel.NV_ID;
                            nhanvienEntity.CtrVersion = nhanvienModel.NV_CTRVERSION;

                            nhanvienEntity.XoaYN = "Y";

                            nhanvienEntity = await repo.UpdatePartial(nhanvienEntity,
                                                                      nameof(Entity.MSSQL_QLDN_QLNS.Entity.NhanVien.XoaYN)
                                                                      );

                            nhanvienModel.XoaYN = nhanvienEntity.XoaYN;
                        }
                    }
                }

                return(ActionHelper.returnActionResult(HttpStatusCode.OK, _listNhanVien, null));
            }
            catch (FormatException ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.BadRequest, ex.Message));
            }
            catch (Exception ex)
            {
                return(ActionHelper.returnActionError(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Exemplo n.º 13
0
 public NhanvienController(NhanVienRepository repository)
 {
     this.repository = repository;
 }
Exemplo n.º 14
0
 public static string AddNhanVien(NhanVien nhanvien)
 {
     return(NhanVienRepository.AddNhanVienToDB(nhanvien));
 }
Exemplo n.º 15
0
 public NhanVienBusiness()
 {
     repository = new NhanVienRepository();
 }
 public ThongTinNhanVienController(NhanVienRepository repository)
 {
     _repository = repository ?? throw new ArgumentNullException(nameof(repository));
 }
Exemplo n.º 17
0
 public static List <NhanVien> ShowAllNhanVien()
 {
     return(NhanVienRepository.ShowAllNhanVienFromDB());
 }
Exemplo n.º 18
0
 public NhanVienController(NhanVienRepository repository, IConfiguration config)
 {
     _repository = repository ?? throw new ArgumentNullException(nameof(repository));
     _config     = config;
 }
Exemplo n.º 19
0
 public static bool ShowNhanVien(string manv, string matkhau)
 {
     return(NhanVienRepository.ShowNhanVienFromDB(manv, matkhau));
 }
Exemplo n.º 20
0
 public NhanVienService(NhanVienRepository nhanVienRepository)
 {
     _nhanVienRepository = nhanVienRepository;
 }
Exemplo n.º 21
0
 public static string SuaThongTinNhanVien(NhanVien nhanvien)
 {
     return(NhanVienRepository.SuaThongTinNhanVien(nhanvien));
 }
Exemplo n.º 22
0
 public static string XoaNhanVien(string manv)
 {
     return(NhanVienRepository.XoaNhanVien(manv));
 }
Exemplo n.º 23
0
 public HomeController()
 {
     nvRepo = new NhanVienRepository();
 }