Exemplo n.º 1
0
        private void Save()
        {
            var returDeposit = new ReturDepositModel
            {
                ReturDepositID    = ReturDepositIDText.Text,
                Tgl               = TglText.Value.ToString("dd-MM-yyyy"),
                Jam               = JamText.Text,
                DepositID         = DepositIDText.Text,
                JenisKasID        = JenisKasCombo.SelectedValue.ToString(),
                Catatan           = KeteranganReturDepositText.Text,
                NilaiSisaDeposit  = SisaDepositText.Value,
                NilaiReturDeposit = NilaiReturText.Value
            };

            var deposit = _depositBL.GetData(returDeposit.DepositID);

            using (var trans = TransHelper.NewScope())
            {
                var result   = _returDepositBL.Save(returDeposit);
                var bpKas    = _bpKasBL.Generate(returDeposit);
                var bpHutang = _bpHutangBL.GenHutang(returDeposit, deposit);

                trans.Complete();
            }
        }
Exemplo n.º 2
0
        private void Save()
        {
            var lunasKasBon = new LunasKasBonModel
            {
                LunasKasBonID    = LunasKasBonIDText.Text,
                Tgl              = TglText.Value.ToString("dd-MM-yyyy"),
                Jam              = JamText.Text,
                KasBonID         = KasBonIDText.Text,
                PihakKeduaID     = PihakKeduaIDText.Text,
                NilaiSisaPiutang = NilaiSisaPiutangText.Value,
                NilaiTotLunas    = NilaiTotLunasText.Value
            };

            List <LunasKasBonDetilModel> listLunas = null;

            foreach (DataRow dr in ListLunasTable.Rows)
            {
                if (listLunas == null)
                {
                    listLunas = new List <LunasKasBonDetilModel>();
                }
                if (dr["KeteranganCol"].ToString().Trim() == "")
                {
                    continue;
                }

                listLunas.Add(new LunasKasBonDetilModel
                {
                    LunasKasBonID      = "",
                    LunasKasBonDetilID = "",
                    JenisLunasID       = dr["JenisLunasIDCol"].ToString(),
                    Keterangan         = dr["KeteranganCol"].ToString(),
                    NilaiLunas         = Convert.ToDecimal(dr["NilaiLunasCol"]),
                    PenjualanID        = dr["PenjualanID"].ToString(),
                });
            }
            lunasKasBon.ListLunas = listLunas;
            var kasBon = _kasBonBL.GetData(lunasKasBon.KasBonID);

            using (var trans = TransHelper.NewScope())
            {
                var result       = _lunasKasBonBL.Save(lunasKasBon);
                var bpKas        = _bpKasBL.Generate(lunasKasBon, kasBon);
                var bpPiutang    = _bpPiutangBL.GenPiutang(lunasKasBon, kasBon);
                var biaya        = _biayaBL.Generate(lunasKasBon);
                var listBPHutang = _bpHutangBL.GenHutang(lunasKasBon);

                trans.Complete();
            }
        }
Exemplo n.º 3
0
        private void Save()
        {
            ErrorProvider1.Clear();
            if (PihakKeduaCombo.SelectedValue == null)
            {
                ErrorProvider1.SetError(LabelPihakKedua, "Pilih Pihak Kedua");
                return;
            }
            if (JenisBayarCombo.SelectedValue == null)
            {
                ErrorProvider1.SetError(JenisBayarLabel, "Pilih Jenis Bayar");
                return;
            }
            if (BuyerNameTextBox.Text == "")
            {
                ErrorProvider1.SetError(BuyerNameLabel, "Isi Contact Person Customer");
                return;
            }

            var deposit = new DepositModel
            {
                DepositID    = BiayaIDText.Text,
                Tgl          = TglText.Value.ToString("dd-MM-yyyy"),
                Jam          = JamText.Text,
                PihakKeduaID = PihakKeduaCombo.SelectedValue.ToString(),
                BuyerName    = BuyerNameTextBox.Text,
                JenisBayarID = JenisBayarCombo.SelectedValue.ToString(),
                Keterangan   = KeteranganText.Text,
                NilaiDeposit = NilIText.Value,
                ListBrg      = _listBrg
            };

            using (var trans = TransHelper.NewScope())
            {
                var result = _depositBL.Save(deposit);
                _bpKasBL.Generate(result);
                _bpHutangBL.GenHutang(result);
                trans.Complete();
            }
            ClearForm();
            TglText.Focus();
        }
