protected void btnsave_Click(object sender, EventArgs e) { SchoolInformation info = new SchoolInformation(); MyDate mydate = new MyDate(); foreach (ListViewItem item in ListView1.Items) { Button btnActive = (Button)item.FindControl("btnActive"); if (btnActive.Text == "غياب") { StudentsAbsence abs = new StudentsAbsence(); RadioButtonList radio = ((RadioButtonList)item.FindControl("radio")); abs.SemesterId = MyDate.getCurrentSemesterId(); abs.SchoolId = info.getId(); abs.StudentId = int.Parse(((HiddenField)item.FindControl("HiddenField1")).Value).ToString(); abs.Date = DateTime.Now; abs.IsExcuse = Convert.ToBoolean(radio.SelectedValue); km.StudentsAbsences.Add(abs); km.SaveChanges(); } else if (btnActive.Text == "حضور") { StudentsAttendence att = new StudentsAttendence(); att.Date = DateTime.Now; att.SchoolId = info.getId(); att.SemesterId = MyDate.getCurrentSemesterId(); att.StudentId = ((HiddenField)item.FindControl("HiddenField1")).Value; //TextBox txtArrive = (TextBox)item.FindControl("txtarrivingTime"); //if (!String.IsNullOrEmpty(txtArrive.Text)) //att.ArrivingTime = Convert.ToDateTime(txtArrive.Text).TimeOfDay; //TextBox txtDeparture = (TextBox)item.FindControl("txtdeptime"); //if (!String.IsNullOrEmpty(txtDeparture.Text)) // att.DepartureTime = Convert.ToDateTime(txtDeparture.Text).TimeOfDay; km.StudentsAttendences.Add(att); km.SaveChanges(); } else if (btnActive.Text == "تأخر") { StudentsLateness late = new StudentsLateness(); if (!String.IsNullOrEmpty(((TextBox)item.FindControl("TimeLate")).Text)) { late.TotalSeconds = Convert.ToDateTime(((TextBox)item.FindControl("TimeLate")).Text).TimeOfDay.TotalSeconds; late.Amount = Convert.ToDateTime(((TextBox)item.FindControl("TimeLate")).Text).TimeOfDay; } late.Date = DateTime.Now; late.SchoolId = info.getId(); late.SemesterId = MyDate.getCurrentSemesterId(); late.StudentId = ((HiddenField)item.FindControl("HiddenField1")).Value; km.StudentsLatenesses.Add(late); km.SaveChanges(); } // ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('تم التسجيل بنجاح')", true); } Response.Redirect("~/Student/StudentAttendenceReport.aspx"); }
public IHttpActionResult DeleteStudentsAbsence(int id) { StudentsAbsence studentsAbsence = service.DeleteStudentsAbsence(id); if (studentsAbsence == null) { return(NotFound()); } return(Ok(studentsAbsence)); }
public IHttpActionResult GetStudentsAbsenceById(int id) { StudentsAbsence studentsAbsence = service.GetStudentsAbsenceById(id); if (studentsAbsence == null) { return(NotFound()); } return(Ok(studentsAbsence)); }
protected void btnSave_Click(object sender, EventArgs e) { int schoolId = SchoolInfo.getId(); //task.SchoolId = schoolId; int semesterId = MyDate.getCurrentSemesterId(); foreach (ListItem item in Lstpart.Items) { var userId = item.Value; StudentsAbsence abs = new StudentsAbsence(); abs.StudentId = userId; abs.SchoolId = schoolId; abs.SemesterId = semesterId; abs.IsExcuse = Convert.ToBoolean(radioIsExecuse.SelectedValue); if (abs.IsExcuse == true) { abs.Reason = txtReason.Text; } if (Calendar1.CultureName == "ar-EG") { abs.Date = DateTime.ParseExact(datepicker.Text, "yyyy/MM/dd", CultureInfo.CreateSpecificCulture("ar-EG")); } else { abs.Date = MyDate.convertHijriToGregorian(datepicker.Text); } abs.IsOneDay = radioDay.SelectedValue == "1"; if (abs.IsOneDay == false) { if (Calendar1.CultureName == "ar-EG") { abs.DateTo = DateTime.ParseExact(datepicker2.Text, "yyyy/MM/dd", CultureInfo.CreateSpecificCulture("ar-EG")); } else { abs.DateTo = MyDate.convertHijriToGregorian(datepicker2.Text); } } km.StudentsAbsences.Add(abs); km.SaveChanges(); } ClientScript.RegisterStartupScript(this.GetType(), "openModal", "<script> addSuccess(' تم الاضافة بنجاح بنجاح'); </script>", false); }
public StudentsAbsence DeleteStudentsAbsence(int id) { StudentsAbsence studentsAbsence = db.StudentsAbsenceRepository.GetByID(id); if (studentsAbsence == null) { return(null); } db.StudentsAbsenceRepository.Delete(id); db.Save(); logger.Info("Deleted students absence (id:{0})", id); return(studentsAbsence); }
public IHttpActionResult PutStudentsAbsence(int id, StudentsAbsence studentsAbsence) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } bool done = service.PutStudentsAbsence(id, studentsAbsence); if (done == false) { return(BadRequest()); } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostStudentsAbsence(StudentsAbsence studentsAbsence) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } StudentsAbsence postedStudentsAbsence = service.PostStudentsAbsence(studentsAbsence); if (postedStudentsAbsence == null) { return(BadRequest()); } return(Created("", postedStudentsAbsence)); }
public bool PutStudentsAbsence(int id, StudentsAbsence studentsAbsence) { if (id != studentsAbsence.Id) { return(false); } StudentsAbsence checkStudentsAbsence = db.StudentsAbsenceRepository.GetByID(id); if (checkStudentsAbsence == null) { return(false); } checkStudentsAbsence.Justified = studentsAbsence.Justified; db.StudentsAbsenceRepository.Update(checkStudentsAbsence); db.Save(); logger.Info("Updated students absence (id:{0})", checkStudentsAbsence.Id); return(true); }
public StudentsAbsence PostStudentsAbsence(StudentsAbsence studentsAbsence) { Student student = db.StudentRepository.GetByID(studentsAbsence.StudentId); Lecture lecture = db.LectureRepository.GetByID(studentsAbsence.LectureId); if (student == null || lecture == null) { return(null); } StudentsAbsence newStudentsAbsence = new StudentsAbsence(); newStudentsAbsence.Justified = false; newStudentsAbsence.Student = student; newStudentsAbsence.Lecture = lecture; db.StudentsAbsenceRepository.Insert(newStudentsAbsence); db.Save(); logger.Info("Added new students absence"); return(newStudentsAbsence); }
public StudentsAbsence GetStudentsAbsenceById(int id) { StudentsAbsence studentsAbsence = db.StudentsAbsenceRepository.GetByID(id); return(studentsAbsence); }