private void threadSearch_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { this.Cursor = null; btnSearch.IsEnabled = true; if (e.Error != null) { MessageBox.Show(e.Error.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } ProductionMemoModel productionMemo = e.Result as ProductionMemoModel; if (productionMemo != null) { lblMemoId.Text = productionMemo.MemoId; SectionModel section = sectionList.Where(s => s.SectionId == productionMemo.SectionId).FirstOrDefault(); if (section != null) { cboSection.SelectedItem = section; } string[] productNumberArray = productionMemo.ProductionNumbers.Split(';'); foreach (string productNumber in productNumberArray) { if (string.IsNullOrEmpty(productNumber) == false) { productionNumbers.Add(new ProductionNumberModel() { Value = productNumber }); } } if (productionMemo.Picture != null) { imgPicture.Source = ConvertJPGHelper.GetBitmapImageFromJPG(productionMemo.Picture); } if (productionMemo.Picture1 != null) { imgPicture1.Source = ConvertJPGHelper.GetBitmapImageFromJPG(productionMemo.Picture1); } if (productionMemo.Picture2 != null) { imgPicture2.Source = ConvertJPGHelper.GetBitmapImageFromJPG(productionMemo.Picture2); } if (productionMemo.Picture3 != null) { imgPicture3.Source = ConvertJPGHelper.GetBitmapImageFromJPG(productionMemo.Picture3); } if (productionMemo.Picture4 != null) { imgPicture4.Source = ConvertJPGHelper.GetBitmapImageFromJPG(productionMemo.Picture4); } } else { MessageBox.Show("Not Found!", "Search", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { SectionModel section = cboSection.SelectedItem as SectionModel; if (section == null) { return; } List <ProductionNumberModel> productionNumberList = productionNumbers.Where(p => p != null && string.IsNullOrEmpty(p.Value.Trim()) == false).ToList(); if (productionNumberList.Count <= 0) { return; } BitmapImage picture = imgPicture.Source as BitmapImage; BitmapImage picture1 = imgPicture1.Source as BitmapImage; BitmapImage picture2 = imgPicture2.Source as BitmapImage; BitmapImage picture3 = imgPicture3.Source as BitmapImage; BitmapImage picture4 = imgPicture4.Source as BitmapImage; if (picture == null && picture1 == null && picture2 == null && picture3 == null && picture4 == null) { return; } string productionNumberString = ""; foreach (ProductionNumberModel productionNumber in productionNumberList) { productionNumberString += productionNumber.Value + ";"; } ProductionMemoModel model = new ProductionMemoModel() { SectionId = section.SectionId, ProductionNumbers = productionNumberString, Picture = null, Picture1 = null, Picture2 = null, Picture3 = null, Picture4 = null, }; if (picture != null) { model.Picture = ConvertJPGHelper.GetJPGFromBitmapImage(picture); } if (picture1 != null) { model.Picture1 = ConvertJPGHelper.GetJPGFromBitmapImage(picture1); } if (picture2 != null) { model.Picture2 = ConvertJPGHelper.GetJPGFromBitmapImage(picture2); } if (picture3 != null) { model.Picture3 = ConvertJPGHelper.GetJPGFromBitmapImage(picture3); } if (picture4 != null) { model.Picture4 = ConvertJPGHelper.GetJPGFromBitmapImage(picture4); } if (threadInsert.IsBusy == true) { return; } this.Cursor = Cursors.Wait; btnSave.IsEnabled = false; threadInsert.RunWorkerAsync(model); }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Save?", "Confirm", MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK) { return; } string memoId = lblMemoId.Text; if (string.IsNullOrEmpty(memoId) == true) { return; } List <ProductionNumberModel> productionNumberList = productionNumbers.Where(p => p != null && string.IsNullOrEmpty(p.Value.Trim()) == false).ToList(); if (productionNumberList.Count <= 0) { return; } BitmapImage picture = imgPicture.Source as BitmapImage; BitmapImage picture1 = imgPicture1.Source as BitmapImage; BitmapImage picture2 = imgPicture2.Source as BitmapImage; BitmapImage picture3 = imgPicture3.Source as BitmapImage; BitmapImage picture4 = imgPicture4.Source as BitmapImage; if (picture == null && picture1 == null && picture2 == null && picture3 == null && picture4 == null) { return; } string productionNumberString = ""; foreach (ProductionNumberModel productionNumber in productionNumberList) { productionNumberString += productionNumber.Value + ";"; } ProductionMemoModel model = new ProductionMemoModel() { MemoId = memoId, ProductionNumbers = productionNumberString, Picture = null, Picture1 = null, Picture2 = null, Picture3 = null, Picture4 = null, }; if (picture != null) { model.Picture = ConvertJPGHelper.GetJPGFromBitmapImage(picture); } if (picture1 != null) { model.Picture1 = ConvertJPGHelper.GetJPGFromBitmapImage(picture1); } if (picture2 != null) { model.Picture2 = ConvertJPGHelper.GetJPGFromBitmapImage(picture2); } if (picture3 != null) { model.Picture3 = ConvertJPGHelper.GetJPGFromBitmapImage(picture3); } if (picture4 != null) { model.Picture4 = ConvertJPGHelper.GetJPGFromBitmapImage(picture4); } if (threadInsert.IsBusy == true) { return; } this.Cursor = Cursors.Wait; btnSave.IsEnabled = false; threadInsert.RunWorkerAsync(model); }
private void dgProductionMemo_MouseDoubleClick(object sender, MouseButtonEventArgs e) { ProductionMemoModel productionMemoView = dgProductionMemo.CurrentItem as ProductionMemoModel; if (productionMemoView == null) { return; } lblMemoId.Text = null; cboSection.SelectedItem = null; productionNumbers.Clear(); imgPicture.Source = null; imgPicture1.Source = null; imgPicture2.Source = null; imgPicture3.Source = null; imgPicture4.Source = null; ProductionMemoModel productionMemo = productionMemoList.Where(p => p.MemoId == productionMemoView.MemoId).FirstOrDefault(); if (productionMemo != null) { lblMemoId.Text = productionMemo.MemoId; SectionModel section = sectionList.Where(s => s.SectionId == productionMemo.SectionId).FirstOrDefault(); if (section != null) { cboSection.SelectedItem = section; } string[] productNumberArray = productionMemo.ProductionNumbers.Split(';'); foreach (string productNumber in productNumberArray) { if (string.IsNullOrEmpty(productNumber) == false) { productionNumbers.Add(new ProductionNumberModel() { Value = productNumber }); } } if (productionMemo.Picture != null) { imgPicture.Source = ConvertJPGHelper.GetBitmapImageFromJPG(productionMemo.Picture); } if (productionMemo.Picture1 != null) { imgPicture1.Source = ConvertJPGHelper.GetBitmapImageFromJPG(productionMemo.Picture1); } if (productionMemo.Picture2 != null) { imgPicture2.Source = ConvertJPGHelper.GetBitmapImageFromJPG(productionMemo.Picture2); } if (productionMemo.Picture3 != null) { imgPicture3.Source = ConvertJPGHelper.GetBitmapImageFromJPG(productionMemo.Picture3); } if (productionMemo.Picture4 != null) { imgPicture4.Source = ConvertJPGHelper.GetBitmapImageFromJPG(productionMemo.Picture4); } } else { MessageBox.Show("Not Found!", "Search", MessageBoxButton.OK, MessageBoxImage.Error); } }