public void Insert(Teacher teacherObj) { string insertCommand = "INSERT INTO Teacher (NAME) VALUES (@NAME)"; SqlCommand sqlCommand = new SqlCommand(insertCommand); SqlParameter nameParam = new SqlParameter("@NAME", SqlDbType.VarChar); nameParam.Value = teacherObj.NAME; sqlCommand.Parameters.Add(nameParam); dataAccess.Execute(sqlCommand); }
private void insertButton_Click(object sender, EventArgs e) { if (teacherNameTextBox.Text.Length != 0) { Teacher teacherObj = new Teacher(); teacherObj.NAME = teacherNameTextBox.Text; TeacherData teacherData = new TeacherData(); teacherData.Insert(teacherObj); populate(); } }
public void Update(Teacher teacherObj) { string updateCommand = "UPDATE Teacher SET NAME = @NAME WHERE ID = @ID"; SqlCommand sqlCommand = new SqlCommand(updateCommand); SqlParameter nameParam = new SqlParameter("@NAME", SqlDbType.VarChar); nameParam.Value = teacherObj.NAME; SqlParameter idParam = new SqlParameter("@ID", SqlDbType.Int); idParam.Value = teacherObj.ID; sqlCommand.Parameters.Add(nameParam); sqlCommand.Parameters.Add(idParam); dataAccess.Execute(sqlCommand); }
protected void gvTeacher_RowEditing(object sender, GridViewEditEventArgs e) { unlockControls(); Int32 code = Convert.ToInt32(gvTeacher.Rows[e.NewEditIndex].Cells[0].Text); Entities.Teacher oTeacher = TeacherBLL.getInstance().getTeacher(code); txtCode.Text = oTeacher.code.ToString(); txtId.Text = oTeacher.id.ToString(); txtName.Text = oTeacher.name.ToString(); txtLastName.Text = oTeacher.lastName.ToString(); txtHomePhone.Text = oTeacher.homePhone.ToString(); txtCellPhone.Text = oTeacher.cellPhone.ToString(); txtEmail.Text = oTeacher.email.ToString(); cboModality.SelectedValue = oTeacher.Position.code.ToString(); cboState.SelectedValue = oTeacher.state.ToString(); ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "$('html, body').animate({ scrollTop: $('body').offset().top });", true); }
public List<Teacher> getList() { List<Teacher> teacherList = new List<Teacher>(); SqlCommand command = new SqlCommand("SELECT * FROM Teacher"); DataTable dt = dataAccess.Query(command); for (int i = 0; i < dt.Rows.Count; i++) { Teacher teacherObj = new Teacher(); teacherObj.ID = (int)dt.Rows[i][0]; teacherObj.NAME = (string)dt.Rows[i][1]; teacherList.Add(teacherObj); } return teacherList; }
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.Teacher oTeacher = new Entities.Teacher(); Entities.InternalDesignation oInternalDesignation = new Entities.InternalDesignation(); oTeacher.code = Convert.ToInt32(txtCode.Text); oTeacher.id = txtId.Text; oTeacher.name = txtName.Text; oTeacher.lastName = txtLastName.Text; oInternalDesignation.code = Convert.ToInt32(cboModality.SelectedValue); oTeacher.homePhone = txtHomePhone.Text; oTeacher.cellPhone = txtCellPhone.Text; oTeacher.email = txtEmail.Text; oTeacher.state = Convert.ToInt16(cboState.SelectedValue); oTeacher.Position = oInternalDesignation; if (TeacherBLL.getInstance().exists(oTeacher.code)) { records = TeacherBLL.getInstance().modify(oTeacher); } else { records = TeacherBLL.getInstance().insert(oTeacher); } 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); } }