コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
            }

            string idProjetoSelecionado = "";

            if (!(Request.QueryString["idProjeto"] == null))
            {
                HiddenFieldEditando.Value = "true";
                idProjetoSelecionado      = Request.QueryString["idProjeto"].ToString();
                ProjetoNegocio projetoNegocio = new ProjetoNegocio();
                projetoGlobal = projetoNegocio.ObterProjetoPorCodigo(idProjetoSelecionado);
                if (!IsPostBack)
                {
                    FillAllFieldsToEdit(projetoGlobal);
                }
            }
            else
            {
            }


            PanelSucesso.Visible = false;
            PanelErro.Visible    = false;
        }
コード例 #2
0
        private void SelecionaProjeto(string idProjeto)
        {
            ProjetoNegocio projetoNegocio = new ProjetoNegocio();
            Projeto        projeto;

            if (!idProjeto.Equals(String.Empty))
            {
                projeto = projetoNegocio.ObterProjetoPorCodigo(idProjeto);
                ChangeDdlProjetosSelectedItem(idProjeto);
            }
            else
            {
                projeto = projetoNegocio.ObterProjetoPorCodigo(this.DropDownListProjetos.SelectedValue);
            }


            this.HiddenFieldValorCurso.Value = Convert.ToString(projeto.Valor).Replace('.', ',');
            this.LabelValorFinal.Text        = "R$ " + projeto.Valor.ToString("#0.00").Replace('.', ',');

            if (Request.QueryString["idMatricula"] == null)
            {
                FillComboAlunos(projeto);
            }
            else
            {
                FillComboTodosAlunos(projeto);
            }

            VerificaAlunoSelecionado();
        }
コード例 #3
0
        private void FillComboProjetos()
        {
            ProjetoNegocio projetoNegocio = new ProjetoNegocio();
            List <Projeto> listProjeto    = projetoNegocio.ObterTodosProjetos();

            this.DropDownListProjetos.DataSource     = listProjeto;
            this.DropDownListProjetos.DataTextField  = "Nome";
            this.DropDownListProjetos.DataValueField = "Codigo";
            this.DropDownListProjetos.DataBind();
        }
コード例 #4
0
        private void LoadGridViewListaProjetos()
        {
            ProjetoNegocio projeto      = new ProjetoNegocio();
            List <Projeto> listProjetos = projeto.ObterTodosProjetos();

            GridViewListaProjetos.Columns.Clear();

            GridViewListaProjetos.DataSource          = listProjetos;
            GridViewListaProjetos.AutoGenerateColumns = false;

            BoundField bfCodigo = new BoundField();

            bfCodigo.DataField  = "Codigo";
            bfCodigo.HeaderText = "Codigo";
            GridViewListaProjetos.Columns.Add(bfCodigo);

            BoundField bfNomeProjeto = new BoundField();

            bfNomeProjeto.DataField  = "Nome";
            bfNomeProjeto.HeaderText = "Nome";
            GridViewListaProjetos.Columns.Add(bfNomeProjeto);

            BoundField bfValorProjeto = new BoundField();

            bfValorProjeto.DataField  = "Valor";
            bfValorProjeto.HeaderText = "Valor";
            GridViewListaProjetos.Columns.Add(bfValorProjeto);

            CommandField cmdField = new CommandField();

            cmdField.ButtonType       = ButtonType.Image;
            cmdField.DeleteImageUrl   = "Icons/cross.png";
            cmdField.EditImageUrl     = "Icons/page_edit.png";
            cmdField.ShowDeleteButton = true;
            cmdField.ShowEditButton   = true;
            cmdField.EditText         = "Editar Projeto";
            cmdField.DeleteText       = "Remover Projeto";

            GridViewListaProjetos.Columns.Add(cmdField);

            GridViewListaProjetos.DataBind();
        }
コード例 #5
0
        protected void GridViewListaProjetos_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            List <Projeto> listProjeto    = (List <Projeto>)GridViewListaProjetos.DataSource;
            String         IdProjeto      = listProjeto[e.RowIndex].Codigo;
            ProjetoNegocio projeto        = new ProjetoNegocio();
            ProjetoNegocio projetoNegocio = new ProjetoNegocio();

            if (projetoNegocio.ProjetoDeletarOK(IdProjeto))
            {
                if (projetoNegocio.DeletarProjeto(IdProjeto))
                {
                    ShowSuccessMessage("Projeto deletado com sucesso.");
                    LoadGridViewListaProjetos();
                }
                else
                {
                    ShowSuccessMessage("Ocorreu um erro no processo.");
                }
            }
            else
            {
                ShowErrorMessage("Este Projeto não pode ser deletado.");
            }
        }
コード例 #6
0
        protected void ButtonCadastrar_Click(object sender, EventArgs e)
        {
            bool   errorOccured = false;
            string errorMessage = "Ocorreram erros durante o processamento. <ul>";

            Projeto projeto = new Projeto();

            if (this.TextBoxCodigoProjeto.Text.Trim().ToString() != "")
            {
                projeto.Codigo = this.TextBoxCodigoProjeto.Text;
            }
            else
            {
                errorOccured  = true;
                errorMessage += "Código do projeto é obrigatório.";
            }

            if (this.TextBoxNomeProjeto.Text.Trim().ToString() != "")
            {
                projeto.Nome = this.TextBoxNomeProjeto.Text;
            }
            else
            {
                errorOccured  = true;
                errorMessage += "Nome do projeto é obrigatório.";
            }

            projeto.Descricao = this.TextBoxDescricaoProjeto.Text;

            Double valorProjeto = 0.0;

            if (Double.TryParse(this.TextValorProjeto.Text, NumberStyles.Currency, _culture, out valorProjeto) && valorProjeto > 0)
            {
                projeto.Valor = valorProjeto;
            }
            else
            {
                errorOccured  = true;
                errorMessage += "Valor inválido para o valor do projeto.";
            }

            ProjetoNegocio projetoNegocio = new ProjetoNegocio();

            if (errorOccured)
            {
                ShowErrorMessage(errorMessage);
            }
            else
            {
                if (!Boolean.Parse(HiddenFieldEditando.Value))
                {
                    if (projetoNegocio.IncluirProjeto(projeto))
                    {
                        ShowSuccessMessage("Cadastro  do projeto realizado com sucesso. <a href=\"ProjetoNovoEditar.aspx?idProjeto=" + projeto.Codigo + "\">Clique aqui para editar este projeto.</a>");
                    }
                }
                else
                {
                    if (projetoNegocio.AtualizarProjeto(projeto))
                    {
                        ShowSuccessMessage("Projeto atualizado com sucesso.");
                    }
                    ;
                }
            }
        }