public async Task <IHttpActionResult> Put(decimal id, INCOMETAX incomeTax)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != incomeTax.ID)
            {
                return(BadRequest());
            }

            db.Entry(incomeTax).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (!IncomeTaxExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IHttpActionResult> Put(decimal personid, WAGE wage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (personid != wage.PERSONID)
            {
                return(BadRequest());
            }

            db.Entry(wage).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (!WageExists(personid))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #3
0
        public async Task <IHttpActionResult> Put(decimal id, decimal bracketLevel, INCOMETAXBRACKET incomeTaxBracket)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != incomeTaxBracket.ID || bracketLevel != incomeTaxBracket.BRACKETLEVEL)
            {
                return(BadRequest());
            }

            db.Entry(incomeTaxBracket).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (!IncomeTaxBracketExists(id, bracketLevel))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #4
0
        private void btSalvar_Click(object sender, EventArgs e)
        {
            if (modificaPessoa == false)
            {
                string   nome      = tbNome.Text;
                string   endereco  = tbEndereco.Text;
                string   cpf       = tbCpf.Text;
                string   telefone  = tbTelefone.Text;
                DateTime data_nasc = DateTime.Parse(tbData_Nasc.Text);
                Cliente  pf        = new Cliente();

                pf.Nome      = nome;
                pf.Endereco  = endereco;
                pf.Cpf       = cpf;
                pf.Telefone  = telefone;
                pf.Data_Nasc = data_nasc;

                var context = new PFContext();
                context.PessoaFisicas.Add(pf);

                context.SaveChanges();
                MessageBox.Show("Cliente Inserido com sucesso.", "Alerta");
                LimpaCamposPessoa();
                PreencheGrid();
            }
            else
            {
                var     context = new PFContext();
                int     aux     = Convert.ToInt32(id);
                Cliente pf      = context.PessoaFisicas.Single(x => x.ClienteID == aux);

                pf.Nome      = tbNome.Text.ToString();
                pf.Endereco  = tbEndereco.Text.ToString();
                pf.Cpf       = tbCpf.Text.ToString();
                pf.Data_Nasc = DateTime.Parse(tbData_Nasc.Text);
                pf.Telefone  = tbTelefone.Text.ToString();

                context.PessoaFisicas.Attach(pf);
                context.Entry(pf).State = System.Data.Entity.EntityState.Modified;
                context.SaveChanges();
                LimpaCamposPessoa();

                MessageBox.Show("Cliente Alterado com sucesso.", "Alerta");
                modificaPessoa = false;
                PreencheGrid();
            }
        }