private void FillShifts() { StaffShiftsLogic shifts = new StaffShiftsLogic(manager); ShiftsCB.ValueMember = "ID"; ShiftsCB.DisplayMember = "Name"; ShiftsCB.DropDownStyle = ComboBoxStyle.DropDownList; StaffShift none = new StaffShift(); //none.ID = -1; none.Name = "- не вибрано -"; List<StaffShift> list = new List<StaffShift>(); list.Add(none); list.AddRange(shifts.GetAll()); ShiftsCB.DataSource = list; if (mode == "edit" || mode == "copy") { if (sheduler != null && sheduler.ShiftID != null) { int i = 0; foreach (object o in ShiftsCB.Items) { StaffShift shift = (StaffShift)o; if (shift.ID == sheduler.ShiftID) { ShiftsCB.SelectedIndex = i; } i++; } } } }
private void FillShifts() { StaffShiftsLogic shifts = new StaffShiftsLogic(manager); ShiftsCB.ValueMember = "ID"; ShiftsCB.DisplayMember = "Name"; ShiftsCB.DropDownStyle = ComboBoxStyle.DropDownList; StaffShift none = new StaffShift(); //none.ID = -1; none.Name = "- не вибрано -"; List<StaffShift> list = new List<StaffShift>(); list.Add(none); list.AddRange(shifts.GetAll()); ShiftsCB.DataSource = list; }