private void FrmTambahJadwalPraktikan_Load(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 jadwal_umum( )
            {
                id_periode = periode.id_periode
            };

            gridControl1.DataSource = service.ViewJadwalUmum(data).Select(x => new {
                HARI  = x.hari,
                SHIFT = x.fk_jadwalUmum_Shift.id_shift,
                WAKTU =
                    string.Format("{0:HH:mm} - {1:HH:mm}",
                                  x.fk_jadwalUmum_Shift.mulai,
                                  x.fk_jadwalUmum_Shift.selesai),
                PRAKTIKUM = x.fk_jadwalUmum_matakuliah.mata_kuliah,
                KELAS     = x.fk_jadwalUmum_kelas.Kelas
            });

            // add checkbox and enable multi select rows
            gridView1.OptionsSelection.MultiSelect     = true;
            gridView1.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect;
            // disable focused row and move column
            for (var i = 0; i < gridView1.Columns.Count; i++)
            {
                gridView1.Columns[i].OptionsColumn.AllowFocus = false;
                gridView1.Columns[i].OptionsColumn.AllowMove  = false;
            }
        }
Beispiel #2
0
        public static int PeriodeId(ComboBoxEdit comboBoxEdits)
        {
            var service = new IadmClient();

            var s        = new string[3];
            var combobox = comboBoxEdits.SelectedItem.ToString();

            if (combobox[5] != ' ')
            {
                s[0] = "Ganjil";
                s[1] = combobox.Substring(7, 4);
                s[2] = combobox.Substring(12, 4);
            }
            else
            {
                s[0] = "Genap";
                s[1] = combobox.Substring(6, 4);
                s[2] = combobox.Substring(11, 4);
            }
            var p = service.viewPeriode().FirstOrDefault(x => x.semester == s[0] &&
                                                         x.awalSemester.ToString("yyyy") == s[1] &&
                                                         x.akhirSemester.ToString("yyyy") == s[2]);

            return(p.id_periode);
        }
Beispiel #3
0
        public static void ComboBoxEditAdd(string option, ComboBoxEdit comboBoxEdit)
        {
            var service = new IadmClient();

            comboBoxEdit.Properties.Items.Clear();
            if (option == "Jurusan")
            {
                var jurusan = service.GetJurusan();
                for (var i = 0; i < jurusan.Count(); i++) // Add Jurusan
                {
                    comboBoxEdit.Properties.Items.Add(jurusan[i].NamaJurusan);
                }
            }
            if (option == "Angkatan")
            {
                var angkatan = service.GetAngkatan();
                for (var i = 0; i < angkatan.Count(); i++) // Add Angkatan
                {
                    comboBoxEdit.Properties.Items.Add(angkatan[i].TahunAngkatan);
                }
            }
            if (option == "Periode")
            {
                var periode =
                    service.viewPeriode()
                    .Select(
                        z =>
                        new { start = z.awalSemester.ToString("yyyy"), finish = z.akhirSemester.ToString("yyyy") })
                    .Distinct()
                    .ToList();
                for (int i = 0; i < periode.Count(); i++)
                {
                    comboBoxEdit.Properties.Items.Add($"{periode[i].start:yyyy}/{periode[i].finish:yyyy}");
                }
            }
            if (option == "Semester")
            {
                var semester = service.viewPeriode().Select(z => z.semester).Distinct().ToList();

                for (var i = 0; i < semester.Count(); i++)
                {
                    comboBoxEdit.Properties.Items.Add(semester[i]);
                }
            }
            comboBoxEdit.SelectedIndex = 0;
            service.Close();
        }
Beispiel #4
0
        public static void AddPeriode(ComboBoxEdit comboBoxEdits)
        {
            comboBoxEdits.Properties.Items.Clear();
            var service = new IadmClient();

            comboBoxEdits.Properties.Items.AddRange(service.viewPeriode().Select(x => x.semester + " " +
                                                                                 x.awalSemester.ToString("yyyy") +
                                                                                 "/" +
                                                                                 x.akhirSemester.ToString("yyyy"))
                                                    .ToList());
            comboBoxEdits.SelectedIndex = 0;
            service.Close();
        }
Beispiel #5
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            var service = new IadmClient();
            var periode = service.viewPeriode().ToList()
                          .FirstOrDefault(x => x.awalSemester <service.ServerTime() &&
                                                               x.akhirSemester> service.ServerTime());
            var praktikum = comboBoxEdit4.SelectedItem.ToString();
            var shift     = comboBoxEdit3.SelectedItem.ToString();
            var periodeID = new jadwal_umum()
            {
                id_periode = periode.id_periode
            };
            var jadwal = service.ViewJadwalUmum(periodeID).ToList()
                         .FirstOrDefault(x => x.fk_jadwalUmum_Shift.id_shift == shift &&
                                         x.fk_jadwalUmum_matakuliah.mata_kuliah == praktikum &&
                                         x.hari == comboBoxEdit2.SelectedItem.ToString());

            bool errorMessage = false;

            try
            {
                List <jadwalStaff> j = new List <jadwalStaff>();
                var data             = new jadwalStaff()
                {
                    staff = new Staff()
                    {
                        id_staff = comboBoxEdit1.SelectedItem.ToString()
                    },
                    jadwal_umum = new jadwal_umum()
                    {
                        id_jadwal_umum = jadwal.id_jadwal_umum
                    }
                };
                j.Add(data);
                service.AddJadwalStaffAsisten(j.ToArray());
                service.Close();
            }
            catch (Exception)
            {
                errorMessage = true;
                XtraMessageBox.Show("Tidak ada praktikum " + praktikum + " shift " + shift + " hari " + comboBoxEdit2.SelectedItem.ToString());
            }

            if (errorMessage == false)
            {
                Close();
            }
        }
