Exemple #1
0
        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);
        }