コード例 #1
0
 public IEnumerator DesarmarArco()
 {
     yield return new WaitForSeconds(0.15f);
     acaoAtual = Acao.Parado;
     arco.right = (olhar == Olhar.Direita)? transform.right : -transform.right; // FIXME meio tosco
     projetil.tag = "Flechas";
 }
コード例 #2
0
        internal int Gravar(Territorio territorio, Acao acao)
        {
            ComandoSQL.Parameters.Clear();
            if (acao == Acao.Adicionar)
                ComandoSQL.CommandText = @"insert into Territories (TerritoryID, TerritoryDescription, RegionID)
                            values (@codigo, @descricao, @regiao)";
            else
                ComandoSQL.CommandText = @"update Territories set TerritoryDescription = @descricao, RegionID = @regiao
                            where TerritoryID = @codigo";

            ComandoSQL.Parameters.AddWithValue("@codigo", territorio.Id);
            ComandoSQL.Parameters.AddWithValue("@descricao", territorio.Descricao);
            ComandoSQL.Parameters.AddWithValue("@regiao", territorio.CodigoRegiao);

            return ExecutaComando(false);
        }
コード例 #3
0
ファイル: AcaoController.cs プロジェクト: adelsonrms/tpa
        public async Task <ActionResult> Create([Bind(Include = "Id, Nome, NomeAmigavel, DescricaoAmigavel")] Acao acao)
        {
            if (ModelState.IsValid)
            {
                db.Acoes.Add(acao);
                try
                {
                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index"));
                }
                catch (DbUpdateConcurrencyException duce)
                {
                    MensagemParaUsuarioViewModel.MensagemErro("Talvez esse registro tenha sido excluído por outra pessoa. " + duce.Message, TempData, ModelState);
                }
                catch (Exception err)
                {
                    MensagemParaUsuarioViewModel.MensagemErro("Esse registro não pôde ser salvo. " + err.Message, TempData, ModelState);
                }
            }

            return(View(acao));
        }
コード例 #4
0
    void ControlaMovimento()
    {
        if(inputX == 0){
            acaoAtual = Acao.Parado;
        }
        else {
            acaoAtual = Acao.Andando;
            if(inputX > 0){
                olhar = Olhar.Direita;
            }
            else {
                olhar = Olhar.Esquerda;
            }
        }

        estaNoChao = Physics2D.Linecast(transform.position, sensorChao.position,
                                        1<<LayerMask.NameToLayer("Chao"));
        animator.SetBool("EstaNoChao", estaNoChao);
        if(estaNoChao && Input.GetButtonDown("Jump")){
            pular = true;
        }
        if(!estaNoChao) pular = false;
    }
コード例 #5
0
ファイル: Protocolo.cs プロジェクト: mourawaldson/apartamento
        //Converte a mensagem de sequência de bytes para um comando válido
        public Protocolo(byte[] data)
        {
            //Os primeiros 4 bytes são a ação
            this.cmdAcao = (Acao)BitConverter.ToInt32(data, 0);

            //Os 4 seguintes armazenam o compimento do elemento
            int elementoLen = BitConverter.ToInt32(data, 4);

            //Os próximos 4 armazenam o comprimento da mensagem
            int msgLen = BitConverter.ToInt32(data, 8);

            //Verifica se realmente foi passado um elemento... E se foi, captura-o.
            if (elementoLen > 0)
                this.strElemento = Encoding.UTF8.GetString(data, 12, elementoLen);
            else
                this.strElemento = null;

            //Checa se a mensagem é nula.
            if (msgLen > 0)
                this.strMensagem = Encoding.UTF8.GetString(data, 12 + elementoLen, msgLen);
            else
                this.strMensagem = null;
        }
コード例 #6
0
 public ActionResult CadastrarAcao(Acao _novaAcao)
 {
     if (!ModelState.IsValid)
     {
         return(View("Cadastrar", _novaAcao));
     }
     {
         try
         {
             if (Session["id"] != null)
             {
                 _novaAcao.Registro = int.Parse(Session["id"].ToString());
             }
             _DAO.SalvarAcao(_novaAcao);
             Logador.LogEntidade(Logador.LogAcoes.Salvar, _novaAcao);
             return(RedirectToAction("Index").ComMensagemDeSucesso("Ação cadastrada com sucesso"));
         }
         catch (Exception ex)
         {
             return(RedirectToAction("Cadastrar", _novaAcao).ComMensagemDeErro(ex.Message));
         }
     }
 }