Exemplo n.º 4
0
        private void SaveTransaksi()
        {
            //  pindah textbox ke variable utk proses simpan
            var kodeTrs    = NoTrsTextBox.Text;
            var tglTrs     = TanggalDateTime.Value.ToString("dd-MM-yyyy");
            var jamTrs     = JamTextBox.Text;
            var customerID = "";

            if (CustomerComboBox.SelectedValue != null)
            {
                customerID = CustomerComboBox.SelectedValue.ToString();
            }
            //
            var buyerName = BuyerNameTextBox.Text;
            var alamat    = AlamatTextBox.Text;
            var noTelpon  = NoTelpTextBox.Text;
            var catatan   = CatatanTextBox.Text;
            //
            var biayaKirim = BiayaKirimNumText.Value;
            var total      = TotalNumText.Value;
            var diskon     = DiskonNumText.Value;
            var biayaLain  = BiayaLainNumText.Value;
            var grandTotal = GrandTotalNumText.Value;
            var bayarCash  = BayarCashNumText.Value;
            var totalBayar = BayarNonCashNumText.Value + BayarCashNumText.Value;
            var kembali    = KembaliNumText.Value;

            //--ambil data grid barang
            var dtlTrs = new List <Penjualan2Model>();
            var noUrut = 0;
            List <Penjualan2Model> listDetilBrg = null;

            foreach (DataRow dr in DetilPenjualanTable.Rows)
            {
                if (listDetilBrg == null)
                {
                    listDetilBrg = new List <Penjualan2Model>();
                }

                if (dr["BrgID"].ToString().Trim() == "")
                {
                    continue;
                }

                var dtlAdj = new Penjualan2Model()
                {
                    NoUrut   = noUrut,
                    BrgID    = dr["BrgID"].ToString(),
                    BrgName  = "",
                    BPStokID = dr["BPStokID"].ToString(),
                    Qty      = Convert.ToDecimal(dr["Qty"]),
                    Harga    = Convert.ToDecimal(dr["Harga"]),
                    Diskon   = Convert.ToDecimal(dr["Diskon"]),
                    SubTotal = Convert.ToDecimal(dr["SubTotal"])
                };
                listDetilBrg.Add(dtlAdj);
                noUrut++;
            }

            //  siapkan object tampung pembayaran
            List <PenjualanBayarModel> listDetilBayar = null;

            //  ambil data bayar detil
            if (_listBayarDetil != null)
            {
                foreach (var item in _listBayarDetil)
                {
                    var itemNonCash = new PenjualanBayarModel
                    {
                        JenisBayarID = item.JenisBayarID,
                        NilaiBayar   = item.NilaiBayar,
                        Catatan      = item.Catatan
                    };
                    if (listDetilBayar == null)
                    {
                        listDetilBayar = new List <PenjualanBayarModel>();
                    }
                    listDetilBayar.Add(itemNonCash);
                }
            }

            if (kembali != 0)
            {
                var itemKembali = new PenjualanBayarModel
                {
                    JenisBayarID = "KAS",
                    NilaiBayar   = -kembali,
                    Catatan      = ""
                };
                if (listDetilBayar == null)
                {
                    listDetilBayar = new List <PenjualanBayarModel>();
                }
                listDetilBayar.Add(itemKembali);
            }

            //  cari nilai deposit
            decimal bayarDepositDeposit = 0;

            if (DepositCheckBox.Checked)
            {
                decimal nilaiDeposit = NilaiDepositText.Value;
                bayarDepositDeposit = Math.Min((grandTotal - totalBayar), nilaiDeposit);
            }


            var penjualan = new PenjualanModel
            {
                PenjualanID  = kodeTrs,
                TglPenjualan = tglTrs,
                JamPenjualan = jamTrs,
                CustomerID   = customerID,
                BuyerName    = buyerName,
                Alamat       = alamat,
                NoTelp       = noTelpon,
                Catatan      = catatan,

                IsBayarDeposit = DepositCheckBox.Checked,
                DepositID      = DepositIDText.Text,
                NilaiDeposit   = bayarDepositDeposit,

                NilaiBiayaKirim = biayaKirim,
                NilaiTotal      = total,
                NilaiDiskonLain = diskon,
                NilaiBiayaLain  = biayaLain,
                NilaiGrandTotal = grandTotal,
                NilaiBayar      = totalBayar,
                NilaiKembali    = kembali,

                ListBrg   = listDetilBrg,
                ListBayar = listDetilBayar
            };

            PenjualanModel result = null;

            try
            {
                using (var trans = TransHelper.NewScope())
                {
                    //  save penjualan
                    result = _penjualanBL.Save(penjualan);

                    //  generate kas
                    BPKasModel bpKas = null;
                    if (penjualan.ListBayar != null)
                    {
                        bpKas = _bpKasBL.Generate(penjualan);
                    }

                    //  generate hutang lunas (kalo ada deposit)
                    BPHutangModel bpHutang = null;
                    if (penjualan.IsBayarDeposit)
                    {
                        var deposit = _depositBL.GetData(penjualan.DepositID);
                        bpHutang = _bpHutangBL.GenHutang(penjualan, deposit);
                    }

                    //  Gen BP Piutang (Jika Ada)
                    _bpPiutangBL.GenPiutang(penjualan);

                    //  generate stok
                    //  copy original list
                    var listBrgOri = result.ListBrg.CloneObject();
                    //  remove item2 jasa di list
                    var listBrg = new List <Penjualan2Model>();
                    foreach (var item in result.ListBrg)
                    {
                        if (item.BrgID.ToLower().Contains("jasa"))
                        {
                        }
                        else
                        {
                            listBrg.Add(item);
                        }
                    }
                    result.ListBrg = listBrg;
                    var bpStok = _bpStokBL.Generate(result);
                    //  kembalikan list original-nya (utk kepentingan cetak)
                    result.ListBrg = listBrgOri;

                    trans.Complete();
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            if (result != null)
            {
                LastIDLabel.Text = result.PenjualanID;
            }

            if (MessageBox.Show("Cetak Nota ?", "Penjualan", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                //  ubah nama barang menjadi nama brg versi pendek (utk print)
                foreach (var item in result.ListBrg)
                {
                    var brg = _brgBL.GetData(item.BrgID);
                    if (brg.BrgNamePrint.Trim() != "")
                    {
                        item.BrgName = brg.BrgNamePrint;
                    }
                }
                var printDoc = new NotaJualPrintDoc(result);
                printDoc.Print();
            }
            ClearForm();
        }