Exemplo n.º 1
0
        public void Update(BiayaModel model)
        {
            var sSql = @"
                UPDATE
                    Biaya 
                SET 
                    Tgl = @Tgl, 
                    Jam = @Jam, 
                    Keterangan = @Keterangan, 
                    JenisBiayaID = @JenisBiayaID, 
                    JenisKasID = @JenisKasID, 
                    NilaiBiaya = @NilaiBiaya 
                WHERE
                    BiayaID = @BiayaID ";

            using (var conn = new SqlConnection(_connString))
                using (var cmd = new SqlCommand(sSql, conn))
                {
                    cmd.AddParam("@BiayaID", model.BiayaID);
                    cmd.AddParam("@Tgl", model.Tgl.ToTglYMD());
                    cmd.AddParam("@Jam", model.Jam);
                    cmd.AddParam("@Keterangan", model.Keterangan);
                    cmd.AddParam("@JenisBiayaID", model.JenisBiayaID);
                    cmd.AddParam("@JenisKasID", model.JenisKasID);
                    cmd.AddParam("@NilaiBiaya", model.NilaiBiaya);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
        }
Exemplo n.º 2
0
        public void Insert(BiayaModel model)
        {
            var sSql = @"
                INSERT INTO
                    Biaya (
                        BiayaID, Tgl, Jam, Keterangan, 
                        JenisBiayaID, JenisKasID, NilaiBiaya)
                VALUES (
                        @BiayaID, @Tgl, @Jam, @Keterangan, 
                        @JenisBiayaID, @JenisKasID, @NilaiBiaya) ";

            using (var conn = new SqlConnection(_connString))
                using (var cmd = new SqlCommand(sSql, conn))
                {
                    cmd.AddParam("@BiayaID", model.BiayaID);
                    cmd.AddParam("@Tgl", model.Tgl.ToTglYMD());
                    cmd.AddParam("@Jam", model.Jam);
                    cmd.AddParam("@Keterangan", model.Keterangan);
                    cmd.AddParam("@JenisBiayaID", model.JenisBiayaID);
                    cmd.AddParam("@JenisKasID", model.JenisKasID);
                    cmd.AddParam("@NilaiBiaya", model.NilaiBiaya);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
        }
Exemplo n.º 3
0
 public void GenDelete(BiayaModel biaya)
 {
     if (biaya == null)
     {
         throw new ArgumentNullException(nameof(biaya));
     }
     _bpKasDal.Delete(biaya.BiayaID);
 }
Exemplo n.º 4
0
        public BPKasModel Generate(BiayaModel biaya)
        {
            if (biaya == null)
            {
                throw new ArgumentNullException(nameof(biaya));
            }
            var bpKas  = (BPKasModel)biaya;
            var result = Save(bpKas);

            return(result);
        }
Exemplo n.º 5
0
        public IEnumerable <BiayaModel> ListData(string tgl1, string tgl2)
        {
            List <BiayaModel> result = null;
            var sSql = @"
                SELECT
                    aa.BiayaID, aa.Tgl, aa.Jam, aa.Keterangan, 
                    aa.JenisBiayaID, aa.JenisKasID, aa.NilaiBiaya,
                    ISNULL(bb.JenisBiayaName, '') JenisBiayaName,
                    ISNULL(cc.JenisKasName, '') JenisKasName
                FROM
                    Biaya aa
                    LEFT JOIN JenisBiaya bb ON aa.JenisBiayaID = bb.JenisBiayaID
                    LEFT JOIN JenisKas cc ON aa.JenisKasID = cc.JenisKasID
                WHERE
                    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 <BiayaModel>();
                        while (dr.Read())
                        {
                            var item = new BiayaModel
                            {
                                BiayaID        = dr["BiayaID"].ToString(),
                                Tgl            = dr["Tgl"].ToString().ToTglDMY(),
                                Jam            = dr["Jam"].ToString(),
                                Keterangan     = dr["Keterangan"].ToString(),
                                JenisBiayaID   = dr["JenisBiayaID"].ToString(),
                                JenisBiayaName = dr["JenisBiayaName"].ToString(),
                                JenisKasID     = dr["JenisKasID"].ToString(),
                                JenisKasName   = dr["JenisKasName"].ToString(),
                                NilaiBiaya     = Convert.ToDecimal(dr["NilaiBiaya"])
                            };
                            result.Add(item);
                        }
                    }
                }
            return(result);
        }
Exemplo n.º 6
0
        private void Save()
        {
            var biaya = new BiayaModel
            {
                BiayaID      = BiayaIDText.Text,
                Tgl          = TglText.Value.ToString("dd-MM-yyyy"),
                Jam          = JamText.Text,
                JenisBiayaID = JenisBiayaCombo.SelectedValue.ToString(),
                JenisKasID   = JenisKasCombo.SelectedValue.ToString(),
                Keterangan   = KeteranganText.Text,
                NilaiBiaya   = NilIText.Value
            };
            var result = _biayaBL.Save(biaya);

            _bpKasBL.Generate(result);
        }
