protected void gvTimeSheet_RowUpdating(object sender, GridViewUpdateEventArgs e) { //Get the new Values. GridViewRow row = gvTimeSheet.Rows[e.RowIndex]; Label lblWorkDate = (Label)row.FindControl("lblWorkDate"); Label lblHours = (Label)row.FindControl("lblHours"); Label lblPartnerHours = (Label)row.FindControl("lblPartnerHours"); TextBox tbPartnerHours = (TextBox)row.FindControl("tbPartnerHours"); Label lblOpportunityID = (Label)row.FindControl("lblOpportunityID"); Label lblStudentID = (Label)row.FindControl("lblStudentID"); // Code to update the DataSource. StudentTimeEntry Ste = new StudentTimeEntry(); Ste.PartnerApprovedHours = Convert.ToInt32(tbPartnerHours.Text); Ste.OpportunityID = Convert.ToInt32(Session["OpportunityID"]); Ste.StudentID = Convert.ToInt32(Session["StudentID"]); Ste.WorkDate = lblWorkDate.Text; Ste.UpdatePartnerHours(); //Reset the edit index. gvTimeSheet.EditIndex = -1; //Bind data to the GridView control. DataBind(); }
public List <StudentTimeEntry> GetTimeEntries(int studentId, int opportunityId) { var reader = dbHelper.GetTimeEntries(Constant.SP_GetTimeEntries, studentId, opportunityId); List <StudentTimeEntry> studentTimeEntryList = new List <StudentTimeEntry>(); StudentTimeEntry studentTimeEntry = null; while (reader.Read()) { studentTimeEntry = new StudentTimeEntry(); studentTimeEntry.WorkDate = reader["WorkDate"].ToString(); studentTimeEntry.HoursVolunteered = Convert.ToInt32(reader["HoursVolunteered"]); studentTimeEntry.PartnerApprovedHours = Convert.ToInt32(reader["PartnerApprovedHours"]); studentTimeEntryList.Add(studentTimeEntry); } return(studentTimeEntryList); }
private void DataBind() { int studentId = Convert.ToInt32(Session["Student_StudentID"]); int opportunityId = Convert.ToInt32(Session["Student_SelectedOpportunityID"]); StudentTimeEntry studentTimeEntry = new StudentTimeEntry(); List <StudentTimeEntry> studentTimeEntryList = studentTimeEntry.GetStudentTimeEntriesByOpportunityId(studentId, opportunityId); if (studentTimeEntryList.Count == 0) { StudentTimeEntry timeEntry = new StudentTimeEntry(); studentTimeEntryList.Add(timeEntry); gvTimeEntry.DataSource = studentTimeEntryList; gvTimeEntry.DataBind(); gvTimeEntry.Rows[0].Visible = false; } else { gvTimeEntry.DataSource = studentTimeEntryList; gvTimeEntry.DataBind(); } }
public void DataBind() { // int OpportunityID = Convert.ToInt32(Session["OpportunityID"]); //int StudentID = Convert.ToInt32(Session["StudentID"]); //int CPPID = Convert.ToInt32(Session["CPPID"]); StudentTimeEntry Ste = new StudentTimeEntry(); List <StudentTimeEntry> Lste = Ste.GetTimeEntries(12, 1); if (Lste.Count == 0) { StudentTimeEntry TimeEntry = new StudentTimeEntry(); Lste.Add(TimeEntry); gvTimeSheet.DataSource = Lste; gvTimeSheet.DataBind(); gvTimeSheet.Rows[0].Visible = false; } else { gvTimeSheet.DataSource = Lste; } gvTimeSheet.DataBind(); }
protected void validation() { if (tboxDateVolunteered.Text == "" || tboxHoursVolunteered.Text == "") { lblTimeEntryWarning.Text = "Please entry a date and volunteered hour(s)"; } else { lblTimeEntryWarning.Text = ""; StudentTimeEntry studentTimeEntry = new StudentTimeEntry(); studentTimeEntry.WorkDate = tboxDateVolunteered.Text; studentTimeEntry.OpportunityID = Convert.ToInt32(Session["Student_SelectedOpportunityID"]); studentTimeEntry.StudentID = Convert.ToInt32(Session["Student_StudentID"]); studentTimeEntry.CPPID = 2; studentTimeEntry.PartnerApprovedHours = 0; studentTimeEntry.TimeEntryDate = DateTime.Today.ToShortDateString(); studentTimeEntry.HoursVolunteered = Convert.ToInt32(tboxHoursVolunteered.Text); studentTimeEntry.SubmitStudentTimeEntry(studentTimeEntry); } }
public void SubmitStudentTimeEntry(StudentTimeEntry studentTimeEntry) { dbHelper.SubmitStudentTimeEntry(Constant.SP_AddTimeEntries, studentTimeEntry.WorkDate, studentTimeEntry.OpportunityID, studentTimeEntry.StudentID, studentTimeEntry.CPPID, studentTimeEntry.PartnerApprovedHours, studentTimeEntry.TimeEntryDate, studentTimeEntry.HoursVolunteered); }