private void cbox_molecules_Click(object sender, EventArgs e) { cbox_molecules.Items.Clear(); var molecules = MoleculeController.getAll(); foreach (var molecule in molecules) { cbox_molecules.Items.Add(molecule.real_name); } }
public void ReloadPanel() { pnl_molecules.Controls.Clear(); var molecules = MoleculeController.getAll(); foreach (var m in molecules) { pnl_molecules.Controls.Add(new uc_MoleculeModel { id = m.id, generic_name = m.generic_name, real_name = m.real_name, formula = m.formula }); } }
private void btn_search_Click(object sender, EventArgs e) { if (tbox_search.Text != "Rechercher...") { pnl_molecules.Controls.Clear(); var molecules = MoleculeController.getAll(); molecules = molecules.Where(m => m.real_name.Contains(tbox_search.Text) || m.generic_name.Contains(tbox_search.Text) || m.formula.Contains(tbox_search.Text)); foreach (var m in molecules) { pnl_molecules.Controls.Add(new uc_MoleculeModel { id = m.id, generic_name = m.generic_name, real_name = m.real_name, formula = m.formula }); } } else { ReloadPanel(); } }
private void LoadAnalytic() { cartesianChart_MoneyByTime.Series.Clear(); cartesianChart_MoneyByTime.AxisX.Clear(); cartesianChart_MoneyByTime.AxisY.Clear(); pieChart_ContractsByCompany.Series.Clear(); pieChart_UtilitiesByMolecule.Series.Clear(); #region CartesianChart cartesianChart_MoneyByTime.AxisX.Add(new Axis { Title = "Mois", Labels = new[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } }); cartesianChart_MoneyByTime.AxisY.Add(new Axis { Title = "Revenue", LabelFormatter = value => value.ToString("C2") }); SeriesCollection series = new SeriesCollection(); var request = ContractController.getYears(); for (int year = request.Item1; year <= request.Item2; year++) { List <double> values = new List <double>(); for (int month = 0; month <= 12; month++) { values.Add(ContractController.getPriceFromMonth(year, month)); } series.Add(new LineSeries() { Title = year.ToString(), Values = new ChartValues <double>(values) }); } cartesianChart_MoneyByTime.Series = series; cartesianChart_MoneyByTime.LegendLocation = LegendLocation.Right; #endregion #region pieChart var companies = CompanyController.getAll(); Func <ChartPoint, string> labelPoint = chartPoint => string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation); foreach (var company in companies) { var contracts = ContractController.getByCompany(company.id); pieChart_ContractsByCompany.Series.Add(new PieSeries { Title = company.name, Values = new ChartValues <double> { contracts.Count() }, DataLabels = true, LabelPoint = labelPoint }); } pieChart_ContractsByCompany.LegendLocation = LegendLocation.Bottom; var molecules = MoleculeController.getAll(); foreach (var molecule in molecules) { var utilities = UtilityController.getByMolecule(molecule.id); pieChart_UtilitiesByMolecule.Series.Add(new PieSeries { Title = molecule.real_name, Values = new ChartValues <double> { utilities.Count() }, DataLabels = true, LabelPoint = labelPoint }); } pieChart_UtilitiesByMolecule.LegendLocation = LegendLocation.Bottom; #endregion // Load all chart cartesianChart_MoneyByTime.Hide(); cartesianChart_MoneyByTime.Show(); pieChart_ContractsByCompany.Hide(); pieChart_ContractsByCompany.Show(); pieChart_UtilitiesByMolecule.Hide(); pieChart_UtilitiesByMolecule.Show(); }