コード例 #7
0
        public ActionResult GravarAcao(Acao Acao)
        {
            string strconexao = ConfigurationManager.ConnectionStrings["conexao"].ToString();

            IAcaoRepositorio repositorio = new AcaoRepositorio(strconexao);
            AcaoAplicacao    aplicacao   = new AcaoAplicacao(repositorio);

            EntidadeDTO entidade = EntidadeModelParaDTO(Acao.Entidade);

            entidade.Id = Guid.Parse(Session["idUsuario"].ToString());

            var acao = new AcaoDTO()
            {
                Id        = Acao.Id,
                Categoria = CategoriaModelParaDTO(Acao.Categoria),
                Entidade  = entidade,
                Descricao = Acao.Descricao
            };

            aplicacao.Inserir(acao);

            return(RedirectToAction("Index", "Entidade"));
        }
コード例 #8
0
        private void HabilitaEdicao(Acao acao)
        {
            this.btnSalvar.Enabled = true;
            this.btnSalvar.Tag     = acao;
            switch (acao)
            {
            case Acao.Inserir:
                this.pnStatusAdd.Visible = true;
                break;

            case Acao.Alterar:
                this.pnStatusAlt.Visible = true;
                SelecFuncionario(this.txtFuncionario.Text);
                SelecFornecedor(this.txtFornecedor.Text);
                break;
            }
            this.btnCancelar.Enabled = true;

            DesabilitaFuncionario_Simples();
            DesabilitaFornecedor_Simples();
            dtData.Enabled                     = true;
            this.GridPedidos.Enabled           = false;
            this.pnBarraFiltroPedido.Enabled   = false;
            this.pnBarraFiltroPedido.BackColor = Color.Azure;

            this.txtQtdeSolicitada.ReadOnly = false;

            this.tabctrDados.Tag = true;
            SelecDetalhes();

            this.btnConsultar.Enabled = false;
            this.btnNovo.Enabled      = false;
            this.btnEditar.Enabled    = false;
            this.btnExcluir.Enabled   = false;

            this.btnAddItem.Enabled = true;
        }
コード例 #9
0
ファイル: AcaoController.cs プロジェクト: adelsonrms/tpa
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Acao acao = await db.Acoes.FindAsync(id);

            if (acao != null)
            {
                if (acao.Perfis.Count > 0)
                {
                    MensagemParaUsuarioViewModel.MensagemAlerta("Essa ação não pode ser excluída porque já tem perfis associados a ela.", TempData);
                    return(RedirectToAction("Index"));
                }

                try
                {
                    db.Acoes.Remove(acao);
                    await db.SaveChangesAsync();

                    MensagemParaUsuarioViewModel.MensagemSucesso("Registro Excluido.", TempData);
                    return(RedirectToAction("Index"));
                }
                catch (DbUpdateConcurrencyException duce)
                {
                    MensagemParaUsuarioViewModel.MensagemErro(" Talvez esse registro tenha sido excluído por outra pessoa. " + duce.Message, TempData, ModelState);
                }
                catch (Exception err)
                {
                    MensagemParaUsuarioViewModel.MensagemErro("Esse registro não pôde ser excluído. " + err.Message, TempData, ModelState);
                }
            }
            else
            {
                MensagemParaUsuarioViewModel.MensagemErro("Ação não encontrada.", TempData, ModelState);
            }

            return(View(acao));
        }
コード例 #10
0
        static void Main(string[] args)
        {
            MercadoDeAcoes <Acao> MercadoDeAcoes = new MercadoDeAcoes <Acao>();

            MercadoDeAcoes.Adicionar(new BradescoCorretora());
            MercadoDeAcoes.Adicionar(new ItauCorretora());

            var PETR3 = new Acao("PETR3", 27.55);
            var EMBR3 = new Acao("EMBR3", 14.70);

            MercadoDeAcoes.AdicionaAtualizaAcao(PETR3);
            MercadoDeAcoes.AdicionaAtualizaAcao(EMBR3);

            Console.ReadKey();

            var VVAR3 = new Acao("VVAR3", 12.15);

            MercadoDeAcoes.AdicionaAtualizaAcao(VVAR3);

            EMBR3.Preco = 14.82;
            MercadoDeAcoes.AdicionaAtualizaAcao(EMBR3);

            Console.ReadKey();
        }
コード例 #11
0
        private void HabilitaEdicao(Acao acao)
        {
            this.btnSalvar.Enabled = true;
            this.btnSalvar.Tag     = acao;
            switch (acao)
            {
            case Acao.Inserir:
                this.pnStatusAdd.Visible = true;
                break;

            case Acao.Alterar:
                this.pnStatusAlt.Visible = true;
                break;
            }
            this.btnCancelar.Enabled = true;

            this.txtNome.ReadOnly        = false;
            this.txtCPF.ReadOnly         = false;
            this.txtRG.ReadOnly          = false;
            this.txtCTPS.ReadOnly        = false;
            this.txtEndereco.ReadOnly    = false;
            this.txtTelefone.ReadOnly    = false;
            this.txtE_mail.ReadOnly      = false;
            this.txtLogin.ReadOnly       = false;
            this.txtSenha.ReadOnly       = false;
            this.chAdmin.Enabled         = true;
            this.rdMasc.Enabled          = true;
            this.rdFem.Enabled           = true;
            this.Grid.Enabled            = false;
            this.pnBarraFiltro.Enabled   = false;
            this.pnBarraFiltro.BackColor = Color.Azure;

            this.btnNovo.Enabled    = false;
            this.btnEditar.Enabled  = false;
            this.btnExcluir.Enabled = false;
        }
