private void Savereceivedgood_Click(object sender, RoutedEventArgs e)
        {
            if (dtReceived.Text == "" || cbCurrency.Text == "" || txtReceivedNumber.Text == "" || cbCash.Text == "" || cbLocation.Text == "" || dtDelivery.Text == "" || cbAnnual.Text == "" || txtAnnualFrequency.Text == "" || dtAnnual.Text == "")
            {
                MessageBox.Show("please fill in the blank fields", ("Form Validation"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            ReceivedGoodsBLL    goodBLL             = new ReceivedGoodsBLL();
            Receivedgood        receivedgood        = new Receivedgood();
            PurchasedeliveryBLL purchasedeliveryBLL = new PurchasedeliveryBLL();

            receivedgood.IdKodeTransaksi   = 8;
            receivedgood.KodeTransaksi     = "PJ";
            receivedgood.IdPeriodeAkutansi = 1;
            receivedgood.NoOrder           = txtReceivedNumber.Text;
            if (this.kontakSelected != null)
            {
                receivedgood.IdVendor   = this.kontakSelected.Id;
                receivedgood.NamaVendor = this.kontakSelected.NamaA;
            }
            receivedgood.Email        = txtemail.Text;
            receivedgood.NoHp         = txthp.Text;
            receivedgood.TanggalOrder = DateTime.Parse(dtReceived.Text);
            if (this.DataMataUangSelected != null)
            {
                receivedgood.IdMataUang = this.DataMataUangSelected.Id;
                receivedgood.MataUang   = this.DataMataUangSelected.KodeMataUang;
                receivedgood.KursTukar  = this.DataMataUangSelected.KursTukar;
            }
            if (this.dokumenSelected != null)
            {
                receivedgood.IdNoReferensiDokumen  = this.dokumenSelected.Id;
                receivedgood.NoReferensiDokumentNi = this.dokumenSelected.NoReferensiDokumen;
            }
            receivedgood.NoOrderPembeliaan = double.Parse(txtReceivedNumber.Text);
            if (this.purchaseDeliverySelected != null)
            {
                receivedgood.IdPD = this.purchaseDeliverySelected.IdPengirimanBarangPembelian;
                receivedgood.NoPD = this.purchaseDeliverySelected.NoPengirimanBarangPembelian;
            }
            if (this.purchaseDeliverySelected != null)
            {
                receivedgood.IdTransaksi = this.purchaseDeliverySelected.IdTransaksi;
            }
            if (this.purchaseOrderSelected != null)
            {
                receivedgood.IdOrderPembeliaan = this.purchaseOrderSelected.IdOrderPembelian;
                receivedgood.NoOrderPembeliaan = this.purchaseOrderSelected.NoOrderPembelian;
            }
            if (this.dropdownBankKasSelected != null)
            {
                receivedgood.IdBankCash = this.dropdownBankKasSelected.Id;
                receivedgood.BankCash   = this.dropdownBankKasSelected.DropdownBankkas;
            }
            if (this.lokasiSelected != null)
            {
                receivedgood.IdLokasi   = this.lokasiSelected.Id;
                receivedgood.NamaLokasi = this.lokasiSelected.NamaTempatLokasi;
            }
            receivedgood.Keterangan = txtNote.Text;
            if (this.dataDepartemenSelected != null)
            {
                receivedgood.IdDepartmen = this.dataDepartemenSelected.Id;
            }
            if (this.dataProyekSelected != null)
            {
                receivedgood.IdProyek = this.dataProyekSelected.Id;
            }
            receivedgood.CheckboxInclusiveTax = chktax.IsChecked;
            receivedgood.TanggalPengiriman    = DateTime.Parse(dtDelivery.Text);
            receivedgood.CheckboxBerulang     = chkannual.IsChecked;
            if (this.optionAnnualSelected != null)
            {
                receivedgood.IdOptionAnnual = this.optionAnnualSelected.IdOptionAnnual;
                receivedgood.Annual         = this.optionAnnualSelected.Annual;
            }
            if (this.petugasSelected != null)
            {
                receivedgood.IdPetugas   = this.petugasSelected.Id;
                receivedgood.NamaPetugas = this.petugasSelected.NamaA;
            }
            receivedgood.CicilanPerbulan                = double.Parse(txtAnnualFrequency.Text);
            receivedgood.TanggalBerulang                = DateTime.Parse(dtAnnual.Text);
            receivedgood.TotalSebelumPajak              = double.Parse(txttotalbeforetax.Text);
            receivedgood.TotalPajak                     = double.Parse(txtTotalTax.Text);
            receivedgood.TotalDebitAkunPajakProduk      = double.Parse(txtTotalTax.Text);
            receivedgood.TotalDebitAkunPersediaanProduk = double.Parse(txttotalbeforetax.Text);
            receivedgood.TotalSetelahPajak              = double.Parse(txtAfterTotalTax.Text);
            //receivedgood.SaldoTerhutang = double.Parse(txtoutstanding.Text);

            receivedgood.RealRecordingTime = DateTime.Now;
            receivedgood.Checkboxaktif     = true;
            if (goodBLL.AddReceivedGoods(receivedgood) > 0)
            {
                //  this.ClearForm();
                MessageBox.Show("Received Good successfully added !");
            }
            else
            {
                MessageBox.Show("Received Good failed to add !");
            }
            if (DGSKUReceivedGood.Items.Count > 0)
            {
                foreach (var item1 in DGSKUReceivedGood.Items)
                {
                    if (item1 is ListOrderBeli)
                    {
                        ListOrderBeli oNewData1 = (ListOrderBeli)item1;
                        oNewData1.Tanggal = DateTime.Parse(dtReceived.Text);
                        if (this.lokasiSelected != null)
                        {
                            oNewData1.IdLokasi   = this.lokasiSelected.Id;
                            oNewData1.NamaLokasi = this.lokasiSelected.NamaTempatLokasi;
                        }
                        if (this.dataDepartemenSelected != null)
                        {
                            oNewData1.IdDepartemen = this.dataDepartemenSelected.Id;
                        }
                        if (this.dataProyekSelected != null)
                        {
                            oNewData1.IdProyek = this.dataProyekSelected.Id;
                        }
                        if (int.Parse(txttota.Text) == 0)
                        {
                            oNewData1.IdTransaksi = receivedgood.IdOrder;
                        }
                        if (this.purchaseDeliverySelected != null)
                        {
                            oNewData1.IdTransaksi = this.purchaseDeliverySelected.IdTransaksi;
                        }
                        oNewData1.Checkboxaktif = false;
                        if (goodBLL.EditOrderProdukbeli(oNewData1, receivedgood) == true)
                        {
                        }
                    }
                }
            }
            if (cbPurchasedelivery.Items.Count > 0)
            {
                foreach (var item in cbPurchasedelivery.Items)
                {
                    if (item is Purchasedelivery)
                    {
                        Purchasedelivery oNewData2 = (Purchasedelivery)item;
                        oNewData2.Checkboxaktif = false;
                        if (purchasedeliveryBLL.EditPurchasedelivery(oNewData2) == true)
                        {
                        }
                    }
                }
            }
            ReceivedGood v = new ReceivedGood();

            Switcher.Switchnewreceived(v);
        }
        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            ReceivedGood v = new ReceivedGood();

            Switcher.Switchnewreceived(v);
        }