public static void CariPraktikan(ComboBoxEdit comboBoxEdit1, ComboBoxEdit comboBoxEdit2, GridControl gridcontrol, GridView gridview) { try { var service = new IadmClient(); comboBoxEdit1.SelectedIndex = 0; comboBoxEdit2.SelectedIndex = 0; var nmAngkatan = comboBoxEdit1.SelectedItem.ToString(); var nmJurusan = comboBoxEdit2.SelectedItem.ToString(); var angkatan = service.GetAngkatan().FirstOrDefault(q => q.TahunAngkatan == nmAngkatan); var jurusan = service.GetJurusan().FirstOrDefault(q => q.NamaJurusan == nmJurusan); praktikan data = new praktikan() { angkatan = new angkatan() { KodeAngkatan = angkatan?.KodeAngkatan }, jurusan = new jurusan() { KodeJurusan = jurusan?.KodeJurusan } }; gridcontrol.DataSource = service.GetPraktikan(data) .Select( x => new { x.Foto, x.NRP, x.Nama, KodeAngkatan = x.angkatan.KodeAngkatan, KodeJurusan = x.jurusan.KodeJurusan }) .ToList(); gridview.RowHeight = 60; gridview.Columns["Foto"].Width = 70; gridview.Columns["NRP"].Width = 150; gridview.Columns["NRP"].Caption = @"NO MAHASISWA"; gridview.Columns["Foto"].Caption = @"FOTO"; gridview.Columns["Nama"].Caption = @"NAMA"; gridview.Columns["KodeAngkatan"].Caption = @"ANGKATAN"; gridview.Columns["KodeJurusan"].Caption = @"JURUSAN"; for (int i = 0; i < gridview.Columns.Count; i++) { gridview.Columns[i].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Near; } service.Close(); } catch (Exception) { //XtraMessageBox.Show(err.ToString()); //XtraMessageBox.Show("data pencarian tidak lengkap"); throw; } }
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."); } }