private void MarkSelect() { try { if (!String.IsNullOrWhiteSpace(cmbMark.Text)) { if (cmbMark.SelectedValue != null && cmbMark.SelectedIndex > -1) { txtDescription.Focus(); } else { var markName = cmbMark.Text.Trim(); this.MarkList(); cmbMark.Text = markName; if (cmbMark.SelectedValue != null && cmbMark.SelectedIndex > -1) { txtDescription.Focus(); } else { if (XtraMessageBox.Show("No se encuentra esta marca ¿Desea crearla?", "Pregunta de seguridad", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.Yes) { var mark = new RuleMark(); mark.Save(new MarkEntity() { MarkID = Guid.NewGuid(), MarkName = markName }); this.MarkList(); cmbMark.Text = markName; txtDescription.Focus(); } } } } else { cmbMark.SelectedIndex = -1; txtDescription.Focus(); } } catch (Exception ex) { Msg.Err(ex.Message); } }
public void MarkList() { try { var mark = new RuleMark(); cmbMark.DataSource = mark.List(); cmbMark.ValueMember = "MarkID"; cmbMark.DisplayMember = "MarkName"; cmbMark.SelectedIndex = -1; } catch (Exception ex) { Msg.Err(ex.Message); } }