public int Create(DetailPesanan psn)
        {
            int result1 = 0;

            // cek npm yang diinputkan tidak boleh kosong
            if (string.IsNullOrEmpty(psn.KdDetail))
            {
                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 DetailPesananRepository(context);

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

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

            return(result1);
        }
Ejemplo n.º 2
0
        public int Update(DetailPesanan detail)
        {
            int result = 0;


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

                // panggil method Update class repository untuk mengupdate data
                result = _repository.Update(detail);
            }

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

            return(result);
        }
Ejemplo n.º 3
0
        public int Delete(DetailPesanan dtlpsn)
        {
            int result = 0;

            // Validasi kode barang tidak boleh NULL
            if (string.IsNullOrEmpty(dtlpsn.KdDetail))
            {
                MessageBox.Show("Kode detail 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 DetailPesananRepository(context);

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

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

            return(result);
        }
Ejemplo n.º 4
0
        public int Create(DetailPesanan dtlpsn)
        {
            int result1 = 0;

            // Validasi kode detail tidak boleh NULL
            if (string.IsNullOrEmpty(dtlpsn.KdDetail))
            {
                MessageBox.Show("Kode Detail harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

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

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

            // Validasi kuantitas tidak boleh NULL
            if (string.IsNullOrEmpty(dtlpsn.Qty.ToString()))
            {
                MessageBox.Show("Kuantitas 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 DetailPesananRepository(context);

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

            if (result1 > 0)
            {
                MessageBox.Show("Data Detail Pesanan berhasil ditambah !", "Informasi",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Data Detail Pesanana gagal ditambah !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            return(result1);
        }
Ejemplo n.º 5
0
        public List <DetailPesanan> ReadAllDetail()
        {
            List <DetailPesanan> list = new List <DetailPesanan>();

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

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

            return(list);
        }
Ejemplo n.º 6
0
        public int Subtotal(string kddet)
        {
            int no;

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

                // panggil method Create class repository untuk menambahkan data
                no = _repository.BacaSUb(kddet);
            }

            return(no);
        }