public bool IsExist(ClassTime model) { return _classTime.Count(X => X.DayEn == model.DayEn && X.ClassId == model.ClassId && X.TimeFrom == model.TimeFrom && X.TimeTo == model.TimeTo) != 0; }
public async Task ExecuteShouldChangePresenceForMemberAndGetPassEntry() { //Arrange SchoolManagementContext context = new ContextBuilder().BuildClean(); new RoleBuilder(context).WithName(Roles.Participant).BuildAndSave(); GroupClass groupClass = new GroupClassBuilder(context) .WithStartClasses(DateTime.Now) .WithTimeDurationInMinutes(90) .AddClassDayOfWeek(x => x.WithDate(DayOfWeek.Monday, new TimeSpan(18, 0, 0))) .AddParticipant(userBuilder => userBuilder.WithName("Piotr", "Kowalski"), ParticipantRole.Follower, passBuilder => passBuilder.WithNumberOfEntry(2)) .WithName("Boogie woogie") .WithNumberOfClasses(5) .CreateSchedule().BuildAndSave(); User participant = context.Users.First(); ClassTime classTime = context.ClassTimes.First(); Command command = new Command { ClassTimeId = classTime.Id, ParticipantId = participant.Id, IsPresence = true, PresenceType = PresenceType.Member }; //Act DataResult dataResult = await new Handler(context).Handle(command, CancellationToken.None); //Assert ParticipantClassTime participantClassTime = classTime.PresenceParticipants.First(); participantClassTime.WasPresence.Should().BeTrue("we set presence"); }
public static void GetLastInputTime() { uint idleTime = 0; LASTINPUTINFO lastInputInfo = new LASTINPUTINFO(); lastInputInfo.cbSize = Marshal.SizeOf(lastInputInfo); lastInputInfo.dwTime = 0; uint envTicks = (uint)Environment.TickCount; if (GetLastInputInfo(ref lastInputInfo)) { uint lastInputTick = lastInputInfo.dwTime; idleTime = envTicks - lastInputTick; if (idleTime >= 5000 * k) { ClassTime.inc(); k++; } if (lastInputTick != last) { last = lastInputTick; k = 1; } } }
public bool IsOverlap(ClassTime time) { var map = new TimeMap(); map.Set(time); return(IsOverlap(map)); }
public async Task <DataResult> Handle(Command request, CancellationToken cancellationToken) { ClassTime classTime = await _context.ClassTimes.Where(x => x.Id == request.Id) .Include(x => x.GroupClass) .FirstOrDefaultAsync(cancellationToken); ClassTimeAggregate.FromState(classTime) .WithDate(request.Start, request.End); //Update order List <ClassTime> allClasses = await _context.ClassTimes.Where(x => x.Id != request.Id) .Where(x => x.GroupClassId == classTime.GroupClassId) .OrderBy(x => x.StartDate) .ToListAsync(cancellationToken); allClasses.Add(classTime); allClasses = allClasses.OrderBy(x => x.StartDate).ToList(); int nextNumber = 1; allClasses.ForEach(x => { x.NumberOfClass = nextNumber++; x.NumberOfClasses = classTime.GroupClass.NumberOfClasses; }); _context.UpdateRange(allClasses); await _context.SaveChangesAsync(cancellationToken); return(DataResult.Success()); }
public async Task ExecuteShouldThrowExceptionParticipantNotFound() { SchoolManagementContext context = new ContextBuilder().BuildClean(); new RoleBuilder(context).WithName(Roles.Participant).BuildAndSave(); GroupClass groupClassToMakeUp = new GroupClassBuilder(context) .WithStartClasses(DateTime.Now.Subtract(TimeSpan.FromDays(30))) .WithNumberOfClasses(14) .AddClassDayOfWeek(x => x.WithDate(DayOfWeek.Monday, TimeSpan.FromHours(18))) .AddParticipant(x => x.WithEmail("*****@*****.**"), ParticipantRole.Follower, passBuilder => passBuilder.AsActive()) .WithTimeDurationInMinutes(90) .CreateSchedule() .BuildAndSave(); ClassTime classTime = groupClassToMakeUp.Schedule.First(); Command command = new Command { ParticipantId = "dsad", ClassTimeId = classTime.Id }; DataResult dataResult = await new Handler(context).Handle(command, CancellationToken.None); dataResult.Status.Should().Be(DataResult.ResultStatus.Error); dataResult.Message.Should().Be(PolishReadableMessage.Presence.ParticipantNotFound); }
private List <ClassTime> CreateSchedule(IUpdateGroupClass request, int numberOfClasses, DateTime startDate, int duration) { var numberOfWeeks = numberOfClasses / request.DayOfWeeks.Count; List <ClassTime> classTimes = new List <ClassTime>(); int numberOfClass = 1; for (int i = 0; i < numberOfWeeks; i++) { foreach (ClassDayOfWeekDto requestDayOfWeek in request.DayOfWeeks) { DateTime nextDayOfWeeks = FindNearestOfDayOfWeek(startDate, requestDayOfWeek); nextDayOfWeeks = nextDayOfWeeks.Add(requestDayOfWeek.BeginTime).AddMinutes(request.UtcOffsetInMinutes); ClassTime classTime = ClassTimeAggregate.New() .FromGroupClass(State) .WithNumberOfClass(numberOfClass++) .WithNumberOfClasses(numberOfClasses) .AddParticipant(State.Participants.Select(x => x.User).ToList(), PresenceType.None) .WithDate(nextDayOfWeeks, duration).State; classTimes.Add(classTime); } startDate = startDate.AddDays(7); } return(classTimes); }
public async Task ExecuteShouldThrowWrongType() { SchoolManagementContext context = new ContextBuilder().BuildClean(); User user = new UserBuilder(context).BuildAndSave(); new RoleBuilder(context).WithName(Roles.Participant).BuildAndSave(); GroupClass groupClassToMakeUp = new GroupClassBuilder(context) .WithStartClasses(DateTime.Now.Subtract(TimeSpan.FromDays(30))) .WithNumberOfClasses(14) .AddClassDayOfWeek(x => x.WithDate(DayOfWeek.Monday, TimeSpan.FromHours(18))) .AddParticipant(x => x.WithUser(user), ParticipantRole.Follower, passBuilder => passBuilder.AsActive()) .WithTimeDurationInMinutes(90) .CreateSchedule() .BuildAndSave(); List <ParticipantClassTime> participantClassTimes = context.ParticipantPresences.ToList(); for (int i = 0; i < participantClassTimes.Count - 5; i++) { participantClassTimes[i].WasPresence = true; participantClassTimes[i].PresenceType = PresenceType.Member; } ParticipantClassTime makeUpParticipantClassTime = participantClassTimes[participantClassTimes.Count - 5]; makeUpParticipantClassTime.PresenceType = PresenceType.MakeUp; context.UpdateRange(participantClassTimes); context.SaveChanges(); GroupClass makeUpClass = new GroupClassBuilder(context) .WithStartClasses(DateTime.Now.Subtract(TimeSpan.FromDays(30))) .WithNumberOfClasses(14) .AddClassDayOfWeek(x => x.WithDate(DayOfWeek.Monday, TimeSpan.FromHours(18))) .AddParticipant(x => x.WithEmail("*****@*****.**"), ParticipantRole.Follower, passBuilder => passBuilder.AsActive()) .AddParticipant(x => x.WithUser(user), ParticipantRole.Follower) .WithTimeDurationInMinutes(90) .CreateSchedule() .BuildAndSave(); ClassTime classTime = context.ClassTimes.Last(x => x.GroupClassId == makeUpClass.Id); ParticipantClassTime newUserToRemove = classTime.PresenceParticipants.Last(); newUserToRemove.MakeUpParticipant = makeUpParticipantClassTime; newUserToRemove.MakeUpParticipantId = makeUpParticipantClassTime.Id; newUserToRemove.PresenceType = PresenceType.Help; context.Update(newUserToRemove); context.SaveChanges(); Command command = new Command { ParticipantId = user.Id, ClassTimeId = classTime.Id }; DataResult dataResult = await new Handler(context).Handle(command, CancellationToken.None); dataResult.Status.Should().Be(DataResult.ResultStatus.Error); dataResult.Message.Should().Be(PolishReadableMessage.Presence.RemoveWrongType); classTime.PresenceParticipants.Should().HaveCount(2); }
public async Task ExecuteShouldSetPresenceAsHelp() { SchoolManagementContext context = new ContextBuilder().BuildClean(); User user = new UserBuilder(context).BuildAndSave(); new RoleBuilder(context).WithName(Roles.Participant).BuildAndSave(); GroupClass makeUpClass = new GroupClassBuilder(context) .WithStartClasses(DateTime.Now.Subtract(TimeSpan.FromDays(30))) .WithNumberOfClasses(14) .AddClassDayOfWeek(x => x.WithDate(DayOfWeek.Monday, TimeSpan.FromHours(18))) .AddParticipant(x => x.WithEmail("*****@*****.**"), ParticipantRole.Follower, passBuilder => passBuilder.AsActive()) .WithTimeDurationInMinutes(90) .CreateSchedule() .BuildAndSave(); ClassTime classTime = context.ClassTimes.First(x => x.GroupClassId == makeUpClass.Id); Command command = new Command { ParticipantId = user.Id, ClassTimeId = classTime.Id }; DataResult dataResult = await new Handler(context).Handle(command, CancellationToken.None); dataResult.Status.Should().Be(DataResult.ResultStatus.Success); classTime.PresenceParticipants.Should().HaveCount(2); classTime.PresenceParticipants[1].WasPresence.Should().BeTrue(); classTime.PresenceParticipants[1].PresenceType = PresenceType.Help; }
public async Task <DataResult> Handle(Command request, CancellationToken cancellationToken) { ClassTime classTime = await _context.ClassTimes .Include(x => x.PresenceParticipants) .Where(x => x.Id == request.ClassTimeId) .Include(x => x.PresenceParticipants) .FirstOrDefaultAsync(cancellationToken); if (classTime is null) { return(DataResult.Error(PolishReadableMessage.Presence.ClassNotFound)); } ParticipantClassTime participantClassTime = classTime.PresenceParticipants.FirstOrDefault(x => x.ParticipantId == request.ParticipantId); if (participantClassTime is null) { return(DataResult.Error(PolishReadableMessage.Presence.ParticipantNotFound)); } if (participantClassTime.PresenceType != PresenceType.Help) { return(DataResult.Error(PolishReadableMessage.Presence.RemoveWrongType)); } ClassTimeAggregate classTimeAggregate = ClassTimeAggregate.FromState(classTime); classTimeAggregate.RemoveParticipant(participantClassTime.ParticipantId); _context.Remove(participantClassTime); _context.Update(classTimeAggregate.State); await _context.SaveChangesAsync(cancellationToken); return(DataResult.Success()); }
public async Task <DataResult> Handle(Command request, CancellationToken cancellationToken) { User participant = await _context.Users.Where(x => x.Id == request.ParticipantId).FirstOrDefaultAsync(cancellationToken); if (participant is null) { return(DataResult.Error(PolishReadableMessage.Presence.ParticipantNotFound)); } ClassTime classTime = await _context.ClassTimes .Where(x => x.Id == request.ClassTimeId) .Include(x => x.PresenceParticipants) .FirstOrDefaultAsync(cancellationToken); if (classTime is null) { return(DataResult.Error(PolishReadableMessage.Presence.ClassNotFound)); } ClassTimeAggregate classTimeAggregate = ClassTimeAggregate.FromState(classTime); ParticipantClassTime participantClassTime = classTimeAggregate.AddParticipant(participant, PresenceType.Help); participantClassTime.WasPresence = true; await _context.AddAsync(participantClassTime, cancellationToken); _context.Update(classTimeAggregate.State); await _context.SaveChangesAsync(cancellationToken); return(DataResult.Success()); }
public FullClassRecord(ClassTime classTime, Group group, ClassRecord @class) { Group = group; ClassTime = classTime; Subject = @class.Subject; Lecturer = @class.Lecturer; Classroom = @class.Classroom; }
private void AddTime_Click(object sender, RoutedEventArgs e) { ClassTime time = new ClassTime(); time.ClassTimeChanged += Handler; spClassTimesViewer.Children.Add(time); Handler(); }
public FullClassRecord(ClassTime classTime, Group group, Subject subject, Lecturer lecturer, Classroom classroom) { Group = group; ClassTime = classTime; Subject = subject; Lecturer = lecturer; Classroom = classroom; }
private void AddBookForm_Load(object sender, EventArgs e) { AddImageButton.BackColor = Color.Transparent; AddImageButton.Parent = BookImagePictureBox; AddImageButton.Location = new Point(40, 77); AddImageButton.BringToFront(); IDTextBox.Text = ClassTime.getNextIsbn(); //max 99 books per day }
internal WorldCommands(Function function) : base(function) { Objective = new ClassObjective(function); Team = new ClassTeam(function); Datapack = new ClassDatapack(function); Time = new ClassTime(function); Border = new ClassBorder(function); BossBar = new ClassBossBar(function); LoadSquare = new ClassLoadSquare(function); Data = new ClassData(function); }
public async Task ExecuteShouldGetSecondPassWhenFirstIsUsed() { //Arrange SchoolManagementContext context = new ContextBuilder().BuildClean(); new RoleBuilder(context).WithName(Roles.Participant).BuildAndSave(); GroupClass groupClass = new GroupClassBuilder(context) .WithStartClasses(DateTime.Now) .WithTimeDurationInMinutes(90) .AddClassDayOfWeek(x => x.WithDate(DayOfWeek.Monday, new TimeSpan(18, 0, 0))) .AddParticipant(userBuilder => userBuilder.WithName("Piotr", "Kowalski"), ParticipantRole.Follower, passBuilder => passBuilder.WithNumberOfEntry(2).AsActive()) .WithName("Boogie woogie") .WithNumberOfClasses(1) .CreateSchedule().BuildAndSave(); User participant = context.Users.First(); ParticipantGroupClass participantGroupClass = context.GroupClassMembers.First(); new PassBuilder(context) .WithNumberOfEntry(5) .WithStartDate(groupClass.StartClasses) .With(x => x.Used = 5) .With(x => x.Id = 4) .WithParticipant(participant) .WithParticipantGroupClass(participantGroupClass).BuildAndSave(); ClassTime classTime = context.ClassTimes.First(); ParticipantClassTime participantClassTime = classTime.PresenceParticipants.First(); participantClassTime.WasPresence = true; participantClassTime.PresenceType = PresenceType.Member; Command command = new Command { ParticipantClassTimeId = participantClassTime.Id }; //Act DataResult <PassMessage> dataResult = await new Handler(context).Handle(command, CancellationToken.None); //Assert participantClassTime.PassId.Should().NotBeNull("all presence member have to contains pass entry"); Pass activePass = context.Passes.First(x => x.Status == Pass.PassStatus.Active); activePass.Used.Should().Be(1); activePass.ParticipantClassTimes.Should().HaveCount(1); Pass noActivePass = context.Passes.First(x => x.Status == Pass.PassStatus.NotActive); noActivePass.Used.Should().Be(5); dataResult.Data.Should().NotBeNull(); }
public IServiceResults<bool> EditClassTime(ClassTime model) { _classTime.Attach(model); model.DayFa = model.DayEn.GetDescription(); _uow.Entry(model).State = EntityState.Modified; var result = _uow.SaveChanges(); return new ServiceResults<bool> { IsSuccessfull = result.ToBool(), Message = result.ToMessage(BusinessMessage.Error), Result = result.ToBool() }; }
public void Unset(ClassTime target) { foreach (var time in target.Items) { int start = ClassTimeItem.TimeSpanToPeriod(time.Start); int end = ClassTimeItem.TimeSpanToPeriod(time.End); for (int i = start; i < end; i++) { map[(int)time.Day, i] -= 1; } } }
public async Task WhenPassIsOutThenDuplicateAndMarkAsNotPaidAndLogEntryFromNew() { //Arrange SchoolManagementContext context = new ContextBuilder().BuildClean(); new RoleBuilder(context).WithName(Roles.Participant).BuildAndSave(); GroupClass groupClass = new GroupClassBuilder(context) .WithStartClasses(DateTime.Now) .WithTimeDurationInMinutes(90) .AddClassDayOfWeek(x => x.WithDate(DayOfWeek.Monday, new TimeSpan(18, 0, 0))) .AddParticipant(userBuilder => userBuilder.WithName("Piotr", "Kowalski"), ParticipantRole.Follower, passBuilder => passBuilder.WithNumberOfEntry(2).AsActive()) .WithName("Boogie woogie") .WithNumberOfClasses(5) .CreateSchedule().BuildAndSave(); User participant = context.Users.First(); ClassTime classTime = context.ClassTimes.First(); ParticipantClassTime participantClassTime = classTime.PresenceParticipants.First(); participantClassTime.WasPresence = true; participantClassTime.PresenceType = PresenceType.Member; Command command = new Command { ParticipantClassTimeId = participantClassTime.Id }; Pass oldPass = context.Passes.OrderBy(x => x.Id).First(); oldPass.NumberOfEntry = 10; oldPass.Status = Pass.PassStatus.NotActive; oldPass.Used = 10; //Act DataResult <PassMessage> dataResult = await new Handler(context).Handle(command, CancellationToken.None); //Assert participantClassTime.PassId.Should().NotBeNull("presence for make up have to contain pass "); context.Passes.Should().HaveCount(2); Pass newPass = context.Passes.OrderBy(x => x.Id).Last(); newPass.WasGenerateAutomatically.Should().BeTrue("we generate this pass"); newPass.Status.Should().Be(Pass.PassStatus.Active); newPass.Used.Should().Be(1); newPass.Start.Should().Be(participantClassTime.ClassTime.StartDate); newPass.ParticipantClassTimes.Should().HaveCount(1); dataResult.Data.Should().NotBeNull(); }
public GroupClassBuilder CreateSchedule() { if (State.DurationTimeInMinutes == 0) { throw new BuilderException("Duration time is not set"); } if (!State.ClassDaysOfWeek.Any()) { throw new BuilderException("Class day of week is not set"); } if (State.NumberOfClasses == 0) { throw new BuilderException("Number of classes is not set"); } DateTime startClasses = State.StartClasses; if (startClasses == new DateTime()) { throw new BuilderException("Start date is not set"); } var numberOfWeeks = State.NumberOfClasses / State.ClassDaysOfWeek.Count; List <ClassTime> classTimes = new List <ClassTime>(); int numberOfClasses = 1; for (int i = 0; i < numberOfWeeks; i++) { foreach (ClassDayOfWeek requestDayOfWeek in State.ClassDaysOfWeek) { DateTime nextDayOfWeeks = FindNearestOfDayOfWeek(startClasses, requestDayOfWeek); nextDayOfWeeks = nextDayOfWeeks.Add(requestDayOfWeek.Hour); ClassTime classTime = ClassTimeAggregate.New() .AddParticipant(State.Participants.Select(x => x.User).ToList(), PresenceType.None) .FromGroupClass(State) .WithNumberOfClass(numberOfClasses++) .WithDate(nextDayOfWeeks, State.DurationTimeInMinutes).State; classTimes.Add(classTime); } startClasses = startClasses.AddDays(7); } State.Schedule.AddRange(classTimes); return(this); }
public ActionResult AddClassTime(Addclasstimeviewmodel ct) { if (ModelState.IsValid) { ClassTime c = new ClassTime(); c.Classid = Convert.ToInt32(ct.Classid); c.ClassTime1 = ct.ClassTime; _context.ClassTimes.Add(c); _context.SaveChanges(); return(RedirectToAction("Viewclasses", "Trainer")); } else { return(View(ct)); } }
private void Handler() { bool dayChecked = false; bool timePicked = false; //Loop through class times for (int i = 0; i < spClassTimesViewer.Children.Count; i++) { ClassTime time = spClassTimesViewer.Children[i] as ClassTime; WrapPanel panel = time.FindName("wpDays") as WrapPanel; Grid timeGrid = time.FindName("TimeGrid") as Grid; //Loop through checkboxes for (int j = 0; j < panel.Children.Count; j++) { if (panel.Children[i] is CheckBox) { CheckBox check = panel.Children[j] as CheckBox; if (check.IsChecked == true) { dayChecked = true; } } } //Loop through time pickers for (int j = 0; j < timeGrid.Children.Count; j++) { if (timeGrid.Children[j] is TimePicker) { TimePicker picker = timeGrid.Children[j] as TimePicker; timePicked = picker.SelectedTime != null; } } } if (dayChecked && timePicked && txtClassName.Text != "") { btnSaveClass.IsEnabled = true; } else { btnSaveClass.IsEnabled = false; } }
private void SelectItem() { if (!IsSelectedMode) { Edit(); return; } if (uiMainDataGridView.SelectedRows.Count <= 0) { return; } if (uiMainDataGridView.SelectedRows[0].Cells["Id"].Value != null) { DialogResult = DialogResult.OK; SelectedClassTime = _classTimes.FirstOrDefault(g => g.Id == (int)(uiMainDataGridView.SelectedRows[0].Cells["Id"].Value)); } }
public void DeleteTimesheetEntry(string UsrNam, string UsrPwd, Int32 TimeId) { try { Int32 UserId = GetUserId(UsrNam, UsrPwd); if (UserId > 0) { ClassTime oTim = new ClassTime(); oTim.Delete(TimeId); } } catch (Exception ex) { Log.LogMsg(ex.Message); } }
public IServiceResults<int> AddClassTime(ClassTime model) { if (IsExist(model)) return new ServiceResults<int> { IsSuccessfull = false, Message = BusinessMessage.RecordExist, Result = model.ClassTimeId }; model.DayFa = model.DayEn.GetDescription(); _classTime.Add(model); var result = _uow.SaveChanges(); return new ServiceResults<int>() { IsSuccessfull = result.ToBool(), Message = result.ToMessage(BusinessMessage.Error), Result = model.ClassTimeId }; }
private void Commit() { int number = -606217; try { number = Convert.ToInt32(uiNumberTextBox.Text); if (number == -606217) { MessageBox.Show("Данный номер зарезервирован системой :(", "Извините"); return; } } catch { MessageBox.Show("Заполните пожалуйста номер урока числовым значением!", "Так не камильфо"); } if (number != -606217) { try { var classTime = new ClassTime(number, uiStartTimeTextBox.Text, uiEndTimeTextBox.Text); if (_id == -1) { classTime.AddToDatabase(); } else { classTime.UpdateInDatabase(_id); } DialogResult = DialogResult.OK; Close(); } catch (Exception) { MessageBox.Show("Номер урока должен быть уникальным!", "Так не камильфо"); } } }
public EditClassWindow(Class _class) { InitializeComponent(); this._class = _class; txtClassName.Text = _class.ClassName; for (int i = 0; i < _class.ClassTimes.Length; i++) { if (_class.ClassTimes[i][0] == null || _class.ClassTimes[i][1] == null) { continue; } ClassTime time = ClassTimeExist(_class.ClassTimes[i][0]) ?? new ClassTime(); time.tpStartTime.SelectedTime = _class.ClassTimes[i][0]; time.tpEndTime.SelectedTime = _class.ClassTimes[i][1]; //Loop through class times WrapPanel wrap = time.FindName("wpDays") as WrapPanel; foreach (CheckBox check in wrap.Children) { if (check.Content.ToString() == ((DayOfWeek)i).ToString()) { check.IsChecked = true; } } time.ClassTimeChanged += Handler; _classTimes.Add(time); if (!spClassTimesViewer.Children.Contains(time)) { spClassTimesViewer.Children.Add(time); } } }
protected void GridTime_RowCommand(object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case "Delete": ClassTime oTim = new ClassTime(); oTim.Delete(Convert.ToInt32(e.CommandArgument)); ShowGrid(0); break; case "Edit": ViewState["TimeId"] = Convert.ToInt32(e.CommandArgument).ToString(); ShowTime(Convert.ToInt32(e.CommandArgument)); break; } }
private void EnableControls(Boolean bOkay) { this.ddlProjects.Enabled = bOkay; //this.DdlTasks.Enabled = bOkay; this.ddlTimeInHours.Enabled = bOkay; this.ddlTimeInMinutes.Enabled = bOkay; this.ddlTimeInAMPM.Enabled = bOkay; this.ddlTimeOutHours.Enabled = bOkay; this.ddlTimeOutMinutes.Enabled = bOkay; this.ddlTimeOutAMPM.Enabled = bOkay; this.ddlLunchHours.Enabled = bOkay; this.ddlLunchMinutes.Enabled = bOkay; //this.ddlStatus.Enabled = bOkay; //this.TxtComment.Enabled = bOkay; //this.TxtReference.Enabled = bOkay; //this.txtTotalHours.Enabled = bOkay; this.BtnSubmit.Enabled = bOkay; ClassTime oTim = new ClassTime(Int32.Parse(ViewState["TimeId"].ToString())); if (oTim.Locked == true) this.BtnSubmit.Enabled = false; }
private void ShowGrid(Int32 PageNo) { DateTime DateStart = this.cc2DateSelector.StartDate(); DateTime DateEnd = this.cc2DateSelector.EndDate(); this.LblFrom.Text = DateStart.ToString("dd MMM yyyy"); this.LblTo.Text = DateEnd.ToString("dd MMM yyyy"); ClassReport oRep = new ClassReport(); DataSet oDs = oRep.GetTimeSheet(Int32.Parse(ViewState["UserId"].ToString()), DateStart, DateEnd); double dTotal = 0; foreach (DataRow oDr in oDs.Tables[0].Rows) dTotal += double.Parse(oDr["Hours"].ToString()); ViewState["TotalHours"] = dTotal.ToString(); this.GridTime.DataSource = oDs; this.GridTime.PageIndex = (PageNo >= 0) ? PageNo : 0; this.GridTime.DataBind(); if (Int32.Parse(ViewState["TimeId"].ToString()) == 0) { this.BtnSubmit.Text = "Submit"; this.LblTimeId.Text = "New"; } else { this.BtnSubmit.Text = "Update"; this.LblTimeId.Text = string.Format("Update ({0})", Int32.Parse(ViewState["TimeId"].ToString())); } // Time events which are locked cannot be edited or deleted. ClassTime oTim = new ClassTime(); foreach (GridViewRow oRow in GridTime.Rows) { ImageButton oDel = (ImageButton)oRow.FindControl("ImgTrash"); if (oDel != null) { oTim.Load(Int32.Parse(oDel.CommandArgument)); if (oTim.Locked) { oDel.ToolTip = ""; oDel.Enabled = false; oDel.ImageUrl = "~/Images/BlankIcon.gif"; } } } ShowTimeError(""); }
private void ShowGrid() { DataSet oDs = GetGridData(); double dTotal = 0; this.LblFrom.Text = this.cc2DateSelector.StartDate().ToString("d MMMM yyyy"); this.LblTo.Text = this.cc2DateSelector.EndDate().ToString("d MMMM yyyy"); foreach (DataRow oDr in oDs.Tables[0].Rows) { dTotal += double.Parse(oDr["Hours"].ToString()); } ViewState["TotalHours"] = dTotal.ToString(); this.GridTime.DataSource = oDs; this.GridTime.DataBind(); // Time events which are locked cannot be edited or deleted. ClassTime oTim = new ClassTime(); foreach (GridViewRow oRow in GridTime.Rows) { ImageButton oDel = (ImageButton)oRow.FindControl("ImgTrash"); if (oDel != null) { oTim.Load(Int32.Parse(oDel.CommandArgument)); if (oTim.Locked) { oDel.ToolTip = ""; oDel.Enabled = false; oDel.ImageUrl = "~/Images/BlankIcon.gif"; } } } }
private void LockAndUnlock(Boolean SetLock) { ClassTime oTim = new ClassTime(); DateTime DateStart = this.cc2DateSelector.StartDate(); DateTime DateEnd = this.cc2DateSelector.EndDate(); foreach (GridViewRow oRow in GridUsers.Rows) { Label oLbl = (Label) oRow.FindControl("LblUserId"); if (oLbl != null) { CheckBox oChk = (CheckBox) oRow.FindControl("ChkLock"); if (oChk != null) { if (oChk.Checked) oTim.LockAndUnlock(SetLock, Convert.ToInt32(oLbl.Text), DateStart, DateEnd); } } } }
protected void BtnSubmit_Click(object sender, EventArgs e) { //ClassTask oTsk = new ClassTask(Convert.ToInt32(this.DdlTasks.SelectedValue)); //Boolean bOkay = false; Boolean bOkay = true; //if ((oTsk.ValidationType & (Int32)Enum.ValidationType.NoValidation) != 0) //{ // // No validation for job reference. User can enter anything // // they like. // bOkay = true; //} //else if ((oTsk.ValidationType & (Int32)Enum.ValidationType.JobMustPreExist) != 0) //{ // // Job must pre-exist and be active in tblJobs. // //ClassJob oJob = new ClassJob(); // //if (oJob.IsJobActive(this.TxtReference.Text) == true) // //{ // // // Job reference is available and is active. // // bOkay = true; // //} // //else // //{ // // // Job reference either doesn't exist or it isn't // // // currently active in tblJobs. // // bOkay = false; // // ShowTimeError("Job reference does not pre-exist!"); // //} //} //else if ((oTsk.ValidationType & (Int32)Enum.ValidationType.UseRegularExpression) != 0) //{ // // Job reference must meet regular expression. // //System.Text.RegularExpressions.Regex oReg = new System.Text.RegularExpressions.Regex(oTsk.ReferenceRegEx); // //if (oReg.IsMatch(this.TxtReference.Text) == true) // //{ // // // Regular expression match is okay. // // bOkay = true; // //} // //else // //{ // // // Regular expression failed. // // bOkay = false; // // ShowTimeError("Job reference failed regular expression check!"); // //} //} //else if ((oTsk.ValidationType & (Int32)Enum.ValidationType.UseDropDownListBox) != 0) //{ // // Job reference supplied via dropdown listbox. // if (this.DdlJobs.Items.Count > 0) // { // // The user has selected via the dropdown listbox. // //this.TxtReference.Text = this.DdlJobs.SelectedValue; // bOkay = true; // } //} if (bOkay == true) { // We have passed the job reference validation check (if any). ClassTime oTim = new ClassTime(Convert.ToInt32(ViewState["TimeId"].ToString())); ClassUser oUsr = new ClassUser(); oTim.DateVal = this.cc2DateSelector.GetDate(); oTim.UserId = Int32.Parse(ViewState["UserId"].ToString()); oTim.ProjectId = Convert.ToInt32(this.ddlProjects.SelectedValue); //oTim.TaskId = oTsk.TaskId; //oTim.StatusId = Convert.ToInt32(this.ddlStatus.SelectedValue); //oTim.Comment = this.TxtComment.Text; //oTim.JobRef = this.TxtReference.Text; // Check that hours entered is a valid number. System.Text.RegularExpressions.Regex oReg = new System.Text.RegularExpressions.Regex("[-+]?[0-9]*\\.?[0-9]+"); if (!oReg.IsMatch(this.txtTotalHours.Text)) { // Regular expression for hours failed. ShowTimeError("The hours entered are incorrectly specified!"); } else { // Hours entered is a valid number. double HoursVal; if (double.TryParse(this.txtTotalHours.Text, out HoursVal) != true) { // Problem with the submitted hours value. ShowTimeError("The hours entered are invalid!"); } else { // Hours value is okay. oTim.Hours = HoursVal; oTim.Save(Int32.Parse(ViewState["TimeId"].ToString())); ShowTime(oTim.TimeId); ShowGrid(0); ViewState["TimeId"] = "0"; //this.TxtComment.Text = ""; this.txtTotalHours.Text = "0.00"; this.LblTimeId.Text = "New"; this.BtnSubmit.Text = "Submit"; ResetTime(); EnableControls(false); BtnSubmit.Enabled = false; } } } //this.DdlProject.Focus(); }
private void SetClassTime(ClassTime selectedClassTime) { _classTimeTable.ClassTime = selectedClassTime; RefreshClassTimes(); }
public static StatisticOfTime StaticticOfTime(Schedule schedule, ClassTime time) { return(new StatisticOfTime(schedule, time)); }
public virtual ActionResult EditClassTime(ClassTime model) { if (!ModelState.IsValid) { return View(model); } var result = _classTimeService.EditClassTime(model); if (!result.IsSuccessfull) { this.NotificationController().Notify(result.Message, NotificationStatus.Error); return View(model); } return RedirectToAction(MVC.Class.ActionNames.AddClass, MVC.Class.Name); }
public virtual ActionResult AddClassTime(ClassTime model) { if (ModelState.IsValid) { var result = _classTimeService.AddClassTime(model); if (!result.IsSuccessfull) this.NotificationController().Notify(result.Message, NotificationStatus.Error); } return RedirectToAction(MVC.Class.ActionNames.AddClassTime, MVC.Class.Name, new { classId = model.ClassId }); }
public static StatisticOfTime StaticticOfTime(Schedule schedule, ClassTime time) { return new StatisticOfTime(schedule, time); }
private void ShowTime(Int32 TimeId) { ClassTime oTim = new ClassTime(TimeId); this.cc2DateSelector.SetDate(oTim.DateVal); try { this.ddlProjects.SelectedValue = oTim.ProjectId.ToString(); } catch (Exception ex) { string var = ex.Message; // No error. } this.ShowTasks(); try { //this.DdlTasks.SelectedValue = oTim.TaskId.ToString(); } catch (Exception) { // No error. } try { //this.ddlStatus.SelectedValue = oTim.StatusId.ToString(); } catch (Exception) { // No error. } //this.TxtComment.Text = oTim.Comment; //this.TxtReference.Text = oTim.JobRef; this.txtTotalHours.Text = string.Format("{0:N2}", oTim.Hours); ViewState["TimeId"] = TimeId.ToString(); this.LblTimeId.Text = string.Format("Update ({0})", ViewState["TimeId"].ToString()); this.BtnSubmit.Text = "Update"; // User cannot modify locked records. if (oTim.Locked == true) { // Locked time records cannot be re-submitted. EnableControls(false); this.BtnSubmit.Enabled = false; } else { EnableControls(true); } if (ViewState["UserId"].ToString() == "0") { // Administrator cannot submit timesheets. this.BtnSubmit.Enabled = false; } }
public TimeCardViewModel(ClassTime time) { var i = time.Number; Time = i > ClassTime.ClassIntervals.Count() || i < 0 ? "Whenever" : ClassTime.ClassIntervals[time.Number]; }
public async Task ExecuteShouldAddGroupAndAddPresence() { SchoolManagementContext context = new ContextBuilder().BuildClean(); GroupLevel groupLevel = new GroupLevelBuilder(context).With(x => x.Level = 1).With(x => x.Name = "Początkujący").BuildAndSave(); Room room = new RoomBuilder(context).WithName("Sala biała").BuildAndSave(); User anchor = new UserBuilder(context).WithEmail("*****@*****.**").BuildAndSave(); Role role = new RoleBuilder(context).WithName(Roles.Anchor).AddUserToRole(anchor).BuildAndSave(); List <User> participants = new List <User>(); var participantRoleBuilder = new RoleBuilder(context).WithName(Roles.Participant); for (var i = 0; i < 10; i++) { User user = new UserBuilder(context).WithEmail($"email{i}@gmail.com").BuildAndSave(); participants.Add(user); participantRoleBuilder.AddUserToRole(user); } participantRoleBuilder.BuildAndSave(); Command cmd = new Command { Name = "Groupa zajęciowa", Anchors = new List <string> { anchor.Id }, IsSolo = true, ParticipantLimit = 20, PassPrice = 200, GroupLevelId = groupLevel.Id, UtcOffsetInMinutes = 0, Participants = participants.Select(x => new ParticipantDto { Id = x.Id, Role = ParticipantRole.Leader }).ToList(), RoomId = room.Id, DayOfWeeks = new List <ClassDayOfWeekDto> { new ClassDayOfWeekDto() { DayOfWeek = System.DayOfWeek.Monday, BeginTime = new TimeSpan(18, 0, 0) }, new ClassDayOfWeekDto() { DayOfWeek = System.DayOfWeek.Thursday, BeginTime = new TimeSpan(19, 0, 0) } }, Start = new DateTime(2019, 09, 01), //Sunday DurationTimeInMinutes = 90, NumberOfClasses = 20 }; DataResult dataResult = await new Handler(context).Handle(cmd, CancellationToken.None); dataResult.Status.Should().Be(DataResult.ResultStatus.Success, "all parameters are corrected"); context.ParticipantPresences.Should().NotBeNullOrEmpty() .And.HaveCount(cmd.NumberOfClasses * cmd.Participants.Count) .And.NotContainNulls(x => x.ClassTime) .And.NotContainNulls(x => x.Participant); context.ClassTimes.Should().NotBeEmpty().And.HaveCount(cmd.NumberOfClasses).And .NotContainNulls(x => x.PresenceParticipants); ClassTime classTime = context.ClassTimes.First(); classTime.PresenceParticipants.Should().HaveCount(10); ParticipantClassTime participantClassTime = context.ParticipantPresences.First(); AssertPass(context, participants, cmd); }
private void buttonSave_Click(object sender, EventArgs e) { // Instantiate a new class object. ClassTree newClass = new ClassTree(); // Validate necessary fields (Class Title & Class Time(s)). If so add to new class. if (FieldValidator()) { newClass.ClassTitle = textBoxClassTitle.Text; // Enumerate the class times and add to the new class object. newClass.ClassTreeTimes = new ClassTimes(); foreach (string time in listBoxClassTimes.Items) { ClassTime classTime = new ClassTime(textBoxClassTitle.Text, time); newClass.ClassTreeTimes.Add(classTime); } } else { return; } // Populate the rest of the class information. newClass.ClassLocation = textBoxLocation.Text; newClass.ClassWebSite = textBoxWebSite.Text; newClass.ClassCreditHours = textBoxCreditHours.Text; // Populate the teacher information into the new class. newClass.ClassTeacher = textBoxTeacher.Text; newClass.ClassTeacherOffice = textBoxTeacherOffice.Text; newClass.ClassTeacherOfficeHours = textBoxOfficeHours.Text; newClass.ClassTeacherEmail = textBoxEmail.Text; newClass.ClassTeacherPhone = textBoxTeacherPhone.Text; newClass.ClassNote = richTextBoxClassNotes.Text; // newClass.ClassTreeAssignments.Add(new ClassAssignment("Assignment01", "", "", "", newClass.ClassTitle, DateTime.Now, false)); // populate this forms property for reference from calling form. ClassPass = newClass; // Write Class file to disk. DatabaseClass.CreateClass(newClass, newClass.ClassTitle); // Set the saveClose variable to true for calling form. saveClose = true; this.Close(); }
public async Task ExecuteShouldAddGroupAndAddScheduleWithOffset() { SchoolManagementContext context = new ContextBuilder().BuildClean(); GroupLevel groupLevel = new GroupLevelBuilder(context).With(x => x.Level = 1).With(x => x.Name = "Początkujący").BuildAndSave(); Room room = new RoomBuilder(context).WithName("Sala biała").BuildAndSave(); User anchor = new UserBuilder(context).WithEmail("*****@*****.**").BuildAndSave(); Role role = new RoleBuilder(context).WithName(Roles.Anchor).AddUserToRole(anchor).BuildAndSave(); Command cmd = new Command { Name = "Groupa zajęciowa", Anchors = new List <string> { anchor.Id }, IsSolo = true, ParticipantLimit = 20, GroupLevelId = groupLevel.Id, RoomId = room.Id, UtcOffsetInMinutes = 60, DayOfWeeks = new List <ClassDayOfWeekDto> { new ClassDayOfWeekDto() { DayOfWeek = System.DayOfWeek.Monday, BeginTime = new TimeSpan(18, 0, 0) }, new ClassDayOfWeekDto() { DayOfWeek = System.DayOfWeek.Thursday, BeginTime = new TimeSpan(19, 0, 0) } }, Start = new DateTime(2019, 09, 01), //Sunday DurationTimeInMinutes = 90, NumberOfClasses = 20 }; DataResult dataResult = await new Handler(context).Handle(cmd, CancellationToken.None); dataResult.Status.Should().Be(DataResult.ResultStatus.Success, "all parameters are corrected"); List <ClassTime> classTimes = context.ClassTimes.ToList(); classTimes.Should().NotBeEmpty("we set schedule") .And.HaveCount(20, "because we have classes 20 number of classes"); ClassTime classes = classTimes.First(); classes.Room.Should().Be(room); classes.RoomId.Should().Be(cmd.RoomId); GroupClass groupClass = context.GroupClass.First(); groupClass.DurationTimeInMinutes.Should().Be(90); groupClass.NumberOfClasses.Should().Be(20); groupClass.StartClasses.Should().Be(new DateTime(2019, 09, 01).ToUniversalTime()); List <ClassDayOfWeek> groupClassClassDaysOfWeek = groupClass.ClassDaysOfWeek; groupClassClassDaysOfWeek.Should() .NotBeNullOrEmpty() .And .HaveCount(2); groupClassClassDaysOfWeek.First().Hour.Should().Be(new TimeSpan(18, 0, 0)); classes.GroupClass.Should().Be(groupClass); classes.GroupClassId.Should().Be(groupClass.Id); DateTime expectedStartTimeForOdd = new DateTime(2019, 09, 02, 18, 0, 0); DateTime expectedEndTimeForOdd = new DateTime(2019, 09, 02, 19, 30, 0); DateTime expectedStartTimeForEven = new DateTime(2019, 09, 05, 19, 0, 0); DateTime expectedEndTimeForEven = new DateTime(2019, 09, 05, 20, 30, 0); int index = 1; foreach (ClassTime classTime in classTimes) { if (index % 2 == 1) { classTime.StartDate.Should().Be(expectedStartTimeForOdd.ToUniversalTime().AddMinutes(cmd.UtcOffsetInMinutes)); classTime.StartDate.DayOfWeek.Should().Be(System.DayOfWeek.Monday); classTime.EndDate.Should().Be(expectedEndTimeForOdd.ToUniversalTime().AddMinutes(cmd.UtcOffsetInMinutes), "because classes during 90 minutes"); expectedStartTimeForOdd = expectedStartTimeForOdd.AddDays(7); expectedEndTimeForOdd = expectedEndTimeForOdd.AddDays(7); } else { classTime.StartDate.Should().Be(expectedStartTimeForEven.ToUniversalTime().AddMinutes(cmd.UtcOffsetInMinutes)); classTime.StartDate.DayOfWeek.Should().Be(System.DayOfWeek.Thursday); classTime.EndDate.Should().Be(expectedEndTimeForEven.ToUniversalTime().AddMinutes(cmd.UtcOffsetInMinutes), "because classes during 90 minutes"); expectedStartTimeForEven = expectedStartTimeForEven.AddDays(7); expectedEndTimeForEven = expectedEndTimeForEven.AddDays(7); } index++; } }
// The function of this method is to load information according to stateCode public static List <ClassTime> loadByState(string unitCode) { List <ClassTime> ClassTime = new List <ClassTime>(); // You can use MySqlConnection conn = DBconn.getConnection(); // Now because of the inheritance relationship, you can directly access the protected method of the parent class MySqlConnection conn = getConnection(); MySqlDataReader rdr = null; // This short paragraph is for testing purposes only, and should be deleted when submitting if (conn != null) { Console.WriteLine("In ClasstimeDB, the database connection is successful!"); } else { Console.WriteLine("In ClasstimeDB, the database connection is unsuccessful!"); } // delete above try { conn.Open(); //! ! ! Note the modification here! ! ! // select [*] [] content: * means select all, if not select all, write the column names in the class table in the database // from [aiis_activity_time] [] content: aiis_activity_time, change it to the corresponding table in your database, it should be class // where [state_code=?stateCode] The content in []: state_code=?stateCode, the previous state_code represents the name of the column in the table in the database, change it to the corresponding column name in the class table in your database // The following stateCode corresponds to the first variable in cmd.Parameters.AddWithValue("stateCode", stateCode); // cmd.Parameters.AddWithValue("stateCode", stateCode); The second variable in the corresponding function entry is the value passed in: public static List<ActivityTime> loadByState(string stateCode) MySqlCommand cmd = new MySqlCommand("select * from aiis_activity_time where state_code=?stateCode", conn); cmd.Parameters.AddWithValue("unitCode", unitCode); rdr = cmd.ExecuteReader(); // This short paragraph is for testing purposes only, and should be deleted when submitting if (rdr != null) { Console.WriteLine("ActivityTime Data read successfully!"); } else { Console.WriteLine("ActivityTime Data read unsuccessfully!"); }// delete above while (rdr.Read()) { // set method ClassTime a = new ClassTime(); a.setUnitCode(rdr.GetString(0)); a.setCityBranch(rdr.GetString(1)); a.setDay(parseEnum <DayOfWeek>(rdr.GetString(2))); a.setStart(rdr.GetTimeSpan(3)); a.setEnd(rdr.GetTimeSpan(4)); a.setClassType(parseEnum <ClassType>(rdr.GetString(5))); a.setPostalCode(rdr.GetString(6)); a.setStaffID(rdr.GetInt32(7)); ClassTime.Add(a); } } // For fault tolerance catch (MySqlException e) { ReportError("loading unit staff times", e); } // Close database connection finally { if (rdr != null) { rdr.Close(); } if (conn != null) { conn.Close(); } } return(ClassTime); }
public Int32 SubmitTimesheetEntry(string UsrNam, string UsrPwd, DateTime DateVal, Int32 ProjectId, Int32 TaskId, Int32 StatusId, string Comment, string JobRef, double Hours) { Int32 RetVal = 0; try { Int32 UserId = GetUserId(UsrNam, UsrPwd); if (UserId > 0) { ClassTime oTim = new ClassTime(); oTim.DateVal = DateVal; oTim.UserId = UserId; oTim.ProjectId = ProjectId; oTim.TaskId = TaskId; oTim.StatusId = StatusId; oTim.Comment = Comment; oTim.JobRef = JobRef; oTim.Hours = Hours; RetVal = oTim.Save(0); } else { // Valid user not found! RetVal = -1; } } catch (Exception ex) { Log.LogMsg(ex.Message); RetVal = -1; } return RetVal; }