void SelectedBarangChanged(PenjualanViewModel penjualan, object barang)
 {
     penjualan.Satuan       = ((BarangModel)barang).Satuan;
     penjualan.NamaBarang   = ((BarangModel)barang).NamaBarang;
     penjualan.Harga        = ((BarangModel)barang).Harga;
     penjualan.NoPenerimaan = ((BarangModel)barang).NoPenerimaan;
 }
Example #2
0
 public PenjualanForm(PenjualanViewModel vm)
 {
     InitializeComponent();
     if (vm.ModelPenjualan == null)
     {
         vm.ModelPenjualan         = new Penjualan();
         vm.ModelPenjualan.Tanggal = DateTime.Today;
     }
     DataContext = vm;
 }
Example #3
0
        public PenjualanView()
        {
            InitializeComponent();

            vm = new PenjualanViewModel();

            vm.OnReload += () =>
            {
                LstData.ItemsSource = null;
                LstData.ItemsSource = vm.DataPenjualan;
                if (form != null)
                {
                    form.Close();
                }
                vm.ModelPenjualan = null;
            };
            DataContext = vm;
        }
        public void Proses()
        {
            //  cari barangnya berdasarkan keyword
            var searchKeyword = _view.SearchKeyword;

            _dep.PenjualanBL.SearchFilter = new SearchFilter
            {
                UserKeyword = searchKeyword,
                Date1       = _view.PeriodeAwal,
                Date2       = _view.PeriodeAkhir
            };
            IEnumerable <PenjualanSearchModel> listPenjualan = _dep.PenjualanBL.Search();

            //  jika barang tidak ditemukan, then escape point and kosongkan result
            if (listPenjualan == null)
            {
                _view.ListResult = new List <PenjualanViewModel>();
                return;
            }

            //  persiapkan return value
            List <PenjualanViewModel> listResult = new List <PenjualanViewModel>();

            //  scan result, compose the returning list
            _view.ProgressCounter = 0;
            _view.ProgressMax     = listPenjualan.Count();
            var result    = new List <PenjualanViewModel>();
            var lastTgl   = "";
            var itemTotal = new PenjualanViewModel
            {
                Tgl          = "",
                NoNota       = "",
                CustomerName = "TOTAL"
            };

            foreach (var item in listPenjualan.OrderBy(x => x.TglJual + x.PenjualanID))
            {
                var itemResult = new PenjualanViewModel
                {
                    Tgl          = lastTgl == item.TglJual ? "" : item.TglJual,
                    NoNota       = item.PenjualanID,
                    CustomerName = item.BuyerName,
                };
                lastTgl = item.TglJual;
                var jual = _dep.PenjualanBL.GetData(item.PenjualanID);

                itemResult.Penjualan = jual.NilaiGrandTotal;

                if (jual.ListBayar != null)
                {
                    var tempItem = jual.ListBayar.Where(x => x.JenisBayarID == "KAS");
                    if (tempItem != null)
                    {
                        itemResult.Kas = tempItem.Sum(x => x.NilaiBayar);
                    }

                    tempItem = jual.ListBayar.Where(x => x.JenisBayarID == "ED1");
                    if (tempItem != null)
                    {
                        itemResult.BcaEdc = tempItem.Sum(x => x.NilaiBayar);
                    }

                    tempItem = jual.ListBayar.Where(x => x.JenisBayarID == "ED2");
                    if (tempItem != null)
                    {
                        itemResult.BriEdc = tempItem.Sum(x => x.NilaiBayar);
                    }

                    tempItem = jual.ListBayar.Where(x => x.JenisBayarID == "TR1");
                    if (tempItem != null)
                    {
                        itemResult.BcaTrf = tempItem.Sum(x => x.NilaiBayar);
                    }

                    tempItem = jual.ListBayar.Where(x => x.JenisBayarID == "TR2");
                    if (tempItem != null)
                    {
                        itemResult.BriTrf = tempItem.Sum(x => x.NilaiBayar);
                    }

                    tempItem = jual.ListBayar.Where(x => x.JenisBayarID == "PTG");
                    if (tempItem != null)
                    {
                        itemResult.Piutang = tempItem.Sum(x => x.NilaiBayar);
                    }
                }

                itemResult.Deposit    = jual.NilaiDeposit;
                itemResult.Keterangan = jual.DepositID != "" ? $"Deposit: {jual.DepositID}" : "";
                result.Add(itemResult);

                //  update nilai total

                _view.ProgressCounter++;
            }
            itemTotal.Penjualan = result.Sum(x => x.Penjualan);
            itemTotal.Kas       = result.Sum(x => x.Kas);
            itemTotal.BcaEdc    = result.Sum(x => x.BcaEdc);
            itemTotal.BcaTrf    = result.Sum(x => x.BcaTrf);
            itemTotal.BriEdc    = result.Sum(x => x.BriEdc);
            itemTotal.BriTrf    = result.Sum(x => x.BriTrf);
            itemTotal.Piutang   = result.Sum(x => x.Piutang);
            itemTotal.Deposit   = result.Sum(x => x.Deposit);
            result.Add(itemTotal);
            _view.ListResult = result;
        }