private void NewBOMCreateBOMButton_Click(object sender, EventArgs e) { List <int> idList; CLIENT newClient = new CLIENT(); idList = (from cnt in mainForm.dbo.CLIENT select cnt.CLIENTID).ToList(); newClient.CLIENTID = mainForm.GetUniqueID(idList); newClient.NAME = NewClientTextBox.Text; mainForm.dbo.AddToCLIENT(newClient); mainForm.dbo.SaveChanges(); mainForm.currentClient = newClient; mainForm.BOMTable.Rows.Clear(); Close(); }
private void AddInitiativeToTableButton_Click(object sender, EventArgs e) { List <int> idList; var selectedInitiativeQuery = from ini in mainForm.dbo.INITIATIVE where ini.NAME == InitiativeComboBox.Text select ini; if (selectedInitiativeQuery.Count() == 0) { selectedInitiative = new INITIATIVE(); selectedInitiative.NAME = InitiativeComboBox.Text; idList = (from ini in mainForm.dbo.INITIATIVE select ini.INITIATIVEID).ToList(); selectedInitiative.INITIATIVEID = mainForm.GetUniqueID(idList); var selectedBusinessObjectiveQuery = from bus in mainForm.dbo.BUSINESSOBJECTIVE where bus.NAME == BusinessObjectiveComboBox.Text select bus; if (selectedBusinessObjectiveQuery.Count() == 0) { selectedBusinessObjective = new BUSINESSOBJECTIVE(); selectedBusinessObjective.NAME = BusinessObjectiveComboBox.Text; idList = (from bus in mainForm.dbo.BUSINESSOBJECTIVE select bus.BUSINESSOBJECTIVEID).ToList(); selectedBusinessObjective.BUSINESSOBJECTIVEID = mainForm.GetUniqueID(idList); var selectedCategoryQuery = from cat in mainForm.dbo.CATEGORY where cat.NAME == CategoryComboBox.Text select cat; if (selectedCategoryQuery.Count() == 0) { selectedCategory = new CATEGORY(); selectedCategory.NAME = CategoryComboBox.Text; idList = (from cat in mainForm.dbo.CATEGORY select cat.CATEGORYID).ToList(); selectedCategory.CATEGORYID = mainForm.GetUniqueID(idList); selectedCategory.BUSINESSOBJECTIVE.Add(selectedBusinessObjective); mainForm.dbo.AddToCATEGORY(selectedCategory); } selectedBusinessObjective.CATEGORY = selectedCategory; selectedBusinessObjective.INITIATIVE.Add(selectedInitiative); mainForm.dbo.AddToBUSINESSOBJECTIVE(selectedBusinessObjective); } selectedInitiative.BUSINESSOBJECTIVE = selectedBusinessObjective; mainForm.dbo.AddToINITIATIVE(selectedInitiative); } BOM newBOM = new BOM(); idList = (from bom in mainForm.dbo.BOM select bom.BOMID).ToList(); newBOM.BOMID = mainForm.GetUniqueID(idList); newBOM.CLIENT = mainForm.currentClient; newBOM.INITIATIVE = selectedInitiative; selectedInitiative.BOM.Add(newBOM); mainForm.dbo.SaveChanges(); DataGridViewRow row = (DataGridViewRow)mainForm.BOMTable.Rows[0].Clone(); row.Cells[0].Value = selectedCategory.NAME; row.Cells[1].Value = selectedBusinessObjective.NAME; row.Cells[2].Value = selectedInitiative.NAME; mainForm.BOMTable.Rows.Add(row); this.Close(); }