private void Save_Click(object sender, RoutedEventArgs e)
        {
            if (dtDeliveryorderdate.Text == "" || cbCurrency.Text == "" || txtDeliveryOrderNo.Text == "" || cbSalesorder.Text == "" || cbLocation.Text == "" || dtValiditydate.Text == "" || txtAnnualFrequency.Text == "" || dtAnnualdate.Text == "")
            {
                MessageBox.Show("please fill in the blank fields", ("Form Validation"), MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            DeliveryOrdersBLL deliveryBLL    = new DeliveryOrdersBLL();
            Deliveryorders    deliveryorders = new Deliveryorders();

            if (this.kontakSelected != null)
            {
                deliveryorders.IdPelanggan   = this.kontakSelected.Id;
                deliveryorders.NamePelanggan = this.kontakSelected.NamaA;
            }
            deliveryorders.Email     = txtemail.Text;
            deliveryorders.NoHp      = txthp.Text;
            deliveryorders.TanggalDo = DateTime.Parse(dtDeliveryorderdate.Text);
            if (this.DataMataUangSelected != null)
            {
                deliveryorders.IdMaatUang = this.DataMataUangSelected.Id;
                deliveryorders.MaatUang   = this.DataMataUangSelected.NamaMataUang;
                deliveryorders.KursTukar  = this.DataMataUangSelected.KursTukar;
            }
            if (this.dokumenSelected != null)
            {
                deliveryorders.IdNoReferansiDokumen = this.dokumenSelected.Id;
                deliveryorders.NoReferansiDokumen   = this.dokumenSelected.NoReferensiDokumen;
            }
            deliveryorders.NoDo = txtDeliveryOrderNo.Text;
            if (this.SalesOrderSelected != null)
            {
                deliveryorders.IdOrderPenjualan    = this.SalesOrderSelected.IdOrderPenjualan;
                deliveryorders.NomorOrderPenjualan = this.SalesOrderSelected.NoOrderPenjualan;
            }
            deliveryorders.Keterangan = txtNote.Text;
            if (this.lokasiSelected != null)
            {
                deliveryorders.IdLokasi   = this.lokasiSelected.Id;
                deliveryorders.NameLokasi = this.lokasiSelected.NamaTempatLokasi;
            }
            if (this.dataDepartemenSelected != null)
            {
                deliveryorders.IdDepartemen = this.dataDepartemenSelected.Id;
            }
            if (this.dataProyekSelected != null)
            {
                deliveryorders.IdProyek = this.dataProyekSelected.Id;
            }
            deliveryorders.CheckboxInclusivePajak = chkinclusive.IsChecked;
            deliveryorders.TanggalPengiriman      = DateTime.Parse(dtValiditydate.Text);
            deliveryorders.DurationBerulang       = double.Parse(txtAnnualFrequency.Text);
            deliveryorders.TanggalBerulang        = DateTime.Parse(dtAnnualdate.Text);
            if (this.optionAnnualSelected != null)
            {
                deliveryorders.IdOpsiAnnual = this.optionAnnualSelected.IdOptionAnnual;
                deliveryorders.Annual       = this.optionAnnualSelected.Annual;
            }
            if (this.petugasSelected != null)
            {
                deliveryorders.IdPetugas   = this.petugasSelected.Id;
                deliveryorders.NamePetugas = this.petugasSelected.NamaA;
            }
            deliveryorders.CheckboxBerulang   = chkannual.IsChecked;
            deliveryorders.IdKodeTransaksi    = 25;
            deliveryorders.KodeTransaksi      = "DO";
            deliveryorders.IdReferalTransaksi = 1;
            deliveryorders.IdPeriodeAkuntansi = 1;
            deliveryorders.RealRecordingTime  = DateTime.Now;
            deliveryorders.TotalKreditAkunPersediaanProduk    = double.Parse(txtTotalbeforeTax.Text);
            deliveryorders.TotalDebitAkunPengirimanJualProduk = double.Parse(txtTotalbeforeTax.Text);
            deliveryorders.TotalSebelumPajak = double.Parse(txtTotalbeforeTax.Text);
            deliveryorders.TotalPajak        = double.Parse(txtTotalTax.Text);
            if (this.SalesOrderSelected != null)
            {
                deliveryorders.IdTransaksi = this.SalesOrderSelected.IdTransaksi;
            }
            deliveryorders.TotalSetelahPajak = double.Parse(txtAfterTotalTax.Text);
            if (deliveryBLL.AddDeliveryOrder(deliveryorders) > 0)
            {
                //  this.ClearForm();
                MessageBox.Show("Delivery Order successfully added !");
            }
            else
            {
                MessageBox.Show("Delivery Order failed to add !");
            }

            Deliveryorder v = new Deliveryorder();

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

            Switcher.SwitchNewDeliveryorder(v);
        }