public int Delete(Model.Entity.Absensi absen)
        {
            int result = 0;

            // cek nilai npm yang diinputkan tidak boleh kosong
            if (string.IsNullOrEmpty(absen.Id.ToString()))
            {
                MessageBox.Show("pilih absen atau masukkan Id yg akan dihapus!!!", "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 AbsensiRepository(context);

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

            if (result > 0)
            {
                MessageBox.Show("penghapusan berhasil !", "Informasi",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("penghapusan gagal !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return(result);
        }
        public int Create(Model.Entity.Absensi absen)
        {
            int result = 0;

            // cek npm yang diinputkan tidak boleh kosong

            if (string.IsNullOrEmpty(absen.Id_karyawan.ToString()))
            {
                MessageBox.Show("Masukkan ID Karyawan !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return(0);
            }

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

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

            if (result > 0)
            {
                MessageBox.Show("Karyawan Berhasil absensi !", "Informasi",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Karyawn Gagal Presensi !!!", "Peringatan",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            return(result);
        }