private void OnInsert() { mdc = new ModelDataContext(); try { Model.Turma turma = new Model.Turma(); turma.idMateria = int.Parse(tbCodMaterias.Text.Trim()); turma.Nome = tbNome.Text.Trim(); turma.dataCadastro = Convert.ToDateTime(tbDataCadastro.Text.Trim()); mdc.Turma.InsertOnSubmit(turma); mdc.SubmitChanges(); Response.Redirect("Turma.aspx"); } catch (Exception) { throw; } finally { mdc.Dispose(); } }
private void PopulateFields(int pGetID = 0) { mdc = new ModelDataContext(); try { if (pGetID > 0) { Model.Turma turma = mdc.Turma.First(tur => tur.idTurma == pGetID); tbCodTurma.Text = pGetID.ToString(); tbCodMateria.Text = turma.idMateria.ToString().Trim(); tbNome.Text = turma.Nome.Trim(); } else { Response.Redirect("Turma.aspx"); } } catch (Exception) { } finally { mdc.Dispose(); } }
private void OnUpdate() { mdc = new ModelDataContext(); try { Model.Turma turma = mdc.Turma.First(tur => tur.idTurma == int.Parse(tbCodTurma.Text.Trim())); turma.idMateria = int.Parse(tbCodMateria.Text.Trim()); turma.Nome = tbNome.Text.Trim(); mdc.SubmitChanges(); Response.Redirect("Turma.aspx"); } catch (Exception) { } finally { mdc.Dispose(); } }
private void OnDelete() { mdc = new ModelDataContext(); try { Model.Turma turma = mdc.Turma.First(tur => tur.idTurma == int.Parse(tbCodTurma.Text.Trim())); mdc.Turma.DeleteOnSubmit(turma); mdc.SubmitChanges(); Response.Redirect("Turma.aspx"); } catch (Exception) { Response.Redirect("Turma.aspx"); } finally { mdc.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.PopulateGrid(int.Parse(Request.QueryString["id"])); mdc = new ModelDataContext(); try { Model.Turma turma = mdc.Turma.First(tur => tur.idTurma == int.Parse(Request.QueryString["id"])); var turmaDisp = turma.Nome; headerTurma.InnerText = "Todas as Notas da Turma " + turmaDisp; headerTurma.InnerHtml = "<h1>" + headerTurma.InnerText; } catch (Exception) { throw; } finally { mdc.Dispose(); } } }
private void detach_Turma(Turma entity) { this.SendPropertyChanging(); entity.Materia = null; }
private void attach_Turma(Turma entity) { this.SendPropertyChanging(); entity.Materia = this; }
partial void DeleteTurma(Turma instance);
partial void UpdateTurma(Turma instance);
partial void InsertTurma(Turma instance);