Example #1
0
        //add attandence
        private void btnAddAttendance_Click(object sender, EventArgs e)
        {
            int    t           = ajdbClass.TRec("select * from ClassAttendance");
            string _DataFields = "AttendanceDate";
            string _Values     = "'" + dtpAttendance.Value + "'";
            string Result      = ajdbClass.InsertIntoDatabase("ClassAttendance", _DataFields, _Values);

            System.Threading.Thread.Sleep(1000);
            DataSet ds = new DataSet();

            ds = ajdbClass.GetRecords("tbl", "SELECT TOP (1) Id, AttendanceDate FROM  ClassAttendance order by id desc");
            string _lastid = "";

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                _lastid = dr["id"].ToString().Trim();
            }
            DataSet dsStudents = new DataSet();

            dsStudents = ajdbClass.GetRecords("tbl", "select * from Student where status='5'");
            foreach (DataRow dr in dsStudents.Tables[0].Rows)
            {
                string _atid = _lastid;
                string stid  = dr["id"].ToString();
                _DataFields = "AttendanceId, studentid,AttendanceStatus";
                _Values     = "'" + _lastid.Replace("'", "''") + "','" + stid + "','1'";
                Result      = ajdbClass.InsertIntoDatabase("StudentAttendance", _DataFields, _Values);
                System.Threading.Thread.Sleep(500);
            }
            ajdbClass.popList(lstAttendace, "select * from ClassAttendance order by AttendanceDate desc", "AttendanceDate");
            gvAttandance.DataSource = GetAttendanceRecord();
            MessageBox.Show("Attandance Taken!!!");
        }