public PCSchedule(ScheudeForm frmMain) { InitializeComponent(); dGridPCSchedule.Rows.Clear(); var context = new whitmanenterprisecraigslistEntities(); var pcScheduleList = context.vinclapppcschedules.ToList(); var totalSchedule = context.vinclappdealerschedules.First().Schedules.GetValueOrDefault(); for (var i = 1; i <= Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["MaximumComputer"].ToString(CultureInfo.InvariantCulture)); i++) { var newRow = new DataGridViewRow(); newRow.CreateCells(dGridPCSchedule); newRow.Cells[0].Value = i; if (pcScheduleList.Any(x => x.PC == i)) { newRow.Cells[1].Value = pcScheduleList.First(x => x.PC == i).Schedule; } dGridPCSchedule.Rows.Add(newRow); } var tmpCom = new List <ComplicatedValueComboBox>(); for (var y = 1; y <= totalSchedule; y++) { var newComp = new ComplicatedValueComboBox() { Text = y, Value = y }; tmpCom.Add(newComp); } var comboCol = new DataGridViewComboBoxColumn { Name = "cmbSchedule", HeaderText = "Select Schedule", DataSource = tmpCom, DisplayMember = "Text", ValueMember = "Value", }; dGridPCSchedule.Columns.Add(comboCol); }
public static PCSchedule Instance(ScheudeForm frmMain) { if (sForm == null) { sForm = new PCSchedule(frmMain); } else { sForm.Close(); sForm = null; sForm = new PCSchedule(frmMain); } return(sForm); }