public async Task <IHttpActionResult> GetStaff(int id) { Staff a = await db.Staffs.FindAsync(id); if (a == null) { return(NotFound()); } StaffDTO staff = new StaffDTO { Id = a.Id, LName = a.LName, FName = a.FName, EmployedDate = a.EmployedDate, Flights = a.Flights.Select(b => new FlightDTO() { Id = b.Id, Code = b.Code, DestPlace = b.DestPlace, FlightDate = b.FlightDate } ).ToList() }; return(Ok(staff)); }
private void textBoxCapNhatMaNhanVien_TextChanged(object sender, TextChangedEventArgs e) { StaffDTO staffDTO = StaffBUS.Instance.FindStaffByID(textBoxCapNhatMaNhanVien.Text); if (staffDTO != null) { textBoxCapNhatHoTen.Text = staffDTO.Name; textBoxCapNhatDiaChi.Text = staffDTO.Address; textBoxCapNhatDienThoai.Text = staffDTO.PhoneNumber; textBoxCapNhatEmail.Text = staffDTO.Email; textBoxCapNhatCMND.Text = staffDTO.IdentityNumber; comboBoxCapNhatViTri.Text = staffPositionsIDToName[staffDTO.PositionID]; textBoxCapNhatMucLuong.Text = staffDTO.Salary.ToString(); } else { textBoxCapNhatHoTen.Text = ""; textBoxCapNhatDiaChi.Text = ""; textBoxCapNhatDienThoai.Text = ""; textBoxCapNhatEmail.Text = ""; textBoxCapNhatCMND.Text = ""; comboBoxCapNhatViTri.Text = ""; textBoxCapNhatMucLuong.Text = ""; } }
private void AddNewStaff() { try { SelectedStaff = new StaffDTO { Code = _staffService.GetStaffCode(), Type = StaffTypes.OfficeStaff, EducationLevel = EducationLevelTypes.Elementary, IsActive = true, Sex = Sex.Male, Address = new AddressDTO { Country = "Ethiopia", City = "Addis Abeba" }, }; SelectedStaff.ContactPerson = new ContactPersonDTO() { DisplayName = "-", Address = new AddressDTO { Country = "Ethiopia", City = "Addis Abeba" } }; EmployeeShortImage = new BitmapImage(); } catch (Exception) { //MessageBox.Show("Problem on adding new staff"); } }
public bool TestAddStaffToLocation() { using (var scope = services.CreateScope()) { var locationService = scope.ServiceProvider.GetService <ILocationService>(); var locationRepo = scope.ServiceProvider.GetService <IRepository <Location> >(); LocationDTO locationDTO = new LocationDTO() { Name = "Test location", Address = "E la tara", Capacity = 2, RentFee = 2200 }; int locationId = locationService.CreateLocation(locationDTO); StaffDTO staffDTO = new StaffDTO() { Id = 1059, FirstName = "Cosmin1", LastName = "Popescu", Email = "*****@*****.**", Phone = "0745600566", Fee = 1500, StaffRoleId = 2 }; StaffDTO staffDTO1 = new StaffDTO() { Id = 0, FirstName = "Becks", LastName = "LA1L", Email = "*****@*****.**", Phone = "0789898989", Fee = 8, StaffRoleId = 3 }; List <StaffDTO> staffDTOs = new List <StaffDTO>() { staffDTO, staffDTO1 }; locationService.AddStaffLocation(staffDTOs, locationId); int numberOfTotalStaffOfNewLocation = locationRepo.Query().Include(l => l.Staffs).Where(l => l.Id == locationId).FirstOrDefault().Staffs.Count; return(numberOfTotalStaffOfNewLocation == 2); } }
private void buttonCapNhat_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(textBoxThemHoTen.Text) || string.IsNullOrEmpty(comboBoxThemViTri.Text) || string.IsNullOrEmpty(textBoxThemMucLuong.Text)) { MessageBox.Show("Xin hãy nhập những trường thông tin cần thiết", "!!!", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (MessageBox.Show("Bạn có chắc chắn muốn cập nhật không?", "!!!", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { StaffDTO staffDTO = new StaffDTO(textBoxCapNhatMaNhanVien.Text, textBoxCapNhatHoTen.Text, textBoxCapNhatDiaChi.Text, textBoxCapNhatDienThoai.Text, textBoxCapNhatEmail.Text, textBoxCapNhatCMND.Text, staffPositionsNameToID[comboBoxThemViTri.Text], decimal.Parse(textBoxCapNhatMucLuong.Text)); try { StaffBUS.Instance.UpdateStaff(staffDTO); MessageBox.Show("Cập nhật nhân viên thành công", "Thành công", MessageBoxButton.OK, MessageBoxImage.Information); textBoxThemMaNhanVien.Text = StaffBUS.Instance.GetNewStaffID(); DisplayAllStaffs(); } catch (BUSException ex) { MessageBox.Show(ex.ToString(), "!!!", MessageBoxButton.OK, MessageBoxImage.Error); } } }
public string Validate(StaffDTO staff) { if (null == staff) { return(GenericMessages.ObjectIsNull); } if (staff.Address == null) { return("Address " + GenericMessages.ObjectIsNull); } if (String.IsNullOrEmpty(staff.DisplayName)) { return(staff.DisplayName + " " + GenericMessages.StringIsNullOrEmpty); } if (staff.DisplayName.Length > 255) { return(staff.DisplayName + " can not be more than 255 characters "); } if (!string.IsNullOrEmpty(staff.Code) && staff.Code.Length > 50) { return(staff.Code + " can not be more than 50 characters "); } return(string.Empty); }
public StaffDTO GetDepartmentLeader(Guid departmentId) { var result = new StaffDTO(); SessionManager.DoWork(session => { Staff st = ControllerHelpers.GetCurrentStaff(session); //Nếu ở bộ môn vào ko có chức vụ => giảng viên if (st.StaffInfo.Subject != null && st.StaffInfo.Position == null) { //Lấy trưởng bộ môn Staff staff = session.Query <Staff>().FirstOrDefault(s => s.StaffInfo.Subject != null && s.StaffInfo.Subject.Id == st.StaffInfo.Subject.Id && s.StaffInfo.Position != null && s.StaffInfo.Position.AgentObjectType.Id == 6); if (staff != null) { result = ParseStaff(staff); } } else { if (departmentId != Guid.Empty) { Staff staff = session.Query <Staff>().FirstOrDefault(s => s.Department.Id == departmentId && (s.StaffInfo.Position.AgentObjectType.Id == 3 || s.StaffInfo.Position.AgentObjectType.Id == 5)); if (staff != null) { result = ParseStaff(staff); } } } }); return(result); }
public bool ObjectExists(StaffDTO staff) { var objectExists = false; var iDbContext = DbContextUtil.GetDbContextInstance(); try { var catRepository = new Repository <StaffDTO>(iDbContext); var catExists = catRepository.Query() .Filter(bp => (bp.DisplayName == staff.DisplayName) && bp.Id != staff.Id) .Get() .FirstOrDefault(); if (catExists != null) { objectExists = true; } } finally { iDbContext.Dispose(); } return(objectExists); }
public string Disable(StaffDTO staff) { //if (_unitOfWork.Repository<DeliveryHeaderDTO>().Query().Get().Any(i => i.StaffId == staff.Id) || // _unitOfWork.Repository<DocumentDTO>().Query().Get().Any(i => i.StaffId == staff.Id)) //{ // return "Can't delete the item, it is already in use..."; //} if (staff == null) { return(GenericMessages.ObjectIsNull); } string stat; try { _staffRepository.Update(staff); _unitOfWork.Commit(); stat = string.Empty; } catch (Exception exception) { stat = exception.Message; } return(stat); }
public string InsertOrUpdate(StaffDTO staff) { try { var validate = Validate(staff); if (!string.IsNullOrEmpty(validate)) { return(validate); } if (ObjectExists(staff)) { return(GenericMessages.DatabaseErrorRecordAlreadyExists + Environment.NewLine + "With the same name exists"); } _staffRepository.InsertUpdate(staff); _unitOfWork.Commit(); return(string.Empty); } catch (Exception exception) { return(exception.Message); } }
public ActionResult StaffInfo(StaffDTO dto, string actionStr) { //如果为更新 则移除 password 验证 if (actionStr == "update") { ModelState.Remove("Password"); } if (ModelState.IsValid) { //添加 if (actionStr == "insert") { string result = StaffSrv.InsertStaff(dto); if (!string.IsNullOrEmpty(result) && result != "-2") { result = "1"; } return(Content(result, "text/plain")); } else if (actionStr == "update") { //编辑 StaffSrv.UpdateStaff(dto); return(Content("1", "text/plain")); } } //获取ErrorMessage string errorMsg = ModelState.Values.First(x => x.Errors.Count > 0).Errors[0].ErrorMessage; return(Content(errorMsg, "text/plain")); }
private void btn_luu_customer_Click_1(object sender, EventArgs e) { string a; if (check_erro() == true) { if (Radio_Nam.Checked == true) { a = Radio_Nam.Text; } else { a = Radio_Nu.Text; } StaffDTO b = new StaffDTO(tb_user.Text, tb_manv.Text, tb_ten_nv.Text, date_nv.Value, tb_dia_chi.Text, tb_phone.Text, a, cb_loainv.Text); if (StaffBUS.Instance.insert_staff(b, tb_user.Text, tb_email.Text, tb_password.Text) == true) { MessageBox.Show("Thêm thành công"); this.Close(); } else { MessageBox.Show("Thêm không thành công"); } //this.Close(); } }
public void AddSubordinate(StaffDTO mentorStaffDto, StaffDTO subordinateStaffDTO) { FixStaffDTO(mentorStaffDto); FixStaffDTO(subordinateStaffDTO); mentorStaffDto.AddSubordinate(subordinateStaffDTO.Id); _repository.Update(mentorStaffDto.ToStaffDAL()); }
public void FixStaffDTO(StaffDTO staffDTO) { var staffDAL = staffDTO.ToStaffDAL(); _repository.Fix(staffDAL); staffDTO.Id = staffDAL.Id; }
public void AddStaff(StaffDTO staff) { var s = Mapper.Map <StaffDTO, Staff>(staff); Database.Staffs.Create(s); Database.Save(); }
/// <summary> /// Business logic for creating staff records in database /// </summary> /// <param name="userID"></param> /// <param name="superUser"</param> /// <returns>BLL result object</returns> internal object AddStaffBLL(int userID, bool superUser) { // Create a new APIException object to store possible exceptions as checks are performed. APIException exceptionList = new APIException(); Dictionary <string, bool> exceptionTests = new Dictionary <string, bool>() { { "Specified userID does not exist", !_context.Users.Any(x => x.UserID == userID) } }; foreach (KeyValuePair <string, bool> kvp in exceptionTests) { if (kvp.Value) { exceptionList.AddExMessage(kvp.Key); } } if (!exceptionList.HasExceptions) { StaffDTO newStaff = new StaffDTO { UserID = userID, SuperUser = superUser }; return(newStaff); } else { return(exceptionList); } } // End of AddStaffBLL
} // End of AddStaffBLL /// <summary> /// Business logic for modifying Staff records /// </summary> /// <param name="staff"></param> /// <returns></returns> internal object ModifyUserBLL(StaffDTO staff) { APIException exceptionList = new APIException(); Dictionary <string, bool> exceptionTests = new Dictionary <string, bool>() { { "Specified UserID does not exist", !_context.Users.Any(x => x.UserID == staff.UserID) }, { "Specified StaffID does not exist", !_context.Staff.Any(x => x.StaffID == staff.StaffID) } }; foreach (KeyValuePair <string, bool> kvp in exceptionTests) { if (kvp.Value) { exceptionList.AddExMessage(kvp.Key); } } if (!exceptionList.HasExceptions) { return(staff); } else { return(exceptionList); } } // End of ModifyStaff
public async Task UpdateSaveAsync(StaffDTO dto) { using (UCDbContext ctx = new UCDbContext()) { var id = dto.Id; var entity = await ctx.Staffs.Where(s => s.Id == id).FirstOrDefaultAsync(); if (entity == null) { throw new Exception("编辑的人员不存在"); } entity.JobTitle = dto.JobTitle; entity.ParentId = dto.ParentId; entity.PhoneNumber = dto.PhoneNumber; entity.ResignationDate = dto.ResignationDate; entity.StaffCode = dto.StaffCode; entity.Telephone = dto.Telephone; entity.Birthday = dto.Birthday; entity.CALLNumber = dto.CALLNumber; entity.ChName = dto.ChName; entity.DepartmentId = dto.DepartmentId; entity.EmploymentDate = dto.EmploymentDate; entity.EnName = dto.EnName; entity.Email = dto.Email; entity.Email = dto.Remark; entity.UpdateTime = dto.UpdateTime; entity.UserName = dto.UserName; await ctx.SaveChangesAsync(); } }
public async Task <IActionResult> CreateStaff(StaffDTO staffDto) { var staff = _mapper.Map <StaffDTO, Staff>(staffDto); await _repository.Add(staff); return(CreatedAtAction(nameof(GetStaff), new { id = staff.StaffId }, staff)); }
/// <summary> /// 编辑用户 /// </summary> /// <param name="Id"></param> /// <returns></returns> public ActionResult StaffEdit(string Id) { ViewBag.actionStr = "update"; var staffDomain = Gecko.Security.Service.StaffSrv.GetStaffByLoginId(Id); StaffDTO dto = new StaffDTO(); dto.LoginId = staffDomain.LoginId; dto.Name = staffDomain.Name; dto.Disabled = staffDomain.Disabled; dto.OrderId = staffDomain.OrderId; dto.IdCard = staffDomain.IdCard; dto.Code = staffDomain.Code; dto.OfficePhone = staffDomain.OfficePhone; dto.ExtNumber = staffDomain.ExtNumber; dto.CellPhone = staffDomain.CellPhone; dto.FamilyPhone = staffDomain.FamilyPhone; dto.Email = staffDomain.Email; dto.ZipCode = staffDomain.ZipCode; dto.Remark = staffDomain.Remark; dto.Address = staffDomain.Address; dto.DegreeTag = staffDomain.DegreeTag; dto.Sex = staffDomain.Sex; dto.PoliticalAppearanceTag = staffDomain.PoliticalAppearanceTag; dto.Married = staffDomain.Married; dto.Birthday = staffDomain.Birthday; dto.CountryTag = staffDomain.CountryTag; dto.EntersDay = staffDomain.EntersDay; dto.NationTag = staffDomain.NationTag; dto.LeavesDay = staffDomain.LeavesDay; dto.PositionTag = staffDomain.PositionTag; dto.TitleTag = staffDomain.TitleTag; return(View("StaffInfo", dto)); }
private static Staff ToEntity(StaffDTO dto) { Staff entity = new Staff(); entity.StaffCode = dto.StaffCode; entity.ChName = dto.ChName; entity.EnName = dto.EnName; entity.Telephone = dto.Telephone; entity.PhoneNumber = dto.PhoneNumber; entity.CALLNumber = dto.CALLNumber; entity.DepartmentId = dto.DepartmentId; entity.JobTitle = dto.JobTitle; entity.Birthday = dto.Birthday; entity.EmploymentDate = dto.EmploymentDate; entity.ResignationDate = dto.ResignationDate; entity.ParentId = dto.ParentId ?? 1; entity.Email = dto.Email; entity.Remark = dto.Remark; entity.CreateDateTime = dto.CreateDateTime; entity.UpdateTime = dto.UpdateTime; entity.Status = dto.Status; entity.UserName = dto.UserName; return(entity); }
/// <summary> /// 更新职员。 /// </summary> /// <param name="dto">待更新职员的信息。</param> public static void UpdateStaff(StaffDTO dto) { Staff s = Db.Session.Load(typeof(Staff), dto.LoginId) as Staff; s.Name = dto.Name; s.Disabled = dto.Disabled; s.OrderId = dto.OrderId; s.IdCard = dto.IdCard; s.Code = dto.Code; s.OfficePhone = dto.OfficePhone; s.ExtNumber = dto.ExtNumber; s.CellPhone = dto.CellPhone; s.FamilyPhone = dto.FamilyPhone; s.Email = dto.Email; s.ZipCode = dto.ZipCode; s.Remark = dto.Remark; s.Address = dto.Address; s.DegreeTag = dto.DegreeTag; s.Sex = dto.Sex; s.PoliticalAppearanceTag = dto.PoliticalAppearanceTag; s.Married = dto.Married; s.Birthday = dto.Birthday; s.CountryTag = dto.CountryTag; s.EntersDay = dto.EntersDay; s.NationTag = dto.NationTag; s.LeavesDay = dto.LeavesDay; s.PositionTag = dto.PositionTag; s.TitleTag = dto.TitleTag; Db.TransUpdate(s); }
public async Task <IActionResult> Create(StaffDTO StaffDTO) { var Staff = _mapper.Map <StaffDTO, Staff>(StaffDTO); await _unitOfWork.Staff.Add(Staff); return(CreatedAtAction(nameof(GetBy), new { id = Staff.StaffId }, Staff)); }
public EditStaff(int id) { InitializeComponent(); try { StaffDTO staff = StaffDAO.Instance.GetStaffById(id); this.btnConfirm.Tag = staff; AccountDTO account = AccountDAO.Instance.GetAccountByIdUser(staff.Id); txtNameEmployee.Text = staff.Name; txtUserNameEmployee.Text = account.UserName; txtEmailEmployee.Text = staff.Email; txtPhoneEmployee.Text = staff.Phone; txtSalaryEmployee.Text = staff.Salary.ToString(); cmbPoition.SelectedIndex = staff.Position; if (staff.Sex == 1) { rdoMale.IsChecked = true; } else { rdoFemale.IsChecked = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public async Task <IActionResult> Put(Guid id, [FromBody] StaffDTO value) { var cmd = new UpdateStaffCommand(id, value); var result = await _mediator.Send(cmd); return(Ok(result)); }
public void RemoveSubordinate(StaffDTO mentorStaffDTO, StaffDTO subordinateStaffDTO) { FixStaffDTO(mentorStaffDTO); FixStaffDTO(subordinateStaffDTO); mentorStaffDTO.RemoveSubordinate(subordinateStaffDTO.Id); _repository.Update(mentorStaffDTO.ToStaffDAL()); }
public static void UpdateStaff(StaffDTO staff) { string strSql = "update NHANVIEN set ho_ten = N'" + staff.ten_nhan_vien + "' ,ngay_sinh = '" + staff.ngay_sinh + "', dia_chi = N'" + staff.dia_chi + "', dien_thoai = '" + staff.so_dien_thoai + "' where ma_nhan_vien = '" + staff.ma_nhan_vien + "'"; DataProvider.ExecNonQuery(strSql); }
public int CreateStaff(StaffDTO staff) { var newStaff = (Staff) new Staff().InjectFrom(staff); staffRepo.Add(newStaff); unitOfWork.Commit(); return(newStaff.Id); }
public int CreateDailyReport(StaffDTO staffDTO) { _staffService.FixStaffDTO(staffDTO); var reportDAL = new ReportDTO(-1, DateTime.Now, staffDTO.Id).ToReportDAL(); _repository.Create(reportDAL); return(reportDAL.Id); }
/// <summary> /// DEPRECATED. Build UserSessionProfileDTO manually through class properties instead /// </summary> /// <param name="staff"></param> /// <param name="association"></param> /// <returns></returns> public UserSessionProfile MapUserSessionProfile(StaffDTO staff, StaffEducationOrganizationAssignmentAssociation association) { return(new UserSessionProfile() { Staff = staff, StaffEducationOrganizationAssignmentAssociation = association, }); }
/// <summary> /// Selecteds the name of the user. /// </summary> /// <param name="userDT">The user DT.</param> private void SelectedUserName(StaffDTO userDetails) { UserName = userDetails.UserName; }