protected void gvSchedule_RowEditing(object sender, GridViewEditEventArgs e) { unlockControls(); Int32 code = Convert.ToInt32(gvSchedule.Rows[e.NewEditIndex].Cells[0].Text); Entities.Schedule oSchedule = ScheduleBLL.getInstance().getSchedule(code); txtCode.Text = oSchedule.code.ToString(); txtDescription.Text = oSchedule.name; cboTypeSchedule.SelectedValue = oSchedule.typeSchedule; txtStart.Text = String.Format("{0:t}", oSchedule.startTime); txtEndHour.Text = String.Format("{0:t}", oSchedule.endTime); cboprogram.SelectedValue = oSchedule.oProgram.code.ToString(); cboState.SelectedValue = oSchedule.state.ToString(); SelectchkDays(oSchedule.codday); ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "$('html, body').animate({ scrollTop: $('body').offset().top });", true); }
//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])); } } }
public List <ClassRoom> getAllActiveBySchedule(int periodId, int programid, Entities.Schedule oSchedule, int[] days) { String sql = "SP_CLASSROOMBYSCHEDULE"; try { SqlCommand oCommand = new SqlCommand(sql); oCommand.CommandType = System.Data.CommandType.StoredProcedure; oCommand.Parameters.AddWithValue("@period", periodId); oCommand.Parameters.AddWithValue("@program", programid); oCommand.Parameters.AddWithValue("@inicialHour", oSchedule.startTime); oCommand.Parameters.AddWithValue("@finalhour", oSchedule.endTime); oCommand.Parameters.AddWithValue("@day1", Convert.ToInt32(days[0])); oCommand.Parameters.AddWithValue("@day2", Convert.ToInt32(days[1])); oCommand.Parameters.AddWithValue("@day3", Convert.ToInt32(days[2])); oCommand.Parameters.AddWithValue("@day4", Convert.ToInt32(days[3])); oCommand.Parameters.AddWithValue("@day5", Convert.ToInt32(days[4])); oCommand.Parameters.AddWithValue("@day6", Convert.ToInt32(days[5])); oCommand.Parameters.AddWithValue("@day7", Convert.ToInt32(days[6])); DataTable oDataTable = DAO.getInstance().executeQuery(oCommand); List <ClassRoom> listClassRoom = new List <ClassRoom>(); foreach (DataRow oDataRow in oDataTable.Rows) { ClassRoom oClassRoom = new ClassRoom(); Location oLocation = new Location(); Headquarters oHeadquarters = new Headquarters(); ClassRoomsType oClassRoomsType = new ClassRoomsType(); oClassRoom.code = Convert.ToInt32(oDataRow[0].ToString()); oClassRoom.num_room = oDataRow[1].ToString(); oClassRoomsType.description = oDataRow[2].ToString(); oLocation.code = Convert.ToInt32(oDataRow[3].ToString()); oLocation.building = oDataRow[4].ToString(); oLocation.module = oDataRow[5].ToString(); oHeadquarters.description = oDataRow[6].ToString(); oLocation.oHeadquarters = oHeadquarters; oClassRoom.oClassRoomsType = oClassRoomsType; oClassRoom.oLocation = oLocation; listClassRoom.Add(oClassRoom); } return(listClassRoom); } catch (Exception) { throw; } finally { } }
//when the chkEspecial is selected the cmbCourse is going to fill in with the courses of the all programs public void getRoomEspecial(Int32 cod) { Entities.Schedule oSchedule = BLL.ScheduleBLL.getInstance().getSchedulebyCodeActive(cod); int[] days = selectDays(oSchedule.codday); int periodId = Convert.ToInt32(cboPeriod.SelectedValue); List <Entities.ClassRoom> listClassRoom = new List <Entities.ClassRoom>(); listClassRoom = BLL.ClassRoomScheduleBLL.getInstance().getAllActiveByScheduleEspecial(periodId, oSchedule, days); ListItem oItemS = new ListItem("---- Seleccione ----", "0"); cboRoom.Items.Add(oItemS); foreach (Entities.ClassRoom olistClassRoom in listClassRoom) { ListItem oItem = new ListItem(olistClassRoom.num_room + " (" + olistClassRoom.oLocation.oHeadquarters.description + " " + olistClassRoom.oLocation.building + " " + olistClassRoom.oLocation.module + ") ", olistClassRoom.code.ToString()); cboRoom.Items.Add(oItem); } }
//To select the teachers that have free time and can give class public void getTeacherSchedule(Int32 cod) { Entities.Schedule oSchedule = BLL.ScheduleBLL.getInstance().getSchedulebyCodeActive(cod); int[] days = selectDays(oSchedule.codday); int programid = Convert.ToInt32(cboProgram.SelectedValue); int periodId = Convert.ToInt32(cboPeriod.SelectedValue); List <Entities.Teacher> listTeacher = new List <Entities.Teacher>(); listTeacher = BLL.TeacherScheduleBLL.getInstance().getAllActiveTeacherBySchedule(periodId, oSchedule, days); ListItem oItemS = new ListItem("---- Seleccione ----", "0"); cboTeacher.Items.Add(oItemS); foreach (Entities.Teacher oTeacher in listTeacher) { ListItem oItem = new ListItem(oTeacher.name + " " + oTeacher.lastName, oTeacher.code.ToString()); cboTeacher.Items.Add(oItem); } }
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"; } } }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { Int32 records = -1; if (validateData()) { Entities.Schedule oSchedule = new Entities.Schedule(); oSchedule.code = Convert.ToInt32(txtCode.Text); oSchedule.name = txtDescription.Text; oSchedule.typeSchedule = cboTypeSchedule.SelectedValue; oSchedule.startTime = Convert.ToDateTime(txtStart.Text); oSchedule.endTime = Convert.ToDateTime(txtEndHour.Text); oSchedule.state = Convert.ToInt32(cboState.SelectedValue); oSchedule.oProgram.code = Convert.ToInt32(cboprogram.SelectedValue); oSchedule.codday = codDays; if (ScheduleBLL.getInstance().exists(oSchedule.code)) { records = ScheduleBLL.getInstance().modify(oSchedule); } else { records = ScheduleBLL.getInstance().insert(oSchedule); } blockControls(); loadData(); if (records > 0) { lblMessage.Text = "Datos almacenados correctamente."; } } //no c para que es esto else { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "comboBox", "comboBox();", true); } }
} // 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 { } }