private void TambahJadwalPraktikan(object sender, EventArgs e) { var service = new IadmClient( ); var jadwal = new List <jadwalPraktikan>( ); var values = gridView1.GetSelectedRows( ); var periode = service.viewPeriode( ).FirstOrDefault( x => service.ServerTime() >= x.awalSemester && service.ServerTime() <= x.akhirSemester); var data = new jadwal_umum( ) { id_periode = periode.id_periode }; var listjadwal = new List <jadwalPraktikan>( ); for (var i = 0; i < values.Count( ); i++) { var shift = gridView1.GetRowCellValue(values[i], gridView1.Columns[1]).ToString( ); var hari = gridView1.GetRowCellValue(values[i], gridView1.Columns[0]).ToString( ); var matkul = gridView1.GetRowCellValue(values[i], gridView1.Columns[3]).ToString( ); var id = service.ViewJadwalUmum(data).FirstOrDefault(x => (x.fk_jadwalUmum_Shift.id_shift == shift && x.hari == hari) && x.fk_jadwalUmum_matakuliah.mata_kuliah == matkul); var jadwalpraktikan = new jadwalPraktikan( ) { nrp = simpleLabelItem1.Text, id_jadwal_umum = new jadwal_umum( ) { id_jadwal_umum = id.id_jadwal_umum } }; listjadwal.Add(jadwalpraktikan); } try { service.AddJadwalPraktikan(listjadwal.ToArray( )); } catch (Exception) { XtraMessageBox.Show("Tidak ada jadwal"); } Close( ); }
private void simpleButton2_Click(object sender, EventArgs e) { var service = new IadmClient( ); var periode = service.viewPeriode( ).FirstOrDefault(x => service.ServerTime() >= x.awalSemester && service.ServerTime() <= x.akhirSemester); var data = new jadwalPraktikan( ) { nrp = nrppraktikan, id_jadwal_umum = new jadwal_umum( ) { id_periode = periode.id_periode } }; try { service.DeleteJadwalPraktikan(data); } catch (Exception) { XtraMessageBox.Show("Error"); } Close( ); }