private void makeAttendance() { conn = new conDB(); int count = (int)conn.dataReaderScalar("select count(AtID) from Attendance where Date = '" + datetime + "' "); //MessageBox.Show(count.ToString()); if (count == 0) { int x = (int)conn.dataReaderScalar("select count(EmpID) from Employee where MarkedStatus='on' "); //MessageBox.Show(x.ToString()); SqlDataReader dr = conn.dataReader("select EmpID from Employee where MarkedStatus='on' "); for (int i = 0; i < x; i++) { while (dr.Read()) { IDvalues = dr[0].ToString(); //MessageBox.Show(IDvalues); conn = new conDB(); conn.executeQry("INSERT INTO Attendance (Date,EmpID) VALUES ('" + datetime + "','" + IDvalues + "') "); } } } conn.closeConnection(); }
public EmpDetAtt() { InitializeComponent(); tbl = new Table(5, Next, Previous, pnltbl, true, 1, 4); tbl.setTblRowsImage(r1, r2, r3, r4, r5); tbl.setQuery1("select EmpID,Photo,EmpNIC,EmpfName+' '+EmplName as FullName,Position from Employee where MarkedStatus='on' ORDER BY EmpID ASC"); tbl.setQuery2("select count(*) from Employee where MarkedStatus='on' "); // tbl.setCBoxs(c1, c2); tbl.setPath(@"C:\Users\House MoNaRa\Documents\Visual Studio 2015\Projects\EmployeeM\EmployeeM\Images\"); tbl.tblTheamSetter(Color.FromArgb(38, 95, 141), Color.FromArgb(47, 50, 67), Color.FromArgb(89, 89, 89, 89), Color.FromArgb(169, 171, 183)); tbl.setSelects(); tbl.enablePagination(); tbl.setPages(); tbl.loadFirstPage(); days = (int)conn.dataReaderScalar("select count(*) from tempAtt where Month='" + datetime.Month + "' and Year='" + datetime.Year + "' group by Date "); //MessageBox.Show(days.ToString()); SqlDataReader dr = conn.dataReader("select EmpID from tempAtt group by EmpID "); for (int i = 0; i < days; i++) { while (dr.Read()) { IDvalues = dr[0].ToString(); //MessageBox.Show(IDvalues); totaldays = (int)conn.dataReaderScalar("select count(*) from tempAtt where Month='" + datetime.Month + "' and Year='" + datetime.Year + "' group by Date "); present = (int)conn.dataReaderScalar("select count(EmpID) from tempAtt where EmpID='" + IDvalues + "' and Month='" + datetime.Month + "' and Year='" + datetime.Year + "' and AttendanceStatus='Present' group by EmpID"); absent = (int)conn.dataReaderScalar("select count(EmpID) from tempAtt where EmpID='" + IDvalues + "' and Month='" + datetime.Month + "' and Year='" + datetime.Year + "' and AttendanceStatus='Absent' group by EmpID"); //MessageBox.Show(totaldays.ToString() + '=' + present.ToString() + '+' + absent.ToString()); monpreavg = (present / (double)totaldays) * 100; //MessageBox.Show(monpreavg.ToString("f2")); //conn.executeQry("INSERT INTO Attendance (Date,EmpID) VALUES ('" + datetime + "','" + IDvalues + "') "); } } fulldays = (int)conn.dataReaderScalar("select COUNT(*) from tempAtt group by EmpID "); //MessageBox.Show(fulldays.ToString()); SqlDataReader sdr = conn.dataReader("select EmpID from tempAtt group by EmpID "); for (int i = 0; i < fulldays; i++) { while (sdr.Read()) { FullIDvalues = sdr[0].ToString(); //MessageBox.Show(FullIDvalues); fulltotaldays = (int)conn.dataReaderScalar("select count(*) from tempAtt where Year='" + datetime.Year + "' group by Year,EmpID "); fullpresent = (int)conn.dataReaderScalar("select count(EmpID) from tempAtt where EmpID='" + FullIDvalues + "' and AttendanceStatus='Present' and Year='" + datetime.Year + "' group by Year,EmpID "); fullabsent = (int)conn.dataReaderScalar("select count(EmpID) from tempAtt where EmpID='" + FullIDvalues + "' and AttendanceStatus='Absent' and Year='" + datetime.Year + "' group by Year,EmpID "); //MessageBox.Show(fulltotaldays.ToString() + '=' + fullpresent.ToString() + '+' + fullabsent.ToString()); yrpreavg = (fullpresent / (double)fulltotaldays) * 100; //MessageBox.Show(yrpreavg.ToString("f2")); //conn.executeQry("INSERT INTO Attendance (Date,EmpID) VALUES ('" + datetime + "','" + IDvalues + "') "); } } conn.closeConnection(); }