コード例 #12
0
ファイル: AcaoService.cs プロジェクト: ertprs/crm_fonte
 public string IntegracaoBarramento(Acao objModel)
 {
     Domain.Integracao.MSG0299 msg = new Domain.Integracao.MSG0299(RepositoryService.NomeDaOrganizacao, RepositoryService.IsOffline);
     return(msg.Enviar(objModel));
 }
コード例 #13
0
 public CadastroService(Acao a)
 {
     _a = a;
 }
コード例 #14
0
 public OperacaoComissaoBTC(string descricao, Acao acao)
     : base(descricao)
 {
     this.Acao = acao;
 }
コード例 #15
0
        public void CadastrarErroGenerico(int grvId, int usuarioId, string identificadorNota, OrigemErro origemErro, Acao acao, string mensagemErro)
        {
            var erro = new NfeWsErroModel
            {
                GrvId             = grvId,
                IdentificadorNota = identificadorNota,
                UsuarioId         = usuarioId,
                Acao         = (char)acao,
                OrigemErro   = (char)origemErro,
                MensagemErro = mensagemErro
            };

            try
            {
                int id = new NfeWsErroController().Cadastrar(erro);
            }
            catch { }
        }
コード例 #16
0
 public void Add(Acao acao)
 {
     repo.Add(acao);
 }
コード例 #17
0
 public Emolumento(string descricao, Acao acao, EmolumentoTipo tipo)
     : base(descricao)
 {
     Acao = acao;
     Tipo = tipo;
 }
コード例 #18
0
 public FRM018(Endereco endereco, Acao acao)
 {
     InitializeComponent();
     this.endereco = endereco;
     this.acao     = acao;
 }
コード例 #19
0
        public JsonResult AddUsrAcao(long IdAcao, string IdUsuario)
        {
            bool   resposta = false;
            string msg      = string.Empty;
            string nome     = string.Empty;
            string usrName  = string.Empty;
            string email    = string.Empty;

            try
            {
                using (AppServiceAcoesUsuarios appServAcoesUsuarios = new AppServiceAcoesUsuarios(this.UfwCartNew, this.IdCtaAcessoSist))
                {
                    Acao acao = appServAcoesUsuarios.UfwCartNew.Repositories.GenericRepository <Acao>().GetWhere(a => a.Id == IdAcao).FirstOrDefault();

                    if ((acao != null) || (!string.IsNullOrEmpty(acao.Programa)))
                    {
                        var usuario = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().Users.Where(u => u.Id == IdUsuario).FirstOrDefault();

                        if ((usuario == null) || (!usuario.Ativo))
                        {
                            msg = "Usuário inexistente ou não ativo, não pode ser adicionado.";
                        }
                        else
                        {
                            if (acoesAdmin.Contains(acao.Id ?? 0))
                            {
                                if (!(usuario.Claims.Where(c => (c.ClaimType == ClaimTypes.Role) && (c.ClaimValue == "Admin")).Count() > 0))
                                {
                                    msg = "Esta permissão só pode ser atribuída para usuários do grupo Admin!";
                                }
                            }
                            else
                            {
                                //fazer add
                                var appResp = appServAcoesUsuarios.AddUsrAcao(IdAcao, IdUsuario);
                                resposta = appResp.Execute;
                                msg      = appResp.Message;
                                usrName  = usuario.UserName;
                                nome     = usuario.Nome;
                                email    = usuario.Email;
                            }
                        }
                    }
                    else
                    {
                        msg = string.Format("Ação {0} não encontrado!", IdAcao);
                    }
                }
            }
            catch (Exception ex)
            {
                TypeInfo t = this.GetType().GetTypeInfo();
                IOFunctions.GerarLogErro(t, ex);
                msg = "Erro na solicitação: " + ex.Message;
            }

            var resultado = new
            {
                resposta = resposta,
                msg      = msg,
                usuario  = new
                {
                    Id       = IdUsuario,
                    UserName = usrName,
                    Nome     = nome,
                    Email    = email
                }
            };

            return(Json(resultado));
        }
