Hướng phát triển

Một phần của tài liệu đồ án tốt nghiệp website quản lý nhân sự cho doanh nghiệp – HRM blueberry (Trang 71 - 124)

+ Tìm hiểu thêm về quản lý lương tự động hóa, KPI công việc, nâng cấp giao diện table đẹp mắt hơn.

+ Thêm các tính năng cần thiết để đưa website đến với doanh nghiệp.

+ Do thời gian thực hiện không nhiều và kinh nghiệm cũng như trình độ còn hạn chế nên không thể hoàn thành tốt website. Rất mong được sự đóng góp ý kiến từ quý thầy cô.

Tài Liệu Tham Khảo [1]. https://webdesign.tutsplus.com/vi/tutorials/an-introduction-to-ajax-for- front-end-designers--cms-25099. [2]. https://completejavascript.com/gioi-thieu-tong-quan-ve-ngon-ngu-lap- trinh-javascript. [3]. https://monamedia.co/mvc-la-gi-ung-dung-cua-mo-hinh-mvc-trong-lap-trinh/ [4]. https://netcore.vn/bai-viet/tong-quan-ve-aspnet-core [5]. https://adminlte.io/ [6]. https://www.datatables.net/ [7]. https://getbootstrap.com/docs/4.5/getting-started/introduction/ [8]. https://www.dropzonejs.com/#configuration [9]. https://www.dropzonejs.com/#events

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT

Phụ Lục Sơ đồ Cấu trúc

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT

