private void btnSave_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(tbTitle.Text)) { MessageBox.Show("Название работы не может быть пустым!"); return; } if (string.IsNullOrEmpty(tbCopy.Text)) { MessageBox.Show("Укажите копию работы!"); return; } if (string.IsNullOrEmpty(cbArtist.Text)) { MessageBox.Show("Укажите автора работы!"); return; } if (string.IsNullOrEmpty(dpAcuired.Text)) { MessageBox.Show("Укажите дату приобретения работы!"); return; } if (string.IsNullOrEmpty(tbAcquisitionPrice.Text)) { MessageBox.Show("Укажите цену приобретения работы!"); return; } WorkDto work = new WorkDto { Title = tbTitle.Text, Copy = tbCopy.Text, Description = tbDescription.Text, Artist = (ArtistDto)this.cbArtist.SelectedItem }; TransactionDto transaction = new TransactionDto { AcquisitionPrice = Convert.ToDecimal(tbAcquisitionPrice.Text), DateAcquired = Convert.ToDateTime(this.dpAcuired.Text) }; IWorkProcess workProcess = ProcessFactory.GetWorkProcess(); ITransactionProcess transProcess = ProcessFactory.GetTransactionProcess(); if (_id == 0) { workProcess.Add(work); FreeForSale = ProcessFactory.GetWorkProcess().GetList(); transaction.Work = FreeForSale.Last(); transProcess.Add(transaction); } else { work.Id = _id; workProcess.Update(work); } this.Close(); }
public void PushWork(IWorkProcess work) { workQueue.Add(work); SortWork(); if (working != null && (work.priority > working.priority)) { WorkInterrupt(); } NextWork(); }
void NextWork() { if (working == null && workQueue.Count > 0) { working = workQueue[0]; working.Work(() => { Debug.Log(working.interupted); if (working.interupted) { } else { Debug.Log("done"); workQueue.Remove(working); working = null; NextWork(); } }); } }
public void WorkInterrupt() { working.Stop(() => { }); working = null; }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (cbArtist == null) { MessageBox.Show("Необходимо выбрать художника", "Проверка"); return; } if (string.IsNullOrEmpty(tbCopy.Text)) { MessageBox.Show("Информация о копии не должна быть пустой", "Проверка"); return; } if (string.IsNullOrEmpty(tbDescription.Text)) { MessageBox.Show("Описание не должно быть пустым", "Проверка"); return; } if (string.IsNullOrEmpty(tbTitle.Text)) { MessageBox.Show("Название картины не должно быть пустым", "Проверка"); return; } WorkDto work = new WorkDto { Title = tbTitle.Text, Copy = tbCopy.Text, Description = tbDescription.Text, Artist = (ArtistDto)this.cbArtist.SelectedItem }; TransDto trans = new TransDto { AcquisitionPrice = Convert.ToDecimal(tbAcquisitionPrice.Text), DateAcquired = Convert.ToDateTime(this.dpAquired.Text) }; IWorkProcess workProcess = ProcessFactory.GetWorkProcess(); ITransProcess transProcess = ProcessFactory.GetTransProcess(); if (_workid == 0) { workProcess.Add(work); FreeForSale = ProcessFactory.GetWorkProcess().GetList(); trans.Work = FreeForSale.Last(); transProcess.Add(trans); } else { work.WorkID = _workid; workProcess.Update(work); } /*WorkDto work = new WorkDto(); * work.Artist = cbArtist.SelectedItem as ArtistDto; * work.Title = tbTitle.Text; * work.Copy = tbCopy.Text; * work.Description = tbDescription.Text; * IWorkProcess workProcess = ProcessFactory.GetWorkProcess(); * if(_workid==0) * { * workProcess.Add(work); * } * else * { * work.WorkID = _workid; * workProcess.Update(work); * }*/ Close(); }