public void LoadData() { //initializing the lists for the dropdown field List <string> lstWines; List <string> listAlerts; //clearing already present data comboAlertOUT.Items.Clear(); comboWineChoice.Items.Clear(); //list for all wines in "add an alert" lstWines = req.GetListWines(); for (int i = 0; i < lstWines.Count; i++) { comboWineChoice.Items.Add(lstWines[i].ToString()); } //list for all alerts in "remove an alert" listAlerts = req.GetListAlerts(); for (int i = 0; i < listAlerts.Count; i++) { comboAlertOUT.Items.Add(listAlerts[i].ToString()); } grpAddAlert.Show(); grpDel.Hide(); dvgAlerts.ColumnCount = 3; //option for display dvgAlerts.ColumnHeadersDefaultCellStyle.BackColor = Color.Navy; dvgAlerts.ColumnHeadersDefaultCellStyle.ForeColor = Color.White; dvgAlerts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dvgAlerts.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single; dvgAlerts.CellBorderStyle = DataGridViewCellBorderStyle.Single; dvgAlerts.GridColor = Color.Black; //columns name dvgAlerts.Columns[0].Name = "Nom de l'alerte"; dvgAlerts.Columns[1].Name = "Message de l'alerte"; dvgAlerts.Columns[2].Name = "Bouteilles associƩes"; dvgAlerts.Columns[0].Width = 130; dvgAlerts.Rows.Clear(); List <Alerts> lstAlert = Alerts.ShowAllAlerts(); foreach (Alerts alert in lstAlert) { string[] row = { alert.Name, alert.Message, alert.LinkedBottles }; dvgAlerts.Rows.Add(row); } }
private void BottlesManagementfrm_Load(object sender, EventArgs e) { grpDel.Visible = false; btnDel.Visible = false; LoadData(); /** * load all lists for the drop down fields, to be able to add bottles */ //initializing the lists for the dropdown field List <string> lstManufacturers; List <string> lstColors; List <string> lstVarieties; List <double> lstVolumes; List <string> lstStorages; List <string> lstWines; List <int> lstYears; //list for all manufacturer in "add a bottle" and "remove a bottle" lstManufacturers = req.GetListManufacturers(); for (int i = 0; i < lstManufacturers.Count; i++) { comboManufacturer.Items.Add(lstManufacturers[i].ToString()); comboManufacturerOUT.Items.Add(lstManufacturers[i].ToString()); } //list for all colors in "add a bottle" lstColors = req.GetListColors(); for (int i = 0; i < lstColors.Count; i++) { comboColor.Items.Add(lstColors[i].ToString()); } //list for possible volumes in "add a bottle" and "remove a bottle" // fixed -> to enable other volumes, it has to be added in the list lstVolumes = new List <double>() { 0.2, 0.375, 0.5, 0.75, 1.0, 1.5, 3 }; for (int i = 0; i < lstVolumes.Count; i++) { comboVolume.Items.Add(lstVolumes[i].ToString()); comboVolumeOUT.Items.Add(lstVolumes[i].ToString()); } /** * list for all varieties in "add a bottle" * there are 3 dropdown fields with the same list, so all are initialized at the same time */ lstVarieties = req.GetListVarieties(); for (int i = 0; i < lstVarieties.Count; i++) { comboVariety1.Items.Add(lstVarieties[i].ToString()); comboVariety2.Items.Add(lstVarieties[i].ToString()); comboVariety3.Items.Add(lstVarieties[i].ToString()); } //list for all storageBoxes in "add a bottle" lstStorages = req.GetListStorages(); for (int i = 0; i < lstStorages.Count; i++) { comboStorage.Items.Add(lstStorages[i].ToString()); } //list for all years in "remove a bottle" lstYears = req.GetListDistinctYears(); for (int i = 0; i < lstYears.Count; i++) { comboYearOUT.Items.Add(lstYears[i].ToString()); } lstWines = req.GetListWines(); for (int i = 0; i < lstWines.Count; i++) { comboWine.Items.Add(lstWines[i].ToString()); } }