Code API Login namespace HRMBlueBerry.API { [Route("api/[controller]")] [ApiController]

public class LoginController : ControllerBase

{

private HRMBlueberryDbContext context = new HRMBlueberryDbContext();

[HttpPut("Forgotpassword")]

public string forgotpassword([FromQuery] string Email)

{

Employee nhanvien = context.Employees.Where(nv => nv.EMAIL_EMP.Trim() == Email.Trim()).FirstOrDefault();

if (nhanvien == null)

{

return "Email Không Tồn Tại!";

}

var newPass = Guid.NewGuid().ToString().Substring(0, 8);

nhanvien.PASS_EMP = MD5Encryption.GetHash(newPass); context.Employees.Update(nhanvien);

context.SaveChanges();

return SendMail.Send(Email, "Đặt lại mật khẩu", "Mật khẩu mới của bạn là:

" + newPass); }

// Ham check login

[HttpPost("CheckLogin")]

public string CheckLogin ([FromBody]User employee)

{

try

{ (adsbygoogle = window.adsbygoogle || []).push({});

Employee _nv = context.Employees.Where(nv => nv.EMAIL_EMP.ToUpper() == employee.EMAIL_EMP.ToUpper()).FirstOrDefault();

if (_nv == null)

{

return "Tài khoản không tồn tại";

}

if (_nv.PASS_EMP == MD5Encryption.GetHash(employee.PASS_EMP))

{

return "OK";

}

return "Tài khoản / mật khẩu không chính xác";

}

catch (Exception ex)

{

return ex.Message;

} }

[HttpGet("GetInformation")]

public object GetInformation([FromQuery]string email)

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT

{

try

{

Employee _nv = context.Employees.Where(nv => nv.EMAIL_EMP.ToUpper() == email.ToUpper()).Include(nv => nv.GROUP).FirstOrDefault(); if (_nv == null) { return null; } return new { _nv.GROUP, _nv.EMAIL_EMP, _nv.NAME_EMP, _nv.AVATAR_EMP, _nv.CODE_EMP }; }

catch (Exception ex)

{ return null; } } } }

API Phân quyền

namespace HRMBlueBerry.API

{

[Route("api/[controller]")] [ApiController]

public class PermissionsController : ControllerBase

{ (adsbygoogle = window.adsbygoogle || []).push({});

private HRMBlueberryDbContext context = new HRMBlueberryDbContext();

[HttpGet("CheckPermission")]

public List<Permission> CheckPermission([FromQuery] string email, [FromQuery]

string screenCode)

{

Models.Employee employee = context.Employees.Include(employee => employee.GROUP).FirstOrDefault(emp => emp.EMAIL_EMP == email);

// Screen screen = context.screens.FirstOrDefault(s => s.Code == screenCode);

return context.permissions.Include(per => per.Function).Where(per =>per.Group.ID == employee.GROUP.ID && per.Function.Screen.Code == screenCode).ToList();

} } }

API Employees

namespace HRMBlueBerry.API

{

[Route("api/[controller]")] [ApiController]

public class EmployeeController : ControllerBase

{

private HRMBlueberryDbContext context = new

HRMBlueberryDbContext(); private IWebHostEnvironment hosting;

public EmployeeController(IWebHostEnvironment _hosting)

{

hosting = _hosting; }

[HttpGet("DSNhanVienPB")]

public object DSNhanVienPB([FromQuery]string department)

{

// Lay danh sach nhan vien

//List<Employee> employees = context.Employees.Where(nv => nv.Department == department).Include(cv => cv.CODE_JTT).ToList();

List<Employee> employees = context.Employees.Where(pb => pb.Department.CODE_DPM == department).ToList();

var result = from nv in employees

join cv in context.Jobtitles on nv.jobtitle.CODE_JTT equals

cv.CODE_JTT

join slr in context.Salarys on nv.Salary.CODE_SLR equals (adsbygoogle = window.adsbygoogle || []).push({});

slr.CODE_SLR select new { employee = nv, jobtitle = cv, salary = slr }; return result; } [HttpGet("DSNhanVien")]

public object DSNhanVien([FromQuery] string department)

{

// Lay danh sach nhan vien

var employees = context.Employees.Include(x => x.Department).Include(p => p.jobtitle).ToList();

return employees;

}

[HttpPost("UploadAvatar")]

public Message UploadAvatar(IFormFile file)

{

try

{

string fileName = DateTime.Now.ToString("ddMMyyyyhhmmss") +Path.GetExtension(file.FileName);

using (var stream = System.IO.File.Create(hosting.WebRootPath +

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT "\\image\\" + fileName + ".temp"))

{

file.CopyTo(stream); }

Message message = new Message { Code = "I001", NewEntity = fileName, Type = "info" }; message.NewEntity = fileName; return message; }

catch (Exception ex)

{

return new Message

{ Code = "E001", Description = ex.Message, Type = "error" }; } } [HttpPut("ChangeAvatar")]

public string ChangeAvatar([FromQuery] string nhanvienId, string fileName)

{

try

{

// Kiểm tra xem đối tượng đã tồn tại không

Employee _localUser = context.Employees.Where(user => user.CODE_EMP == nhanvienId).FirstOrDefault();

if (_localUser == null)

{ (adsbygoogle = window.adsbygoogle || []).push({});

return "Khong tim thay nhan vien nay";

}

var oldAvatar = _localUser.AVATAR_EMP;

_localUser.AVATAR_EMP = fileName; context.Employees.Update(_localUser); context.SaveChanges();

// Xóa bỏ đuôi .temp

string copyFrom = hosting.WebRootPath + "\\image\\" + fileName +

".temp";

string copyTo = hosting.WebRootPath + "\\image\\" + fileName;

System.IO.File.Move(copyFrom, copyTo, true);

// Delete avatar cũ

if (oldAvatar != null && oldAvatar.Trim().Length > 0)

{

if (System.IO.File.Exists(hosting.WebRootPath + "\\image\\" +

oldAvatar))

{ System.IO.File.Delete(hosting.WebRootPath + "\\image\\" + oldAvatar); } } return "OK"; }

catch (Exception ex)

{

return ex.Message;

} }

/ Them nhan vien

[HttpPost("AddNew")]

public string AddNew([FromBody] Employee employee)

{

try

{

/ kiem tra ma nhan vien co ton tai khong

Employee _emp = context.Employees.Where(emp => emp.CODE_EMP == employee.CODE_EMP).FirstOrDefault();

employee.PASS_EMP = MD5Encryption.GetHash(employee.PASS_EMP);

if (_emp != null)

{ (adsbygoogle = window.adsbygoogle || []).push({});

return "Đã tồn tại " + employee.CODE_EMP + " trong cơ sở dữ liệu";

}

// Các khóa ngoại

Department department = context.Departments.FirstOrDefault(x => x.CODE_DPM == employee.Department.CODE_DPM);

employee.Department = department;

Jobtitle jobtitles = context.Jobtitles.FirstOrDefault(x => x.CODE_JTT = employee.jobtitle.CODE_JTT); employee.jobtitle = jobtitles; EDUCATIONLEVEL eDUCATIONLEVEL = context.EDUCATIONLEVELS.FirstOrDefault(x => x.CODE_EDCT == employee.EDUCATIONLEVEL.CODE_EDCT); employee.EDUCATIONLEVEL = eDUCATIONLEVEL;

Contract contract = context.Contracts.FirstOrDefault(x => x.CODE_CT == employee.Contract.CODE_CT);

employee.Contract = contract;

Salary salary = context.Salarys.FirstOrDefault(x => x.CODE_SLR == employee.Salary.CODE_SLR);

employee.Salary = salary;

Group groupuser = context.groups.FirstOrDefault(x => x.ID == employee.GROUP.ID); employee.GROUP = groupuser; context.Employees.Add(employee); context.SaveChanges(); return "OK"; }

catch(Exception ex)

{

return ex.Message;

}

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT

}

[HttpPut("Edit")]

public string Edit([FromBody] Employee employee)

{

try

{

//Employee _emp = context.Employees.Where(emp => emp.CODE_EMP == employee.CODE_EMP).FirstOrDefault();

employee.PASS_EMP = MD5Encryption.GetHash(employee.PASS_EMP); Department department = context.Departments.FirstOrDefault(x => x.CODE_DPM == employee.Department.CODE_DPM);

employee.Department = department;

Jobtitle jobtitles = context.Jobtitles.FirstOrDefault(x => x.CODE_JTT = employee.jobtitle.CODE_JTT); employee.jobtitle = jobtitles; EDUCATIONLEVEL eDUCATIONLEVEL = context.EDUCATIONLEVELS.FirstOrDefault(x => x.CODE_EDCT == employee.EDUCATIONLEVEL.CODE_EDCT); employee.EDUCATIONLEVEL = eDUCATIONLEVEL;

Contract contract = context.Contracts.FirstOrDefault(x => x.CODE_CT == employee.Contract.CODE_CT);

employee.Contract = contract;

Salary salary = context.Salarys.FirstOrDefault(x => x.CODE_SLR == employee.Salary.CODE_SLR);

employee.Salary = salary; (adsbygoogle = window.adsbygoogle || []).push({});

Group groupuser = context.groups.FirstOrDefault(x => x.ID == employee.GROUP.ID); employee.GROUP = groupuser; context.Employees.Update(employee); context.SaveChanges(); return "OK"; }

catch (Exception ex)

{

return ex.Message;

} }

[HttpGet("GetEmployeeByCode")]

public Employee GetEmployeeByCode([FromQuery] string employeeCode)

{

return context.Employees.FirstOrDefault(emp => emp.CODE_EMP ==employeeCode);

} } }

API WordOder

namespace HRMBlueBerry.API {

[Route("api/[controller]")] [ApiController]

public class WOController : ControllerBase {

private HRMBlueberryDbContext context = new HRMBlueberryDbContext();

private enum WOStatus { RELEASE, DOING, COMPLETED, CANCELED, } [HttpGet("GetEmployeeList")] public object GetEmployeeList() {

List<Employee> employees = context.Employees.ToList(); return employees.Select(emp => new {

emp.CODE_EMP, emp.NAME_EMP });

}

[HttpGet("GetAll")]

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT public object GetAll(string email)

{

var result = from wo in context.WorkOrders.Include(w => w.AssignTo) join nguoigiao in context.Employees on wo.CreatedBy equals nguoigiao.CODE_EMP select new { wo, nguoigiao }; return result; } [HttpPost("AddNew")]

public Message AddNew([FromBody] WorkOrder workOrder) {

try {

//

Employee employee = context.Employees.FirstOrDefault(e => e.CODE_EMP == workOrder.AssignTo.CODE_EMP);

workOrder.AssignTo = employee;

workOrder.CreatedDate = DateTime.Now; //workOrder.CreatedBy = employee;

// Lấy số thứ tự WO (adsbygoogle = window.adsbygoogle || []).push({});

int count = context.WorkOrders.Count();

if (count == 0) { workOrder.WONo = 1; } else {

int max = context.WorkOrders.Select(wo => wo.WONo).Max(); workOrder.WONo = max + 1;

}

context.Add(workOrder); context.SaveChanges(); return new Message {

Type = "info",

Description = "Đã tạo mới WO thành công", Code = "I001"

}; }

catch (Exception ex) {

return new Message {

Type = "error",

Description = ex.Message, Code = "E001"

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT };

} }

[HttpPut("Update")]

public Message Update([FromBody] WorkOrder workOrder) {

try {

//

WorkOrder _wo = context.WorkOrders.FirstOrDefault(wo => wo.ID == workOrder.ID);

if (_wo == null) {

return new Message {

Type = "warning",

Description = "WO không tồn tại", Code = "W001"

}; }

if (_wo.Status == WOStatus.COMPLETED.ToString() || _wo.Status

= WOStatus.CANCELED.ToString()) {

return new Message {

Type = "warning",

Description = "WO này không được phép cập nhật dữ liệu", Code = "W002"

}; } (adsbygoogle = window.adsbygoogle || []).push({});

Employee employee = context.Employees.FirstOrDefault(e => e.CODE_EMP == workOrder.AssignTo.CODE_EMP); _wo.AssignTo = employee; _wo.UpdatedDate = DateTime.Now; _wo.Deadline = workOrder.Deadline; _wo.Description = workOrder.Description; _wo.Priority = workOrder.Priority; _wo.UpdatedBy = workOrder.UpdatedBy; //_wo.Status = wo context.Update(_wo); context.SaveChanges(); return new Message { Type = "info", Description = "Đã cập nhật WO thành công", Code = "I002" }; }

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT catch (Exception ex)

{

return new Message { Type = "error", Description = ex.Message, Code = "E001" }; } } [HttpPut("Doing")]

public Message Doing([FromQuery] Guid workOrderId) {

try {

//

WorkOrder _wo = context.WorkOrders.FirstOrDefault(wo => wo.ID == workOrderId);

if (_wo == null) {

return new Message {

Type = "warning",

Description = "WO không tồn tại", Code = "W001"

};

}

if (_wo.Status == WOStatus.COMPLETED.ToString() || _wo.Status

= WOStatus.CANCELED.ToString()) {

return new Message {

Type = "warning",

Description = "WO này không được phép cập nhật dữ liệu", Code = "W002" }; } _wo.Status = WOStatus.DOING.ToString(); context.Update(_wo); context.SaveChanges(); return new Message { Type = "info", Description = "Đã cập nhật WO thành công", Code = "I002" }; }

catch (Exception ex) {

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT return new Message

{ Type = "error", Description = ex.Message, Code = "E001" }; } } [HttpPut("Complete")]

public Message Complete([FromQuery] Guid workOrderId) {

try {

//

WorkOrder _wo = context.WorkOrders.FirstOrDefault(wo => wo.ID == workOrderId);

if (_wo == null) {

return new Message {

Type = "warning",

Description = "WO không tồn tại", Code = "W001" (adsbygoogle = window.adsbygoogle || []).push({});

}; }

if (_wo.Status == WOStatus.COMPLETED.ToString() || _wo.Status

= WOStatus.CANCELED.ToString() ) {

return new Message {

Type = "warning",

Description = "WO này không được phép cập nhật dữ liệu", Code = "W002" }; } _wo.Status = WOStatus.COMPLETED.ToString(); _wo.CompletedDate = DateTime.Now; context.Update(_wo); context.SaveChanges(); return new Message { Type = "info", Description = "Đã cập nhật WO thành công", Code = "I002" }; }

catch (Exception ex) {

return new Message

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT { Type = "error", Description = ex.Message, Code = "E001" }; } } [HttpPut("Cancel")]

public Message Cancel([FromQuery] Guid workOrderId) {

try {

//

WorkOrder _wo = context.WorkOrders.FirstOrDefault(wo => wo.ID == workOrderId);

if (_wo == null) {

return new Message {

Type = "warning",

Description = "WO không tồn tại", Code = "W001"

}; }

if (_wo.Status == WOStatus.COMPLETED.ToString() || _wo.Status

= WOStatus.CANCELED.ToString() ) {

return new Message {

Type = "warning",

Description = "WO này không được phép cập nhật dữ liệu", Code = "W002" }; } _wo.Status = WOStatus.CANCELED.ToString(); context.Update(_wo); context.SaveChanges(); return new Message { Type = "info", Description = "Đã cập nhật WO thành công", Code = "I002" }; }

catch (Exception ex) {

return new Message {

Type = "error",

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT Description = ex.Message, Code = "E001" }; } } [HttpDelete("Delete")]

public Message Delete([FromQuery] Guid workOrderId) {

try {

// (adsbygoogle = window.adsbygoogle || []).push({});

WorkOrder _wo = context.WorkOrders.FirstOrDefault(wo => wo.ID == workOrderId);

if (_wo == null) {

return new Message {

Type = "warning",

Description = "WO không tồn tại", Code = "W001"

}; }

if (_wo.Status == WOStatus.COMPLETED.ToString() || _wo.Status

= WOStatus.CANCELED.ToString()) {

return new Message {

Type = "warning",

Description = "WO này không được phép xóa", Code = "W003"

}; }

context.Remove(_wo); context.SaveChanges(); return new Message {

Type = "info",

Description = "Đã xóa WO thành công", Code = "I003"

}; }

catch (Exception ex) {

return new Message { Type = "error", Description = ex.Message, Code = "E001" }; }

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT }

#region KPI

public int GetWOCount(string userCode, string woStatus) {

switch (woStatus) {

case "*": return context.WorkOrders.Where(wo => wo.AssignTo.CODE_EMP == userCode && wo.Status !=

WOStatus.CANCELED.ToString()).Count(); default:

return context.WorkOrders.Where(wo =>

wo.AssignTo.CODE_EMP == userCode && wo.Status == woStatus).Count(); }

}

public float GetKPIRate(int completedWO, int totalWO) {

if (totalWO == 0) {

return 0; } (adsbygoogle = window.adsbygoogle || []).push({});

return ((float)completedWO / totalWO) * 100; }

[HttpGet("GetKPITable")]

public object GetKPITable() {

var result = from employee in context.Employees.ToList() select new { employee.CODE_EMP, employee.NAME_EMP, totalWO = GetWOCount(employee.CODE_EMP, "*"), releaseWO = GetWOCount(employee.CODE_EMP, WOStatus.RELEASE.ToString()), doingWO = GetWOCount(employee.CODE_EMP, WOStatus.DOING.ToString()), complete = GetWOCount(employee.CODE_EMP, WOStatus.COMPLETED.ToString()), kpiRate = GetKPIRate(GetWOCount(employee.CODE_EMP, WOStatus.COMPLETED.ToString()), GetWOCount(employee.CODE_EMP, "*")) }; return result; } #endregion } }

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT

API Group User

namespace HRMBlueBerry.API

{

[Route("api/[controller]")] [ApiController]

public class GroupsController : ControllerBase

{

private HRMBlueberryDbContext context = new HRMBlueberryDbContext();

[HttpGet("getall")]

public List<Group> Getnhomnguoidungs()

{ return context.groups.ToList(); } } } API Screen namespace HRMBlueBerry.API { [Route("api/[controller]")] [ApiController]

public class ScreenController : ControllerBase

{

private HRMBlueberryDbContext context = new HRMBlueberryDbContext();

[HttpGet("getall")]

public List<Screen> Getmanhinhs()

{ return context.screens.ToList(); } } } API Function namespace HRMBlueBerry.API { [Route("api/[controller]")] [ApiController]

public class FunctionController : ControllerBase

{

private HRMBlueberryDbContext context = new HRMBlueberryDbContext();

[HttpGet("getall")]

public List<Function> GetChucnangs()

{

return context.functions.ToList();

} } }

API Mã hóa mật khẩu (adsbygoogle = window.adsbygoogle || []).push({});

namespace HRMBlueBerry.API

{

public class MD5Encryption

{

public static string GetHash(string plainText)

{

MD5 md5 = new MD5CryptoServiceProvider(); / Compute hash from the bytes of text

md5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(plainText));

/ Get hash result after compute it

byte[] result = md5.Hash;

StringBuilder strBuilder = new StringBuilder(); for

(int i = 0; i < result.Length; i++){

strBuilder.Append(result[i].ToString("x2")); } return strBuilder.ToString(); } } }

API gửi mail lấy lại mật khẩu

namespace HRMBlueBerry.API

{

public class SendMail

{

private static readonly string _from = "congnghexanhvungtau@gmail.com"; // Email của Sender (của bạn)

private static readonly string _pass = "Maiduchienvt01"; // Mật khẩu Email của Sender (của bạn)

public static string Send(string sendto, string subject, string content)

{

/ sendto: Email receiver (người nhận)

/ subject: Tiêu đề email

/ content: Nội dung của email, bạn có thể viết mã HTML

/ Nếu gửi email thành công, sẽ trả về kết quả: OK,

/ không thành công sẽ trả về thông tin lỗi

try

{

MailMessage mail = new MailMessage(); (adsbygoogle = window.adsbygoogle || []).push({});

SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress(_from);

mail.To.Add(sendto); mail.Subject = subject; mail.IsBodyHtml = true; mail.Body = content; mail.Priority = MailPriority.High; SmtpServer.Port = 587;

SmtpServer.Credentials = new System.Net.NetworkCredential(_from, _pass);

SmtpServer.EnableSsl = true;

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT

SmtpServer.Send(mail);

return "OK";

}

catch (Exception ex)

{ return ex.ToString(); } } } }

API Phòng ban, chức vụ, trình độ học vấn, lương

namespace HRMBlueBerry.API

{

[Route("api/[controller]")] [ApiController]

public class DepartmentController : ControllerBase

{

private HRMBlueberryDbContext context = new HRMBlueberryDbContext();

[HttpGet("getall")]

public List<Department> GetPhongbans()

{ return context.Departments.ToList(); } } } namespace HRMBlueBerry.API { [Route("api/[controller]")] [ApiController]

public class JobtitleController : ControllerBase

{

private HRMBlueberryDbContext context = new HRMBlueberryDbContext();

[HttpGet("getall")]

public List<Jobtitle> GetChucvus()

{ return context.Jobtitles.ToList(); } } } namespace HRMBlueBerry.API { [Route("api/[controller]")] [ApiController]

public class EducationController : ControllerBase

{

private HRMBlueberryDbContext context = new HRMBlueberryDbContext();

[HttpGet("getall")] (adsbygoogle = window.adsbygoogle || []).push({});

public List<EDUCATIONLEVEL> Gettrinhdo()

{

return context.EDUCATIONLEVELS.ToList(); } } } namespace HRMBlueBerry.API { [Route("api/[controller]")] [ApiController]

public class SalaryController : ControllerBase

{

private HRMBlueberryDbContext context = new HRMBlueberryDbContext();

[HttpGet("getall")]

public List<Salary> Gethopdongs()

{ return context.Salarys.ToList(); } } } API Biểu đồ namespace HRMBlueBerry.API { [Route("api/[controller]")] [ApiController]

public class DashboardController : ControllerBase

{

private HRMBlueberryDbContext context = new HRMBlueberryDbContext();

[HttpGet("GetCount")]

public object GetCount()

{ int pb = context.Departments.Count(); int nv = context.Employees.Count(); int wo = context.WorkOrders.Count(); return new { pb, nv, wo }; } } }

Đồ án tốt nghiệp đại học – Khóa 2017 – 2021 Trường ĐHBRVT

Model

Dbcontext- kết nối cơ sở dữ liệu

namespace HRMBlueBerry.Models.Dbcontext

{

public class HRMBlueberryDbContext: DbContext

{

public HRMBlueberryDbContext() : base(new

DbContextOptionsBuilder<HRMBlueberryDbContext>().UseSqlServer("Server = .\\SQLEXPRESS; Initial catalog =HRMBlueberry; UID = sa; PWD = Hienit").Options)

{ }

public DbSet<Employee> Employees { get; set; }

public DbSet<Department> Departments { get; set; }

public DbSet<Contract> Contracts { get; set; }

public DbSet<Dependent> Dependents { get; set; }

public DbSet<EDUCATIONLEVEL> EDUCATIONLEVELS { get; set; } (adsbygoogle = window.adsbygoogle || []).push({});

public DbSet<Experience> Experiences { get; set; }

public DbSet<InfoContact> InfoContacts { get; set; }

public DbSet<Jobtitle> Jobtitles { get; set; }

//public DbSet<Majors> Majors { get; set; }

public DbSet<Salary> Salarys { get; set; }

public DbSet<Skill> Skills { get; set; }

public DbSet<GroupUser.Group> groups { get; set; } public DbSet<GroupUser.Function> functions { get; set; }

public DbSet<GroupUser.Screen> screens { get; set; }

public DbSet<GroupUser.Permission> permissions { get; set; }

public DbSet<WorkOrder> WorkOrders { get; set; }

} }

Group User

namespace HRMBlueBerry.Models.GroupUser

{

public class AuditInformation

{

public DateTime CreatedDate { get; set; }

[MaxLength(30)]

public string CreatedBy { get; set; }

public DateTime? UpdatedDate { get; set; }

[MaxLength(30)]

Một phần của tài liệu đồ án tốt nghiệp website quản lý nhân sự cho doanh nghiệp – HRM blueberry (Trang 71 - 124)