Example #1
0
        public int Update(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.Update(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);
        }
Example #2
0
        public int Update(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 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.Update(psn);
            }

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

            return(result1);
        }