예제 #1
0
        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");
            }
        }
예제 #2
0
        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");
            }
        }