}// end get next code //insert the academic offer public Int32 insert(Entities.AcademicOffer oAcademicOffer) { String oSql = "SP_INSERTACADEMIC_OFFER"; try { SqlCommand oCommand = new SqlCommand(oSql); oCommand.CommandType = CommandType.StoredProcedure; oCommand.Parameters.AddWithValue("@ID", oAcademicOffer.code); oCommand.Parameters.AddWithValue("@TEACHER_ID", oAcademicOffer.oteacher.code); oCommand.Parameters.AddWithValue("@PERIOD_ID", oAcademicOffer.oPeriod.code); oCommand.Parameters.AddWithValue("@PROGRAM_ID", oAcademicOffer.oProgram.code); oCommand.Parameters.AddWithValue("@COURSE_ID", oAcademicOffer.oCourse.id); oCommand.Parameters.AddWithValue("@PRICE", oAcademicOffer.price); oCommand.Parameters.AddWithValue("@CLASSROOM_ID", oAcademicOffer.oClassRoom.code); oCommand.Parameters.AddWithValue("@SCHEDULE_ID", oAcademicOffer.oSchedule.code); oCommand.Parameters.AddWithValue("@HOURS", oAcademicOffer.hours); return(DAO.getInstance().executeSQL(oCommand)); } catch (Exception) { throw; } finally { } }
//this method insert the new schedule for the teacher public void insertTeacherSchedule(Entities.AcademicOffer oAcademic) { Int32 cod = Convert.ToInt32(cboSchedule.SelectedValue); Entities.Schedule oSchedule = BLL.ScheduleBLL.getInstance().getSchedule(cod); int[] days = selectDays(oSchedule.codday); for (int i = 0; i < days.Count(); i++) { if (Convert.ToInt32(days[i]) != 9) { int newCod = Convert.ToInt32(TeacherScheduleBLL.getInstance().getNextCode().ToString()); TeacherScheduleBLL.getInstance().insert(oAcademic, oSchedule, newCod, Convert.ToInt32(days[i])); } } }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { Int32 records = 0; if (validateData()) { Entities.Period oPeriod = new Entities.Period(); Entities.Program oProgram = new Entities.Program(); Entities.Course oCourse = new Entities.Course(); Entities.ClassRoom oClassRoom = new Entities.ClassRoom(); Entities.Schedule oSchedule = new Entities.Schedule(); Entities.Teacher oteacher = new Entities.Teacher(); Int32 code = Convert.ToInt32(txtCode.Text.ToString()); oPeriod.code = Convert.ToInt32(cboPeriod.SelectedValue.ToString()); oProgram.code = Convert.ToInt32(cboProgram.SelectedValue.ToString()); oCourse.id = Convert.ToInt32(cboCourse.SelectedValue.ToString()); Decimal price = Convert.ToDecimal(txtPrice.Text.ToString()); oSchedule.code = Convert.ToInt32(cboSchedule.SelectedValue.ToString()); oClassRoom.code = Convert.ToInt32(cboRoom.SelectedValue.ToString()); oteacher.code = Convert.ToInt32(cboTeacher.SelectedValue.ToString()); Int32 hour = Convert.ToInt32(cboHours.SelectedValue.ToString()); Entities.AcademicOffer oAcademicOffer = new Entities.AcademicOffer(code, oPeriod, oProgram, oCourse, price, oClassRoom, oSchedule, oteacher, hour); if (BLL.AcademicOfferBLL.getInstance().exists(code)) { lblMessage.Text = "Esta solicitud no puede ser procesada"; } else { records = BLL.AcademicOfferBLL.getInstance().insert(oAcademicOffer); insertClasroomSchedule(oAcademicOffer); insertTeacherSchedule(oAcademicOffer); } blockControls(); loadData(); if (records > 0) { lblMessage.Text = "Datos almacenados correactamente"; } } }
} // getNextCode End public Int32 insert(Entities.AcademicOffer oAcademicOffer, Entities.Schedule oSchedule, int cod, int day) { String oSql = "SP_INSERTCLASSROOM_SCHEDULE"; SqlCommand oCommand = new SqlCommand(oSql); oCommand.CommandType = CommandType.StoredProcedure; oCommand.Parameters.AddWithValue("@CLASSROOM_ID", oAcademicOffer.oClassRoom.code); oCommand.Parameters.AddWithValue("@CLASSROOM_SCHEDULE_ID", cod); oCommand.Parameters.AddWithValue("@PERIOD_ID", oAcademicOffer.oPeriod.code); oCommand.Parameters.AddWithValue("@Course_ID", oAcademicOffer.oCourse.id); oCommand.Parameters.AddWithValue("@DIA_ID", day); oCommand.Parameters.AddWithValue("@INITIAL_HOUR", oSchedule.startTime); oCommand.Parameters.AddWithValue("@FINAL_HOUR", oSchedule.endTime); oCommand.Parameters.AddWithValue("@ACADEMICOFFER_ID", oAcademicOffer.code); try { return(DAO.getInstance().executeSQL(oCommand)); } catch (Exception) { throw; } finally { } }
public void modify(Entities.AcademicOffer oAcademicOffer) { throw new NotImplementedException(); }