private void simpleButton3_Click(object sender, EventArgs e) { var sheet = listBoxControl1.SelectedItem.ToString().Replace("'", Empty); var data = ExcelToDataTable(_dialog.FileName, sheet); var praktikan = new praktikan[data.Rows.Count]; var jur = Empty; var angk = Empty; for (var i = 0; i < data.Rows.Count; i++) { var nrpmhs = data.Rows[i][0].ToString(); var biodata = new praktikan() { NRP = data.Rows[i][0].ToString(), Nama = data.Rows[i][1].ToString(), jurusan = new jurusan() { KodeJurusan = Concat(nrpmhs[0], nrpmhs[1], nrpmhs[2]) }, angkatan = new angkatan() { KodeAngkatan = Concat(nrpmhs[3], nrpmhs[4]) }, Foto = ImageToByteArray(pictureEdit1.Image) }; praktikan[i] = biodata; jur = Concat(nrpmhs[0], nrpmhs[1], nrpmhs[2]); angk = Concat(nrpmhs[3], nrpmhs[4]); } try { var service = new IadmClient(); var jurusan = service.GetJurusan().FirstOrDefault(q => q.KodeJurusan == jur); var angkatan = service.GetAngkatan().FirstOrDefault(q => q.KodeAngkatan == angk); var j = jurusan?.KodeJurusan; var a = angkatan?.KodeAngkatan; if (j == jur && a == angk) { service.InsertMultiplePraktikan(praktikan); } service.Close(); Close(); } catch (Exception error) { XtraMessageBox.Show(error.ToString()); XtraMessageBox.Show("Gagal import data mahasiswa."); } }