Beispiel #1
0
        protected void btnCadastrar_Click(object sender, EventArgs e)
        {
            string  descricao = txtDescTipo.Text;
            tb_tipo tip       = new tb_tipo()
            {
                descricao = descricao
            };
            VendasDBEntities1 context = new VendasDBEntities1();

            string valor = Request.QueryString["idItem"];

            if (String.IsNullOrEmpty(valor))
            {
                context.tb_tipo.Add(tip);
                lblmsg.Text = "Registro Inserido!";
            }
            else
            {
                int     id   = Convert.ToInt32(valor);
                tb_tipo tipo = context.tb_tipo.First(c => c.id == id);
                tipo.id        = tip.id;
                tipo.descricao = tip.descricao;
                lblmsg.Text    = "Registro Alterado!";
            };

            context.SaveChanges();
            LoadGrid();
        }
Beispiel #2
0
        private void CarregarDadosPagina()
        {
            string            valor       = Request.QueryString["idItem"];
            int               idItem      = 0;
            tb_tipo           tipo        = new tb_tipo();
            VendasDBEntities1 contextTipo = new VendasDBEntities1();

            if (!String.IsNullOrEmpty(valor))
            {
                idItem           = Convert.ToInt32(valor);
                tipo             = contextTipo.tb_tipo.First(c => c.id == idItem);
                txtDescTipo.Text = tipo.descricao;
            }
        }