private void CarregarDadosPagina()
        {
            string valor  = Request.QueryString["idItem"];
            int    idItem = 0;

            tb_laboratorio         laboratorio        = new tb_laboratorio();
            DB_LaboratorioEntities contextLaboratorio = new DB_LaboratorioEntities();

            if (!String.IsNullOrEmpty(valor))
            {
                idItem      = Convert.ToInt32(valor);
                laboratorio = contextLaboratorio.tb_laboratorio.First(c => c.id == idItem);



                txtNome.Text               = laboratorio.nome;
                txtQtdComputadores.Text    = Convert.ToString(laboratorio.qtdComputadores);
                txtQtdAlunos.Text          = Convert.ToString(laboratorio.qtdAlunos);
                txtProjetor.Text           = Convert.ToString(laboratorio.projetor);
                txtSoftware1.Text          = laboratorio.software1;
                txtSoftware2.Text          = laboratorio.software2;
                txtSoftware3.Text          = laboratorio.software3;
                txtSistemaOperacional.Text = laboratorio.sistemaOperacional;
            }
        }
Exemple #2
0
        protected void CarregarLista()
        {
            DB_LaboratorioEntities context        = new DB_LaboratorioEntities();
            List <tb_laboratorio>  lstLaboratorio = context.tb_laboratorio.ToList <tb_laboratorio>();

            GVLaboratorio.DataSource = lstLaboratorio;
            GVLaboratorio.DataBind();
        }
Exemple #3
0
        protected void GVLaboratorio_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int idItem = Convert.ToInt32(e.CommandArgument.ToString());
            DB_LaboratorioEntities contextLaboratorio = new DB_LaboratorioEntities();
            tb_laboratorio         laboratorio        = new tb_laboratorio();

            laboratorio = contextLaboratorio.tb_laboratorio.First(c => c.id == idItem);

            if (e.CommandName == "ALTERAR")
            {
                Response.Redirect("Laboratorio.aspx?idItem=" + idItem);
            }
            else if (e.CommandName == "EXCLUIR")
            {
                contextLaboratorio.tb_laboratorio.Remove(laboratorio);
                contextLaboratorio.SaveChanges();
                string msg    = "Laboratorio excluido com sucesso!";
                string titulo = "Infomacao";
                CarregarLista();
                DisplayAlert(titulo, msg, this);
            }
        }
        protected void btnCadastrar_Click(object sender, EventArgs e)
        {
            string  nome               = txtNome.Text;
            int     qtdComputadores    = Convert.ToInt32(txtQtdComputadores.Text);
            int     qtdAlunos          = Convert.ToInt32(txtQtdAlunos.Text);
            Boolean projetor           = Convert.ToBoolean(txtProjetor.Text);
            string  software1          = txtSoftware1.Text;
            string  software2          = txtSoftware2.Text;
            string  software3          = txtSoftware3.Text;
            string  sistemaOperacional = txtSistemaOperacional.Text;
            int     sair;

            sair = 0;



            if ((qtdComputadores <= 1) || (qtdAlunos <= 4) || (software1 == null) || (software2 == null) || (software3 == null) || (nome.Length <= 2))
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "ERROR", "<script language=\"javaScript\">" + "alert('Informações Invalidas!');" + "window.location.href='WebForm2.aspx';" + "<" + "/script>");
                sair = 1;
            }

            if (projetor == false)
            {
                //Response.Write("Para utilização do projetor é necessário abrir uma solicitação para o help desk");

                this.ClientScript.RegisterStartupScript(this.GetType(), "ERROR", "<script language=\"javaScript\">" + "alert('Para utilização do projetor é necessário abrir uma solicitação para o help desk');" + "window.location.href='WebForm2.aspx';" + "<" + "/script>");
                sair = 1;
            }


            tb_laboratorio l = new tb_laboratorio()
            {
                nome      = nome, qtdComputadores = qtdComputadores,
                qtdAlunos = qtdAlunos, projetor = projetor, software1 = software1, software2 = software2,
                software3 = software3, sistemaOperacional = sistemaOperacional
            };

            DB_LaboratorioEntities contextLaboratorio = new DB_LaboratorioEntities();
            string valor = Request.QueryString["idItem"];


            if (String.IsNullOrEmpty(valor))
            {
                contextLaboratorio.tb_laboratorio.Add(l);
                lblmsg.Text = "Registro Inserido";
                Clear();
            }
            else
            {
                int            id          = Convert.ToInt32(valor);
                tb_laboratorio laboratorio = contextLaboratorio.tb_laboratorio.First(c => c.id == id);
                laboratorio.nome               = l.nome;
                laboratorio.qtdComputadores    = l.qtdComputadores;
                laboratorio.qtdAlunos          = l.qtdAlunos;
                laboratorio.projetor           = l.projetor;
                laboratorio.software1          = l.software1;
                laboratorio.software2          = l.software2;
                laboratorio.software3          = l.software3;
                laboratorio.sistemaOperacional = l.sistemaOperacional;
                lblmsg.Text = "Registro Alterado";
            }

            contextLaboratorio.SaveChanges();
        }
        protected void btnCadastrar_Click(object sender, EventArgs e)
        {
            string  nome               = txtNome.Text;
            int     qtdComputadores    = Convert.ToInt32(txtQtdComputadores.Text);
            int     qtdAlunos          = Convert.ToInt32(txtQtdAlunos.Text);
            Boolean projetor           = cbxProjetor.Checked;
            string  software1          = txtSoftware1.Text;
            string  software2          = txtSoftware2.Text;
            string  software3          = txtSoftware3.Text;
            string  sistemaOperacional = txtSistemaOperacional.Text;

            if ((qtdComputadores <= 1) || (qtdAlunos <= 4) || (software1 == null) || (software2 == null) || (software3 == null) || (nome.Length <= 2))
            {
                SendMSG("Informações inválidas");
            }
            else
            {
                tb_laboratorio l = new tb_laboratorio()
                {
                    nome               = nome,
                    qtdComputadores    = qtdComputadores,
                    qtdAlunos          = qtdAlunos,
                    projetor           = projetor,
                    software1          = software1,
                    software2          = software2,
                    software3          = software3,
                    sistemaOperacional = sistemaOperacional
                };

                DB_LaboratorioEntities contextLaboratorio = new DB_LaboratorioEntities();
                string valor = Request.QueryString["idItem"];


                if (String.IsNullOrEmpty(valor))
                {
                    contextLaboratorio.tb_laboratorio.Add(l);
                    lblmsg.Text = "Registro Inserido";
                    Clear();
                }
                else
                {
                    int            id          = Convert.ToInt32(valor);
                    tb_laboratorio laboratorio = contextLaboratorio.tb_laboratorio.First(c => c.id == id);
                    laboratorio.nome               = l.nome;
                    laboratorio.qtdComputadores    = l.qtdComputadores;
                    laboratorio.qtdAlunos          = l.qtdAlunos;
                    laboratorio.projetor           = l.projetor;
                    laboratorio.software1          = l.software1;
                    laboratorio.software2          = l.software2;
                    laboratorio.software3          = l.software3;
                    laboratorio.sistemaOperacional = l.sistemaOperacional;
                    lblmsg.Text = "Registro Alterado";
                }

                contextLaboratorio.SaveChanges();

                if (!projetor)
                {
                    SendMSG("Para utilização do projetor é necessário abrir uma solicitação para o help desk");
                }
            }
        }