コード例 #20
0
        private bool validarAtributo(Atributo atributo, Acao acao)
        {
            //valida o total de pontos
            if(acao.Equals(Acao.subir)) {
                int totalParaGastar = (totalPontos - (forca + destreza + inteligencia));
                if(totalParaGastar == 0) {
                    return false;
                }
            }

            //força
            if(atributo == Atributo.forca) {

                if(acao == Acao.subir) {
                    if(forca >= maxAtributo) {
                        return false;
                    }
                    return true;
                }
                else {
                    if(forca <= minimoAtributo) {
                        return false;
                    }
                    return true;
                }
            }

            //destreza
            else if(atributo == Atributo.destreza) {

                if(acao == Acao.subir) {
                    if(destreza >= maxAtributo) {
                        return false;
                    }
                    return true;
                }
                else {
                    if(destreza <= minimoAtributo) {
                        return false;
                    }
                    return true;
                }
            }

            //inteligencia
            else {

                if(acao == Acao.subir) {
                    if(inteligencia >= maxAtributo) {
                        return false;
                    }
                    return true;
                }
                else {
                    if(inteligencia <= minimoAtributo) {
                        return false;
                    }
                    return true;
                }
            }
        }
コード例 #21
0
 // Use this for initialization
 void Start()
 {
     acaoAtual = Acao.Parado;
     olhar = Olhar.Direita;
     offsetMira = mira.position - transform.position;
     escala = transform.localScale;
     animator = GetComponent<Animator>();
     //JogoManager.i.gameOver = false;
 }
コード例 #22
0
 public OperacaoTaxaEmprestimo(string descricao, Acao acao)
     : base(descricao)
 {
     Acao = acao;
 }
コード例 #23
0
    void ControlaTiros()
    {
        // quando acabou de pressionar o botao de tiro
        if(Input.GetButtonDown("Fire1") && acaoAtual != Acao.Atirando){
            animator.SetTrigger("AtirarFlecha");
            acaoAtual = Acao.Atirando;
            //animacao.state.SetAnimation(0, "Idle", true);
            //motor.canControl = false;
            mira.gameObject.SetActive(true);

            if(olhar == Olhar.Direita) {
                mira.position = transform.position + new Vector3(offsetMira.x, offsetMira.y);
            }
            else {
                mira.position = transform.position + new Vector3(-offsetMira.x, offsetMira.y);
            }
            projetil = ObjectPool.Spawn(
                projetilPrefab,
                maoFlecha.position,
                Quaternion.identity
                );
            projetil.GetChild(0).tag = "Untagged";
            projetil.rigidbody2D.isKinematic = true;
            projetil.collider2D.isTrigger = true;
        }

        // quando esta segurando o botao de tiro
        if(Input.GetButton("Fire1") && acaoAtual == Acao.Atirando){
            float novoAnguloMira = 0f;

            float anguloAnterior =
                Mathf.Atan2(mira.position.y-transform.position.y,
                            mira.position.x-transform.position.x) * 180 / Mathf.PI;

            projetil.position = maoFlecha.position;

            Vector3 mousePos = Input.mousePosition;
            mousePos.z = Vector3.Distance(Camera.main.transform.position, transform.position); //The distance from the camera to the player object
            Vector3 lookPos = Camera.main.ScreenToWorldPoint(mousePos);
            lookPos = lookPos - transform.position;
            float anguloMira = Mathf.Atan2(lookPos.y, lookPos.x) * Mathf.Rad2Deg;

            mira.RotateAround(arco.position, arco.forward, anguloMira-anguloAnterior);
            Vector3 targetDir = mira.position - arco.position;
            float angulo = Mathf.Atan2(targetDir.y, targetDir.x) * Mathf.Rad2Deg;
            mira.rotation = Quaternion.AngleAxis(angulo, Vector3.forward);
            projetil.right = mira.right;
            arco.right = projetil.right;
        }

        // quando solta o botao de tiro
        if(Input.GetButtonUp("Fire1") && acaoAtual == Acao.Atirando){
            projetil.rigidbody2D.isKinematic = false;
            projetil.collider2D.isTrigger = false;
            projetil.rigidbody2D.AddForce(projetil.right*forcaFlecha*100);
            mira.gameObject.SetActive(false);
            animator.SetTrigger("DisparouFlecha");
            StartCoroutine(DesarmarArco());
        }
    }
