public ActionResult Edit([Bind(Include = "JobId,JobTitle,JobNumber,ShiftTimes,StreetAddress,City,State,Zipcode,Note")] Job job, [Bind(Include = "ShiftTimeId, Default, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday")] ShiftTime shiftTime) { if (ModelState.IsValid) { //Checking if more than 5 days have been selected List <string> weekDays = new List <string> { job.ShiftTimes.Monday, job.ShiftTimes.Tuesday, job.ShiftTimes.Wednesday, job.ShiftTimes.Thursday, job.ShiftTimes.Friday, job.ShiftTimes.Saturday, job.ShiftTimes.Sunday }; List <string> countDays = new List <string>(); foreach (string d in weekDays) { if (d != null) { countDays.Add(d); } } if (countDays.Count() > 5) { ViewBag.ErrorMessage = "Please select no more than 5 Weekdays "; return(View(job)); } //Update the DB db.Entry(job).State = EntityState.Modified; db.Entry(job.ShiftTimes).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(job)); }
/// <summary> /// Shows the correct shift upon execution. /// </summary> /// <param name="time"></param> private void ShowShift(ShiftTime time) { // Refreshes the shift data from the shiftStorage shiftEmployees.Clear(); shiftStorage = new ShiftMySQL(); newShift = shiftStorage.Get(date, time); //Department currentSelectedDepartment = currentSelectedDepartment(); // If a shift exists, show it. Else create a new one if (newShift != null) { shiftEmployees = shiftStorage.GetEmployees(newShift.Id); schedule = new SchedulingWindow(labelCalendarDate.Text, labelCalendarDay.Text, time, date, shiftEmployees, true, newShift.Id, newShift.Capacity, allEmployees, currentSelectedDepartment, loggedInUser); } else { schedule = new SchedulingWindow(labelCalendarDate.Text, labelCalendarDay.Text, time, date, shiftEmployees, false, 0, 0, allEmployees, currentSelectedDepartment, loggedInUser); } // Show a dialog for the shift if (schedule.ShowDialog() == DialogResult.OK) { ReloadCalendarDayEvent?.Invoke(); ReloadEmployeeHoursEvent?.Invoke(); } }
protected void btnKaydet_DirectClick(object sender, DirectEventArgs e) { ShifTimeService stService = new ShifTimeService(); if (txtshiftTimeId.Text == "") { ShiftTime sT = new ShiftTime() { departureTime = cmbdepartureTime.SelectedItem.Value.ToString(), plate = new Bus() { plate = cmbplate.SelectedItem.Text }, driverId = new Driver() { driverId = Convert.ToInt32(cmbDriver.SelectedItem.Value.ToString()) }, lineId = new Line() { lineName = cmblineName.SelectedItem.Text }, stiftStart = Convert.ToDateTime(txtstiftStart.Text), shiftEnd = Convert.ToDateTime(txtshiftEnd.Text) }; stService.Save(sT); } else { ShiftTime sT = new ShiftTime() { departureTime = cmbdepartureTime.SelectedItem.Value.ToString(), plate = new Bus() { plate = cmbplate.SelectedItem.Text }, driverId = new Driver() { driverId = Convert.ToInt32(cmbDriver.SelectedItem.Value.ToString()) }, lineId = new Line() { lineName = cmblineName.SelectedItem.Text }, stiftStart = Convert.ToDateTime(txtstiftStart.Text), shiftEnd = Convert.ToDateTime(txtshiftEnd.Text) }; stService.Save(sT); } txtshiftEnd.Clear(); txtshiftTimeId.Clear(); txtstiftStart.Clear(); cmbdepartureTime.Clear(); cmbDriver.Clear(); cmblineName.Clear(); cmbplate.Clear(); X.Msg.Alert("UYARI", "Bilgiler kayıt edilmiştir.").Show(); WindowST.Hide(this.Form); btnGet_DirectClick(new object(), new DirectEventArgs(null)); }
public IList <ShiftTime> CreateShiftTime(int shiftId, int number) { IList <ShiftTime> list = new List <ShiftTime>(); for (int i = 1; i <= number; i++) { ShiftTime time = new ShiftTime() { ShiftId = shiftId, DayNumber = i, StartTime = TimeSpan.Zero, EndTime = TimeSpan.Zero, IsLaborDay = true, HasLunchTime = false, LunchStartTime = TimeSpan.Zero, LunchEndTime = TimeSpan.Zero, InsertedAt = DateTime.Now, UpdatedAt = DateTime.Now, IsActive = true }; list.Add(time); } return(list); }
/// <summary> /// Checks if an employee wants to work a certain shift (time + day) according to their preferred hours /// </summary> /// <param name="day">The day.</param> /// <param name="shiftTime">The shift time.</param> /// <param name="preferredHours">The preferred hours.</param> /// <returns></returns> private bool WantsToWorkShift(DayOfWeek day, ShiftTime shiftTime, List <string> preferredHours) { switch (day) { case DayOfWeek.Monday: return(WantsToWorkShiftTime(shiftTime, preferredHours[0])); case DayOfWeek.Tuesday: return(WantsToWorkShiftTime(shiftTime, preferredHours[1])); case DayOfWeek.Wednesday: return(WantsToWorkShiftTime(shiftTime, preferredHours[2])); case DayOfWeek.Thursday: return(WantsToWorkShiftTime(shiftTime, preferredHours[3])); case DayOfWeek.Friday: return(WantsToWorkShiftTime(shiftTime, preferredHours[4])); case DayOfWeek.Saturday: return(WantsToWorkShiftTime(shiftTime, preferredHours[5])); case DayOfWeek.Sunday: return(WantsToWorkShiftTime(shiftTime, preferredHours[6])); } return(false); }
public Shift(int id, DateTime date, ShiftTime shiftTime, int capacity) { this.id = id; this.date = date; this.shiftTime = shiftTime; this.capacity = capacity; }
public ActionResult DeleteConfirmed(int id) { ShiftTime shiftTime = db.ShiftTimes.Find(id); db.ShiftTimes.Remove(shiftTime); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ShiftTimeId,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday,Default")] ShiftTime shiftTime) { if (ModelState.IsValid) { db.Entry(shiftTime).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(shiftTime)); }
public ActionResult EditShift(ShiftViewModel shift) { bool success = false; string message = ""; if (ModelState.IsValid) { var shiftedit = db.Shifts .Where(w => w.ShiftId == shift.ShiftId).FirstOrDefault(); if (shiftedit != null) { shiftedit.Name = shift.ShiftName; shiftedit.Description = shift.ShiftDescription; shiftedit.UpdatedAt = DateTime.Now; shiftedit.IsActive = shift.IsActive; shiftedit.ExtraHourId = shift.ExtraHourId; db.Entry(shiftedit).State = EntityState.Modified; } foreach (var t in shift.TimeList) { ShiftTime shifttime = db.ShiftTimes.Find(t.ShiftTimeId); if (shifttime != null) { shifttime.StartTime = t.StartTime; shifttime.EndTime = t.EndTime; shifttime.HasLunchTime = t.HasLunchTime; shifttime.IsLaborDay = t.IsLaborDay; shifttime.IsActive = t.IsActive; shifttime.LunchEndTime = t.LunchEndTime; shifttime.LunchStartTime = t.LunchStartTime; shifttime.UpdatedAt = DateTime.Now; db.Entry(shifttime).State = EntityState.Modified; } } try { db.SaveChanges(); MyLogger.GetInstance.Info("Shift was edited successfull, Id: " + shift.ShiftId); success = true; } catch (Exception e) { message = e.Message; success = false; MyLogger.GetInstance.Error("Error", e); } } return(Json(new { success = success, message = message })); }
public ActionResult Edit([Bind(Include = "ShiftTimeId,ShiftId,DayNumber,IsLaborDay,StartTime,EndTime,HasLunchTime,LunchStartTime,LunchEndTime,InsertedAt,UpdatedAt,IsActive")] ShiftTime shiftTime) { if (ModelState.IsValid) { db.Entry(shiftTime).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ShiftId = new SelectList(db.Shifts, "ShiftId", "Name", shiftTime.ShiftId); return(View(shiftTime)); }
private void AddShiftInfo(string name, string code, string fromTime, string toTime) { ShiftTime shiftTime = new ShiftTime(); shiftTime.Name = name; shiftTime.Code = code; shiftTime.From = fromTime; shiftTime.To = toTime; _lstShift.Add(shiftTime); }
public ActionResult Create([Bind(Include = "ShiftTimeId,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday,Default")] ShiftTime shiftTime) { if (ModelState.IsValid) { shiftTime.ShiftTimeId = Guid.NewGuid(); db.ShiftTime.Add(shiftTime); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(shiftTime)); }
// GET: ShiftTimes/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ShiftTime shiftTime = db.ShiftTimes.Find(id); if (shiftTime == null) { return(HttpNotFound()); } return(View(shiftTime)); }
// GET: ShiftTimes/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ShiftTime shiftTime = db.ShiftTimes.Find(id); if (shiftTime == null) { return(HttpNotFound()); } ViewBag.ShiftId = new SelectList(db.Shifts, "ShiftId", "Name", shiftTime.ShiftId); return(View(shiftTime)); }
public List <Employee> Filter(Shift shift, int departmentId, List <Shift> weekShifts, List <WorkingEmployee> workingEmployees, List <Employee> employees) { List <Employee> output = new List <Employee>(); DayOfWeek day = shift.Date.DayOfWeek; ShiftTime shiftTime = shift.ShiftTime; foreach (Employee employee in employees) { List <String> employeePreferredHours = SplitPreferredHours(employee.PreferredHours); if (WantsToWorkShift(day, shiftTime, employeePreferredHours)) { output.Add(employee); } } return(output); }
public Manage_Shift_Admin() { InitializeComponent(); // khởi tạo listShiftTime = ShiftTime.getAllShift(); //thêm vào map (shift,button,textbox) listShiftMapping.Add(new ShiftMapping(listShiftTime[0], Add_Fri_Shift1_btn, Shift1_Fri)); listShiftMapping.Add(new ShiftMapping(listShiftTime[1], Add_Fri_Shift2_btn, Shift2_Fri)); listShiftMapping.Add(new ShiftMapping(listShiftTime[2], Add_Fri_Shift3_btn, Shift3_Fri)); listShiftMapping.Add(new ShiftMapping(listShiftTime[3], Add_Fri_Shift4_btn, Shift4_Fri)); listShiftMapping.Add(new ShiftMapping(listShiftTime[4], Add_Mon_Shift1_btn, Shift1_Mon)); listShiftMapping.Add(new ShiftMapping(listShiftTime[5], Add_Mon_Shift2_btn, Shift2_Mon)); listShiftMapping.Add(new ShiftMapping(listShiftTime[6], Add_Mon_Shift3_btn, Shift3_Mon)); listShiftMapping.Add(new ShiftMapping(listShiftTime[7], Add_Mon_Shift4_btn, Shift4_Mon)); listShiftMapping.Add(new ShiftMapping(listShiftTime[8], Add_Sat_Shift1_btn, Shift1_Sat)); listShiftMapping.Add(new ShiftMapping(listShiftTime[9], Add_Sat_Shift2_btn, Shift2_Sat)); listShiftMapping.Add(new ShiftMapping(listShiftTime[10], Add_Sat_Shift3_btn, Shift3_Sat)); listShiftMapping.Add(new ShiftMapping(listShiftTime[11], Add_Sat_Shift4_btn, Shift4_Sat)); listShiftMapping.Add(new ShiftMapping(listShiftTime[12], Add_Sun_Shift1_btn, Shift1_Sun)); listShiftMapping.Add(new ShiftMapping(listShiftTime[13], Add_Sun_Shift2_btn, Shift2_Sun)); listShiftMapping.Add(new ShiftMapping(listShiftTime[14], Add_Sun_Shift3_btn, Shift3_Sun)); listShiftMapping.Add(new ShiftMapping(listShiftTime[15], Add_Sun_Shift4_btn, Shift4_Sun)); listShiftMapping.Add(new ShiftMapping(listShiftTime[16], Add_Thu_Shift1_btn, Shift1_Thu)); listShiftMapping.Add(new ShiftMapping(listShiftTime[17], Add_Thu_Shift2_btn, Shift2_Thu)); listShiftMapping.Add(new ShiftMapping(listShiftTime[18], Add_Thu_Shift3_btn, Shift3_Thu)); listShiftMapping.Add(new ShiftMapping(listShiftTime[19], Add_Thu_Shift4_btn, Shift4_Thu)); listShiftMapping.Add(new ShiftMapping(listShiftTime[20], Add_Tues_Shift1_btn, Shift1_Tues)); listShiftMapping.Add(new ShiftMapping(listShiftTime[21], Add_Tues_Shift2_btn, Shift2_Tues)); listShiftMapping.Add(new ShiftMapping(listShiftTime[22], Add_Tues_Shift3_btn, Shift3_Tues)); listShiftMapping.Add(new ShiftMapping(listShiftTime[23], Add_Tues_Shift4_btn, Shift4_Tues)); listShiftMapping.Add(new ShiftMapping(listShiftTime[24], Add_Wed_Shift1_btn, Shift1_Wed)); listShiftMapping.Add(new ShiftMapping(listShiftTime[25], Add_Wed_Shift2_btn, Shift2_Wed)); listShiftMapping.Add(new ShiftMapping(listShiftTime[26], Add_Wed_Shift3_btn, Shift3_Wed)); listShiftMapping.Add(new ShiftMapping(listShiftTime[27], Add_Wed_Shift4_btn, Shift4_Wed)); }
/// <summary> /// A form in which the user can schedule and unschedule employees for a certain shift. /// </summary> /// <param name="dateAndMonth"></param> /// <param name="weekDay"></param> /// <param name="shiftTime"></param> /// <param name="date"></param> /// <param name="working"></param> /// <param name="editing"></param> /// <param name="oldShiftId"></param> public SchedulingWindow(string dateAndMonth, string weekDay, ShiftTime shiftTime, DateTime date, List <Employee> working, bool editing, int oldShiftId, int capacity, List <Employee> allEmployees, Department previousSelectedDepartment, Employee loggedInUser) { InitializeComponent(); InitializeComboBoxShiftTime(); LoadEmployees(working, allEmployees); this.date = date; this.shiftTime = shiftTime; this.comboBoxShiftTime.SelectedItem = shiftTime; textBoxWeekDay.Text = weekDay; textBoxCalendarDate.Text = dateAndMonth; this.isEditing = editing; this.oldId = oldShiftId; this.capacity = capacity; this.previousSelectedDepartment = previousSelectedDepartment; this.loggedInUser = loggedInUser; employeeStorage = new EmployeeMySQL(); numericUpDownCapacity.Value = capacity; AddEmployeeListToShift(working); LoadDepartments(); CheckPermissions(); }
public static unsafe void bb4() { Input x = new Input(4, 2, 1); var sum = new ShiftTime(x, new Dimension[] { -1 }); sum.Name = "sum"; Stopwatch c = new Stopwatch(); c.Start(); for (int i2 = 0; i2 < 1; i2++) { Tensor data = new Tensor((10, 3, 4), DeviceConfig.Host_Float); for (int i = 0; i < data.Shape.TotalSize; i++) { ((float *)data.Array)[i] = i / 12; } x.SetInput(data); sum.PreCheck(); Index a = new Index(x.OuterShape); a.SetZero(); for (int i = 0; i < x.OuterShape.TotalSize; i++, a.Increase(1)) { Console.WriteLine("Term " + i + ":" + sum.GetTerm(a).GetResult()); } c.Restart(); sum.Minimize(); c.Stop(); data.Dispose(); Console.WriteLine($"{i2} took {c.ElapsedMilliseconds}ms"); } }
/// <summary> /// Sets the occupation counter of each shift to the correct amount as determined by the amount of employeeIds present for that shift. /// </summary> /// <param name="shiftTime"></param> /// <param name="employeeIds"></param> private void SetShiftOccupation(ShiftTime shiftTime, int numberScheduled, int capacity) { switch (shiftTime) { case ShiftTime.Morning: labelCapacityMorning.Text = $"{numberScheduled}/{capacity}"; labelCapacityMorning.BackColor = IndicatorColor(numberScheduled, capacity); break; case ShiftTime.Afternoon: labelCapacityAfternoon.Text = $"{numberScheduled}/{capacity}"; labelCapacityAfternoon.BackColor = IndicatorColor(numberScheduled, capacity); break; case ShiftTime.Evening: labelCapacityEvening.Text = $"{numberScheduled}/{capacity}"; labelCapacityEvening.BackColor = IndicatorColor(numberScheduled, capacity); break; default: break; } }
private async void Reset_Shift_btn_Click(object sender, RoutedEventArgs e) { Reset_Shift_btn.Visibility = Visibility.Hidden; //quăng phần update dưới db cho 1 thread khác, UI không quan tâm phần này Task t = Task.Run(() => { ShiftDAO dao = new ShiftDAO(); List <UserShiftEntity> data = dao.getAll() as List <UserShiftEntity>; List <UserShiftEntity> Weekdata = data.Where(x => x.Week == DateTime.Today.DayOfYear / 7).ToList(); foreach (var c in Weekdata) { dao.delete(c); } }); ShiftTime.resetShift(); Page_Loaded(null, null); MessageBox.Show("RESET DONE!", "INFO", MessageBoxButton.OK, MessageBoxImage.Information); await t; Reset_Shift_btn.Visibility = Visibility.Visible; }
/// <summary> /// Checks if a 3-character string of preferred hours matches the shifttime of the shift. /// Decides based on that whether the employee wants to work during that time and day. /// </summary> /// <param name="shiftTime">The shift time.</param> /// <param name="preferredHours">The preferred hours.</param> /// <returns></returns> private bool WantsToWorkShiftTime(ShiftTime shiftTime, string preferredHours) { switch (shiftTime) { case ShiftTime.Morning: if (preferredHours[0].ToString() == "1") { return(true); } else { return(false); } case ShiftTime.Afternoon: if (preferredHours[1].ToString() == "1") { return(true); } else { return(false); } case ShiftTime.Evening: if (preferredHours[2].ToString() == "1") { return(true); } else { return(false); } } return(false); }
public async void Load_Table() { //update status shift listShiftTime = ShiftTime.getAllShift(); //update trong map for (int i = 0; i < listShiftMapping.Count; i++) { listShiftMapping[i].shift = listShiftTime[i]; } //khởi tạo list thread, 1 task = 1 thread List <Task> taskList = new List <Task>(); //duyệt mỗi ô, update mỗi ô = 1 thread foreach (ShiftMapping shiftMapping in listShiftMapping) { //add vào thead tự chạy taskList.Add(LoadShift(shiftMapping)); } //đợi cho tất cả các ô chạy xong await Task.WhenAll(taskList); }
public void Insert(ShiftTime shiftTime) { throw new NotImplementedException(); }
public ShiftTime Save(ShiftTime shifTime) { return(shifTimeService.Save(shifTime)); }
private void btnClockIn_Click(object sender, EventArgs e) { if (cmbShift.SelectedIndex == -1) { return; } if (chbxForceShift.Checked) { DateTime date = dtpDate.Value.Date; int shifttype = (cmbShift.SelectedItem as ComboboxItem).Value; ShiftTime shifttime = new ShiftTime(); switch (shifttype) { case 0: shifttime = ShiftTime.Morning; break; case 1: shifttime = ShiftTime.Afternoon; break; case 2: shifttime = ShiftTime.Evening; break; } Shift shift = shiftStorage.Get(date, shifttime); if (shift == null) { // shift does not exist shift = new Shift(0, date, shifttime, 1); shiftStorage.Create(shift); shift = shiftStorage.Get(date, shifttime); } // check if a department is selected if (cmbxDepartment.SelectedIndex == -1) { MessageBox.Show("Please select a department!"); return; } int depid = (cmbxDepartment.SelectedItem as ComboboxItem).Value; shiftStorage.Assign(shift.Id, this.userid, depid); string dateclockin = dtpClockIn.Value.ToString("yyyy-MM-dd hh:mm:ss"); shiftStorage.CreateAttendance(this.userid, shift.Id, dateclockin); MessageBox.Show("Succesfully clocked in! Tip: in order to have minutes worked you have to clock out"); } else { // modify an existing shift int shiftid = (cmbShift.SelectedItem as ComboboxItem).Value; string dateclockin = dtpClockIn.Value.ToString("yyyy-MM-dd hh:mm:ss"); int attendenceid = shiftStorage.CheckAttendance(this.userid, shiftid); if (attendenceid != 0) { shiftStorage.ModifyClockInAttendance(attendenceid, dateclockin); } else { shiftStorage.CreateAttendance(this.userid, shiftid, dateclockin); } MessageBox.Show("Succesfully clocked in! Tip: in order to have minutes worked you have to clock out"); } cmbxDepartment.Items.Clear(); lblDepartment.Visible = false; cmbxDepartment.Visible = false; chbxForceShift.Checked = false; }
public void ImportExcel() { ExcelShiftsOfDepartment excelShiftsOfDepartment = ReadExcelShiftData(); excelShiftsOfDepartment.DepartmentId = 2; //HR excelShiftsOfDepartment.Location = 2; excelShiftsOfDepartment.Month = 7; excelShiftsOfDepartment.Year = 2017; Dictionary <string, int> duplicatedEmployees = ValidateDuplicatedData(excelShiftsOfDepartment); string siteUrl = "http://rbvhspdev01:81/"; ShiftManagementDAL _shiftManagementDAL = new ShiftManagementDAL(siteUrl); ShiftManagementDetailDAL _shiftManagementDetailDAL = new ShiftManagementDetailDAL(siteUrl); List <ShiftManagement> shiftManagements = _shiftManagementDAL.GetByMonthYearDepartment(excelShiftsOfDepartment.Month, excelShiftsOfDepartment.Year, excelShiftsOfDepartment.DepartmentId, excelShiftsOfDepartment.Location); List <ShiftManagementDetail> shiftManagementDetails = new List <ShiftManagementDetail>(); if (shiftManagements != null && shiftManagements.Count > 0) { shiftManagementDetails = _shiftManagementDetailDAL.GetByShiftManagementID(shiftManagements[0].ID); } EmployeeInfoDAL _employeeInfoDAL = new EmployeeInfoDAL(siteUrl); List <EmployeeInfo> employeesOfDepartment = _employeeInfoDAL.GetByLocationAndDepartment(2, excelShiftsOfDepartment.DepartmentId, true, 4, StringConstant.EmployeeInfoList.EmployeeIDField); if (shiftManagementDetails != null && shiftManagementDetails.Count > 0) { foreach (var employeeShift in excelShiftsOfDepartment.EmployeeShifts) { EmployeeInfo employeeInfo = employeesOfDepartment.Where(e => e.EmployeeID == employeeShift.EmployeeID).FirstOrDefault(); if (employeeInfo != null) { employeeShift.EmployeeLookupID = employeeInfo.ID; } } List <int> employeeLookupIds = excelShiftsOfDepartment.EmployeeShifts.Select(e => e.EmployeeLookupID).ToList(); shiftManagementDetails = shiftManagementDetails.Where(e => employeeLookupIds.Contains(e.Employee.LookupId)).ToList(); } foreach (ExcelEmployeeShift excelEmployeeShift in excelShiftsOfDepartment.EmployeeShifts) { ShiftManagementDetail shiftManagementDetail = shiftManagementDetails.Where(e => e.Employee.LookupId == excelEmployeeShift.EmployeeLookupID).FirstOrDefault(); if (shiftManagementDetail == null) { shiftManagementDetail = new ShiftManagementDetail(); EmployeeInfo employeeInfo = employeesOfDepartment.Where(e => e.EmployeeID == excelEmployeeShift.EmployeeID).FirstOrDefault(); shiftManagementDetail.Employee = new LookupItem() { LookupId = employeeInfo.ID, LookupValue = employeeInfo.FullName }; shiftManagementDetails.Add(shiftManagementDetail); } ShiftTimeDAL _shiftTimeDAL = new ShiftTimeDAL(siteUrl); List <ShiftTime> shiftTimes = _shiftTimeDAL.GetAll(); for (int i = 0; i < 11; i++) { ShiftTime shiftTime = shiftTimes.Where(e => e.Code.ToUpper() == excelEmployeeShift.ShiftCodes[i].ToUpper()).FirstOrDefault(); if (shiftTime != null) { Type type = typeof(ShiftManagementDetail); PropertyInfo shiftApprovalInfo = type.GetProperty(string.Format("ShiftTime{0}Approval", i + 21)); object shiftApprovalValue = shiftApprovalInfo.GetValue(shiftManagementDetail, null); if (shiftApprovalValue != null && Convert.ToBoolean(shiftApprovalValue) == false) { PropertyInfo shiftInfo = type.GetProperty(string.Format("ShiftTime{0}", i + 21)); LookupItem shiftValue = shiftInfo.GetValue(shiftManagementDetail, null) as LookupItem; if (shiftValue == null) { shiftValue = new LookupItem(); } shiftValue.LookupId = shiftTime.ID; shiftValue.LookupValue = shiftTime.Code; } } } for (int i = 11; i < 31; i++) { ShiftTime shiftTime = shiftTimes.Where(e => e.Code.ToUpper() == excelEmployeeShift.ShiftCodes[i].ToUpper()).FirstOrDefault(); if (shiftTime != null) { Type type = typeof(ShiftManagementDetail); PropertyInfo shiftApprovalInfo = type.GetProperty(string.Format("ShiftTime{0}Approval", i - 10)); object shiftApprovalValue = shiftApprovalInfo.GetValue(shiftManagementDetail, null); if (shiftApprovalValue != null && Convert.ToBoolean(shiftApprovalValue) == false) { PropertyInfo shiftInfo = type.GetProperty(string.Format("ShiftTime{0}", i - 10)); LookupItem shiftValue = shiftInfo.GetValue(shiftManagementDetail, null) as LookupItem; if (shiftValue == null) { shiftValue = new LookupItem(); } shiftValue.LookupId = shiftTime.ID; shiftValue.LookupValue = shiftTime.Code; } } } } int shiftId = 0; if (shiftManagements == null || shiftManagements.Count == 0) { Biz.Models.ShiftManagement shiftManagement = new Biz.Models.ShiftManagement(); shiftManagement.Department = new LookupItem() { LookupId = excelShiftsOfDepartment.DepartmentId, LookupValue = excelShiftsOfDepartment.DepartmentId.ToString() }; shiftManagement.Location = new LookupItem() { LookupId = excelShiftsOfDepartment.Location, LookupValue = excelShiftsOfDepartment.Location.ToString() }; shiftManagement.Month = excelShiftsOfDepartment.Month; shiftManagement.Year = excelShiftsOfDepartment.Year; EmployeeInfo requester = _employeeInfoDAL.GetByADAccount(122); shiftManagement.Requester = new LookupItem() { LookupId = requester.ID, LookupValue = requester.FullName }; EmployeeInfo approvedBy = _employeeInfoDAL.GetByPositionDepartment(StringConstant.EmployeePosition.DepartmentHead, excelShiftsOfDepartment.DepartmentId, excelShiftsOfDepartment.Location).FirstOrDefault(); shiftManagement.ApprovedBy = new User() { ID = approvedBy.ADAccount.ID, UserName = approvedBy.ADAccount.UserName, FullName = approvedBy.FullName, IsGroup = false }; shiftId = _shiftManagementDAL.SaveOrUpdate(shiftManagement); } else { shiftId = shiftManagements[0].ID; } if (shiftId > 0) { foreach (ShiftManagementDetail shiftManagementDetail in shiftManagementDetails) { shiftManagementDetail.ShiftManagementID = new LookupItem() { LookupId = shiftId, LookupValue = shiftId.ToString() }; int shiftDetailId = _shiftManagementDetailDAL.SaveOrUpdate(shiftManagementDetail); } } }
private void comboBoxShiftTime_SelectedIndexChanged(Object sender, EventArgs e) { this.shiftTime = (ShiftTime)comboBoxShiftTime.SelectedItem; }
public ActionResult Create([Bind(Include = "JobId,JobTitle,JobNumber,ShiftTimes,StreetAddress,City,State,Zipcode,Note")] Job job, [Bind(Include = "Person, StartDate,EndDate")] Schedule schedule, String Foremen, [Bind(Include = "ShiftTimeId, Default, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday")] ShiftTime shiftTime, string ShiftTimeDefault, string SelectWeekDay1, string SelectWeekDay2, string SelectWeekDay3, string SelectWeekDay4, string SelectWeekDay5, string SelectShiftTime1, string SelectShiftTime2, string SelectShiftTime3, string SelectShiftTime4, string SelectShiftTime5) { if (ModelState.IsValid) { if (db.Jobs.Any(j => j.JobTitle.Equals(job.JobTitle))) { ModelState.AddModelError("JobTitle", "This job title is currently being used, please change the title," + " or delete/modify the job titled " + "\"" + job.JobTitle + "\"."); return(View(job)); } if (db.Jobs.Any(j => j.JobNumber.Equals(job.JobNumber))) { ModelState.AddModelError("JobNumber", "This job number is currently being used, please change the number," + " or delete/modify the job numbered " + "\"" + job.JobNumber + "\"."); return(View(job)); } //Checking if the weekdays repeat HashSet <string> selectWD = new HashSet <string>(); if (!string.IsNullOrEmpty(SelectWeekDay1) && !selectWD.Add(SelectWeekDay1) || !string.IsNullOrEmpty(SelectWeekDay2) && !selectWD.Add(SelectWeekDay2) || !string.IsNullOrEmpty(SelectWeekDay3) && !selectWD.Add(SelectWeekDay3) || !string.IsNullOrEmpty(SelectWeekDay4) && !selectWD.Add(SelectWeekDay4) || !string.IsNullOrEmpty(SelectWeekDay5) && !selectWD.Add(SelectWeekDay5) ) { ViewBag.ErrorMessage = "Please select any Weekday only once"; return(View(job)); } else { shiftTime.ShiftTimeId = Guid.NewGuid();//Creates ShiftTimeID for a job shiftTime.Default = ShiftTimeDefault; RecordShiftTime(SelectWeekDay1, SelectShiftTime1); RecordShiftTime(SelectWeekDay2, SelectShiftTime2); RecordShiftTime(SelectWeekDay3, SelectShiftTime3); RecordShiftTime(SelectWeekDay4, SelectShiftTime4); RecordShiftTime(SelectWeekDay5, SelectShiftTime5); db.ShiftTimes.Add(shiftTime); db.SaveChanges(); job.JobId = Guid.NewGuid(); job.ShiftTimes = db.ShiftTimes.Where(j => j.ShiftTimeId == shiftTime.ShiftTimeId).First(); db.Jobs.Add(job); db.SaveChanges(); //Selects a correct collumn in ShiftTimes Table to record a shifttime ShiftTime RecordShiftTime(string day, string time) { if (day != null) { if (day == "Monday") { shiftTime.Monday = time; } if (day == "Tuesday") { shiftTime.Tuesday = time; } if (day == "Wednesday") { shiftTime.Wednesday = time; } if (day == "Thursday") { shiftTime.Thursday = time; } if (day == "Friday") { shiftTime.Friday = time; } if (day == "Saturday") { shiftTime.Saturday = time; } if (day == "Sunday") { shiftTime.Sunday = time; } } return(shiftTime); } if (schedule != null) { ApplicationUser foreman = db.Users.Where(f => f.Id == Foremen).FirstOrDefault(); schedule.Job = db.Jobs.Where(j => j.JobId == job.JobId).FirstOrDefault(); schedule.Person = foreman; schedule.ScheduleId = Guid.NewGuid(); db.Schedules.Add(schedule); //db.SaveChanges(); Commented as had an error occurs during job creation due to shedule always exists even if the form Foreman is not populated.-NZ } return(RedirectToAction("Index")); } } return(View(job)); }
public ShiftMapping(ShiftTime _shift, Button _button, TextBlock _textBlock) { shift = _shift; button = _button; textBlock = _textBlock; }
public void Update(ShiftTime shiftTime) { throw new NotImplementedException(); }