private void Search() { _projectDataContext = new ProjectDataContext(); _shiftRepository = new ShiftRepository(_projectDataContext); dgvDuLieu.DataSource = _shiftRepository.GetAll().OrderBy(_ => _.ShiftNo); Control(); }
private void frmScanBarcode_Load(object sender, EventArgs e) { _projectDataContext = new ProjectDataContext(); _scanBarcodeRepository = new ScanBarcodeRepository(_projectDataContext); _registBarcodeRepository = new RegistBarcodeRepository(_projectDataContext); _partNumberRepository = new PartNumberRepository(_projectDataContext); _machineRepository = new MachineRepository(_projectDataContext); _moldRepository = new MoldRepository(_projectDataContext); _shiftRepository = new ShiftRepository(_projectDataContext); LanguageTranslate.ChangeLanguageForm(this); LoadCount(); LoadPartNumberData(); LoadMachineData(); LoadMoldData(); _serialPort = new SerialPort(); _serialPort.DataReceived += new SerialDataReceivedEventHandler(this.serialPort_DataReceived); Control.CheckForIllegalCrossThreadCalls = false; ClosePortCOM(GlobalConstants.portCOM); OpenPortCOM(GlobalConstants.portCOM, 9600); timer.Enabled = true; txtBarcode.Focus(); }
private void frmShift_Load(object sender, EventArgs e) { _shiftRepository = new ShiftRepository(_projectDataContext); LanguageTranslate.ChangeLanguageForm(this); LanguageTranslate.ChangeLanguageGridView(viewDuLieu); Search(); }
public void SaveNewAction(int userID, int loggingType, DateTime loggingDate, int deviceID ) { List<Shift> userShift = new List<Shift>(); ShiftRepository shiftRepository = new ShiftRepository(); ActionState actionState= new ActionState(); userShift = shiftRepository.FindByUserIDAndDate(userID, loggingDate, actionState); }
public void ShouldNotReturnShiftsForDateInTheFuture() { var repository = new ShiftRepository(mockDbContext.Object); var shifts = repository.GetShiftsSince(DateTime.Now.AddDays(10)); Assert.Equal(0, shifts.Count); }
public void ShouldReturnShiftsSince() { var repository = new ShiftRepository(mockDbContext.Object); var shifts = repository.GetShiftsSince(DateFixture.ThreeDaysAgo); Assert.Equal(6, shifts.Count); }
public DataManager() { cont = new ModelContainer(); branchRepository = new BranchRepository(cont); categoryRepository = new CategoryRepository(cont); checkDishRepository = new CheckDishRepository(cont); checkMerchandiseRepository = new CheckMerchandiseRepository(cont); clientRepository = new ClientRepository(cont); companyOwnerRepository = new CompanyOwnerRepository(cont); companyRepository = new CompanyRepository(cont); contactPersonRepository = new ContactPersonRepository(cont); dishRepository = new DishRepository(cont); documentRepository = new DocumentRepository(cont); ejectionRepository = new EjectionRepository(cont); employeeRepository = new EmployeeRepository(cont); encashmentRepository = new EncashmentRepository(cont); landlordRepository = new LandlordRepository(cont); orderRepository = new OrderRepository(cont); personRepository = new PersonRepository(cont); positionRepository = new PositionRepository(cont); prepackRepository = new PrepackRepository(cont); productRepository = new ProductRepository(cont); purchaseRepository = new PurchaseRepository(cont); recipeDishIngrRepository = new RecipeDishIngrRepository(cont); recipeDishPrepRepository = new RecipeDishPrepRepository(cont); recipePrepIngrRepository = new RecipePrepIngrRepository(cont); recipePrepPrepRepository = new RecipePrepPrepRepository(cont); roomRepository = new RoomRepository(cont); shiftRepository = new ShiftRepository(cont); tableRepository = new TableRepository(cont); warehouseRepository = new WarehouseRepository(cont); }
public TimeClockUnitOfWork(TimeClockContext context) { _context = context; Employees = new EmployeeRepository(_context); Shifts = new ShiftRepository(_context); IncompleteShifts = new IncompleteShiftRepository(_context); }
public ShiftsController() { _context = new ApplicationDbContext(); _shiftRepository = new ShiftRepository(_context); _employeeRepository = new EmployeeRepository(_context); _departmentRepository = new DepartmentRepository(_context); }
/// <summary> /// شیفت یک روز را برمیگرداند /// </summary> /// <param name="personId"></param> /// <param name="date"></param> /// <returns></returns> public string GetDayShiftByWorkGroup(decimal workGroupID, string date) { try { DateTime dayDate; if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { dayDate = Utility.ToMildiDate(date); } else { dayDate = Utility.ToMildiDateTime(date); } decimal?shiftId = new ShiftRepository(false).GetShiftIdByWorkGroupId(workGroupID, dayDate); if (shiftId == null || shiftId == 0) { return(""); } return(new ShiftRepository(false).GetById((decimal)shiftId, false).Name); } catch (Exception ex) { LogException(ex, "BExceptionShift", "GetDayShift"); throw ex; } }
/// <summary> /// شیفت یک روز را برمیگرداند /// </summary> /// <param name="personId"></param> /// <param name="date"></param> /// <returns></returns> public string GetDayShiftByPersonId(decimal personId, string date) { try { DateTime dayDate; if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { dayDate = Utility.ToMildiDate(date); } else { dayDate = Utility.ToMildiDateTime(date); } Shift shift = new ShiftRepository(false).GetShiftByPerson(personId, dayDate); if (shift == null) { return(""); } return(shift.Name); } catch (Exception ex) { LogException(ex, "BExceptionShift", "GetDayShift"); throw ex; } }
public void SetUp() { var mapper = DtoMappings.GetMapperConfiguration().CreateMapper(); _shiftRepository = new ShiftRepository(_connection); _assignmentRepository = new AssignmentRepository(_connection, mapper); _planRepository = new PlanRepository(_connection, mapper); }
public DialysisService(DialysisRepository repository, ShiftRepository shiftRepository, PatientRepository patientRepository, MessageRepository messageRepository, IUnitWork unitWork, IOptions <MyOptions> optionsAccessor) { _repository = repository; _shiftRepository = shiftRepository; _patientRepository = patientRepository; _messageRepository = messageRepository; _unitWork = unitWork; _optionsAccessor = optionsAccessor.Value; }
public ShiftInfoModel GetShiftInfo(ShiftSearchModel searchModel) { ShiftInfoModel info = new ShiftInfoModel(); DataContext dc = new DataContext(this.DbString); IShiftRepository rep = new ShiftRepository(dc); IQueryable <Shift> results = rep.Search(searchModel); info.shiftCount = dc.Context.GetTable <Shift>().Where(c => c.id.Equals(results.Count() > 0 ? results.First().id : -1)).Count(); return(info); }
/// <summary> /// /// </summary> /// <param name="obj"></param> protected override void DeleteValidate(NobatKari nobatKari) { ShiftRepository shiftRep = new ShiftRepository(false); int count = shiftRep.GetCountByCriteria(new CriteriaStruct(Utility.GetPropertyName(() => new Shift().NobatKari), nobatKari)); if (count > 0) { NHibernateSessionManager.Instance.RollbackTransactionOn(); UIValidationExceptions exception = new UIValidationExceptions(); exception.Add(ExceptionResourceKeys.NobatKariUsedByShift, "این نوبت کاری به شیفت انتساب داده شده است", ExceptionSrc); throw exception; } }
private void frmShiftAddEdit_Load(object sender, EventArgs e) { _shiftRepository = new ShiftRepository(_projectDataContext); LanguageTranslate.ChangeLanguageForm(this); if (String.IsNullOrEmpty(_id)) { Clear(); } else { GetData(); } }
private void frmSignIn_Load(object sender, EventArgs e) { _userRepository = new UserRepository(_projectDataContext); _languageLibraryRepository = new LanguageLibraryRepository(_projectDataContext); _shiftRepository = new ShiftRepository(_projectDataContext); _machineRepository = new MachineRepository(_projectDataContext); LoadLanguage(GlobalConstants.language); LanguageTranslate.ChangeLanguageForm(this); chkKeepMeSignedIn.Checked = Properties.Settings.Default.KeepMeSignedIn; if (chkKeepMeSignedIn.Checked) { txtUsername.Text = Properties.Settings.Default.Username; txtPassword.Text = Properties.Settings.Default.Password; } }
private void frmRegistBarcodeAddEdit_Load(object sender, EventArgs e) { _registBarcodeRepository = new RegistBarcodeRepository(_projectDataContext); _partNumberRepository = new PartNumberRepository(_projectDataContext); _machineRepository = new MachineRepository(_projectDataContext); _moldRepository = new MoldRepository(_projectDataContext); _shiftRepository = new ShiftRepository(_projectDataContext); LanguageTranslate.ChangeLanguageForm(this); LoadPartNumberData(); LoadMachineData(); LoadShiftData(); LoadMoldData(); if (String.IsNullOrEmpty(_id)) { Clear(); } else { Close(); } }
protected void Page_Load(object sender, EventArgs e) { if (this.Request.QueryString["command"] == "delete") { var shiftRepository = new ShiftRepository(); var shiftId = this.Request.QueryString["shiftId"]; int shiftIdInt; if (int.TryParse(shiftId, out shiftIdInt)) { shiftRepository.RemoveShift(shiftIdInt); } this.GoToShiftMainPage(); } if (!this.IsPostBack) { var shiftIdString = this.Request.QueryString["shiftId"]; if (string.IsNullOrEmpty(shiftIdString)) { // New shift } else { // Edit shift int shiftId; if (int.TryParse(shiftIdString, out shiftId)) { this.BindShift(shiftId); } else { this.GoToShiftMainPage(); } } } this.RefreshGrid(); }
public void ExchangeDayByWorkGroup(decimal workGroupId, string firstDay, string secondDay) { UIValidationExceptions exception = new UIValidationExceptions(); if (workGroupId == 0) { exception.Add(ExceptionResourceKeys.ExceptionShiftWorkGroupIdRequierd, "شناسه گروه کاری مشخص نشده است", ExceptionSrc); } if (exception.Count > 0) { throw exception; } using (NHibernateSessionManager.Instance.BeginTransactionOn()) { try { DateTime firstDate, secondDate; if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { firstDate = Utility.ToMildiDate(firstDay); secondDate = Utility.ToMildiDate(secondDay); } else { firstDate = Utility.ToMildiDateTime(firstDay); secondDate = Utility.ToMildiDateTime(secondDay); } ISearchPerson searchTool = new BPerson(); PersonAdvanceSearchProxy proxy = new PersonAdvanceSearchProxy(); proxy.WorkGroupId = workGroupId; proxy.WorkGroupFromDate = Utility.ToString(firstDate); int count = searchTool.GetPersonInAdvanceSearchCount(proxy); IList <Person> persons = searchTool.GetPersonInAdvanceSearch(proxy, 0, count); foreach (Person prs in persons) { decimal personId = prs.ID; objectRep.DeleteExceptionShift(personId, firstDate, firstDate); objectRep.DeleteExceptionShift(personId, secondDate, secondDate); ShiftRepository shiftRep = new ShiftRepository(); decimal? shift1 = shiftRep.GetShiftIdByPersonId(personId, firstDate); decimal? shift2 = shiftRep.GetShiftIdByPersonId(personId, secondDate); ShiftException exShift = new ShiftException(); exShift.RegistrationDate = DateTime.Now.Date; exShift.Date = secondDate; exShift.Person = new Person() { ID = personId }; exShift.UserID = BUser.CurrentUser.ID; if (shift1 != null && shift1 > 0) { exShift.Shift = new Shift() { ID = (decimal)shift1 }; } else { exShift.Shift = null; } base.SaveChanges(exShift, UIActionType.ADD); exShift = new ShiftException(); exShift.RegistrationDate = DateTime.Now.Date; exShift.Date = firstDate; exShift.Person = new Person() { ID = personId }; exShift.UserID = BUser.CurrentUser.ID; if (shift2 != null && shift2 > 0) { exShift.Shift = new Shift() { ID = (decimal)shift2 }; } else { exShift.Shift = null; } base.SaveChanges(exShift, UIActionType.ADD); } NHibernateSessionManager.Instance.CommitTransactionOn(); } catch (Exception ex) { NHibernateSessionManager.Instance.RollbackTransactionOn(); LogException(ex, "BExceptionShift", "ExchangeDayByWorkGroup"); throw ex; } } }
public void ExchangePerson(decimal personId1, decimal personId2, string date1, string date2) { UIValidationExceptions exception = new UIValidationExceptions(); if (personId1 == 0 || personId2 == 0) { exception.Add(ExceptionResourceKeys.ExceptionShiftPersonIdRequierd, "شناسه پرسنل مشخص نشده است", ExceptionSrc); } if (exception.Count > 0) { throw exception; } using (NHibernateSessionManager.Instance.BeginTransactionOn()) { try { DateTime dayDate1, dayDate2; if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { dayDate1 = Utility.ToMildiDate(date1); dayDate2 = Utility.ToMildiDate(date2); } else { dayDate1 = Utility.ToMildiDateTime(date1); dayDate2 = Utility.ToMildiDateTime(date2); } objectRep.DeleteExceptionShift(personId1, dayDate1, dayDate1); objectRep.DeleteExceptionShift(personId1, dayDate2, dayDate2); objectRep.DeleteExceptionShift(personId2, dayDate2, dayDate2); objectRep.DeleteExceptionShift(personId2, dayDate1, dayDate1); ShiftRepository shiftRep = new ShiftRepository(); decimal? shift1 = shiftRep.GetShiftIdByPersonId(personId1, dayDate1); decimal? shift2 = shiftRep.GetShiftIdByPersonId(personId2, dayDate2); ShiftException exShift = new ShiftException(); exShift.RegistrationDate = DateTime.Now.Date; exShift.Date = dayDate1; exShift.Person = new Person() { ID = personId2 }; exShift.UserID = BUser.CurrentUser.ID; if (shift1 != null && shift1 > 0) { exShift.Shift = new Shift() { ID = (decimal)shift1 }; } else { exShift.Shift = null; } base.SaveChanges(exShift, UIActionType.ADD); exShift = new ShiftException(); exShift.RegistrationDate = DateTime.Now.Date; exShift.Date = dayDate2; exShift.Person = new Person() { ID = personId1 }; exShift.UserID = BUser.CurrentUser.ID; if (shift2 != null && shift2 > 0) { exShift.Shift = new Shift() { ID = (decimal)shift2 }; } else { exShift.Shift = null; } base.SaveChanges(exShift, UIActionType.ADD); NHibernateSessionManager.Instance.CommitTransactionOn(); } catch (Exception ex) { NHibernateSessionManager.Instance.RollbackTransactionOn(); LogException(ex, "BExceptionShift", "ExchangePerson"); throw ex; } } }
public void ExchangeWorkGroup(decimal workGroup1, decimal workGroup2, string date1, string date2) { UIValidationExceptions exception = new UIValidationExceptions(); if (workGroup1 == 0 || workGroup2 == 0) { exception.Add(ExceptionResourceKeys.ExceptionShiftWorkGroupIdRequierd, "شناسه گروه کاری مشخص نشده است", ExceptionSrc); } if (exception.Count > 0) { throw exception; } using (NHibernateSessionManager.Instance.BeginTransactionOn()) { try { DateTime dayDate1, dayDate2; if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { dayDate1 = Utility.ToMildiDate(date1); dayDate2 = Utility.ToMildiDate(date2); } else { dayDate1 = Utility.ToMildiDateTime(date1); dayDate2 = Utility.ToMildiDateTime(date2); } ISearchPerson searchTool = new BPerson(); PersonAdvanceSearchProxy proxy = new PersonAdvanceSearchProxy(); proxy.WorkGroupId = workGroup1; proxy.WorkGroupFromDate = Utility.ToString(dayDate1); int count = searchTool.GetPersonInAdvanceSearchCount(proxy); IList <Person> persons1 = searchTool.GetPersonInAdvanceSearch(proxy, 0, count); proxy = new PersonAdvanceSearchProxy(); proxy.WorkGroupId = workGroup2; proxy.WorkGroupFromDate = Utility.ToString(dayDate2); count = searchTool.GetPersonInAdvanceSearchCount(proxy); IList <Person> persons2 = searchTool.GetPersonInAdvanceSearch(proxy, 0, count); ShiftRepository shiftRep = new ShiftRepository(false); decimal? shift1 = shiftRep.GetShiftIdByWorkGroupId(workGroup1, dayDate1); decimal? shift2 = shiftRep.GetShiftIdByWorkGroupId(workGroup2, dayDate2); foreach (Person prs in persons2) { decimal personId2 = prs.ID; objectRep.DeleteExceptionShift(personId2, dayDate2, dayDate2); objectRep.DeleteExceptionShift(personId2, dayDate1, dayDate1); ShiftException exShift = new ShiftException(); exShift.Date = dayDate1; exShift.Person = new Person() { ID = personId2 }; exShift.RegistrationDate = DateTime.Now; if (shift1 != null && shift1 > 0) { exShift.Shift = new Shift() { ID = (decimal)shift1 }; } else { exShift.Shift = null; } base.SaveChanges(exShift, UIActionType.ADD); } foreach (Person prs in persons1) { decimal personId1 = prs.ID; objectRep.DeleteExceptionShift(personId1, dayDate2, dayDate2); objectRep.DeleteExceptionShift(personId1, dayDate1, dayDate1); ShiftException exShift = new ShiftException(); exShift.Date = dayDate2; exShift.Person = new Person() { ID = personId1 }; exShift.RegistrationDate = DateTime.Now; if (shift2 != null && shift2 > 0) { exShift.Shift = new Shift() { ID = (decimal)shift2 }; } else { exShift.Shift = null; } base.SaveChanges(exShift, UIActionType.ADD); } NHibernateSessionManager.Instance.CommitTransactionOn(); } catch (Exception ex) { NHibernateSessionManager.Instance.RollbackTransactionOn(); LogException(ex, "BExceptionShift", "ExchangeWorkGroup"); throw ex; } } }
public List <Shift> All() { IShiftRepository rep = new ShiftRepository(new DataContext(this.DbString)); return(rep.All()); }
private void UpdateShift(Shift shift) { var shiftRepository = new ShiftRepository(); shiftRepository.UpdateShift(shift); }
public ShiftService(ShiftRepository repository, IUnitWork unitWork) { _repository = repository; _unitWork = unitWork; }
private void BindShift(int shiftId) { var shiftRepository = new ShiftRepository(); var shift = shiftRepository.GetShift(shiftId); if (shift == null) { this.GoToShiftMainPage(); return; } var date = new DateTime(2000, 1, 1); hfShiftId.Value = shift.Id.ToString(CultureInfo.InvariantCulture); txtTitle.Text = shift.Title; tprBeginShift.SelectedDate = date + shift.BeginShift; tprEndShift.SelectedDate = date + shift.EndShift; }
private void AddShift(Shift shift) { var shiftRepository = new ShiftRepository(); shiftRepository.AddShift(shift); Globals.NavigateURL(this.TabId); }
public void SetUp() { _timeEntryRepository = new TimeEntryRepository(this._connection); _shiftRepository = new ShiftRepository(this._connection); }
public void FindEngineersAvailableOn_Check_Consecutive_Days(DateTime date, int nEngineers) { string contextName = $"FindEngineersAvailableOn_Check_Consecutive_Days"; _contextNames.Add(contextName); DbContextOptions <BAUDbContext> options = DbContextUtils.GetContextOptions(contextName); IShiftRepository repository = null; const int shiftDuration = 4; // fake data using (BAUDbContext context = new BAUDbContext(options)) { var engineer1 = new Engineer { Name = "1" }; var engineer2 = new Engineer { Name = "2" }; var engineer3 = new Engineer { Name = "3" }; var engineer4 = new Engineer { Name = "4" }; var engineer5 = new Engineer { Name = "5" }; var engineer6 = new Engineer { Name = "6" }; var engineer7 = new Engineer { Name = "7" }; var engineer8 = new Engineer { Name = "8" }; var engineer9 = new Engineer { Name = "9" }; var engineer10 = new Engineer { Name = "10" }; var engineersList = new List <Engineer> { engineer1, engineer2, engineer3, engineer4, engineer5, engineer6, engineer7, engineer8, engineer9, engineer10, }; context.Engineers.AddRange(engineersList); var today = new DateTime(2017, 12, 11); var shifts = new List <EngineerShift> { //first week new EngineerShift { Date = today.Date, Duration = shiftDuration, Engineer = engineer1 }, new EngineerShift { Date = today.Date, Duration = shiftDuration, Engineer = engineer2 }, new EngineerShift { Date = today.Date.AddDays(1), Duration = shiftDuration, Engineer = engineer7 }, new EngineerShift { Date = today.Date.AddDays(2), Duration = shiftDuration, Engineer = engineer3 }, new EngineerShift { Date = today.Date.AddDays(2), Duration = shiftDuration, Engineer = engineer4 }, new EngineerShift { Date = today.Date.AddDays(4), Duration = shiftDuration, Engineer = engineer5 }, new EngineerShift { Date = today.Date.AddDays(4), Duration = shiftDuration, Engineer = engineer6 }, }; context.EngineersShifts.AddRange(shifts); context.SaveChanges(); } // test using (var context = new BAUDbContext(options)) { repository = new ShiftRepository(context, ConfigurationTestBuilder.GetConfiguration()); IList <Engineer> availableEngineers = repository.FindEngineersAvailableOn(date); Assert.Equal(nEngineers, availableEngineers.Count); } }
public ShiftService() { repo = new ShiftRepository(); }
public ShiftController(ShiftRepository repo) { _repo = repo; }
public ShiftRepositoryTests() { RepositoryUnderTest = new ShiftRepository(); }
private IEnumerable<Shift> GetDataSource() { var shiftRepository = new ShiftRepository(); return shiftRepository.GetShifts(); }
public HomeController() { _employeeRepository = EmployeeRepository.Instance; _shiftRepository = ShiftRepository.Instance;; }