コード例 #24
0
    void Update()
    {
        #region Get Actions
        if (currentChar != null)
        {
            Acao nextAction = currentChar.GetComponent <CombatCharacterController>().getAction();
            if (nextAction != null)
            {
                if (currentTurn.Count != 0)
                {
                    portraitController.refreshPortraits();
                    currentChar = currentTurn.Pop();
                    //Debug.Log(currentChar + " Now playing");
                }
                else
                {
                    portraitController.refreshPortraits();
                    earlyActions.AddRange(standardActions);
                    earlyActions.AddRange(lateActions);
                    earlyActions.Reverse();

                    acoesTurno    = new List <Acao>(earlyActions);
                    currentChar   = null;
                    currentAction = getNextAction();
                }
            }
        }
        else if (currentTurn.Count != 0)
        {
            currentChar = currentTurn.Pop();
            //Debug.Log(currentChar + " Now playing");
        }
        #endregion
        #region Execute Actions
        else
        {
            if (currentAction != null)
            {
                if (!currentAction.Started)
                {
                    currentAction.execute();
                }
                else if (currentAction.Ended)
                {
                    if (playerList.Count == 0 && !gameOverScreen)
                    {
                        gameOver();
                    }
                    else if (enemyList.Count == 0)
                    {
                        endCombat(true);
                    }
                    else if (acoesTurno.Count != 0)
                    {
                        currentAction = getNextAction();
                    }
                    else if (!gameOverScreen)
                    {
                        currentAction = null;
                    }
                }
            }
            #endregion
            else
            {
                startNextTurn();
            }
        }
    }
コード例 #25
0
        private Acao LerIndicadoresFundamentus(HtmlDocument documento)
        {
            var acao  = new Acao();
            var nodes = documento.DocumentNode.SelectNodes("//span[@class='txt']");

            if (nodes == null || nodes.Count < 106)
            {
                return(null);
            }

            decimal.TryParse(nodes[3].InnerText, NumberStyles.Any, new CultureInfo("pt-BR"), out decimal cotacao);
            decimal.TryParse(nodes[21].InnerText, NumberStyles.Any, new CultureInfo("pt-BR"), out decimal valorMercado);
            decimal.TryParse(nodes[25].InnerText, NumberStyles.Any, new CultureInfo("pt-BR"), out decimal valorFirma);
            long.TryParse(nodes[27].InnerText, NumberStyles.Any, new CultureInfo("pt-BR"), out long qtd);
            decimal.TryParse(nodes[32].InnerText, NumberStyles.Any, new CultureInfo("pt-BR"), out decimal PL);
            decimal.TryParse(nodes[34].InnerText, NumberStyles.Any, new CultureInfo("pt-BR"), out decimal LPA);
            decimal.TryParse(nodes[37].InnerText, NumberStyles.Any, new CultureInfo("pt-BR"), out decimal PVP);
            decimal.TryParse(nodes[39].InnerText, NumberStyles.Any, new CultureInfo("pt-BR"), out decimal VPA);
            decimal.TryParse(RemoverCaracteresEspeciais(nodes[44].InnerText), NumberStyles.Any, new CultureInfo("pt-BR"), out decimal margemBruta);
            decimal.TryParse(RemoverCaracteresEspeciais(nodes[49].InnerText), NumberStyles.Any, new CultureInfo("pt-BR"), out decimal margemEBIT);
            decimal.TryParse(RemoverCaracteresEspeciais(nodes[54].InnerText), NumberStyles.Any, new CultureInfo("pt-BR"), out decimal margemLiquida);
            decimal.TryParse(RemoverCaracteresEspeciais(nodes[64].InnerText), NumberStyles.Any, new CultureInfo("pt-BR"), out decimal ROIC);
            decimal.TryParse(RemoverCaracteresEspeciais(nodes[69].InnerText), NumberStyles.Any, new CultureInfo("pt-BR"), out decimal ROE);
            decimal.TryParse(RemoverCaracteresEspeciais(nodes[67].InnerText), NumberStyles.Any, new CultureInfo("pt-BR"), out decimal dividendYield);
            decimal.TryParse(RemoverCaracteresEspeciais(nodes[72].InnerText), NumberStyles.Any, new CultureInfo("pt-BR"), out decimal EvEbitda);
            decimal.TryParse(RemoverCaracteresEspeciais(nodes[74].InnerText), NumberStyles.Any, new CultureInfo("pt-BR"), out decimal liquidezCorrente);
            double.TryParse(nodes[89].InnerText, NumberStyles.Any, new CultureInfo("pt-BR"), out double divBruta);
            double.TryParse(nodes[93].InnerText, NumberStyles.Any, new CultureInfo("pt-BR"), out double divLiquida);
            double.TryParse(nodes[97].InnerText, NumberStyles.Any, new CultureInfo("pt-BR"), out double patrimonioLiquido);
            double.TryParse(nodes[106].InnerText, NumberStyles.Any, new CultureInfo("pt-BR"), out double EBIT);

            if (divBruta == 0)
            {
                divLiquida = 0;
            }

            if (patrimonioLiquido == 0)
            {
                double.TryParse(nodes[93].InnerText, NumberStyles.Any, new CultureInfo("pt-BR"), out patrimonioLiquido);
            }

            acao.ValorMercado    = valorMercado;
            acao.ValorFirma      = valorFirma;
            acao.QuantidadeAcoes = qtd;

            acao.Codigo  = nodes[1].InnerText;
            acao.Cotacao = cotacao;
            acao.Classe  = nodes[5].InnerText;
            acao.Nome    = nodes[9].InnerText.Replace(acao.Classe, "");
            acao.Setor   = nodes[13].InnerText;

            acao.PL               = PL;
            acao.LPA              = LPA;
            acao.VPA              = VPA;
            acao.P_VP             = PVP;
            acao.ROIC             = ROIC;
            acao.ROE              = ROE;
            acao.DividendYield    = dividendYield;
            acao.LiquidezCorrente = liquidezCorrente;
            acao.MargemLiquida    = margemLiquida;
            acao.MargemBruta      = margemBruta;
            acao.MargemEBIT       = margemEBIT;
            acao.EV_EBITDA        = EvEbitda;

            acao.DividaBruta       = divBruta;
            acao.DividaLiquida     = divLiquida;
            acao.EBIT              = EBIT;
            acao.PatrimonioLiquido = patrimonioLiquido;

            return(acao);
        }