Beispiel #6
0
        private void Form4_Load(object sender, EventArgs e)
        {
            // Format tgl indonesia
            DateFormatCultureInfo(dateEdit1, dateEdit2);

            //
            IadmClient service = new IadmClient();

            //
            gridControl1.DataSource = service.viewPeriode().Select(x => new
            {
                semester =
                    $"{x.semester} {x.awalSemester.ToString("yyyy")}/{x.akhirSemester.ToString("yyyy")}",
                awalSemester  = x.awalSemester.ToString("dd MMMM yyyy", new CultureInfo("id-ID")),
                akhirSemester = x.akhirSemester.ToString("dd MMMM yyyy", new CultureInfo("id-ID")),
            }).ToList();

            service.Close();
        }
        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( );
        }
Beispiel #8
0
        private void AddPeriode(object sender, EventArgs e)
        {
            DateTime   mulai   = dateEdit1.DateTime;
            DateTime   selesai = dateEdit2.DateTime;
            string     a       = comboBoxEdit1.SelectedItem.ToString();
            IadmClient service = new IadmClient();
            periode    data    = new periode()
            {
                semester      = a,
                awalSemester  = mulai,
                akhirSemester = selesai
            };

            service.addPeriode(data);
            gridControl1.DataSource = service.viewPeriode().Select(x => new
            {
                semester      = $"{x.semester} {x.awalSemester.ToString("yyyy")}/{x.akhirSemester.ToString("yyyy")}",
                awalSemester  = x.awalSemester.ToString("dd MMMM yyyy", new CultureInfo("id-ID")),
                akhirSemester = x.akhirSemester.ToString("dd MMMM yyyy", new CultureInfo("id-ID"))
            }).ToList();
            service.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( );
        }
Beispiel #10
0
        private void Simpan(object sender, EventArgs e)
        {
            var service = new IadmClient();
            var jadwal  = new List <jadwal_umum>();


            var idPeriode = service.viewPeriode().FirstOrDefault(
                q => q.awalSemester.ToString("yyyy") == comboBoxEdit2.SelectedItem.ToString().Substring(0, 4) &&
                q.akhirSemester.ToString("yyyy") == comboBoxEdit2.SelectedItem.ToString().Substring(5, 4) &&
                q.semester == comboBoxEdit1.SelectedItem.ToString());

            if (idPeriode == null)
            {
                XtraMessageBox.Show(
                    $"Semester {comboBoxEdit1.SelectedItem} Periode {comboBoxEdit2.SelectedItem} belum ada");
            }
            else
            {
                //ambil data dari tabel
                for (var i = 0; i < gridView1.RowCount; i++)
                {
                    DataRow row = gridView1.GetDataRow(i);

                    if (row[3].ToString() == string.Empty || row[4].ToString() == string.Empty)
                    {
                        continue;
                    }
                    var idKelas = service.GetKelas().FirstOrDefault(q => q.Kelas == row[4].ToString());
                    var kdMk    = service.GetMatKul().FirstOrDefault(q => q.mata_kuliah == row[3].ToString());

                    Debug.Assert(idKelas != null, "idKelas != null");
                    Debug.Assert(kdMk != null, "kdMk != null");
                    var listJadwal = new jadwal_umum()
                    {
                        hari       = row[0].ToString(),
                        id_kelas   = idKelas.id_kelas,
                        id_periode = idPeriode.id_periode,
                        id_shift   = row[1].ToString(),
                        kode_mk    = kdMk.kode_mk
                    };
                    jadwal.Add(listJadwal);
                }

                //ubah List<jadwal_umum> ke jadwal_umum[]
                var jadd = new jadwal_umum[jadwal.Count];
                for (var i = 0; i < jadwal.Count; i++)
                {
                    var jadum = new jadwal_umum()
                    {
                        hari       = jadwal[i].hari,
                        id_kelas   = jadwal[i].id_kelas,
                        id_periode = jadwal[i].id_periode,
                        id_shift   = jadwal[i].id_shift,
                        kode_mk    = jadwal[i].kode_mk
                    };
                    jadd[i] = jadum;
                }
                var errorMessage = false;
                try
                {
                    service.InsertJadwal(jadd);
                }
                catch (Exception)
                {
                    errorMessage = true;
                    //XtraMessageBox.Show(error.ToString());
                    XtraMessageBox.Show("Tidak ada jadwal yg ditambahkan");
                }
                if (errorMessage == false)
                {
                    Close();
                }
            }
        }