예제 #1
0
        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            Produk v = new Produk();

            Switcher.Switchnewproduk(v);
        }
예제 #2
0
        private void saveproduk_Click(object sender, RoutedEventArgs e)
        {
            if (cbCategory.Text == "" || txtProductName.Text == "" || txtSellingPrice.Text == "" || cbCurrency.Text == "" || cbBaseUnit.Text == "" || txtMinimumOrder.Text == "" || Date1.Text == "" || Date2.Text == "" || cbProductType.Text == "" || cbUnitCost.Text == "" || txtLength.Text == "" || txtWide.Text == "" || txtTall.Text == "" || txtWeight.Text == "" ||
                cbVendorPrimary.Text == "" || txtRemarksVendor.Text == "")
            {
                MessageBox.Show("please fill in the blank fields", ("Form Validation"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            ProdukBLL ProdukBLL = new ProdukBLL();

            if (this.chkmanagestok.IsChecked == false)
            {
                if (ProdukBLL.AddProduk(this.GetData()) > 0)
                {
                    this.ClearForm();
                    MessageBox.Show("Product successfully added !");
                    this.produkForm.LoadProduk("");
                }
                else
                {
                    MessageBox.Show("Product failed to add !");
                }
            }
            else
            {
                if (DGSKUPurchaseDelivery.Items.Count > 0)
                {
                    foreach (var item in DGSKUPurchaseDelivery.Items)
                    {
                        if (item is produk)
                        {
                            produk oData = (produk)item;
                            if (this.kategoriProdukSelected != null)
                            {
                                oData.IdProdukKategori = this.kategoriProdukSelected.Id;
                                oData.ProdukKategori   = this.kategoriProdukSelected.ProdukKategori;
                            }
                            oData.SKU = txtSKU.Text;
                            if (this.GrupProdukSelected != null)
                            {
                                oData.IdGroupProduk   = this.GrupProdukSelected.Id;
                                oData.NamaGroupProduk = this.GrupProdukSelected.NamaGrupProduk;
                            }
                            oData.NamaProduk = txtProductName.Text;
                            oData.HargaJual  = double.Parse(txtSellingPrice.Text);
                            if (this.DataMataUangSelected != null)
                            {
                                oData.IdMataUang = this.DataMataUangSelected.Id;
                                oData.MataUang   = this.DataMataUangSelected.NamaMataUang;
                            }
                            oData.HargaBeli  = double.Parse(txtPurchasingPrice.Text);
                            oData.JumlahStok = double.Parse(txtStock.Text);
                            if (this.satuanDasarSelected != null)
                            {
                                oData.IdSatuanDasar = this.satuanDasarSelected.Id;
                                oData.SatuanDasar   = this.satuanDasarSelected.NamaSatuan;
                            }
                            oData.MinPemesanan         = double.Parse(txtMinimumOrder.Text);
                            oData.CheckboxDiskonProduk = chkdiskon.IsChecked;
                            oData.CheckboxUbahHarga    = chkover.IsChecked;
                            if (chkdiskon.IsChecked == false)
                            {
                                oData.DiskonProdukPersen = "0";
                            }
                            oData.DiskonProdukPersen          = txtDiscount.Text;
                            oData.TanggalMulaiDiskonProduk    = DateTime.Parse(Date1.Text);
                            oData.TanggalBerakhirDiskonProduk = DateTime.Parse(Date2.Text);
                            oData.BatasStokMin = int.Parse(txtMinStock.Text);
                            if (this.typeProdukSelected != null)
                            {
                                oData.IdTipeProduk         = this.typeProdukSelected.Id;
                                oData.TipeProduk           = this.typeProdukSelected.NamaTypeProduk;
                                oData.IdAkunHargaPokok     = this.typeProdukSelected.IdAkunHargaPokok;
                                oData.IdAkunPenjualan      = this.typeProdukSelected.IdAkunPenjualan;
                                oData.IdAkunPersediaan     = this.typeProdukSelected.IdAkunPersediaan;
                                oData.IdAkunPengirimanBeli = this.typeProdukSelected.IdAkunPengirimanBeli;
                                oData.IdAkunPengirimanJual = this.typeProdukSelected.IdAkunPengirimanJual;
                                oData.IdAkunReturPenjualan = this.typeProdukSelected.IdAkunReturPenjualan;
                                oData.IdAkunJasa           = this.typeProdukSelected.IdAkunService;
                            }
                            if (this.hargaPokokSelected != null)
                            {
                                oData.TipeHargaPokok = hargaPokokSelected.TipeHargaPokok;
                            }
                            oData.Keterangan           = txtRemarks.Text;
                            oData.CheckboxPajak        = chktaxable.IsChecked;
                            oData.CheckBoxInclusiveTax = chkinclusive.IsChecked;
                            if (this.dataPajakSelected != null)
                            {
                                oData.IdPajak         = this.dataPajakSelected.Id;
                                oData.Pajak           = this.dataPajakSelected.KodePajak;
                                oData.PersentasePajak = double.Parse(dataPajakSelected.Persentase.ToString());
                                oData.IdAkunPajak     = int.Parse(dataPajakSelected.IdAkunJual.ToString());
                            }
                            oData.Panjang            = txtLength.Text;
                            oData.Lebar              = txtWide.Text;
                            oData.Tinggi             = txtTall.Text;
                            oData.Berat              = txtWeight.Text;
                            oData.CheckBoxTidakAktif = ChkInactive.IsChecked;
                            oData.UploadImage0       = this.UploadFileA;
                            oData.UploadImage1       = this.UploadFileB;
                            oData.UploadImage2       = this.UploadFileC;
                            oData.UploadImage3       = this.UploadFileD;
                            if (this.kontakSelected != null)
                            {
                                oData.IdKontak = this.kontakSelected.Id;
                                oData.SuplierA = this.kontakSelected.NamaA;
                            }
                            if (this.kontakSelected != null)
                            {
                                oData.IdKontak = this.kontakSelected.Id;
                                oData.SuplierB = this.kontakSelected.NamaB;
                            }
                            if (this.kontakSelected != null)
                            {
                                oData.IdKontak = this.kontakSelected.Id;
                                oData.SuplierC = this.kontakSelected.NamaC;
                            }
                            if (this.kontakSelected != null)
                            {
                                oData.IdKontak = this.kontakSelected.Id;
                                oData.SuplierD = this.kontakSelected.NamaD;
                            }
                            oData.KeteranganSuplierA = txtRemarksVendor.Text;
                            oData.KeteranganSuplierB = txtRemarksVendor2.Text;
                            oData.KeteranganSuplierC = txtRemarksVendor3.Text;
                            oData.KeteranganSuplierD = txtRemarksVendor4.Text;
                            oData.AKtif = false;
                            if (ProdukBLL.EditProduk(oData) == true)
                            {
                                MessageBox.Show("Product added successfully !");
                                this.produkForm.LoadProduk("");
                            }
                            else
                            {
                                MessageBox.Show("Product failed to add !");
                            }
                        }
                    }
                }
            }

            Produk v = new Produk();

            Switcher.Switchnewproduk(v);
        }