public void insertUpdate(int month, int year, string locationName, DataGridView dataGridView)
    {
        attendanceContent   = new AttendanceContent();
        attendanceContentDB = new AttendanceContentDB();
        attendanceControl   = new AttendanceControl();
        bool flag         = attendanceControl.checkIfLocationAttendanceSubmitted(month, year, locationName);
        int  attendanceID = attendanceControl.getID(month, year, locationName);

        attendanceContent.setAttendanceID(attendanceID);
        bool flag1 = attendanceContentDB.checkIfAttendanceContentIsSubmitted(attendanceContent);

        if (flag == true)
        {
            //submitted //update
            if (flag1 == true)
            {
                this.update(month, year, locationName, dataGridView);
            }
            else if (flag1 == false)
            {
                this.insert(dataGridView);
            }
        }
        else if (flag == false)
        {
            //not submitted //insert
            attendanceControl.insert(month, year, locationName);
            this.insert(dataGridView);
        }
    }
    public void update(int month, int year, string locationName, DataGridView dataGridView)
    {
        attendanceControl   = new AttendanceControl();
        attendanceContent   = new AttendanceContent();
        attendanceContentDB = new AttendanceContentDB();
        int           attendanceID = attendanceControl.getID(month, year, locationName);
        List <string> list         = new List <string>();

        foreach (DataGridViewRow row in dataGridView.Rows)
        {
            list.Clear();
            int code = int.Parse(row.Cells[0].Value.ToString());
            //string name = row.Cells[1].Value.ToString();
            list.Add(row.Cells[2].Value.ToString());
            list.Add(row.Cells[3].Value.ToString());
            list.Add(row.Cells[4].Value.ToString());
            list.Add(row.Cells[5].Value.ToString());
            list.Add(row.Cells[6].Value.ToString());
            list.Add(row.Cells[7].Value.ToString());
            list.Add(row.Cells[8].Value.ToString());
            list.Add(row.Cells[9].Value.ToString());
            list.Add(row.Cells[10].Value.ToString());
            list.Add(row.Cells[11].Value.ToString());
            list.Add(row.Cells[12].Value.ToString());
            list.Add(row.Cells[13].Value.ToString());
            list.Add(row.Cells[14].Value.ToString());
            list.Add(row.Cells[15].Value.ToString());
            list.Add(row.Cells[16].Value.ToString());
            list.Add(row.Cells[17].Value.ToString());
            list.Add(row.Cells[18].Value.ToString());
            list.Add(row.Cells[19].Value.ToString());
            list.Add(row.Cells[20].Value.ToString());
            list.Add(row.Cells[21].Value.ToString());
            list.Add(row.Cells[22].Value.ToString());
            list.Add(row.Cells[23].Value.ToString());
            list.Add(row.Cells[24].Value.ToString());
            list.Add(row.Cells[25].Value.ToString());
            list.Add(row.Cells[26].Value.ToString());
            list.Add(row.Cells[27].Value.ToString());
            list.Add(row.Cells[28].Value.ToString());
            list.Add(row.Cells[29].Value.ToString());
            list.Add(row.Cells[30].Value.ToString());
            list.Add(row.Cells[31].Value.ToString());
            list.Add(row.Cells[32].Value.ToString());
            attendanceContent.setDays(list);
            attendanceContent.setEmpID(code);
            attendanceContent.setAttendanceID(attendanceID);
            attendanceContentDB.update(attendanceContent);
        }
    }