/// <summary> /// Sets properly the right values for ActualDuration & Qty for services and inventory items and the /// ActualDateTimeBegin & ActualDateTimeEnd for the staff members when starting & re-opening the appointment. /// </summary> public virtual void UpdateAppointmentDetActualFields(AppointmentCore.AppointmentDetails_View appointmentDetails, AppointmentCore.AppointmentServiceEmployees_View appointmentEmployees, bool isReOpen = false) { foreach (FSAppointmentDet fsAppointmentDetRow in appointmentDetails.Select().RowCast <FSAppointmentDet>()) { if (fsAppointmentDetRow.IsService || fsAppointmentDetRow.IsInventoryItem) { if (fsAppointmentDetRow.IsService && fsAppointmentDetRow.StaffRelated == true) { appointmentDetails.Cache.SetDefaultExt <FSAppointmentDet.actualDuration>(fsAppointmentDetRow); } else if (fsAppointmentDetRow.IsService && fsAppointmentDetRow.StaffRelated == false) { appointmentDetails.Cache.SetDefaultExt <FSAppointmentDet.actualDuration>(fsAppointmentDetRow); } if (fsAppointmentDetRow.BillingRule == ID.BillingRule.FLAT_RATE || fsAppointmentDetRow.BillingRule == ID.BillingRule.NONE || fsAppointmentDetRow.IsInventoryItem == true) { fsAppointmentDetRow.Qty = isReOpen ? 0 : fsAppointmentDetRow.EstimatedQty; } appointmentDetails.Update(fsAppointmentDetRow); } } }
/// <summary> /// Gets Staff Members already existing in the Staff tab with the <c>lineRef</c> related. The <c>employeesView</c> can be of type AppointmentEmployees_View or ServiceOrderEmployees_View. /// </summary> /// <param name="staffView">Object of type AppointmentEmployees_View or ServiceOrderEmployees_View.</param> /// <param name="lineRef">Line ref of related Service Line.</param> /// <returns>List of EmployeeID's existing in Employee Tab.</returns> private static List <int?> GetStaffByLineRefTab(object staffView, string lineRef) { List <int?> employeeIDList = new List <int?>(); if (staffView is AppointmentCore.AppointmentServiceEmployees_View) { AppointmentCore.AppointmentServiceEmployees_View appEmployeeView = (AppointmentCore.AppointmentServiceEmployees_View)staffView; foreach (FSAppointmentEmployee fsAppointmentEmployeeRow in appEmployeeView.Select().AsEnumerable().Where(y => ((FSAppointmentEmployee)y).ServiceLineRef == lineRef)) { employeeIDList.Add(fsAppointmentEmployeeRow.EmployeeID); } } if (staffView is ServiceOrderCore.ServiceOrderEmployees_View) { ServiceOrderCore.ServiceOrderEmployees_View soEmployeeView = (ServiceOrderCore.ServiceOrderEmployees_View)staffView; foreach (FSSOEmployee fsSOEmployeeRow in soEmployeeView.Select().AsEnumerable().Where(y => ((FSSOEmployee)y).ServiceLineRef == lineRef)) { employeeIDList.Add(fsSOEmployeeRow.EmployeeID); } } return(employeeIDList); }
/// <summary> /// Initialize the EmployeeGrid filter with the existing employees in the Employee tab. /// </summary> /// <param name="employeesView">Employee view from Appointment or ServiceOrder screen.</param> private static IEnumerable <EmployeeGridFilter> PopulateEmployeeFilter(object employeesView) { HashSet <EmployeeGridFilter> employees = new HashSet <EmployeeGridFilter>(); if (employeesView is AppointmentCore.AppointmentServiceEmployees_View) { AppointmentCore.AppointmentServiceEmployees_View appEmployeeView = (AppointmentCore.AppointmentServiceEmployees_View)employeesView; foreach (FSAppointmentEmployee fsAppointmentEmployeeRow in appEmployeeView.Select()) { EmployeeGridFilter employee = new EmployeeGridFilter(); employee.EmployeeID = fsAppointmentEmployeeRow.EmployeeID; employees.Add(employee); } } if (employeesView is ServiceOrderCore.ServiceOrderEmployees_View) { ServiceOrderCore.ServiceOrderEmployees_View soEmployeeView = (ServiceOrderCore.ServiceOrderEmployees_View)employeesView; foreach (FSSOEmployee fsSOEmployeeRow in soEmployeeView.Select()) { EmployeeGridFilter employee = new EmployeeGridFilter(); employee.EmployeeID = fsSOEmployeeRow.EmployeeID; employees.Add(employee); } } return(employees); }