private void onUpdate()
        {
            mdc = new Model.Model();
            try
            {

                Materias_Edit materia = mdc.Materia.First(mat => mat.idMateria == int.Parse(tbCodMateria.Text.Trim()));

                tbNome.Text = materia.tbNome.Text.Trim();
                tbDescricao.Text = materia.tbDescricao.Text.Trim();
                materia.dataAtualizacao = DateTime.Parse(DateTime.Now.ToShortDateString());

                mdc.AcceptChanges();

                Response.Redirect("Materias.aspx");
            }
            catch (Exception)
            {

            }
            finally
            {
                mdc.Dispose();
            }
        }
        private void popularFields(int pGetID = 0)
        {
            mdc = new Model.Model();
            try
            {
                if (pGetID > 0)
                {

                    Materias_Edit materia = mdc.Materia.First(mat => mat.idMateria == pGetID);

                    tbCodMateria.Text = pGetID.ToString();
                    tbNome.Text = materia.tbNome.Text.Trim();
                    tbDescricao.Text = materia.tbDescricao.Text.Trim();

                }
                else
                {
                    Response.Redirect("Materias.aspx");
                }
            }
            catch (Exception)
            {

            }
            finally
            {
                mdc.Dispose();
            }


        }
        private void onDelete()
        {
            mdc = new Model.Model();
            try
            {
            
                Materias_Edit materia = mdc.Materia.First(mat => mat.idMateria == int.Parse(tbCodigo.Text.Trim()));

                mdc.Materia.RowDeleted();

                mdc.AcceptChanges();

                Response.Redirect("Materias.aspx");

            }
            catch (Exception)
            {

            }
            finally
            {
                mdc.Dispose();
            }
        }