void LoadColorCombo() { ColorComboBox.DataSource = null; ColorComboBox.Items.Clear(); // ambil data var listColor = _colorBL.ListData(); // exit jika kosong if (listColor == null) { return; } var listColorWithHue = from c in listColor select new { c.ColorID, c.RedValue, c.GreenValue, c.BlueValue, Hue = Color.FromName(c.ColorID).GetHue() }; listColorWithHue = listColorWithHue .OrderBy(x => x.RedValue) .ThenBy(x => x.GreenValue) .ThenBy(x => x.BlueValue) .ToList(); ColorComboBox.DataSource = listColorWithHue; ColorComboBox.DisplayMember = "ColorID"; ColorComboBox.ValueMember = "ColorID"; var color = _colorBL.GetData(ColorComboBox.SelectedValue.ToString()); ColorPanel.BackColor = _colorBL.GetFromRGB(color); ColorComboBox.SelectedItem = null; }
private void FillGrid(IEnumerable <BrgModel> listData) { BrgGrid.Rows.Clear(); if (listData == null) { return; } PrgBar.Value = 0; PrgBar.Maximum = listData.Count(); foreach (var item in listData.OrderBy(x => x.BrgName)) { PrgBar.Value++; object[] rowData = { item.BrgID, item.BrgName, item.JenisBrgName, item.SubJenisBrgName, item.MerkName, item.ColorID, "Rp. " }; BrgGrid.Rows.Add(rowData); if (item.ColorID.Trim() != "") { var color = _colorBL.GetData(item.ColorID); if (color != null) { BrgGrid.Rows[PrgBar.Value - 1].Cells["BrgColorCol"].Style.BackColor = _colorBL.GetFromRGB(color); if (color.IsWhiteForeColor) { BrgGrid.Rows[PrgBar.Value - 1].Cells["BrgColorCol"].Style.ForeColor = Color.White; } } } RefreshPrice(PrgBar.Value - 1); } PrgBar.Value = 0; }