Beispiel #1
0
        public LabBookDto AddNew(LabBookDto labBook)
        {
            var result = _repository.Save(labBook);

            if (result != null)
            {
                DataRow newRow = _dataTable.NewRow();
                newRow["id"]          = result.Id;
                newRow["title"]       = result.Title;
                newRow["density"]     = result.Density;
                newRow["observation"] = result.Observation;
                newRow["remarks"]     = result.Remarks;
                newRow["user_id"]     = result.UserId;
                newRow["cycle_id"]    = result.CycleId;
                newRow["created"]     = result.Created;
                newRow["modified"]    = result.Modified;
                newRow["deleted"]     = result.Deleted;

                var tmp = _modified;
                _dataTable.Rows.Add(newRow);
                var row = _dataTable.AsEnumerable()
                          .SingleOrDefault(r => r.Field <long>("id") == result.Id);
                row.AcceptChanges();
                _modified = tmp;
            }

            return(result);
        }
Beispiel #2
0
        public bool AddNewSeries(LabBookDto labBook)
        {
            var      tmp      = "";
            var      count    = 0;
            InputBox inputBox = new InputBox("Podaj ilość pustych rekordów:", "Ilość");

            if (inputBox.ShowDialog() == true)
            {
                tmp = inputBox.Answer;
            }

            if (!int.TryParse(tmp, out count))
            {
                MessageBox.Show("Wprowadzona wartość nie jest liczbą całkowitą.", "Zła wartość", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }

            if (count == 0)
            {
                return(false);
            }

            for (var i = 0; i < count; i++)
            {
                _ = AddNew(labBook);
            }

            return(true);
        }
Beispiel #3
0
        public SemiProductFormMV(LabBookDto labBookDto)
        {
            _labBookDto      = labBookDto;
            _semiProductView = _materialService.GetAll(MaterialType.SemiProduct);

            OnClosingCommand          = new RelayCommand <CancelEventArgs>(OnClosingCommandExecuted);
            OnSelectionChangedCommand = new RelayCommand <SelectionChangedEventArgs>(OnSelectionChangedCommandExecuted);

            _worker = new BackgroundWorker();
            _worker.WorkerReportsProgress      = true;
            _worker.WorkerSupportsCancellation = true;
            _worker.DoWork             += ProgressRun;
            _worker.ProgressChanged    += ProgressChanged;
            _worker.RunWorkerCompleted += ProgressFinished;
        }
Beispiel #4
0
        public SemiProductForm(LabBookDto labBookDto)
        {
            InitializeComponent();

            SemiProductFormMV semiProductFormMV = new SemiProductFormMV(labBookDto);

            DataContext = semiProductFormMV;

            FilterMV     filterMV = Resources["filter"] as FilterMV;
            NavigationMV naviMV   = Resources["navi"] as NavigationMV;

            filterMV.SetWindowEdit(semiProductFormMV);
            naviMV.ModelView = semiProductFormMV;
            semiProductFormMV.NavigationMV = naviMV;
        }
Beispiel #5
0
        public MaterialDto AddNewSemiProduct()
        {
            string   input    = "";
            InputBox inputBox = new InputBox("Podaj numer D nowego półproduktu:", "Numer D");

            if (inputBox.ShowDialog() == true)
            {
                input = inputBox.Answer;
            }
            if (string.IsNullOrEmpty(input) || !long.TryParse(input, out long nrD))
            {
                _ = MessageBox.Show("Wprowadzony numer nie jest liczbą całkowitą!", "Zła wartość", MessageBoxButton.OK, MessageBoxImage.Error);
                return(null);
            }

            LabBookRepository repository = new LabBookRepository();
            LabBookDto        labBookDto = repository.GetById(nrD, LabBookRepository.GetByIdQuery);

            if (labBookDto == null)
            {
                _ = MessageBox.Show("Podany numer D" + nrD + " nie istnieje w bazie danych!", "Brak numeru", MessageBoxButton.OK, MessageBoxImage.Information);
                return(null);
            }
            if (_repository.ExistById(nrD, MaterialRepository.ExistByIntDQuery))
            {
                _ = MessageBox.Show("Półprodukt o numerze D" + nrD + " istnieje już w tabeli półprodukty.", "Brak numeru", MessageBoxButton.OK, MessageBoxImage.Information);
                return(new MaterialDto("", nrD));
            }

            MaterialDto material = new MaterialDto(labBookDto.Title, nrD)
            {
                LoginId = UserSingleton.Id
            };

            return(Save(material));
        }
Beispiel #6
0
        public LabBookDto CopyFromNumberD()
        {
            string tmp = "";
            long   id  = 0;

            InputBox inputBox = new InputBox("Podaj numer D do skopiowania:", "Numer D");

            if (inputBox.ShowDialog() == true)
            {
                tmp = inputBox.Answer;
            }

            if (!long.TryParse(tmp, out id))
            {
                MessageBox.Show("Wprowadzona wartość nie jest liczbą całkowitą.", "Zła wartość", MessageBoxButton.OK, MessageBoxImage.Error);
                return(null);
            }

            LabBookDto labBookDto = _repository.GetById(id, LabBookRepository.GetByIdQuery);

            if (labBookDto != null)
            {
                labBookDto.Created  = DateTime.Now;
                labBookDto.Modified = DateTime.Now;
                labBookDto.Deleted  = false;
                labBookDto.Density  = 0;
                AddNew(labBookDto);
            }
            else if (labBookDto == null)
            {
                MessageBox.Show("Brak takiego numeru. Nie mozna wykonac kopii.", "Brak wartości", MessageBoxButton.OK, MessageBoxImage.Information);
                return(null);
            }

            return(labBookDto);
        }