예제 #1
0
        private void GetButton_Click(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dataSet11.TabelLaporan' table. You can move, or remove it, as needed.
            TabelLaporanTableAdapter adapter = new TabelLaporanTableAdapter();

            DataTable dt = adapter.GetDataBy((int)comboBox1.SelectedValue, dateTimePicker1.Text);

            if (dt.Rows.Count > 0)
            {
                //jika ada data

                DataTable dt_new = adapter.GetDataBy((int)comboBox1.SelectedValue, dateTimePicker1.Text);
                dataGridView1.DataSource = dt_new;
            }
            else
            {
                //jika tdk ada data

                DataSiswaTableAdapter dataSiswa = new DataSiswaTableAdapter();

                DataTable data_siswa = dataSiswa.GetDataByIDKelas((int)comboBox1.SelectedValue);

                foreach (DataRow row in data_siswa.Rows)
                {
                    //menambah Record Laporan tiap siswa
                    adapter.InsertQuery((int)row[0], (int)comboBox1.SelectedValue, dateTimePicker1.Text, "", row[1].ToString(), comboBox1.Text);
                }

                DataTable dt_new = adapter.GetDataBy((int)comboBox1.SelectedValue, dateTimePicker1.Text);
                dataGridView1.DataSource = dt_new;
            }
        }
예제 #2
0
        private void Getbutton1_Click(object sender, EventArgs e)
        {
            //get data

            DataSiswaTableAdapter dataSiswa = new DataSiswaTableAdapter();

            DataTable data_siswa = dataSiswa.GetDataByIDKelas((int)comboBox1.SelectedValue);

            TabelLaporanTableAdapter ada = new TabelLaporanTableAdapter();


            int Hadir = 0, Absen = 0, Terlambat = 0, Ijin = 0;

            //loop
            foreach (DataRow row in data_siswa.Rows)
            {
                //hitung kehadiran
                Hadir = (int)ada.GetDataByReport(dateTimePicker2.Value.Month, row[1].ToString(), "hadir").Rows[0][6];

                //hitung absen
                Absen = (int)ada.GetDataByReport(dateTimePicker2.Value.Month, row[1].ToString(), "absen").Rows[0][6];

                //hitung terlambat
                Terlambat = (int)ada.GetDataByReport(dateTimePicker2.Value.Month, row[1].ToString(), "terlambat").Rows[0][6];

                //Ijin
                Ijin = (int)ada.GetDataByReport(dateTimePicker2.Value.Month, row[1].ToString(), "ijin").Rows[0][6];

                ListViewItem litem = new ListViewItem();
                litem.Text = row[1].ToString();
                litem.SubItems.Add(Hadir.ToString());
                litem.SubItems.Add(Absen.ToString());
                litem.SubItems.Add(Terlambat.ToString());
                litem.SubItems.Add(Ijin.ToString());
                listView1.Items.Add(litem);
            }


            //tambahkan
        }