Exemplo n.º 7
0
        private BiayaModel BiayaDataFactory()
        {
            var result = new BiayaModel
            {
                BiayaID        = "A1",
                Tgl            = "11-02-2019",
                Jam            = "01:38:00",
                Keterangan     = "B1",
                JenisBiayaID   = "C1",
                JenisBiayaName = "",
                JenisKasID     = "D1",
                JenisKasName   = "",
                NilaiBiaya     = 300000
            };

            return(result);
        }
Exemplo n.º 8
0
        public BiayaModel GetData(string id)
        {
            BiayaModel result = null;
            var        sSql   = @"
                SELECT
                    aa.BiayaID, aa.Tgl, aa.Jam, aa.Keterangan, 
                    aa.JenisBiayaID, aa.JenisKasID, aa.NilaiBiaya,
                    ISNULL(bb.JenisBiayaName,'') JenisBiayaName,
                    ISNULL(cc.JenisKasName, '') JenisKasName
                FROM
                    Biaya aa
                    LEFT JOIN JenisBiaya bb ON aa.JenisBiayaID = bb.JenisBiayaID
                    LEFT JOIN JenisKas cc ON aa.JenisKasID = cc.JenisKasID
                WHERE
                    BiayaID = @BiayaID ";

            using (var conn = new SqlConnection(_connString))
                using (var cmd = new SqlCommand(sSql, conn))
                {
                    cmd.AddParam("@BiayaID", id);
                    conn.Open();
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (!dr.HasRows)
                        {
                            return(null);
                        }
                        dr.Read();
                        result = new BiayaModel
                        {
                            BiayaID        = id,
                            Tgl            = dr["Tgl"].ToString().ToTglDMY(),
                            Jam            = dr["Jam"].ToString(),
                            Keterangan     = dr["Keterangan"].ToString(),
                            JenisBiayaID   = dr["JenisBiayaID"].ToString(),
                            JenisBiayaName = dr["JenisBiayaName"].ToString(),
                            JenisKasID     = dr["JenisKasID"].ToString(),
                            JenisKasName   = dr["JenisKasName"].ToString(),
                            NilaiBiaya     = Convert.ToDecimal(dr["NilaiBiaya"])
                        };
                    }
                }
            return(result);
        }
Exemplo n.º 9
0
        public BiayaModel Save(BiayaModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (model.NilaiBiaya <= 0)
            {
                throw new ArgumentException("Nilai Biaya invalid");
            }

            var jenisBiaya = _jenisBiayaBL.GetData(model.JenisBiayaID);

            if (jenisBiaya == null)
            {
                throw new ArgumentException("JenisBiayaID invalid");
            }

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

            if (jenisKas == null)
            {
                throw new ArgumentException("JenisKasID invalid");
            }

            if (model.BiayaID.Trim() == "")
            {
                model.BiayaID = GenNewID();
            }

            using (var trans = TransHelper.NewScope())
            {
                //  hapus data lama
                _biayaDal.Delete(model.BiayaID);
                //  simpan data baru
                _biayaDal.Insert(model);

                trans.Complete();
            }

            return(model);
        }
Exemplo n.º 10
0
        public IEnumerable <BiayaModel> Generate(LunasKasBonModel lunasKasBon)
        {
            List <BiayaModel> result = null;

            if (lunasKasBon == null)
            {
                throw new ArgumentNullException(nameof(lunasKasBon));
            }
            if (lunasKasBon.ListLunas == null)
            {
                throw new ArgumentNullException(nameof(lunasKasBon.ListLunas));
            }

            //  cek kasbon-nya exist atau tidak
            var kasBon = _kasBonBL.GetData(lunasKasBon.KasBonID);

            if (kasBon == null)
            {
                throw new ArgumentException("KasBon tidak ditemukasn");
            }

            //  cek apakah ada detil ListLunas yang BIAYA
            IEnumerable <LunasKasBonDetilModel> listDetilLunasKasBonBiaya =
                from c in lunasKasBon.ListLunas
                where c.JenisLunasID != "KAS"
                select c;

            if (listDetilLunasKasBonBiaya == null)
            {
                return(null);
            }

            // Generate Biaya
            var noUrut = 0;

            foreach (var item in listDetilLunasKasBonBiaya)
            {
                var jenisLunas = _jenisLunasBL.GetData(item.JenisLunasID);
                if (jenisLunas == null)
                {
                    throw new ArgumentException("Generate Biaya failed. JenisLunas invalid");
                }

                var biaya = new BiayaModel
                {
                    BiayaID      = lunasKasBon.LunasKasBonID + '-' + noUrut.ToString().PadLeft(2, '0'),
                    Tgl          = lunasKasBon.Tgl,
                    Jam          = lunasKasBon.Jam,
                    JenisBiayaID = jenisLunas.JenisBiayaID,
                    JenisKasID   = kasBon.JenisKasID,
                    Keterangan   = "[LUNAS-KASBON] " + jenisLunas.JenisLunasName + ' ' + kasBon.Keterangan,
                    NilaiBiaya   = item.NilaiLunas
                };
                var itemResult = Save(biaya);

                if (result == null)
                {
                    result = new List <BiayaModel>();
                }

                result.Add(itemResult);
                noUrut++;
            }
            return(result);
        }