protected void gvResults_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Edit") { int index = Convert.ToInt32(e.CommandArgument); int i = (int)GridView1.DataKeys[index].Value; shift = dataShift.readShiftEDITBusy(i); Session["shiftSession"] = shift; schedule = dataSchedule.readScheduleEDIT(shift.Id, DropDownList1.SelectedValue, DropDownList2.SelectedValue); Session["scheduleSession"] = schedule; dataShift.updateShift(dataShift.readLabEDIT(DropDownList1.SelectedValue), schedule.Busy, shift.Id, dataDate.readDateEDIT(DropDownList2.SelectedValue)); Response.Redirect("/CRUDShift.aspx"); } }
public Date readDate(int id, int idLab, string startTime, string endTime, string date) { Date date1 = new Date(); Lab lab = new Lab(); Shift shift = new Shift(); SqlConnection con = DatabaseConnection("open"); SqlCommand cmd = new SqlCommand("readDate", con); cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@idLab", idLab); cmd.Parameters.AddWithValue("@start time", startTime); cmd.Parameters.AddWithValue("@end time", endTime); cmd.Parameters.AddWithValue("@date", startTime); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.ExecuteNonQuery(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { date1.Id = reader.GetInt32(reader.GetOrdinal("id")); } cmd.Dispose(); DatabaseConnection("close"); return date1; }