using CompressorXN_Service; using DevExpress.XtraEditors; using SqlSugar; using System.Collections.Generic; using System.Web.UI.WebControls; namespace CompressorXN.Untils { public class BindDropdownHelper { private static readonly ProductTypeService _productTypeService = new ProductTypeService(); /// /// 绑定产品型号 /// /// /// public static void BindProductType(LookUpEdit lookUpEdit, bool showPleaseChose = false) { var list = _productTypeService.QueryProductTypes() .Select(m => new ListItem { Value = m.ProductTypeName, Text = SqlFunc.MergeString(m.ProductTypeName, "_", m.IsUsed ? "使用中" : "未使用") }).ToList(); if (showPleaseChose) { ListItem listItem = new ListItem { Value = "", Text = "--请选择--" }; list.Insert(0, listItem); lookUpEdit.EditValue = ""; } lookUpEdit.Properties.ValueMember = "Value"; lookUpEdit.Properties.DisplayMember = "Text"; lookUpEdit.Properties.DataSource = list; lookUpEdit.ItemIndex = 0; } /// /// 绑定波特率 /// /// public static void BindBps(System.Windows.Forms.ComboBox comboBox) { List list = new List { new ListItem { Value = "19200", Text = "19.2k" }, new ListItem { Value = "125000", Text = "125K" }, new ListItem { Value = "250000", Text = "250k" }, new ListItem { Value = "500000", Text = "500k" }, new ListItem { Value = "800000", Text = "800k" }, new ListItem { Value = "1000000", Text = "1000k" }, new ListItem { Value = "2000000", Text = "2000k" }, new ListItem { Value = "4000000", Text = "4000k" }, new ListItem { Value = "5000000", Text = "5000k" }, new ListItem { Value = "8000000", Text = "8000k" } }; comboBox.DataSource = list; comboBox.ValueMember = "Value"; comboBox.DisplayMember = "Text"; } /// /// 绑定报文格式 /// /// /// public static void BindMsgFormat(System.Windows.Forms.ComboBox comboBox) { List list = new List { new ListItem { Value = "Intel", Text = "Intel" }, new ListItem { Value = "Motorola(LSB)", Text = "Motorola(LSB)" }, new ListItem { Value = "Motorola(MSB)", Text = "Motorola(MSB)" }, }; comboBox.DataSource = list; comboBox.ValueMember = "Value"; comboBox.DisplayMember = "Text"; } /// /// 绑定帧类型 /// /// public static void BindFrameType(System.Windows.Forms.ComboBox comboBox) { List list = new List { new ListItem { Value = "STANDARD", Text = "标准帧" }, new ListItem { Value = "EXTEND", Text = "扩展帧" } }; comboBox.DataSource = list; comboBox.ValueMember = "Value"; comboBox.DisplayMember = "Text"; } } }