Exemplo n.º 1
0
        public int Create(Pesanan psn)
        {
            int result1 = 0;

            // cek npm yang diinputkan tidak boleh kosong
            if (string.IsNullOrEmpty(psn.KdPesanan))
            {
                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 PesananRepository(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);
        }
Exemplo n.º 2
0
        public int Create(Pesanan psn)
        {
            int result1 = 0;

            // Validavsi kode pesanan tidak boleh NUL
            if (string.IsNullOrEmpty(psn.KdPesanan))
            {
                MessageBox.Show("Kode barang harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Validavsi Tanggal Pemesanan tidak boleh NUL
            if (string.IsNullOrEmpty(psn.TglPesan))
            {
                MessageBox.Show("Tanggal Pesanan harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Validavsi JatuhTempo Pemesanan tidak boleh NUL
            if (string.IsNullOrEmpty(psn.JatuhTempo))
            {
                MessageBox.Show("Tanggal jatuh tempol harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Validavsi Kode Admin Pemesanan tidak boleh NUL
            if (string.IsNullOrEmpty(psn.KdAdmin))
            {
                MessageBox.Show("Kode Admin harus diisi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

            // Validavsi Status Pesanan Pemesanan tidak boleh NUL
            if (string.IsNullOrEmpty(psn.StatusPesanan))
            {
                MessageBox.Show("Status Pesanan 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 PesananRepository(context);

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

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

            return(result1);
        }