private void SetData2(StepSetting o) { Action <StepSetting> a = p => { if (cmbWebTypeId.Items.Count > 0) { if (p.WebTypeId == 0) { p.WebTypeId = 1; } var webTypeList = cmbWebTypeId.Items.Cast <WebType>().ToList(); var first = webTypeList.FirstOrDefault(m => m.Id == p.WebTypeId) ?? webTypeList.FirstOrDefault(); cmbWebTypeId.SelectedItem = first; } if (cmbData.Items.Count > 0) { if (string.IsNullOrEmpty(p.SuitTblName)) { p.SuitTblName = cmbData.Items.Cast <string>().FirstOrDefault(); } var tempList = cmbData.Items.Cast <string>().ToList(); var first = tempList.FirstOrDefault(m => m == p.SuitTblName) ?? tempList.FirstOrDefault(); cmbData.SelectedItem = first; } if (p.StepDetailSetting.Count > 0) { //设置数据到界面 dgvMain.DataSource = p.StepDetailSetting; } }; this.SetData(o, a); }
private string Validate(StepSetting model) { if (string.IsNullOrEmpty(model.Name)) { return("名称不能为空"); } model.OpDate = DateTime.Now; return(null); }
private void btnAdd_Click(object sender, EventArgs e) { Id = 0; StepSetting s = new StepSetting(); s.NumAdd = 1; s.NumStart = 1; s.NumEnd = 3; lsbMain.SelectedItem = null; SetData2(s); }
private void lsbMain_SelectedIndexChanged(object sender, EventArgs e) { StepSetting s = lsbMain.SelectedItem as StepSetting; if (s == null) { return; } //设置到文本框里 Id = s.Id; SetData2(s); }