Exemplo n.º 1
0
        private async void btnSave_Click(object sender, RoutedEventArgs e)
        {
            Login.MasterPage.Loading(true, this);

            try
            {
                List<DataLibrary.DocumentDTO> _result = new List<DataLibrary.DocumentDTO>();

                List<DataLibrary.DocumentDTO> _savedto = new List<DataLibrary.DocumentDTO>();
                foreach (DataLibrary.DocumentDTO _dto in _trgSafety)
                {
                    //_dto.CWPID = Lib.CWPDataSource.selectedCWP;
                    _dto.DocumentTypeLUID = Lib.DocType.AssociatedDoc;
                    _dto.FIWPID = _fiwpid;
                    _dto.PersonnelID = Login.UserAccount.PersonnelId;
                    //_dto.ProjectScheduleID = Lib.ScheduleDataSource.selectedSchedule;
                    _dto.ProjectID = _projectid;
                    _dto.DisciplineCode = _disciplineCode;
                    _dto.UpdatedBy = Login.UserAccount.UserName;
                    _dto.UpdatedDate = DateTime.Now;
                    
                    _savedto.Add(_dto);
                }

                DataLibrary.DocumentDTO document = new DataLibrary.DocumentDTO();
                document.DocumentTypeLUID = Lib.DocType.AssociatedDoc;
               // document.CWPID = Lib.CWPDataSource.selectedCWP;
                document.ProjectID = _projectid;
                document.DisciplineCode = _disciplineCode;
               // document.ProjectScheduleID = Lib.ScheduleDataSource.selectedSchedule;
                document.FIWPID = _fiwpid;
                document.UpdatedBy = Login.UserAccount.UserName;
                document.UpdatedDate = DateTime.Now;
                

                List<DataLibrary.DocumentDTO> listdocument = new List<DataLibrary.DocumentDTO>();
                listdocument.Add(document);
                
                List<DataLibrary.FiwpDTO> fiwpdto = new List<DataLibrary.FiwpDTO>();
                fiwpdto = Lib.IWPDataSource.iwplist.Where(x => x.FiwpID == _fiwpid).ToList();
                
                fiwpdto[0].DTOStatus = (int)DataLibrary.Utilities.RowStatus.Update;

                fiwpdto[0].DocEstablishedLUID = DataLibrary.Utilities.DocEstablishedForCSU.AssociatedDoc;
               
                _result = await (new Lib.ServiceModel.ProjectModel()).SaveSafetyDocumentForAssembleIWP(_savedto, fiwpdto, listdocument);
                //_result = await (new Lib.ServiceModel.ProjectModel()).SaveAssociatedDocumentForBuildCSU(listdocument, fiwpdto);
                _trgSafety = await (new Lib.ServiceModel.ProjectModel()).GetDocumentForFIWPByDocType(Lib.DocType.AssociatedDoc, _fiwpid, _projectid, _disciplineCode);
                lvFiwpITRForms.ItemsSource = _trgSafety;

                lvITRForms.ItemsSource = null;
                lvITRForms.ItemsSource = (from x in _orgSafety where !(from b in _trgSafety where b.DTOStatus != (int)DataLibrary.Utilities.RowStatus.Delete select b.SPCollectionID).Contains(x.SPCollectionID) select x);


                Lib.IWPDataSource _siwp = new Lib.IWPDataSource();
                await _siwp.GetCSUPackageOnMode(_projectid, Lib.CommonDataSource.selectedSystemID);
               
                DataLibrary.FiwpDTO iwpdto = new DataLibrary.FiwpDTO();
                iwpdto = Lib.IWPDataSource.iwplist.Where(x => x.FiwpID == _fiwpid).FirstOrDefault();

                Lib.IWPDataSource.selectedHydro = iwpdto.FiwpID;
                Lib.IWPDataSource.selectedHydroName = iwpdto.FiwpName;
                Lib.IWPDataSource.isWizard = iwpdto.DocEstablishedLUID == DataLibrary.Utilities.DocEstablishedForCSU.AssociatedDoc ? false : true;

                this.Frame.Navigate(typeof(Discipline.Schedule.BuildCSU.AssembleCSU));

            }

            catch (Exception ex)
            {
                (new WinAppLibrary.Utilities.Helper()).ExceptionHandler(ex, "Associated Document", "There was an error Save to Associated Document. Pleae contact administrator", "Error!");
            }

            Login.MasterPage.Loading(false, this);

        }