Ejemplo n.º 1
0
        protected void btnCadastrar_Click(object sender, EventArgs e)
        {
            string descricao = txtdescricaotipo.Text;
            TIPO   tip       = new TIPO()
            {
                descricao = descricao
            };
            Aula5Entities contextAula5 = new Aula5Entities();

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

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

            contextAula5.SaveChanges();
            LoadGrid();
        }
        protected void btnCadastrar_Click(object sender, EventArgs e)
        {
            int      fornecedor  = int.Parse(ddlFornecedor.SelectedValue.ToString());
            int      tipo        = int.Parse(ddlTipo.SelectedValue.ToString());
            DateTime dataentrada = Convert.ToDateTime(txtdataentrada.Text);
            string   descricao   = txtdescricao.Text;
            decimal  valor       = Convert.ToDecimal(txtvalor.Text);
            MATERIAL m           = new MATERIAL()
            {
                id_fornecedor = fornecedor, id_tipo = tipo, dataentrada = dataentrada, descricao = descricao, valor = valor
            };
            Aula5Entities contextAula5 = new Aula5Entities();

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

            if (String.IsNullOrEmpty(value))
            {
                contextAula5.MATERIAL.Add(m);
                lblmsg.Text = "Registro Inserido!";
            }
            else
            {
                int      id       = Convert.ToInt32(value);
                MATERIAL material = contextAula5.MATERIAL.First(c => c.id == id);
                material.id_fornecedor = m.id_fornecedor;
                material.id_tipo       = m.id_tipo;
                material.dataentrada   = m.dataentrada;
                material.valor         = m.valor;
                material.descricao     = m.descricao;
                lblmsg.Text            = "Registro Alterado!";
            };

            contextAula5.SaveChanges();
            LoadGrid();
        }
        protected void btnCadastrar_Click(object sender, EventArgs e)
        {
            int      fornecedor = int.Parse(ddlFornecedor.SelectedValue.ToString());
            int      cliente    = int.Parse(ddlCliente.SelectedValue.ToString());
            int      material   = int.Parse(ddlMaterial.SelectedValue.ToString());
            DateTime datavenda  = Convert.ToDateTime(txtdatavenda.Text);
            COMPRA   com        = new COMPRA()
            {
                id_fornecedor = fornecedor, id_cliente = cliente, id_material = material, datavenda = datavenda
            };
            Aula5Entities contextAula5 = new Aula5Entities();

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

            if (String.IsNullOrEmpty(valor))
            {
                contextAula5.COMPRA.Add(com);
                lblmsg.Text = "Registro Inserido!";
            }
            else
            {
                int    id     = Convert.ToInt32(valor);
                COMPRA compra = contextAula5.COMPRA.First(c => c.id == id);
                compra.id_cliente    = com.id_cliente;
                compra.id_fornecedor = com.id_fornecedor;
                compra.id_material   = com.id_material;
                compra.datavenda     = com.datavenda;
                lblmsg.Text          = "Registro Alterado!";
            };
            contextAula5.SaveChanges();
            LoadGrid();
        }
Ejemplo n.º 4
0
        protected void btnCadastrar_Click(object sender, EventArgs e)
        {
            if (txtcidade.Text == "" || txtnome.Text == "" || txttelefone.Text == "" || txtcidade.Text == "" || txtCNPJ.Text == "" || txtendereco.Text == "")
            {
                lblmsg.Text = "Preencha todos os campos!";
            }
            else
            {
                string     nome     = txtnome.Text;
                string     telefone = txttelefone.Text;
                string     cidade   = txtcidade.Text;
                string     endereco = txtendereco.Text;
                long       cnpj     = Convert.ToInt64(txtCNPJ.Text.ToString().Substring(0, 8));
                FORNECEDOR f        = new FORNECEDOR()
                {
                    nome = nome, telefone = telefone, cidade = cidade, endereco = endereco, cnpj = cnpj
                };
                Aula5Entities contextAula5 = new Aula5Entities();

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

                if (String.IsNullOrEmpty(valor))
                {
                    contextAula5.FORNECEDOR.Add(f);
                    lblmsg.Text = "Registro Inserido!";
                }
                else
                {
                    int        id         = Convert.ToInt32(valor);
                    FORNECEDOR fornecedor = contextAula5.FORNECEDOR.First(c => c.id == id);
                    fornecedor.id       = f.id;
                    fornecedor.nome     = f.nome;
                    fornecedor.telefone = f.telefone;
                    fornecedor.endereco = f.endereco;
                    fornecedor.cidade   = f.cidade;
                    fornecedor.cnpj     = f.cnpj;
                    lblmsg.Text         = "Registro Alterado!";
                };

                contextAula5.SaveChanges();
                LoadGrid();
            }
        }
