示例#1
0
 private async void BindCrew(FiwpmanonsiteDTO dto)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         var item = lvCrewList.Items.Where(x => (x as FiwpmanonsiteDTO).PersonnelID == dto.PersonnelID).FirstOrDefault();
         if (item != null)
         {
             lvCrewList.SelectedItem = item;
             CrewDTO = item as FiwpmanonsiteDTO;
         }
     });
 }
示例#2
0
 private async void BindCrew(object item)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         if (item != null)
         {
             lvCrewList.SelectedItem = item;
             CrewDTO = item as FiwpmanonsiteDTO;
             imgDefaultCrew.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
         }
     });
 }
示例#3
0
        private async Task<bool> UpdateCrew(FiwpmanonsiteDTO dto)
        {
            bool retValue = false;
            try
            {
                if (dto != null && dto.PersonnelID > 0)
                {
                    List<FiwpmanonsiteDTO> crewList_new = new List<FiwpmanonsiteDTO>() { dto };
                    //assign crew
                    crewList_new = await _projectSM.SaveFiwpManonsite(crewList_new);

                    if (crewList_new != null && crewList_new.Count > 0)
                    {
                        BindCrewList(ForemanDTO);
                        BindCrew(dto);
                        retValue = true;
                    }
                }
            }
            catch (Exception ex)
            {            
                throw ex;
            }

            return retValue;
        }
示例#4
0
        private async void RemoveCrew(FiwpmanonsiteDTO dto)
        {
            try
            {
                //Loading(true);
                var item = lvCrewList.Items.Where(x => (x as FiwpmanonsiteDTO) == dto).FirstOrDefault();
                var crew = _crewList.Where(AlignmentX => AlignmentX.FiwpManOnSiteID == dto.FiwpManOnSiteID).FirstOrDefault();

                if (item != null)
                {
                    dto.DTOStatus = (int)WinAppLibrary.Utilities.RowStatus.Delete;
                    await (new Lib.ServiceModel.ProjectModel()).SaveFiwpManonsite(new List<FiwpmanonsiteDTO>() { dto });                    
                    _crewList.Remove(crew);
                    lvCrewList.Items.Remove(item);
                }

                //Loading(false);
            }
            catch (Exception e)
            {
                (new WinAppLibrary.Utilities.Helper()).ExceptionHandler(e, "RemoveCrew");
                this.NotifyMessage("There was an error to connect to server", "Caution!");
            }
        }
示例#5
0
        private async Task<bool> AssignCrew(int personnelId)
        {
            bool retValue = false;

            if (personnelId > 0)
            {
                if (_crewList.Where(x => x.PersonnelID == personnelId).FirstOrDefault() == null)
                {
                    Loading(true);
                    PersonnelDTO tagmanDto = await _commonSM.GetSinglePersonnelByID(personnelId);

                    if(tagmanDto == null || tagmanDto.PersonnelID == 0)
                        this.NotifyMessage("It doesn't exist in DataBase!", "Alert");
                    else if (tagmanDto != null && tagmanDto.DepartmentID == WinAppLibrary.Utilities.Department.Crew)
                    {

                        FiwpmanonsiteDTO crew = new FiwpmanonsiteDTO();
                        crew.ModuleID = ForemanDTO.CurModuleID;
                        crew.ProjectID = ForemanDTO.CurProjectID;
                        crew.FIWPID = ForemanDTO.CurFIWPID;
                        crew.PersonnelID = tagmanDto.PersonnelID;
                        crew.FullName = tagmanDto.FName ?? "" + ", " + tagmanDto.LName ?? "";
                        crew.DepartStructureID = tagmanDto.CurDepartStructureID;
                        crew.ForemanDepartStructureID = ForemanDTO.CurDepartStructureID;
                        crew.ProjectID = ForemanDTO.CurProjectID;
                        crew.ModuleID = ForemanDTO.CurModuleID;
                        crew.StatusLUID = WinAppLibrary.Utilities.FiwpManonsiteStatus.OnSite;
                        crew.WorkDate = DateTime.Today;
                        crew.DTOStatus = (int)WinAppLibrary.Utilities.RowStatus.New;

                        retValue = await UpdateCrew(crew);
                    }
                    else
                        this.NotifyMessage("It's not crew!. Only crew can be assigned.", "Alert");

                    Loading(false);
                }
                else
                    this.NotifyMessage("This crew is already assigned.", "Alert");
            }

            return retValue;
        }