private void btnAddAssemblyChildItem_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; try { foreach (DataGridViewRow row in gridItems.Rows) { if ((bool)row.Cells["Selected"].Value == true) { int itemID = (int)row.Cells["ID"].Value; AssemblyParentItem item = this.SELECTED_ITEMS.Where(x => x.ItemID == itemID).FirstOrDefault(); if (item == null) { item = new AssemblyParentItem(); item.ItemDescription = row.Cells["Description"].Value.ToString(); item.ItemID = itemID; item.DefaultQTY = 0; item.IsAssembly = false; this.SELECTED_ITEMS.Add(item); } } } PopulateAssemblyChildItems(); } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmAddAssemblyChildItems::btnAddAssemblyChildItem_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Cursor = Cursors.Default; }
private void btnRemoveChildItemsFromAssembly_Click(object sender, EventArgs e) { try { string strSelectedIDs = string.Empty; foreach (DataGridViewRow row in gridChildItems.Rows) { if ((bool)row.Cells["Selected"].Value == true) { strSelectedIDs += row.Cells["ItemID"].Value.ToString() + Program.DefaultStringSeperator; } } strSelectedIDs = strSelectedIDs.TrimEnd(Program.DefaultStringSeperator); if (strSelectedIDs.Trim() != string.Empty) { string[] IDs = strSelectedIDs.Split(Program.DefaultStringSeperator); foreach (string ID in IDs) { int mID = int.Parse(ID); AssemblyParentItem delItem = SELECTED_ITEMS.Where(x => x.ItemID == mID).FirstOrDefault(); if (delItem != null) { SELECTED_ITEMS.Remove(delItem); } } PopulateAssemblyChildItems(); } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmAddAssemblyChildItems::btnRemoveChildItemsFromAssembly_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } }