Exemplo n.º 1
0
        //Student records Function, Crashes Program right now, needs to be fixed
        private void metroButton5_Click(object sender, EventArgs e)
        {
            StudentsTBLTableAdapter students_Adapter = new StudentsTBLTableAdapter();

            DataTable dt_Students = students_Adapter.GetDataByClassID((int)metroComboBox2.SelectedValue);

            AttendanceTBLTableAdapter ada = new AttendanceTBLTableAdapter();

            /*
             * int P = 0;
             * int A = 0;
             * int L = 0;
             * int E = 0;
             */
            //loop databse and get values for PALE

            //foreach (DataRow row in dt_Students.Rows)
            // {


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

            /*/absent
             * A = (int)ada.GetDataByReport(dateTimePicker2.Value.Month,
             * row[1].ToString(),
             * "Absent").Rows[0][6];
             * //late
             * L = (int)ada.GetDataByReport(dateTimePicker2.Value.Month,
             * row[1].ToString(),
             * "Late").Rows[0][6];
             * //excused
             * E = (int)ada.GetDataByReport(dateTimePicker2.Value.Month,
             * row[1].ToString(),
             * "Excused").Rows[0][6];
             */
            //  ListViewItem litem = new ListViewItem();

            // litem.Text = row[1].ToString();
            //litem.SubItems.Add(P.ToString());
            //litem.SubItems.Add(A.ToString());
            //litem.SubItems.Add(L.ToString());
            //litem.SubItems.Add(E.ToString());
            //listView1.Items.Add(litem);


            // }
        }
Exemplo n.º 2
0
        //Clear Records Button
        private void metroButton2_Click(object sender, EventArgs e)
        {
            AttendanceTBLTableAdapter ada = new AttendanceTBLTableAdapter();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.Cells[1].Value != null)
                {
                    ada.UpdateQuery(" ", row.Cells[0].Value.ToString(), (int)metroComboBox1.SelectedValue, dateTimePicker1.Text);
                }
            }

            DataTable dt_new = ada.GetDataBy((int)metroComboBox1.SelectedValue, dateTimePicker1.Text);

            dataGridView1.DataSource = dt_new;
        }
Exemplo n.º 3
0
        //'Get Values' Button
        private void metroButtonGet_Click(object sender, EventArgs e)
        {
            //Check if records exist, load for editing or create a record for each student if none exists

            AttendanceTBLTableAdapter ada = new AttendanceTBLTableAdapter();

            DataTable dt = ada.GetDataBy((int)metroComboBox1.SelectedValue, dateTimePicker1.Text);

            if (dt.Rows.Count > 0)
            {
                //records Exist
                DataTable dt_new = ada.GetDataBy((int)metroComboBox1.SelectedValue, dateTimePicker1.Text);
                dataGridView1.DataSource = dt_new;
            }
            else
            {
                //create record for each
                //get class students list
                StudentsTBLTableAdapter students_Adapter = new StudentsTBLTableAdapter();

                DataTable dt_Students = students_Adapter.GetDataByClassID((int)metroComboBox1.SelectedValue);

                foreach (DataRow row in dt_Students.Rows)
                {
                    //insert new record
                    ada.InsertQuery((int)row[0],
                                    (int)metroComboBox1.SelectedValue,
                                    dateTimePicker1.Text, "",
                                    row[1].ToString(),
                                    metroComboBox1.Text);
                }

                DataTable dt_new = ada.GetDataBy((int)metroComboBox1.SelectedValue, dateTimePicker1.Text);
                dataGridView1.DataSource = dt_new;
            }

            /*TODO Delete, Probably not needed:
             * this.attendanceTBLTableAdapter.Fill(this.dataSet1.AttendanceTBL); */
        }