示例#1
0
        public void Update(ReturDepositModel model)
        {
            var sSql = @"
                UPDATE
                    ReturDeposit 
                SET
                    Tgl = @Tgl, 
                    Jam = @Jam, 
                    DepositID = @DepositID,
                    JenisKasID = @JenisKasID,
                    Catatan = @Catatan, 
                    NilaiSisaDeposit = @NilaiSisaDeposit, 
                    NilaiReturDeposit = @NilaiReturDeposit 
                WHERE
                    ReturDepositID = @ReturDepositID  ";

            using (var conn = new SqlConnection(_connString))
                using (var cmd = new SqlCommand(sSql, conn))
                {
                    cmd.AddParam("@ReturDepositID", model.ReturDepositID);
                    cmd.AddParam("@Tgl", model.Tgl.ToTglYMD());
                    cmd.AddParam("@Jam", model.Jam);
                    cmd.AddParam("@DepositID", model.DepositID);
                    cmd.AddParam("@JenisKasID", model.JenisKasID);
                    cmd.AddParam("@Catatan", model.Catatan);
                    cmd.AddParam("@NilaiSisaDeposit", model.NilaiSisaDeposit);
                    cmd.AddParam("@NilaiReturDeposit", model.NilaiReturDeposit);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
        }
示例#2
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();
            }
        }
示例#3
0
        public void Insert(ReturDepositModel model)
        {
            var sSql = @"
                INSERT INTO 
                    ReturDeposit (
                        ReturDepositID, Tgl, Jam, 
                        DepositID, JenisKasID, Catatan,  
                        NilaiSisaDeposit, NilaiReturDeposit) 
                VALUES (
                        @ReturDepositID, @Tgl, @Jam, 
                        @DepositID, @JenisKasID, @Catatan, 
                        @NilaiSisaDeposit, @NilaiReturDeposit ) ";

            using (var conn = new SqlConnection(_connString))
                using (var cmd = new SqlCommand(sSql, conn))
                {
                    cmd.AddParam("@ReturDepositID", model.ReturDepositID);
                    cmd.AddParam("@Tgl", model.Tgl.ToTglYMD());
                    cmd.AddParam("@Jam", model.Jam);
                    cmd.AddParam("@DepositID", model.DepositID);
                    cmd.AddParam("@JenisKasID", model.JenisKasID);
                    cmd.AddParam("@Catatan", model.Catatan);
                    cmd.AddParam("@NilaiSisaDeposit", model.NilaiSisaDeposit);
                    cmd.AddParam("@NilaiReturDeposit", model.NilaiReturDeposit);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
        }
示例#4
0
        public ReturDepositModel Save(ReturDepositModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            //  validate depositID
            var deposit = _depositBL.GetData(model.DepositID);

            if (deposit == null)
            {
                throw new ArgumentException("DepositID invalid");
            }
            else
            {
                model.PihakKeduaName = deposit.PihakKeduaName;
            }

            //  validate jenisKas
            var jenisKas = _jenisKasBL.GetData(model.JenisKasID);

            if (jenisKas == null)
            {
                throw new ArgumentException("JenisKasID invalid");
            }
            else
            {
                model.JenisKasName = jenisKas.JenisKasName;
            }

            //  cek nilai retur harus antara 0 dan sisa deposit
            if (model.NilaiReturDeposit > model.NilaiSisaDeposit)
            {
                throw new ArgumentException("NilaiReturDeposit Invalid");
            }
            if (model.NilaiReturDeposit <= 0)
            {
                throw new ArgumentException("NilaiReturDeposit Invalid minus");
            }

            //  proses simpan
            using (var trans = TransHelper.NewScope())
            {
                if (model.ReturDepositID.Trim() == "")
                {
                    model.ReturDepositID = GenNewID();
                }

                // hapus data lama
                _returDepositDal.Delete(model.ReturDepositID);
                //  simpan data baru
                _returDepositDal.Insert(model);

                trans.Complete();
            }
            return(model);
        }
示例#5
0
        public BPKasModel Generate(ReturDepositModel returDeposit)
        {
            if (returDeposit == null)
            {
                throw new ArgumentNullException(nameof(returDeposit));
            }
            var bpKas  = (BPKasModel)returDeposit;
            var result = Save(bpKas);

            return(result);
        }
示例#6
0
        public IEnumerable <ReturDepositModel> ListData(string tgl1, string tgl2)
        {
            List <ReturDepositModel> result = null;
            var sSql = @"
                SELECT
                    aa.ReturDepositID, aa.Tgl, aa.Jam, 
                    aa.DepositID, aa.JenisKasID, aa.Catatan,
                    aa.NilaiSisaDeposit, aa.NilaiReturDeposit,
                    ISNULL(bb.JenisKasName, '') JenisKasName,
                    ISNULL(dd.PihakKeduaName, '') PihakKeduaName
                FROM    
                    ReturDeposit aa
                    LEFT JOIN JenisKas bb ON aa.JenisKasID = bb.JenisKasID 
                    LEFT JOIN Deposit cc ON aa.DepositID = cc.DepositID
                    LEFT JOIN PihakKedua dd ON cc.PihakKeduaID = dd.PihakKeduaID
                WHERE
                    aa.Tgl BETWEEN @Tgl1 AND @Tgl2  ";

            using (var conn = new SqlConnection(_connString))
                using (var cmd = new SqlCommand(sSql, conn))
                {
                    cmd.AddParam("@Tgl1", tgl1.ToTglYMD());
                    cmd.AddParam("@Tgl2", tgl2.ToTglYMD());
                    conn.Open();
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (!dr.HasRows)
                        {
                            return(null);
                        }
                        result = new List <ReturDepositModel>();
                        while (dr.Read())
                        {
                            var item = new ReturDepositModel
                            {
                                ReturDepositID    = dr["ReturDepositID"].ToString(),
                                Tgl               = dr["Tgl"].ToString().ToTglDMY(),
                                Jam               = dr["Jam"].ToString(),
                                DepositID         = dr["DepositID"].ToString(),
                                PihakKeduaName    = dr["PihakKeduaName"].ToString(),
                                JenisKasID        = dr["JenisKasID"].ToString(),
                                JenisKasName      = dr["JenisKasName"].ToString(),
                                Catatan           = dr["Catatan"].ToString(),
                                NilaiSisaDeposit  = Convert.ToDecimal(dr["NilaiSisaDeposit"]),
                                NilaiReturDeposit = Convert.ToDecimal(dr["NilaiReturDeposit"]),
                            };
                            result.Add(item);
                        }
                    }
                }
            return(result);
        }
        private ReturDepositModel ReturDepositDataFactory()
        {
            var result = new ReturDepositModel
            {
                ReturDepositID    = "A1",
                Tgl               = "11-02-2019",
                Jam               = "01:38:00",
                DepositID         = "B1",
                JenisKasID        = "C1",
                Catatan           = "D1",
                NilaiSisaDeposit  = 2000,
                NilaiReturDeposit = 1500
            };

            return(result);
        }
