示例#1
0
    public static Tensão Calcular(Potência p, Corrente c)
    {
        Tensão tns = new Tensão();

        tns.Valor = p.Valor / c.Valor;

        return(tns);
    }
示例#2
0
    public static Potência Calcular(Corrente c, Tensão t)
    {
        Potência pot = new Potência();

        pot.Valor = c.Valor * t.Valor;

        return(pot);
    }
示例#3
0
    public static Corrente Calcular(Potência p, Tensão t)
    {
        Corrente crt = new Corrente();

        crt.Valor = p.Valor / t.Valor;

        return(crt);
    }
示例#4
0
    public static void Main()
    {
        Tensão   t1 = 220;
        Corrente c1 = 2;

        Potência p1 = Potência.Calcular(t1, c1);

        Print(p1);

        p1 = 1500;
        t1 = 110;
        Print(Corrente.Calcular(p1, t1));

        c1 = 1.5;
        Print(Tensão.Calcular(p1, c1));
    }
        public bool Delete(int correnteId)
        {
            //pr_VCM_CorrenteDrawingDelete
            try
            {
                _unitOfw.CorrenteDrawingRepository?.Delete(y => y.CorrenteId == correnteId);

                #region  pr_CorrenteDelete  /*Inicio*/
                DiagramaCenario diagramaCenariofare = _unitOfw.DiagramaCenarioRepository.Get(y => y.TransportadorFareloId == correnteId).FirstOrDefault();
                if (diagramaCenariofare != null)
                {
                    diagramaCenariofare.TransportadorFareloId = null;
                    _unitOfw.DiagramaCenarioRepository.Update(diagramaCenariofare);
                }

                DiagramaCenario diagramaCenarioRemo = _unitOfw.DiagramaCenarioRepository.Get(y => y.TransportadorRemoidoId == correnteId).FirstOrDefault();
                if (diagramaCenarioRemo != null)
                {
                    diagramaCenarioRemo.TransportadorFareloId = null;
                    _unitOfw.DiagramaCenarioRepository.Update(diagramaCenarioRemo);
                }

                _unitOfw.CorrenteProdutoRepository?.Delete(y => y.CorrenteId == correnteId);

                _unitOfw.CorrenteCenarioRepository?.Delete(y => y.CorrenteId == correnteId);

                _unitOfw.CorrenteCenarioLimiteRepository?.Delete(y => y.CorrenteId == correnteId);

                _unitOfw.CorrenteCenarioSimboloRepository?.Delete(y => y.CorrenteId == correnteId);

                _unitOfw.CorrenteDrawingRepository?.Delete(y => y.CorrenteId == correnteId);

                Corrente corrente = _unitOfw.CorrenteRepository.Get(y => y.Id == correnteId).FirstOrDefault();

                _unitOfw.pr_ValoresClear(correnteId, corrente.TipoEntidadeId, corrente.TopologiaId, "");

                _unitOfw.CorrenteRepository.Delete(corrente);

                #endregion /*Fim */

                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        protected void BtnSalvar_Click(object sender, EventArgs e)
        {
            //Criação cliente
            Cliente c1 = GetDataCliente();

            if (new ClienteDB().Insert(c1))
            {
                Response.Write("<script>alert('Cliente inserido com sucesso!')</script>");
                TxtNome.Text      = "";
                TxtEstado.Text    = "";
                TxtCidade.Text    = "";
                TxtEndereco.Text  = "";
                TxtTelefone.Text  = "";
                TxtCpf.Text       = "";
                TxtEmail.Text     = "";
                TxtTipoConta.Text = "";
                LoadGrid();
            }
            else
            {
                Response.Write("<script>alert('Erro ao inserir registro!')</script>");
            }

            //Criação conta cliente de acordo com o tipo da conta inserida no cadastro
            if (c1.TipoConta == 1)
            {
                int      id     = new ClienteDB().ReturnIDCliente(c1.Nome);
                Corrente conta1 = GetDataContaCorrente(id);
                new ContaDB().Insert(conta1);
                Response.Write("<script>alert('Conta criada com sucesso!')</script>");
            }
            else if (c1.TipoConta == 2)
            {
                int      id     = new ClienteDB().ReturnIDCliente(c1.Nome);
                Poupanca conta1 = GetDataContaPoupanca(id);
                new ContaDB().Insert(conta1);
                Response.Write("<script>alert('Conta criada com sucesso!')</script>");
            }
        }
        private int Pr_CorrenteInsert(ref string codigo, int topologiaId, int entradaId, int saidaId, string nota = null, int?modalId = null, string descricao = null)
        {
            try
            {
                int tipoEntidadeId = 0;

                if (string.IsNullOrEmpty(codigo))
                {
                    tipoEntidadeId = Fn_find_NovoCodigoByNome("Corrente", topologiaId, ref codigo);
                }

                else
                {
                    tipoEntidadeId = _unitOfw.TipoEntidadeRepository.Get(y => y.Nome == "Corrente").FirstOrDefault().Id;
                }

                Corrente corrente = new Corrente
                {
                    Codigo         = codigo,
                    Descricao      = descricao,
                    TipoEntidadeId = tipoEntidadeId,
                    TopologiaId    = topologiaId,
                    ModalId        = modalId,
                    Nota           = nota,
                    EntradaId      = entradaId,
                    SaidaId        = saidaId
                };

                _unitOfw.CorrenteRepository.Insert(corrente);
                return(corrente.Id);
            }
            catch (Exception ex)
            {
                return(0);

                throw;
            }
        }
示例#8
0
 public static Potência Calcular(Tensão t, Corrente c)
 {
     return(Potência.Calcular(c, t));
 }
        public async System.Threading.Tasks.Task Save()
        {
            DiagramLinkModel correnteDrawingToBeSave = new DiagramLinkModel
            {
                From      = 33497,
                FromPort  = "right",
                To        = 33517,
                ToPort    = "left",
                Color     = "",
                DiagramId = 8095,
                Category  = "S",
                Code      = "",
                Id        = 0
            };

            HttpResponseMessage response = await _clientCall.Save(_baseController + "Save/", JsonConvert.SerializeObject(correnteDrawingToBeSave));

            Assert.IsTrue(response.IsSuccessStatusCode);
            if (response.IsSuccessStatusCode)
            {
                var retorno = await response.Content.ReadAsStringAsync();

                DiagramLinkModel correnteRetornoJson = JsonConvert.DeserializeObject <DiagramLinkModel>(JObject.Parse(retorno)["data"].ToString());


                int      tipoEntidadeId    = _unitOfw.TipoEntidadeRepository.Get(y => y.Nome == "Corrente").FirstOrDefault().Id;
                Corrente correnteAfterSave = _unitOfw.CorrenteRepository.Get(y => y.Id == correnteRetornoJson.Id).FirstOrDefault();

                //Verifica o insert na tabela Corrente
                Assert.AreEqual(correnteAfterSave.TipoEntidadeId, tipoEntidadeId);
                Assert.AreEqual(correnteAfterSave.Codigo, correnteRetornoJson.Code);
                Assert.AreEqual(correnteAfterSave.SaidaId, correnteDrawingToBeSave.To);
                Assert.AreEqual(correnteAfterSave.EntradaId, correnteDrawingToBeSave.From);


                Enum.TryParse <PortSpot>(correnteDrawingToBeSave.FromPort, true, out PortSpot portaEntradaSpot);
                Enum.TryParse <PortSpot>(correnteDrawingToBeSave.ToPort, true, out PortSpot portaSaidaSpot);

                int portaEntradaIdOut = _unitOfw.PortaDrawingRepository.Get(y => y.NoId == correnteDrawingToBeSave.From && y.FluxogramaId == correnteDrawingToBeSave.DiagramId &&
                                                                            y.Index == (Int32)portaEntradaSpot).FirstOrDefault().Id;

                int portaSaidaIdOut = _unitOfw.PortaDrawingRepository.Get(y => y.NoId == correnteDrawingToBeSave.To && y.FluxogramaId == correnteDrawingToBeSave.DiagramId &&
                                                                          y.Index == (Int32)portaSaidaSpot).FirstOrDefault().Id;


                //Verifica o Insert na tabela CorrenteDrawing
                CorrenteDrawing correnteDrawing = _unitOfw.CorrenteDrawingRepository.Get(y => y.CorrenteId == correnteRetornoJson.Id).FirstOrDefault();

                Assert.AreEqual(portaSaidaIdOut, correnteDrawing.PortaSaidaId);
                Assert.AreEqual(portaEntradaIdOut, correnteDrawing.PortaEntradaId);
                Assert.AreEqual(correnteDrawing.FluxogramaId, correnteDrawingToBeSave.DiagramId);


                //Cadastro dos produtos do No de Origem na Corrente
                List <int> noProdutoOrigemList = _unitOfw.NoProdutoRepository.Get(y => y.NoId == correnteDrawingToBeSave.From)
                                                 .Select(y => y.ProdutoId).ToList();

                foreach (var oneProdutoCorrente in noProdutoOrigemList)
                {
                    CorrenteProduto correnteProduto = _unitOfw.CorrenteProdutoRepository.Get(y => y.ProdutoId == oneProdutoCorrente &&
                                                                                             y.CorrenteId == correnteRetornoJson.Id).FirstOrDefault();

                    Assert.IsNotNull(correnteProduto);
                }


                //Produtos do No de origem devem estar cadastrados no No de destino

                //noProdutos origem
                List <int> noProdutosOrigemList = _unitOfw.NoProdutoRepository.Get(y => y.NoId == correnteDrawingToBeSave.From).Select(y => y.ProdutoId).ToList();

                //noProdudos Destino
                List <int> noProdutosDestinoList = _unitOfw.NoProdutoRepository.Get(y => y.NoId == correnteDrawingToBeSave.To).Select(y => y.ProdutoId).ToList();

                //Verifica se algum produto não existe no destino
                List <int> dups = noProdutosOrigemList.Except(noProdutosDestinoList).ToList();

                Assert.AreEqual(0, dups.Count());
            }
        }
示例#10
0
    static void Main(string[] args)
    {
        //-----------------------------------------------
        //---> Classe <---
        //-----------------------------------------------

        /*
         * MinhaClasse mm = new MinhaClasse();
         * Telefone.Discar("9999-9999");
         */

        //-----------------------------------------------
        //---> Composição <---
        //-----------------------------------------------

        /*
         * Roda r1 = new Roda();
         * r1.cor = "Azul";
         * r1.aro = 22;
         *
         * Roda r2 = new Roda();
         * r2.cor = "Vermelha";
         * r2.aro = 22;
         *
         * Moto minhaMoto = new Moto("Azul", r1, r2);
         */

        //-----------------------------------------------
        //---> Encapsulamento <---
        //-----------------------------------------------

        /*
         * Cripto cp = new Cripto();
         * cp.setValor("aeiou");
         * System.Console.WriteLine(cp.getValor());
         */

        //-----------------------------------------------
        //---> Herança <---
        //-----------------------------------------------

        /*
         * Homem eu = new Homem();
         * eu.Idade = 30;
         * eu.Nome = "João da Silva";
         * eu.TamanhoBarba = 0;
         *
         * Mulher mi = new Mulher();
         * mi.TamanhoBusto = 80;
         * mi.Nome = "Maria da Silva";
         * mi.Idade = 21;
         */

        //-----------------------------------------------
        //---> Polimorfismo <---
        //-----------------------------------------------

        /*
         * Mamifero m1 = new Leao();
         * m1.Andar();
         *
         * Mamifero m2 = new Gorila();
         * m2.Andar();
         */

        //-----------------------------------------------
        //---> Polimorfismo 2 <---
        //-----------------------------------------------

        /*
         * Operacao op = new Soma();
         * double n1 = 5, n2 = 4;
         * new Calcular().MostrarResultado(op, n1, n2);
         *
         *
         * Operacao opp = new Subtracao();
         * //double n1 = 5, n2 = 5;
         * new Calcular().MostrarResultado(opp, n1, n2);
         */

        //-----------------------------------------------
        //---> Sobreposição <---
        //-----------------------------------------------

        Poupanca p1 = new Poupanca();

        p1.Saque("99999-9", "1234-5", 100);

        Corrente c1 = new Corrente();

        c1.Saque("88888-8", "5432-1", 100);
    }