/// <summary> /// Handles the Click event of the btn_ProdToPool control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// Erstellt von Veit Berg, am 27.01.16 private void btn_ProdToPool_Click(object sender, EventArgs e) { try{ DataGridViewRow row = dataGridView_ProjProd.SelectedRows[0]; int ProdId = (int)row.Cells[0].Value; int index = dataGridView_ProjProd.CurrentCell.RowIndex; ProjProds.RemoveAt(index); using (ProductController prodCont = new ProductController()) { Product addProd = prodCont.GetProductById(ProdId); AllProds.Add(addProd); projProdCont.ChangeAllocationOfProjectProducstListInDb(ProjectId, ProjProds); } dataGridView_prodAvail.DataSource = null; dataGridView_prodAvail.DataSource = AllProds; dataGridView_ProjProd.DataSource = null; dataGridView_ProjProd.DataSource = ProjProds; dataGridView_ProjProd.Columns.Remove("Project_Id"); dataGridView_ProjProd.Columns.Remove("Product"); dataGridView_ProjProd.Columns.Remove("Project"); dataGridView_ProjProd.Columns[1].Width = 200; } catch (Exception x) { MessageBox.Show(x.Message); } }
/// <summary> /// Handles the Click event of the btn_ProdToProj control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> /// Erstellt von Veit Berg, am 27.01.16 private void btn_ProdToProj_Click(object sender, EventArgs e) { try { DataGridViewRow row = dataGridView_prodAvail.SelectedRows[0]; int ProdId = (int)row.Cells[0].Value; string ProdName = (string)row.Cells[1].Value; int index = dataGridView_prodAvail.CurrentCell.RowIndex; ProjectProduct projProdToAllocate = new ProjectProduct() { Project_Id = ProjectId, Product_Id = ProdId, }; AllProds.RemoveAt(index); ProjProds.Add(projProdToAllocate); dataGridView_prodAvail.DataSource = null; dataGridView_prodAvail.DataSource = AllProds; dataGridView_ProjProd.DataSource = null; using (ProductController prodCon = new ProductController()) { foreach (ProjectProduct projProd in ProjProds) { var singleProdId = prodCon.GetProductById(projProd.Product_Id); projProd.Name = singleProdId.Name.ToString(); } } dataGridView_ProjProd.DataSource = ProjProds; dataGridView_ProjProd.Columns.Remove("Project_Id"); dataGridView_ProjProd.Columns.Remove("Product"); dataGridView_ProjProd.Columns.Remove("Project"); dataGridView_ProjProd.Columns[1].Width = 200; projProdCont.ChangeAllocationOfProjectProducstListInDb(ProjectId, ProjProds); } catch (Exception x) { MessageBox.Show(x.Message); } }