示例#8
0
        public ReturDepositModel GetData(string id)
        {
            ReturDepositModel result = null;
            var sSql = @"
                SELECT
                    aa.ReturDepositID, aa.Tgl, aa.Jam, 
                    aa.DepositID, aa.JenisKasID, aa.Catatan,
                    aa.NilaiSisaDeposit, aa.NilaiReturDeposit,
                    ISNULL(bb.JenisKasName, '') JenisKasName,
                    ISNULL(dd.PihakKeduaName, '') PihakKeduaName
                FROM    
                    ReturDeposit aa
                    LEFT JOIN JenisKas bb ON aa.JenisKasID = bb.JenisKasID 
                    LEFT JOIN Deposit cc ON aa.DepositID = cc.DepositID
                    LEFT JOIN PihakKedua dd ON cc.PihakKeduaID = dd.PihakKeduaID
                WHERE
                    aa.ReturDepositID = @ReturDepositID ";

            using (var conn = new SqlConnection(_connString))
                using (var cmd = new SqlCommand(sSql, conn))
                {
                    cmd.AddParam("@ReturDepositID", id);
                    conn.Open();
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (!dr.HasRows)
                        {
                            return(null);
                        }
                        dr.Read();
                        result = new ReturDepositModel
                        {
                            ReturDepositID    = dr["ReturDepositID"].ToString(),
                            Tgl               = dr["Tgl"].ToString().ToTglDMY(),
                            Jam               = dr["Jam"].ToString(),
                            DepositID         = dr["DepositID"].ToString(),
                            PihakKeduaName    = dr["PihakKeduaName"].ToString(),
                            JenisKasID        = dr["JenisKasID"].ToString(),
                            JenisKasName      = dr["JenisKasName"].ToString(),
                            Catatan           = dr["Catatan"].ToString(),
                            NilaiSisaDeposit  = Convert.ToDecimal(dr["NilaiSisaDeposit"]),
                            NilaiReturDeposit = Convert.ToDecimal(dr["NilaiReturDeposit"]),
                        };
                    }
                }
            return(result);
        }
示例#9
0
        public BPHutangModel GenHutang(ReturDepositModel returDeposit, DepositModel deposit)
        {
            //  ambil data hutang berdasarkan deposit
            var bpHutang = GetData(deposit.DepositID);

            if (bpHutang == null)
            {
                var errMsg = string.Format("Hutang {0} tidak ditemukan ", deposit.DepositID);
                throw new ArgumentException(errMsg);
            }

            //  hapus detil lunas yang id-nya = PenjualanID
            List <BPHutangDetilModel> newListLunas =
                (
                    from c in bpHutang.ListLunas
                    where c.ReffID != returDeposit.ReturDepositID
                    select c
                ).ToList();

            //  tambahkan pelunasan dari retur deposit
            int noUrut = newListLunas.Count + 1;

            newListLunas.Add(new BPHutangDetilModel
            {
                BPHutangID      = bpHutang.BPHutangID,
                BPHutangDetilID = bpHutang.BPHutangID + '-' + noUrut.ToString().PadLeft(2, '0'),
                Tgl             = returDeposit.Tgl,
                Jam             = returDeposit.Jam,
                ReffID          = returDeposit.ReturDepositID,
                Keterangan      = "   Retur Deposit a/n " + returDeposit.PihakKeduaName,
                NilaiHutang     = 0,
                NilaiLunas      = returDeposit.NilaiReturDeposit
            });

            bpHutang.ListLunas = newListLunas;
            //  simpan
            var result = Save(bpHutang);

            return(result);
        }