示例#1
0
        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();
            }
        }
示例#5
0
 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();
         }
     }
 }
示例#6
0
 private void detach_Turma(Turma entity)
 {
     this.SendPropertyChanging();
     entity.Materia = null;
 }
示例#7
0
 private void attach_Turma(Turma entity)
 {
     this.SendPropertyChanging();
     entity.Materia = this;
 }
示例#8
0
 partial void DeleteTurma(Turma instance);
示例#9
0
 partial void UpdateTurma(Turma instance);
示例#10
0
 partial void InsertTurma(Turma instance);