private async void SubmitButton_Click(object sender, RoutedEventArgs e) { var errorMessage = "Harap isi semua kolom berikut: \n"; var anyError = false; if (string.IsNullOrWhiteSpace(YarnTypePrefixTextBox.Text) || string.IsNullOrWhiteSpace(YarnTypeSuffixTextbox.Text)) { anyError = true; errorMessage += "- Jenis Benang\n"; } if (string.IsNullOrWhiteSpace(LotNoTextBox.Text)) { anyError = true; errorMessage += "- Nomor Lot\n"; } decimal.TryParse(QuantityTextBox.Text, out var quantity); if (string.IsNullOrWhiteSpace(QuantityTextBox.Text) || quantity <= 0) { anyError = true; errorMessage += "- Quantity\n"; } if (anyError) { MessageBox.Show(errorMessage); } else { var viewModel = new ProductViewModel( string.Empty, string.Empty, string.Empty, string.Empty, LotNoTextBox.Text, "YARN", string.Empty, string.Empty, YarnTypePrefixTextBox.Text + YarnTypeSuffixTextbox.Text, string.Empty, "BALE", quantity, "PALET" ); var barcode = await PackingInventoryService.PostProduct(viewModel); if (barcode != null && !string.IsNullOrWhiteSpace(barcode.Code)) { LotNoTextBox.Text = string.Empty; YarnTypePrefixTextBox.Text = string.Empty; YarnTypeSuffixTextbox.Text = string.Empty; QuantityTextBox.Text = string.Empty; _barcodes.Add(barcode); BarcodeListView.Items.Add(barcode); } MessageBox.Show("data berhasil disimpan"); } }
private async void SubmitButton_Click(object sender, RoutedEventArgs e) { FormGrid.IsEnabled = false; var errorMessage = "Harap isi semua kolom berikut: \n"; var anyError = false; if (string.IsNullOrWhiteSpace(OrderNo.Text) || string.IsNullOrWhiteSpace(OrderNo.Text)) { anyError = true; errorMessage += "- Nomor Order\n"; } //if (string.IsNullOrWhiteSpace(LotNoTextBox.Text)) //{ // anyError = true; // errorMessage += "- Nomor Lot\n"; //} //decimal.TryParse(QuantityTextBox.Text, out var quantity); //if (string.IsNullOrWhiteSpace(QuantityTextBox.Text) || quantity <= 0) //{ // anyError = true; // errorMessage += "- Quantity\n"; //} //var quantity = QuantityDecimalUpDown.Value.GetValueOrDefault(); if (anyError) { MessageBox.Show(errorMessage); } else { pb.Visibility = Visibility.Visible; //var viewModel = new ProductViewModel( // string.Empty, // string.Empty, // string.Empty, // string.Empty, // LotNoTextBox.Text, // "YARN", // string.Empty, // string.Empty, // YarnTypePrefixTextBox.Text + YarnTypeSuffixTextbox.Text, // string.Empty, // "BALE", // QuantityDecimalUpDown.Value.GetValueOrDefault(), // "PALET" // ); var barcodeList = await PackingInventoryService.GetBarcodeInfoByOrderNo(OrderNo.Text, false); _barcodes = new List <BarcodeInfo>(); BarcodeList = new ObservableCollection <BarcodeInfo>(); foreach (var barcode in barcodeList) { var printedListJson = _cache.StringGet(barcode.productionOrder.no); var printedList = new List <string>(); if (!string.IsNullOrWhiteSpace(printedListJson)) { printedList = JsonConvert.DeserializeObject <List <string> >(printedListJson, new JsonSerializerSettings() { MissingMemberHandling = MissingMemberHandling.Ignore }); } if (printedList != null && printedList.Count > 0) { barcode.productPackingCodes = barcode.productPackingCodes.Where(element => !printedList.Contains(element)).ToList(); } foreach (var packingCode in barcode.productPackingCodes) { var barcodeInfo = new BarcodeInfo() { Color = barcode.color, MaterialConstructionName = barcode.materialConstruction.name, MaterialName = barcode.material.name, OrderNo = barcode.productionOrder.no, PackingCode = packingCode, PackingLength = barcode.productPackingLength.ToString(), PackingType = barcode.productPackingType, YarnMaterialName = barcode.yarnMaterial.name, UOMSKU = barcode.uomUnit }; _barcodes.Add(barcodeInfo); //BarcodeList.Add(barcodeInfo); } if (BarcodeList.Count > 0 && !string.IsNullOrWhiteSpace(PackingSizeFilter.Text)) { if (double.TryParse(PackingSizeFilter.Text, out var packingSize)) { _barcodes = _barcodes.Where(element => element.PackingLength == packingSize.ToString()).ToList(); } } foreach (var _barcode in _barcodes) { BarcodeList.Add(_barcode); } } ////if (barcode != null && !string.IsNullOrWhiteSpace(barcode.PackingCode)) //if (barcode != null /*&& !string.IsNullOrWhiteSpace(barcode.PackingCode)*/) // { // LotNoTextBox.Text = string.Empty; // YarnTypePrefixTextBox.Text = string.Empty; // YarnTypeSuffixTextbox.Text = string.Empty; // //QuantityTextBox.Text = string.Empty; // QuantityDecimalUpDown.Value = null; // _barcodes.Add(barcode); // BarcodeListView.Items.Add(barcode); //} BarcodeGrid.ItemsSource = BarcodeList; pb.Visibility = Visibility.Hidden; } FormGrid.IsEnabled = true; //MessageBox.Show() }
private async void SubmitButton_Click(object sender, RoutedEventArgs e) { var errorMessage = "Harap isi semua kolom berikut: \n"; var anyError = false; if (string.IsNullOrWhiteSpace(CompositionTextBox.Text) || string.IsNullOrWhiteSpace(CompositionTextBox.Text)) { anyError = true; errorMessage += "- Komposisi\n"; } if (string.IsNullOrWhiteSpace(Construction1TextBox.Text) || string.IsNullOrWhiteSpace(Construction2TextBox.Text)) { anyError = true; errorMessage += "- Konstruksi\n"; } if (string.IsNullOrWhiteSpace(WidthTextBox.Text)) { anyError = true; errorMessage += "- Lebar\n"; } if (string.IsNullOrWhiteSpace(DesignTextBox.Text)) { anyError = true; errorMessage += "- Design\n"; } if (string.IsNullOrWhiteSpace(GradeComboBox.Text)) { anyError = true; errorMessage += "- Grade\n"; } decimal.TryParse(QuantityTextBox.Text, out var quantity); if (string.IsNullOrWhiteSpace(QuantityTextBox.Text) || quantity <= 0) { anyError = true; errorMessage += "- Quantity\n"; } if (string.IsNullOrWhiteSpace(PackTypeComboBox.Text)) { anyError = true; errorMessage += "- Jenis Pack\n"; } if (anyError) { MessageBox.Show(errorMessage); } else { var viewModel = new ProductViewModel( CompositionTextBox.Text, $"{Construction1TextBox.Text} X {Construction2TextBox.Text}", DesignTextBox.Text, GradeComboBox.Text, string.Empty, "FABRIC", WidthTextBox.Text, string.Empty, string.Empty, string.Empty, "MTR", quantity, PackTypeComboBox.Text ); var barcode = await PackingInventoryService.PostProduct(viewModel); if (barcode != null && !string.IsNullOrWhiteSpace(barcode.Code)) { CompositionTextBox.Text = string.Empty; Construction1TextBox.Text = string.Empty; Construction2TextBox.Text = string.Empty; DesignTextBox.Text = string.Empty; GradeComboBox.Text = string.Empty; WidthTextBox.Text = string.Empty; PackTypeComboBox.Text = string.Empty; QuantityTextBox.Text = string.Empty; _barcodes.Add(barcode); BarcodeListView.Items.Add(barcode); } MessageBox.Show("data berhasil disimpan"); } }