コード例 #26
0
 private void damaged(Acao sender)
 {
     hitBy = sender;
     SendMessage("animateOnce", "Damage");
 }
コード例 #27
0
        private int?PopularFields <T>(Procedure procedure, PropertyInfo[] fields, T obejto, Acao acao)
        {
            SqlCommand Comando = null;

            try
            {
                Comando = ComandoSQL(procedure);

                if (acao == Acao.Inserir || acao == Acao.Atualizar || acao == Acao.Verificar)
                {
                    TypeCode tipoPropriedade;

                    foreach (PropertyInfo item in fields)
                    {
                        if (item.GetValue(obejto, null) != null)
                        {
                            tipoPropriedade = Type.GetTypeCode(item.GetValue(obejto, null).GetType());
                            Type tipo = item.PropertyType;

                            if (!tipo.IsEnum)
                            {
                                switch (tipoPropriedade)
                                {
                                case TypeCode.Single:
                                {
                                    Comando.Parameters.Add(new SqlParameter("@" + item.Name, SqlDbType.Money));
                                    Comando.Parameters["@" + item.Name].Value = item.GetValue(obejto, null) == null ? null : item.GetValue(obejto, null);
                                    break;
                                }

                                case TypeCode.String:
                                {
                                    string valor = (string)item.GetValue(obejto, null);
                                    if (!string.IsNullOrEmpty(valor))
                                    {
                                        Comando.Parameters.Add(new SqlParameter("@" + item.Name, SqlDbType.NVarChar));
                                        Comando.Parameters["@" + item.Name].Value = item.GetValue(obejto, null);
                                    }
                                    break;
                                }

                                case TypeCode.Int32:
                                {
                                    int?valor = (int?)item.GetValue(obejto, null);
                                    if (valor > 0)
                                    {
                                        Comando.Parameters.Add(new SqlParameter("@" + item.Name, SqlDbType.Int));
                                        Comando.Parameters["@" + item.Name].Value = Convert.ToInt32(valor);
                                    }
                                    break;
                                }

                                case TypeCode.DateTime:
                                {
                                    DateTime?_data = (DateTime?)item.GetValue(obejto, null);
                                    if (_data != null)
                                    {
                                        Comando.Parameters.Add(new SqlParameter("@" + item.Name, SqlDbType.DateTime));
                                        Comando.Parameters["@" + item.Name].Value = _data;
                                    }
                                    break;
                                }

                                case TypeCode.Decimal:
                                {
                                    decimal?valor = (decimal?)item.GetValue(obejto, null);
                                    if (valor != null)
                                    {
                                        Comando.Parameters.Add(new SqlParameter("@" + item.Name, SqlDbType.Decimal));
                                        Comando.Parameters["@" + item.Name].Value = valor;
                                    }
                                    break;
                                }

                                case TypeCode.Int64:
                                {
                                    long valor = (long?)item.GetValue(obejto, null) == null ? 0 : (long)item.GetValue(obejto, null);

                                    if (valor > 0)
                                    {
                                        Comando.Parameters.Add(new SqlParameter("@" + item.Name, SqlDbType.Decimal));
                                        Comando.Parameters["@" + item.Name].Value = valor;
                                    }
                                    break;
                                }

                                case TypeCode.Double:
                                {
                                    double?valor = (double?)item.GetValue(obejto, null);
                                    if (valor != null)
                                    {
                                        Comando.Parameters.Add(new SqlParameter("@" + item.Name, SqlDbType.BigInt));
                                        Comando.Parameters["@" + item.Name].Value = valor;
                                    }
                                    break;
                                }

                                case TypeCode.Boolean:
                                {
                                    bool?consistencia = (bool?)item.GetValue(obejto, null);
                                    if (consistencia != null)
                                    {
                                        Comando.Parameters.Add(new SqlParameter("@" + item.Name, SqlDbType.Bit));
                                        Comando.Parameters["@" + item.Name].Value = Convert.ToInt16(consistencia);
                                    }
                                    break;
                                }

                                case TypeCode.Char:
                                {
                                    string valor = item.GetValue(obejto, null).ToString().Replace(@"\", "");

                                    if (Regex.Replace(valor.ToString(), @"[0-9]", "") != "\0")
                                    {
                                        Comando.Parameters.Add(new SqlParameter("@" + item.Name, SqlDbType.Char));
                                        Comando.Parameters["@" + item.Name].Value = item.GetValue(obejto, null);
                                    }

                                    break;
                                }

                                case TypeCode.Object:
                                {
                                    byte[] valor = (byte[])item.GetValue(obejto, null);

                                    if (valor != null)
                                    {
                                        Comando.Parameters.Add(new SqlParameter("@" + item.Name, SqlDbType.VarBinary));
                                        Comando.Parameters["@" + item.Name].Value = item.GetValue(obejto, null);
                                    }
                                    break;
                                }

                                default:
                                {
                                    break;
                                }
                                }
                            }
                            else
                            {
                                var valor = Convert.ToInt32(item.GetValue(obejto, null));
                                if (valor > 0)
                                {
                                    Comando.Parameters.Add(new SqlParameter("@" + item.Name, SqlDbType.Int));
                                    Comando.Parameters["@" + item.Name].Value = Convert.ToInt32(valor);
                                }
                            }
                        }
                    }
                }
                else
                {
                    //PropertyInfo item = fields[0];
                    foreach (PropertyInfo item in fields)
                    {
                        if (item.GetValue(obejto, null) != null)
                        {
                            if (Type.GetTypeCode(item.GetValue(obejto, null).GetType()) == TypeCode.Int32)
                            {
                                if (Convert.ToInt32(item.GetValue(obejto, null)) > 0)
                                {
                                    object idUsuario = item.GetValue(obejto, null);
                                    Comando.Parameters.Add(new SqlParameter("@" + item.Name.ToString(), SqlDbType.Int));
                                    Comando.Parameters["@" + item.Name].Value = Convert.ToInt32(idUsuario);
                                }
                            }
                        }
                    }
                }

                Comando.Parameters.Add(new SqlParameter("@IDCLIENTE", SqlDbType.Int));
                Comando.Parameters["@IDCLIENTE"].Value = Sessao.CodigoCliente;



                if (acao == Acao.Verificar)
                {
                    retorno = (int?)Comando.ExecuteScalar();
                }
                else if (acao == Acao.Excluir)
                {
                    retorno = 0;
                    // Comando.Parameters.Add(new SqlParameter("@RETORNO", SqlDbType.Int)).Direction = ParameterDirection.ReturnValue;
                    retorno = Comando.ExecuteNonQuery();
                    // retorno = Convert.ToInt32(Comando.Parameters["@RETORNO"].Value);
                }
                else
                {
                    retorno = 0;
                    var newIdParam = Comando.Parameters.Add("@Identity", SqlDbType.Int);
                    newIdParam.Direction = ParameterDirection.Output;
                    retorno = Comando.ExecuteNonQuery();

                    if (newIdParam.Value != DBNull.Value)
                    {
                        retorno = Convert.ToInt32(newIdParam.Value);
                    }
                }
            }
            catch (SqlException sqlEx)
            {
                throw sqlEx;
                //throw new Exception("ERRO AO CADASTRAR: " + sqlEx.Message + " - Na linha" + sqlEx.LineNumber.ToString() + " - da PROCEDURE " + sqlEx.Procedure + " - " + sqlEx.Errors.ToString());
            }

            finally
            {
                DBCONN(Comando);
            }

            return(retorno);
        }
コード例 #28
0
 public Pendencia(string descricao, DateTime pregao, Acao acao)
     : base(descricao)
 {
     this.Pregao = pregao;
     this.Acao   = acao;
 }
コード例 #29
0
 public string Post([FromBody] Acao value)
 {
     return(AcaoDAO.Save(value));
 }
コード例 #30
0
 public ActionResult AdicionarAcao(Acao acao)
 {
     _acaoRepositorio.Gravar(acao);
     return(RedirectToAction("Index"));
 }
コード例 #31
0
ファイル: ActionRetarget.cs プロジェクト: Dugo03/LaCroma
 public abstract void retarget(Acao acao);
コード例 #32
0
ファイル: Protocolo.cs プロジェクト: mourawaldson/apartamento
 //Construtor default
 public Protocolo()
 {
     this.cmdAcao = Acao.Null;
     this.strElemento = null;
     this.strMensagem = null;
 }
コード例 #33
0
        public void AtualizarValores(Acao a)
        {
            if (ArmadilhaAux != null)
            {
                /* Atualiza os valores das operações do menu de propriedades dependendo da operação usada */
                if (a == Acao.AumentarTempoInicio)
                {
                    ArmadilhaAux.TempoInicial += 0.5f;
                }

                else if (a == Acao.ReduzirTempoInicio && ArmadilhaAux.TempoInicial > 0)
                {
                    ArmadilhaAux.TempoInicial -= 0.5f;
                }

                else if (a == Acao.AumentarTempoEntreAtivacoes)
                {
                    ArmadilhaAux.TempoEntreAtivacoes += 0.5f;
                }

                else if (a == Acao.ReduzirTempoEntreAtivacoes && ArmadilhaAux.TempoEntreAtivacoes > 0)
                {
                    ArmadilhaAux.TempoEntreAtivacoes -= 0.5f;
                }

                else
                {
                    if (ArmadilhaAux.TipoA == TipoArmadilha.Espinhos)
                    {
                        if (a == Acao.AumentarTempoAtivo)
                        {
                            ArmadilhaAux.TempoAtivo += 0.5f;
                        }

                        else if (a == Acao.ReduzirTempoAtivo && ArmadilhaAux.TempoAtivo > 0)
                        {
                            ArmadilhaAux.TempoAtivo -= 0.5f;
                        }

                        taValorT.DisplayedString = ArmadilhaAux.TempoAtivo.ToString();
                    }
                    else
                    {
                        taValorT.DisplayedString = na;
                    }
                }

                tiValorT.DisplayedString  = ArmadilhaAux.TempoInicial.ToString();
                teaValorT.DisplayedString = ArmadilhaAux.TempoEntreAtivacoes.ToString();


                // Atualiza a origem dos textos, pois com a mudança no texto a origem deve ser alterada para mantê-la na posição correta
                AtualizarOriginLabels();
            }
            else
            {
                tiValorT.DisplayedString  = na;
                teaValorT.DisplayedString = na;
                taValorT.DisplayedString  = na;
                AtualizarOriginLabels();
            }
        }
コード例 #34
0
 public FRM007(Cliente cliente, Acao acao)
 {
     InitializeComponent();
     this.cliente = cliente;
     this.acao    = acao;
 }
コード例 #35
0
 public virtual void resetAction()
 {
     currentAction = null;
 }
コード例 #36
0
        public void AtualizarFechamento(string acao)
        {
            AlphaVantageApi av = new AlphaVantageApi();
            DataBase        db = new DataBase();

            string result = av.GetTimeSeriesDaily(acao);
            var    tsd    = JsonConvert.DeserializeObject <TimeSeriesDaily>(result);

            DateTime dataInicio = DateTime.Now.AddDays(-7);

            int idAcao = Convert.ToInt32(db.GetAcao(acao).Rows[0].Field <Int64>("IdAcao"));

            foreach (var item in tsd.days.Where(x => Convert.ToDateTime(x.Key) >= dataInicio.Date))
            {
                DateTime data = Convert.ToDateTime(item.Key);

                var dt = db.ConsultaFechamentoAcao(acao, data);


                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0].Field <double>("Valor") != item.Value.close)
                    {
                        var acaoNova = new Acao
                        {
                            IdAcao      = idAcao,
                            Fechamentos = new List <FechamentoAcao>()
                            {
                                new FechamentoAcao {
                                    Valor = item.Value.close
                                }
                            }
                        };

                        db.UpdateFechamto(acaoNova);
                    }
                }
                else
                {
                    var acaoNova = new Acao
                    {
                        IdAcao      = idAcao,
                        Nome        = acao,
                        Habilitado  = 1,
                        Fechamentos = new List <FechamentoAcao>()
                        {
                            new FechamentoAcao
                            {
                                IdAcao = idAcao,
                                Valor  = item.Value.close,
                                Data   = data,
                                Ativo  = 1
                            }
                        }
                    };

                    db.AddFechamentoAcao(acaoNova);
                }

                //item.Value.close
            }

            var close = tsd.days["2021-05-18"].close;
        }
コード例 #37
0
 public void addAcao(Acao a)
 {
     lista_acoes.Add(a);
 }
コード例 #38
0
 public ContaBancariaCommand(ContaBancaria conta, Acao acao, int valor)
 {
     _conta = conta;
     _acao  = acao;
     _valor = valor;
 }
コード例 #39
0
        private bool validarPericia(int indicePericia, Acao acao)
        {
            //valida o total de pontos
            if(acao.Equals(Acao.subir)) {
                if(totalParaGastar() == 0) {
                    return false;
                }
            }

            if(Acao.subir.Equals(acao)) {
                if(valoresPericia[indicePericia] >= maxPericia) {
                    return false;
                }
                else {
                    return true;
                }
            }
            else {
                if(valoresPericia[indicePericia] <= minimoPericia) {
                    return false;
                }
                else {
                    return true;
                }
            }
        }