Ejemplo n.º 5
0
        protected void btnCadastrar_Click(object sender, EventArgs e)
        {
            if (txtcidade.Text == "" || txtnome.Text == "" || txttelefone.Text == "" || txtcidade.Text == "" || txtCPF.Text == "" || txtendereco.Text == "")
            {
                lblmsg.Text = "Preencha todos os campos!";
            }
            else
            {
                string  nome     = txtnome.Text;
                string  telefone = txttelefone.Text;
                string  cidade   = txtcidade.Text;
                string  endereco = txtendereco.Text;
                long    cpf      = Convert.ToInt64(txtCPF.Text.ToString().Substring(0, 9));
                CLIENTE cli      = new CLIENTE()
                {
                    nome = nome, telefone = telefone, cidade = cidade, endereco = endereco, cpf = cpf
                };
                Aula5Entities contextAula5 = new Aula5Entities();

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

                if (String.IsNullOrEmpty(valor))
                {
                    contextAula5.CLIENTE.Add(cli);
                    lblmsg.Text = "Registro Inserido!";
                }
                else
                {
                    int     id      = Convert.ToInt32(valor);
                    CLIENTE cliente = contextAula5.CLIENTE.First(c => c.id == id);
                    cliente.id       = cli.id;
                    cliente.nome     = cli.nome;
                    cliente.telefone = cli.telefone;
                    cliente.endereco = cli.endereco;
                    cliente.cidade   = cli.cidade;
                    cliente.cpf      = cli.cpf;
                    lblmsg.Text      = "Registro Alterado!";
                };
                contextAula5.SaveChanges();
                LoadGrid();
            }
        }
Ejemplo n.º 6
0
        protected void GVTipo_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int           idItem  = Convert.ToInt32(e.CommandArgument.ToString());
            Aula5Entities context = new Aula5Entities();
            TIPO          tipo    = new TIPO();

            tipo = context.TIPO.First(c => c.id == idItem);

            if (e.CommandName == "ALTERAR")
            {
                Response.Redirect("Tipo.aspx?idItem=" + idItem);
            }
            else if (e.CommandName == "EXCLUIR")
            {
                context.TIPO.Remove(tipo);
                context.SaveChanges();
                string msg    = "Fornecedor excluído com sucesso!";
                string titulo = "Informação";
                CarregarListaTipo();
                DisplayAlert(titulo, msg, this);
            }
        }
Ejemplo n.º 7
0
        protected void GVCliente_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int           idItem  = Convert.ToInt32(e.CommandArgument.ToString());
            Aula5Entities context = new Aula5Entities();
            CLIENTE       cliente = new CLIENTE();

            cliente = context.CLIENTE.First(c => c.id == idItem);

            if (e.CommandName == "ALTERAR")
            {
                Response.Redirect("Cliente.aspx?idItem=" + idItem);
            }
            else if (e.CommandName == "EXCLUIR")
            {
                context.CLIENTE.Remove(cliente);
                context.SaveChanges();
                string msg    = "Cliente excluído com sucesso!";
                string titulo = "Informação";
                CarregarListaCliente();
                DisplayAlert(titulo, msg, this);
            }
        }
Ejemplo n.º 8
0
        protected void GVMaterial_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int           idItem   = Convert.ToInt32(e.CommandArgument.ToString());
            Aula5Entities context  = new Aula5Entities();
            MATERIAL      material = new MATERIAL();

            material = context.MATERIAL.First(c => c.id == idItem);

            if (e.CommandName == "ALTERAR")
            {
                Response.Redirect("Material.aspx?idItem=" + idItem);
            }
            else if (e.CommandName == "EXCLUIR")
            {
                context.MATERIAL.Remove(material);
                context.SaveChanges();
                string msg    = "Material excluído com sucesso!";
                string titulo = "Informação";
                CarregarListaMaterial();
                DisplayAlert(titulo, msg, this);
            }
        }