public static AnimalCollection ReadFromJsonFile(string path) { var animalCollection = new AnimalCollection(); var streamReader = new StreamReader(path); var json = (JObject)JToken.ReadFrom(new JsonTextReader(streamReader)); var animalTypes = json.Children(); foreach (var type in animalTypes) { var animals = type.Children().First(); foreach (var animal in animals) { Animal newAnimal = new Animal(type.Path, animal.SelectToken("breed").ToString(), animal.SelectToken("name").ToString(), int.Parse(animal.SelectToken("age").ToString()), animal.SelectToken("gender").ToString()); animalCollection.Add(newAnimal); } } streamReader.Close(); return(animalCollection); }
public void SortInWagon_SmallMeatMediumPlantAnimal_1Wagon() { //Arrange Animal animal = new Animal { Name = "Kat", IsCarnivore = true, Size = 1 }; Animal animal1 = new Animal { Name = "Geit", IsCarnivore = false, Size = 3 }; AnimalCollection animalCollection = new AnimalCollection(); animalCollection.AddAnimal(animal); animalCollection.AddAnimal(animal1); Train train = new Train(); //Act train.SortAllAnimals(animalCollection.GetAnimals()); //Assert Assert.AreEqual(1, train.GetWagons().Count); }
public AlgorithmViewModel() { _animal = new Animal(); _collection = new AnimalCollection(); _train = new Train(); _animals = new List <Animal>(); }
public void CastBeforeAssertSubType() { Zoo zoo = new Zoo(); AnimalCollection animals = zoo.Animals; CodeGenOptions options = GetDefaultOptions(); options.EnumerateAllCollectionProperties = true; options.UpcastTypes.Add(typeof(IAnimal)); AssertBuilder codeGen = new AssertBuilder(); GetAssertBuilderOutput(codeGen, animals, options); Assert.AreEqual(@"Assert.AreEqual(3, target.Count); Assert.AreEqual(4, ((UnitTests.Animal)target[0]).LegCount); Assert.AreEqual(null, ((UnitTests.Animal)target[0]).Sound); Assert.AreEqual(2, ((UnitTests.Animal)target[1]).LegCount); Assert.AreEqual(null, ((UnitTests.Animal)target[1]).Sound); Assert.AreEqual(3, ((UnitTests.Animal)target[2]).LegCount); Assert.AreEqual(null, ((UnitTests.Animal)target[2]).Sound); Assert.AreEqual(9, target.TotalLegs); Assert.AreEqual(4, target.Capacity); Assert.AreEqual(3, target.Count);".NormaliseCrlf(), codeGen.GetEmittedCode().NormaliseCrlf()); }
public static void WriteToJsonFile(AnimalCollection animalCollection, string path) { JContainer jsonFile = (JContainer)JObject.FromObject(new object()); foreach (var animalType in animalCollection.GetTypes()) { var animalArray = new JArray(); foreach (var animal in animalCollection.List(animalType)) { var animalToken = JToken.FromObject(new { breed = animal.Breed, age = animal.Age, name = animal.Name, gender = animal.Gender.ToString() }); animalArray.Add(animalToken); } var animalArrayWithLabel = new JProperty(animalType, animalArray); jsonFile.Add(animalArrayWithLabel); } var streamWriter = new StreamWriter(path); streamWriter.WriteLine(jsonFile); streamWriter.Flush(); streamWriter.Close(); }
/////////////////////////////// //create known list for testing ////////////////////////////// private AnimalCollection StartTestWithListOfKnownAnimals() { var animalCollection = new AnimalCollection { Animals = GetTestListOfFourAnimals() }; return(animalCollection); }
protected void LoadView() { string[] itemNames = Enum.GetNames(typeof(NotificationGroupsEnum)); Array itemValues = Enum.GetValues(typeof(NotificationGroupsEnum)).Cast <int>().ToArray(); for (int i = 0; i <= itemValues.Length - 1; i++) { string localizationValue = NotificationStrings.GetText(itemNames[i]); ListItem item = new ListItem(localizationValue, itemValues.GetValue(i).ToString()); ddlFilteringGroup.Items.Add(item); } ddlFilteringGroup.DataBind(); var animals = AnimalCollection.FetchAll(); animals.Add(new Animal { AnimalId = 0, AnimalName = "All" }); ddlAnimalType.DataSource = animals.OrderBy(x => x.AnimalId); ddlAnimalType.DataValueField = "AnimalId"; ddlAnimalType.DataTextField = "AnimalName"; ddlAnimalType.DataBind(); var areas = AreaCollection.FetchAll(); areas.Add(new Area { AreaId = 0, AreaName = "All" }); ddlArea.DataSource = areas.OrderBy(x => x.AreaId); ddlArea.DataValueField = "AreaId"; ddlArea.DataTextField = "AreaName"; ddlArea.DataBind(); if (FilterId > 0) { var notificationFilter = NotificationFilter.FetchByID(FilterId); ddlArea.SelectedValue = notificationFilter.AreaId.ToString(); txtFromDate.Text = notificationFilter.FromDate.ToString(); txtToDate.Text = notificationFilter.ToDate.ToString(); txtMaxFrequency.Text = notificationFilter.MaxFrequency.ToString(); txtMinFrequency.Text = notificationFilter.MinFrequency.ToString(); txtName.Text = notificationFilter.Name; txtPriority.Text = notificationFilter.Priority.ToString(); ddlAnimalType.SelectedValue = notificationFilter.AnimalTypeId.ToString(); ddlFilteringGroup.SelectedValue = ((int)notificationFilter.Group).ToString(); txtMessage.Text = notificationFilter.MessageTemplate; txtRunEvery.Text = notificationFilter.RunEvery.ToString(); cbIsAuto.Checked = notificationFilter.IsAuto; if (!string.IsNullOrEmpty(notificationFilter.AdImageUrl)) { HomeImage.ImageUrl = MediaUtility.GetImagePath("Banners", notificationFilter.AdImageUrl, 0, 64, 64); HomeImage.ImageUrl = HomeImage.ImageUrl.Contains(".") ? HomeImage.ImageUrl : ""; ImageFileHandler(fuImage, HomeImage, btnDeleteImage, HomeImage.ImageUrl); } } }
private void SetFilteredCollection(AnimalCollection animalCollection) { filteredCollection = animalCollection; lvAnimals.Items.Clear(); foreach (Animal animal in filteredCollection) { ListViewItem item = new ListViewItem(animal.Name); item.SubItems.Add(animal.Category.ToString()); item.SubItems.Add(animal.HasTail ? "Tail" : "No tail"); lvAnimals.Items.Add(item); } }
public void Alterar(Venda venda, AnimalCollection animaisNovosVenda, ListaVendaCollection animaisVenda, ListaVendaCollection listaVendaRemocao) { try { //Limpa todos os parâmetros acessoDadosSqlServer.LimparParametros(); //Adiciona os parâmetros para chamar a store procedure acessoDadosSqlServer.AdicionarParametros("@TipoProcedure", "Alterar"); acessoDadosSqlServer.AdicionarParametros("@VendaID", venda.VendaID); acessoDadosSqlServer.AdicionarParametros("@VendaData", venda.VendaData); acessoDadosSqlServer.AdicionarParametros("@VendaDataEntrega", venda.VendaDataEntrega); acessoDadosSqlServer.AdicionarParametros("@VendaValorTotal", venda.VendaValorTotal); acessoDadosSqlServer.AdicionarParametros("@PessoaID", venda.Pessoa.PessoaID); acessoDadosSqlServer.AdicionarParametros("@UsuarioID", venda.Usuario.UsuarioID); acessoDadosSqlServer.ExecutarManipulacao(CommandType.StoredProcedure, "uspManterVenda"); ListaVendaNegocios listaVendaNegocios = new ListaVendaNegocios(); AnimalNegocios animalNegocios = new AnimalNegocios(); foreach (ListaVenda listaVendaAlterar in animaisVenda) { listaVendaNegocios.Alterar(listaVendaAlterar); } foreach (Animal animalNovo in animaisNovosVenda) { animalNovo.AnimalAtivo = false; animalNegocios.Alterar(animalNovo); ListaVenda listaVendaNova = new ListaVenda(); listaVendaNova.ListaVendaValor = animalNovo.AnimalValor; listaVendaNova.Animal = animalNovo; listaVendaNova.VendaID = venda.VendaID; listaVendaNegocios.Cadastrar(listaVendaNova); } foreach (ListaVenda listaVendaRem in listaVendaRemocao) { listaVendaRem.Animal.AnimalAtivo = true; animalNegocios.Alterar(listaVendaRem.Animal); listaVendaNegocios.Excluir(listaVendaRem); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public frmCadastroPiquete(AnimalCollection animalCollection) { InitializeComponent(); this.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 20, 20)); panelInside.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, panelInside.Width, panelInside.Height, 20, 20)); piquete = new ObjetoTransferencia.Piquete(); piquete.Animais = new AnimalCollection(); piquete.Pasto = new ObjetoTransferencia.Pasto(); animaisOutrosPiquetes = animalCollection; dgvAnimaisAtual.AutoGenerateColumns = false; dgvAnimaisOutroPiquete.AutoGenerateColumns = false; }
private void btnRelatorio_Click(object sender, EventArgs e) { try { string Path = "RacasReport.rdlc"; List <ReportParameter> listReportParameter = new List <ReportParameter>(); listReportParameter.Add(new ReportParameter("TipoRelatorio", "Relatório geral de raças")); listReportParameter.Add(new ReportParameter("UsuarioEmissor", usuario.UsuarioNome)); listReportParameter.Add(new ReportParameter("DataEmissao", DateTime.Now.ToString("dd/MM/yyy"))); List <ReportDataSource> reportDataSources = new List <ReportDataSource>(); RacaCollection racas = new RacaCollection(); RacaNegocios racaNegocios = new RacaNegocios(); racas = racaNegocios.ConsultaPorDescricao(""); AnimalCollection animais = new AnimalCollection(); AnimalNegocios animalNegocios = new AnimalNegocios(); animais = animalNegocios.ConsultaPorDescricao(""); List <AnimalRelatorio> animaisRelatorio = new List <AnimalRelatorio>(); for (int i = 0; i < animais.Count; i++) { animaisRelatorio.Add(new AnimalRelatorio() { AnimalID = animais[i].AnimalID, AnimalDescricao = animais[i].AnimalDescricao, AnimalIdentificador = animais[i].AnimalIdentificador, AnimalAtivo = animais[i].AnimalAtivo, RacaDescricao = animais[i].Raca.RacaDescricao, RacaNome = animais[i].Raca.RacaNome, PesagemData = animais[i].Pesagens[0].PesagemData, PesagemPeso = animais[i].Pesagens[0].PesagemPeso, });; } reportDataSources.Add(new ReportDataSource("DataSetRacas", racas)); reportDataSources.Add(new ReportDataSource("DataSetAnimais", animaisRelatorio)); Variados.Reports.ReportGenerator report = new Variados.Reports.ReportGenerator(); report.CallReport(Path, reportDataSources, listReportParameter); } catch (Exception ex) { } }
public void ExplicitInclude() { Zoo zoo = new Zoo(); AnimalCollection animals = zoo.Animals; AssertBuilder codeGen = new AssertBuilder(); codeGen.Options.IncludeProperties.Add("LegCount"); codeGen.Options.EnumerateAllProperties = false; GetAssertBuilderOutput(codeGen, animals); Assert.AreEqual(@"Assert.AreEqual(3, target.Count); Assert.AreEqual(4, target[0].LegCount); Assert.AreEqual(2, target[1].LegCount); Assert.AreEqual(3, target[2].LegCount);".NormaliseCrlf(), codeGen.GetEmittedCode().NormaliseCrlf()); }
private void btnConsultar_Click(object sender, EventArgs e) { try { AnimalNegocios animalNegocios = new AnimalNegocios(); if (rbID.Checked) { if (txtID.Text.Trim() != string.Empty) { animais = animalNegocios.ConsultaPorID(int.Parse(txtID.Text)); dgvResultados.DataSource = null; dgvResultados.DataSource = animais; } } else if (rbDescricao.Checked) { animais = animalNegocios.ConsultaPorDescricao(txtDescricao.Text); dgvResultados.DataSource = null; dgvResultados.DataSource = animais; } else if (rbIdentificacao.Checked) { animais = animalNegocios.ConsultaPorIdentificador(txtIdentificador.Text); dgvResultados.DataSource = null; dgvResultados.DataSource = animais; } else if (rbPiquete.Checked) { if (txtPiquete.Text.Trim() != "" && txtPiquete.Text.Trim() != "0") { animais = animalNegocios.ConsultaPorPiquete(int.Parse(txtPiquete.Text)); dgvResultados.DataSource = null; dgvResultados.DataSource = animais; } } else if (rbRaca.Checked) { animais = animalNegocios.ConsultaPorRaca(int.Parse(cbbRaca.SelectedValue.ToString())); dgvResultados.DataSource = null; dgvResultados.DataSource = animais; } } catch (Exception ex) { MessageBox.Show("Houve um erro, por favor, tente novamente.", "Tente novamente."); } }
public void GetRandomIndexNumberFromIndexList_ListOfFiveNr_LastIndex() { //I need to to this is a more fashionable way... var animalCollection = new AnimalCollection(); animalCollection.TestState = true; var listOfNumbers = new List <int>() { 5, 2, 13, 6, 8 }; var expectedNumber = 4; var actualNumber = animalCollection.GetRandomIndexNrFromIndexList(listOfNumbers.Count); Assert.Equal(expectedNumber, actualNumber); }
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { AnimalCollection animals = AnimalSettings.Settings.AnimalList; List <Animal> result = new List <Animal>(); foreach (string animalName in value.ToString().Split(',')) { foreach (Animal animal in animals) { if (animalName == animal.Name) { result.Add(animal); } } } return(result); }
public void TestAttackPossibleSymbiosys() { var attacker = new Animal(new Player("player1")); attacker.AddUpgrade(new UpgradeCarnivorous()); var animals = new AnimalCollection(new Player("player2")); var a1 = animals.AddAnimal(); var a2 = animals.AddAnimal(); animals.AddUpgrade(a1, new UpgradeSymbiosys()); var check1 = AttackPossibilityChecker.Instance.CanAttack(attacker, a1); var check2 = AttackPossibilityChecker.Instance.CanAttack(attacker, a2); Assert.True(check1); Assert.False(check2); }
protected void LoadView() { string ImageFile = ""; if (ProductId > 0) { decimal minPrice, maxPrice; Product product = ProductController.GetProductById(ProductId, null, out minPrice, out maxPrice); txtProductName.Text = product.ProductName; txtProductCode.Text = product.ProductCode; txtProductNum.Text = product.ProductNum.ToString(); ImageFile = Snoopi.core.MediaUtility.GetImagePath("Product", product.ProductImage, 0, 64, 64); if (ImageFile.ToLower().Contains(".jpg") || ImageFile.ToLower().Contains(".jpeg") || ImageFile.ToLower().Contains(".png")) { ImageFileHandler(fuImage, imgImage, btnDeleteImage, ImageFile); } txtProductAmount.Text = product.Amount; txtProductDescription.Text = product.Description; txtRecomendedPrice.Text = product.RecomendedPrice.ToString(); } LoadItems(ProductId); //TODO //ImageFileHandler(fuImage, imgImage, btnDeleteImage, MediaUtility.GetAdminImageFileUrl(ProductId, MediaUtility.SUBFOLDER_PRODUCTS, ImageFile, 64, 64)); AnimalCollection animalList = AnimalCollection.FetchAll(); int index = 0; foreach (var item in animalList) { ddlAnimalType.Items.Add(new ListItem(item.AnimalName, item.AnimalId.ToString())); if (ProductAnimal.FetchByID(ProductId, item.AnimalId) != null) { ddlAnimalType.Items[index].Selected = true; } index++; } FillDdlCategory(ProductId); FillDdlSubCategory(ProductId, Convert.ToInt64(ddlCategory.SelectedItem.Value)); }
public void Add_AnimalThatEatsPlants_Succes() { //Arrange Animal animal = new Animal { Name = "Zebra", IsCarnivore = false, Size = 3 }; AnimalCollection animalCollection = new AnimalCollection(); //Act animalCollection.AddAnimal(animal); //Assert foreach (var item in animalCollection.GetAnimals()) { Assert.AreEqual(animal, item); } Assert.AreEqual(1, animalCollection.GetAnimals().Count); }
static void Main(string[] args) { AnimalCollection animals = AnimalSettings.Settings.AnimalList; foreach (Animal animal in animals) { Console.WriteLine($"{animal.Name}\t\t{animal.Age}\t\t{animal.Type}"); } Console.WriteLine(); ZooCollection zoos = ZooSettings.Settings.ZooList; foreach (Zoo zoo in zoos) { Console.WriteLine(zoo.Name); foreach (Animal animal in zoo.Animals) { Console.WriteLine($"{animal.Name}\t\t{animal.Age}\t\t{animal.Type}"); } Console.WriteLine(); } }
public int Alterar(Piquete piquete, AnimalCollection animaisTransferencia) { try { //Limpa todos os parâmetros acessoDadosSqlServer.LimparParametros(); //Adiciona os parâmetros para chamar a store procedure acessoDadosSqlServer.AdicionarParametros("@TipoProcedure", "Alterar"); acessoDadosSqlServer.AdicionarParametros("@PiqueteID", piquete.PiqueteID); acessoDadosSqlServer.AdicionarParametros("@PiqueteDescricao", piquete.PiqueteDescricao); acessoDadosSqlServer.AdicionarParametros("@PiqueteAtivo", piquete.PiqueteAtivo); acessoDadosSqlServer.AdicionarParametros("@PastoID", piquete.Pasto.PastoID); AnimalNegocios animalNegocios = new AnimalNegocios(); if (piquete.Animais != null) { foreach (Animal animal in piquete.Animais) { animalNegocios.Alterar(animal); } } if (animaisTransferencia != null) { foreach (Animal animal in animaisTransferencia) { animalNegocios.Alterar(animal); } } acessoDadosSqlServer.ExecutarManipulacao(CommandType.StoredProcedure, "uspManterPiquete"); return(piquete.PiqueteID); } catch (Exception ex) { throw new Exception(ex.Message); } }
public void SortInWagon_5LargePlantAnimals_3Wagons() { //Arrange Animal animal = new Animal { Name = "Giraffe", IsCarnivore = false, Size = 5 }; AnimalCollection animalCollection = new AnimalCollection(); for (int i = 0; i < 5; i++) { animalCollection.AddAnimal(animal); } Train train = new Train(); //Act train.SortAllAnimals(animalCollection.GetAnimals()); //Assert Assert.AreEqual(3, train.GetWagons().Count); }
public void IsTherePreyForHunters_ListOfMoreEqualLessPrey_CorrectBool(int listNumber, bool expectedBool) { var animalCollection = new AnimalCollection(); switch (listNumber) { case 1: animalCollection.Animals = GetListOfMorePrey(); break; case 2: animalCollection.Animals = GetListOfEqualHunterPrey(); break; case 3: animalCollection.Animals = GetListOfLessPrey(); break; } var actualBool = animalCollection.IsTherePreyForHunters(); Assert.Equal(expectedBool, actualBool); }
public FormMain() { InitializeComponent(); fullCollection = new AnimalCollection(); fullCollection.Add(new Animal("Baboon", AnimalCategory.Primate, true)); fullCollection.Add(new Animal("Chimpanzee", AnimalCategory.Primate, true)); fullCollection.Add(new Animal("Crocodile", AnimalCategory.Reptile, true)); fullCollection.Add(new Animal("Hippopotamus", AnimalCategory.Mammal, true)); fullCollection.Add(new Animal("Snake", AnimalCategory.Reptile, false)); fullCollection.Add(new Animal("Lion", AnimalCategory.Mammal, true)); fullCollection.Add(new Animal("Zebra", AnimalCategory.Mammal, true)); fullCollection.Add(new Animal("Cheetah", AnimalCategory.Mammal, true)); fullCollection.Add(new Animal("Gorilla", AnimalCategory.Primate, false)); fullCollection.Add(new Animal("Giraffe", AnimalCategory.Mammal, true)); fullCollection.Add(new Animal("Lizard", AnimalCategory.Reptile, true)); SetFilteredCollection(fullCollection); cbCategory.Items.Add(AnimalCategory.Mammal); cbCategory.Items.Add(AnimalCategory.Primate); cbCategory.Items.Add(AnimalCategory.Reptile); cbCategory.SelectedIndex = 0; }
public void EnumerateAllCollectionProperties() { Zoo zoo = new Zoo(); AnimalCollection animals = zoo.Animals; CodeGenOptions options = GetDefaultOptions(); options.EnumerateAllCollectionProperties = true; AssertBuilder codeGen = new AssertBuilder(); GetAssertBuilderOutput(codeGen, animals, options); Assert.AreEqual(@"Assert.AreEqual(3, target.Count); Assert.AreEqual(4, target[0].LegCount); Assert.AreEqual(null, target[0].Sound); Assert.AreEqual(2, target[1].LegCount); Assert.AreEqual(null, target[1].Sound); Assert.AreEqual(3, target[2].LegCount); Assert.AreEqual(null, target[2].Sound); Assert.AreEqual(9, target.TotalLegs); Assert.AreEqual(4, target.Capacity); Assert.AreEqual(3, target.Count);".NormaliseCrlf(), codeGen.GetEmittedCode().NormaliseCrlf()); }
public void Add_AnimalThatEatsMeat_Succes() { //Arrange Animal animal = new Animal { Name = "Leeuw", IsCarnivore = true, Size = 3 }; AnimalCollection animalCollection = new AnimalCollection(); //Act animalCollection.AddAnimal(animal); //Assert string result = ""; foreach (Animal animal1 in animalCollection.GetAnimals()) { result = animal1.Name; } Assert.AreEqual(1, animalCollection.GetAnimals().Count); Assert.AreEqual("Leeuw", result); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LoadItem(); ddlAnimalType.DataSource = AnimalCollection.FetchAll(); ddlAnimalType.DataValueField = "AnimalId"; ddlAnimalType.DataTextField = "AnimalName"; ddlAnimalType.DataBind(); ddlAnimalType.Items.Insert(0, new ListItem(ProductsStrings.GetText("Choose"), "0")); ddlCategory.DataSource = CategoryCollection.FetchAll(); ddlCategory.DataValueField = "CategoryId"; ddlCategory.DataTextField = "CategoryName"; ddlCategory.DataBind(); ddlCategory.Items.Insert(0, new ListItem(ProductsStrings.GetText("Choose"), "0")); ddlSubCategory.Items.Insert(0, new ListItem(ProductsStrings.GetText("Choose"), "0")); } ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page); scriptManager.RegisterPostBackControl(this.btnExport); }
public AnimalCollection ConsultaPorRaca(int RacaID) { try { //Limpa e adiciona os parâmetros acessoDadosSqlServer.LimparParametros(); acessoDadosSqlServer.AdicionarParametros("@TipoProcedure", "Raca"); acessoDadosSqlServer.AdicionarParametros("@AnimalID", 0); acessoDadosSqlServer.AdicionarParametros("@AnimalDescricao", ""); acessoDadosSqlServer.AdicionarParametros("@AnimalIdentificador", ""); acessoDadosSqlServer.AdicionarParametros("@RacaID", RacaID); acessoDadosSqlServer.AdicionarParametros("@PiqueteID", 0); //Cria uma DataTable pois a store procedure returna uma tabela de dados DataTable dataTable = acessoDadosSqlServer.ExecutarConsulta(CommandType.StoredProcedure, "uspConsultaAnimal"); AnimalCollection animalCollection = new AnimalCollection(); PesagemNegocios pesagemNegocios = new PesagemNegocios(); foreach (DataRow row in dataTable.Rows) { Animal animal = new Animal(); animal.Piquete = new Piquete(); animal.Raca = new Raca(); animal.Pesagens = new PesagemCollection(); animal.AnimalParentescoPai = new Animal(); animal.AnimalParentescoMae = new Animal(); animal.Piquete.Pasto = new Pasto(); animal.Piquete.Pasto.Cidade = new Cidade(); animal.AnimalID = Convert.ToInt32(row["AnimalID"]); animal.AnimalDescricao = row["AnimalDescricao"].ToString(); if (row["AnimalParentescoPai"] != DBNull.Value) { animal.AnimalParentescoPai.AnimalID = Convert.ToInt32(row["AnimalParentescoPai"]); } if (row["AnimalParentescoMae"] != DBNull.Value) { animal.AnimalParentescoMae.AnimalID = Convert.ToInt32(row["AnimalParentescoMae"]); } animal.AnimalLocalidadeNascimento = row["AnimalLocalidadeNascimento"].ToString(); if (row["AnimalDataNascimento"] != DBNull.Value) { animal.AnimalDataNascimento = Convert.ToDateTime(row["AnimalDataNascimento"]); } animal.AnimalIdentificador = row["AnimalIdentificador"].ToString(); animal.AnimalAtivo = Convert.ToBoolean(row["AnimalAtivo"]); animal.Raca.RacaID = Convert.ToInt32(row["RacaID"]); animal.Raca.RacaNome = row["RacaNome"].ToString(); animal.Pesagens = pesagemNegocios.ConsultaPorAnimal(animal.AnimalID); animal.Piquete.PiqueteDescricao = row["PiqueteDescricao"].ToString(); animal.Piquete.Pasto.PastoDescricao = row["PastoDescricao"].ToString(); animalCollection.Add(animal); } return(animalCollection); } catch (Exception ex) { throw new Exception(ex.Message); } }
private void InitializeUI() { this.animalCollection = AnimalRepository.ReadFromJsonFile(dataPath); Console.WriteLine("Animal Query Program"); Console.WriteLine("Enter a command. Type \"help\" for help."); }
private void dgvResultados_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { PiqueteNegocios piqueteNegocios = new PiqueteNegocios(); ObjetoTransferencia.Piquete piquete = piqueteNegocios.ConsultarPorID(int.Parse(dgvResultados.SelectedRows[0].Cells[0].Value.ToString()))[0]; string Path = "PiquetesReport.rdlc"; List <ReportParameter> listReportParameter = new List <ReportParameter>(); listReportParameter.Add(new ReportParameter("TipoRelatorio", "Teste")); listReportParameter.Add(new ReportParameter("UsuarioEmissor", "Teste.")); listReportParameter.Add(new ReportParameter("DataEmissao", DateTime.Now.ToString("dd/MM/yyy"))); listReportParameter.Add(new ReportParameter("PiqueteID", piquete.PiqueteID.ToString())); listReportParameter.Add(new ReportParameter("PiqueteDescricao", piquete.PiqueteDescricao.ToString())); if (piquete.PiqueteAtivo) { listReportParameter.Add(new ReportParameter("PiqueteAtivo", "Ativo")); } else { listReportParameter.Add(new ReportParameter("PiqueteAtivo", "Inativo")); } listReportParameter.Add(new ReportParameter("PiqueteQuantidadeAnimais", piquete.PiqueteQuantidadeAnimais.ToString())); PastoNegocios pastoNegocios = new PastoNegocios(); piquete.Pasto = pastoNegocios.ConsultaPorID(piquete.Pasto.PastoID); listReportParameter.Add(new ReportParameter("PastoTamanho", piquete.Pasto.PastoTamanho.ToString())); listReportParameter.Add(new ReportParameter("PastoDescricao", piquete.Pasto.PastoDescricao.ToString())); List <ReportDataSource> reportDataSources = new List <ReportDataSource>(); AnimalCollection animais = new AnimalCollection(); AnimalNegocios animalNegocios = new AnimalNegocios(); animais = animalNegocios.ConsultaPorPiquete(piquete.PiqueteID); List <AnimalRelatorio> animaisRelatorio = new List <AnimalRelatorio>(); for (int i = 0; i < animais.Count; i++) { animaisRelatorio.Add(new AnimalRelatorio() { AnimalID = animais[i].AnimalID, AnimalDescricao = animais[i].AnimalDescricao, AnimalIdentificador = animais[i].AnimalIdentificador, AnimalAtivo = animais[i].AnimalAtivo, RacaDescricao = animais[i].Raca.RacaDescricao, RacaNome = animais[i].Raca.RacaNome, PesagemData = animais[i].Pesagens[0].PesagemData, PesagemPeso = animais[i].Pesagens[0].PesagemPeso, });; } reportDataSources.Add(new ReportDataSource("DataSetAnimalPiquete", animaisRelatorio)); Variados.Reports.ReportGenerator report = new Variados.Reports.ReportGenerator(); report.CallReport(Path, reportDataSources, listReportParameter); } catch (Exception ex) { MessageBox.Show("Houve um erro, por favor, tente novamente.", "Tente novamente."); } }