Пример #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();
            }
        }
Пример #2
0
        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();
            }
        }
Пример #3
0
        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();
            }
        }
Пример #4
0
        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);