Exemple #1
0
        private void metroButton2_Click(object sender, EventArgs e)
        {
            AttendanceRecordTBLTableAdapter ada = new AttendanceRecordTBLTableAdapter();

            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;
            }
        }
Exemple #2
0
        private void metroButtonGet_Click(object sender, EventArgs e)
        {
            //check if records exixts load em for edit if not create a record for each student and load for edit

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

            if (dt.Rows.Count > 0)
            {
                //we have records,so we can edit

                DataTable dt_new = ada.GetDataBy((int)metroComboBox1.SelectedValue, dateTimePicker1.Text);
                dataGridView1.DataSource = dt_new;
            }
            else
            {
                //creatr a record for each student
                //Get the class students list
                StudentsTBLTableAdapter students_adapter = new StudentsTBLTableAdapter();
                DataTable dt_Student = students_adapter.GetDataByClassID((int)metroComboBox1.SelectedValue);

                foreach (DataRow row in dt_Student.Rows)
                {
                    //Insert a new record for this student



                    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: This line of code loads data into the 'dataSet1.AttendanceRecordTBL' table. You can move, or remove it, as needed.
            this.attendanceRecordTBLTableAdapter.Fill(this.dataSet1.AttendanceRecordTBL);
        }
Exemple #3
0
        private void metroButton6_Click(object sender, EventArgs e)
        {
            //get students
            StudentsTBLTableAdapter students_adapter = new StudentsTBLTableAdapter();
            DataTable dt_Student = students_adapter.GetDataByClassID((int)metroComboBox2.SelectedValue);



            AttendanceRecordTBLTableAdapter ada = new AttendanceRecordTBLTableAdapter();

            int P = 0, A = 0, L = 0, E = 0;



            //loop through students and get the values
            foreach (DataRow row in dt_Student.Rows)
            {
                int x = dateTimePicker2.Value.Month;

                string y = row[1].ToString();


                /*
                 * P = (int)ada.GetDataByReport(dateTimePicker2.Value.Month, row[2].ToString(), "present").Rows[0][6];
                 *
                 * // Absence
                 * A = (int)ada.GetDataByReport(dateTimePicker2.Value.Month, row[2].ToString(), "absent").Rows[0][6];
                 *
                 * // late
                 * L = (int)ada.GetDataByReport(dateTimePicker2.Value.Month, row[2].ToString(), "late").Rows[0][6];
                 *
                 *
                 * //Execuse
                 * E = (int)ada.GetDataByReport(dateTimePicker2.Value.Month, row[2].ToString(), "execused").Rows[0][6];
                 *
                 *
                 */



                //Presence count


                P = (int)ada.ScalarQuery(dateTimePicker2.Value.Month, row[1].ToString(), "present");

                // Absence
                A = (int)ada.ScalarQuery(dateTimePicker2.Value.Month, row[1].ToString(), "absence");

                // late

                A = (int)ada.ScalarQuery(dateTimePicker2.Value.Month, row[1].ToString(), "late");

                //Execuse

                A = (int)ada.ScalarQuery(dateTimePicker2.Value.Month, row[1].ToString(), "execuse");


                /*       //Presence count
                 *      p = 1;
                 * dateTimePicker2.Value.Month, row[1].ToString(), "late"
                 *      // Absence
                 *      A = 1;
                 *
                 *      // late
                 *      L = 1;
                 *
                 *
                 *      //Execuse
                 *      E = 1;
                 *
                 */



                ListViewItem listitem = new ListViewItem();
                listitem.Text = row[1].ToString();
                listitem.SubItems.Add(P.ToString());
                listitem.SubItems.Add(A.ToString());
                listitem.SubItems.Add(L.ToString());
                listitem.SubItems.Add(E.ToString());
                listViewreport.Items.Add(listitem);
            }
        }