/// <summary> /// Edit the selected footprint /// </summary> private void EditFootprint() { string selectedMPN = dgvFootprints.CurrentRow.Cells[0].Value.ToString(); Footprint footprint = DatabaseOperations.GetFootprint(selectedMPN); FootprintForm footprintForm = new FootprintForm(); footprintForm.SetFootprint(footprint); this.ShowFootprintForm(footprintForm); }
/// <summary> /// Displays the <see cref="PickAndPlaceDatabaseManager.FootprintForm"/> and handles the changes to the data. /// </summary> /// <param name="footprintForm">FootprintForm to display</param> private void ShowFootprintForm(FootprintForm footprintForm) { try { if (footprintForm.ShowDialog() == DialogResult.Yes) { bool newFootprintMade; Footprint footprint = footprintForm.GetFootprint(out newFootprintMade); //The footprintForm makes/updates the footprint in the database DataRow datarow; if (newFootprintMade) { //reloading the complete database would be waste of resorces. //solution: manualy adding the new component to the datatable datarow = footprintTable.NewRow(); datarow["manufacturerPartNumber"] = footprint.ManufacturerPartNumber; footprintTable.Rows.Add(datarow); } else { //Update the edited row datarow = footprintTable.Select("manufacturerPartNumber = '" + footprint.ManufacturerPartNumber + "'")[0]; } datarow["Length"] = footprint.Length; datarow["Height"] = footprint.Height; datarow["width"] = footprint.Width; datarow["offsetStackX"] = footprint.OffsetStackX; datarow["offsetStackY"] = footprint.OffsetStackY; datarow["feedRate"] = footprint.FeedRate; datarow["rotation"] = footprint.Rotation; datarow["nozzle"] = footprint.Nozzle; datarow["stacktype"] = footprint.StackType; } } catch (Exception exc) { MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/*-------------------------------------------------------------*/ private void btnAdd_Click(object sender, EventArgs e) { FootprintForm footprintForm = new FootprintForm(); this.ShowFootprintForm(footprintForm); }