Beispiel #1
0
        public int Delete(Pembelian pbl)
        {
            int result = 0;

            // Validavsi kode pembelian tidak boleh NULL
            if (string.IsNullOrEmpty(pbl.KdPembelian))
            {
                MessageBox.Show("Kode pembelian harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // membuat objek context menggunakan blok using
            using (DbContext context = new DbContext())
            {
                // membuat objek dari class repository
                _repository = new PembelianRepository(context);

                // panggil method Delete class repository untuk menghapus data
                result = _repository.Delete(pbl);
            }

            if (result > 0)
            {
                MessageBox.Show("Data pembelian berhasil dihapus !", "Informasi",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Data pembelian gagal dihapus !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            return(result);
        }
Beispiel #2
0
 public BukuBesarService()
 {
     bukuBesarRepository          = new BukuBesarRepository();
     penjualanRepository          = new PenjualanRepository();
     pembelianRepository          = new PembelianRepository();
     transaksiInternalRepository  = new TransaksiInternalRepository();
     transaksiEksternalRepository = new TransaksiEksternalRepository();
 }
Beispiel #3
0
        public Barang Barang(string kdbrg)
        {
            Barang brg = new Barang();

            using (DbContext context = new DbContext())
            {
                // membuat objek class repository
                _repository = new PembelianRepository(context);

                // panggil method Create class repository untuk menambahkan data
                brg = _repository.Barang(kdbrg);
            }

            return(brg);
        }
Beispiel #4
0
        public List <Pembelian> ReadAllPembelian()
        {
            List <Pembelian> list = new List <Pembelian>();

            using (DbContext context = new DbContext())
            {
                // membuat objek class repository
                _repository = new PembelianRepository(context);

                // panggil method Create class repository untuk menambahkan data
                list = _repository.ReadAllPembelian();
            }

            return(list);
        }
Beispiel #5
0
        public List <Pembelian> ReadByNama(string nama)
        {
            // membuat objek collection
            List <Pembelian> list = new List <Pembelian>();

            // membuat objek context menggunakan blok using
            using (DbContext context = new DbContext())
            {
                // membuat objek dari class repository
                _repository = new PembelianRepository(context);

                // panggil method GetByNama yang ada di dalam class repository
                list = _repository.ReadByNama(nama);
            }

            return(list);
        }
Beispiel #6
0
        public int Create(Pembelian pbl)
        {
            int result = 0;

            // Validavsi kode pembelian tidak boleh NULL
            if (string.IsNullOrEmpty(pbl.KdPembelian))
            {
                MessageBox.Show("Kode pembelian harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Validasi nama barang tidak boleh NULL
            if (string.IsNullOrEmpty(pbl.NamaBarang))
            {
                MessageBox.Show("Nama barang harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Validasi Tanggal pembelian tidak boleh NULL
            if (string.IsNullOrEmpty(pbl.TglPembelian))
            {
                MessageBox.Show("Tanggal Pembelian harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Validasi Harga pembelian tidak boleh NULL
            if (string.IsNullOrEmpty(Convert.ToString(pbl.HargaBeli)))
            {
                MessageBox.Show("Harga harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Validasi jumlah tidak boleh NULL
            if (string.IsNullOrEmpty(Convert.ToString(pbl.Jumlah.ToString())))
            {
                MessageBox.Show("Kuantitas harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Validasi Kode pesanan tidak boleh NULL
            if (string.IsNullOrEmpty(pbl.KdPesanan))
            {
                MessageBox.Show("Kode pesanan harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Validasi Kode barang tidak boleh NULL
            if (string.IsNullOrEmpty(pbl.KdBarang))
            {
                MessageBox.Show("Kode barang harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Validasi Kode produsen tidak boleh NULL
            if (string.IsNullOrEmpty(pbl.KdProdusen))
            {
                MessageBox.Show("Kode produsen harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Validasi Kode admin tidak boleh NULL
            if (string.IsNullOrEmpty(pbl.KdAdmin))
            {
                MessageBox.Show("Kode admin harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // membuat objek menggunakan blok using
            using (DbContext context = new DbContext())
            {
                // buat clas repo
                _repository = new PembelianRepository(context);

                // manggil method repo biar nambah data
                result = _repository.Create(pbl);
            }

            if (result > 0)
            {
                MessageBox.Show("Data pembelian berhasil ditambah !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Data pembelian gagal ditambah !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return(result);
        }
Beispiel #7
0
 public PembelianService()
 {
     pembelianRepository = new PembelianRepository();
     barangRepository    = new BarangRepository();
     shuRepository       = new StokHargaUkuranRepository();
 }
        public int Create(Pembelian pmb)
        {
            int result = 0;

            // kode pembelian wajib diisi
            if (string.IsNullOrEmpty(pmb.KdPembelian))
            {
                MessageBox.Show("Kode pembelian harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // nama barang wajib diisi
            if (string.IsNullOrEmpty(pmb.NamaBarang))
            {
                MessageBox.Show("Nama barang haru diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Harga pembelian wajib diisi
            if (string.IsNullOrEmpty(Convert.ToString(pmb.HargaBeli)))
            {
                MessageBox.Show("Harga harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // produsen
            if (string.IsNullOrEmpty(pmb.KdProdusen))
            {
                MessageBox.Show("Kode produsen harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Barang
            if (string.IsNullOrEmpty(pmb.KdBarang))
            {
                MessageBox.Show("Kode barang harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Pesanan
            if (string.IsNullOrEmpty(pmb.KdPesanan))
            {
                MessageBox.Show("Kode pesanan harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Admin
            if (string.IsNullOrEmpty(pmb.KdAdmin))
            {
                MessageBox.Show("Kode barang harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // membuat objek menggunakan blok using
            using (DbContext context = new DbContext())
            {
                // buat clas repo
                _repository = new PembelianRepository(context);

                // manggil method repo biar nambah data
                result = _repository.Create(pmb);
            }

            if (result > 0)
            {
                MessageBox.Show("Data pembelian berhasil disimpan !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Data pembelian gagal disimpan !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return(result);
        }
Beispiel #9
0
        public int Update(Pembelian pbl)
        {
            int result = 0;

            // cek npm yang diinputkan tidak boleh kosong
            if (string.IsNullOrEmpty(pbl.KdPembelian))
            {
                MessageBox.Show("Kode pembelian harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // cek nama yang diinputkan tidak boleh kosong
            if (string.IsNullOrEmpty(pbl.NamaBarang))
            {
                MessageBox.Show("Nama harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // cek angkatan yang diinputkan tidak boleh kosong
            if (string.IsNullOrEmpty(Convert.ToString(pbl.HargaBeli)))
            {
                MessageBox.Show("Harga harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            if (string.IsNullOrEmpty(Convert.ToString(pbl.Jumlah)))
            {
                MessageBox.Show("Harga harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            if (string.IsNullOrEmpty(pbl.Jumlah))
            {
                MessageBox.Show("Jumlah harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            if (string.IsNullOrEmpty(pbl.KdBarang))
            {
                MessageBox.Show("Kode Barang harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // membuat objek context menggunakan blok using
            using (DbContext context = new DbContext())
            {
                // membuat objek class repository
                _repository = new PembelianRepository(context);

                // panggil method Create class repository untuk menambahkan data
                result = _repository.Update(pbl);
            }

            if (result > 0)
            {
                MessageBox.Show("Data pembelian disimpan !", "Informasi",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Data pembelian gagal disimpan !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            return(result);
        }