public PartForm(int idx) { InitializeComponent(); selectedIdx = idx; headerLabel.Text = "Modify Part"; partIDValue.Text = idx.ToString(); partNameValue.Text = Inventory.SelectedPartName; partInventoryValue.Text = Inventory.SelectedPartInStock.ToString(); partPriceValue.Text = Inventory.SelectedPartPrice.ToString(); partMaxValue.Text = Inventory.SelectedPartMax.ToString(); partMinValue.Text = Inventory.SelectedPartMin.ToString(); if (Inventory.SelectedPart is InHouse) { InHouse machine = (InHouse)Inventory.SelectedPart; partSourceValue.Text = machine.MachineID.ToString(); parttInHouseRadioButton.Checked = true; partSourceLabel.Text = "Machine ID"; } if (Inventory.SelectedPart is Outsourced) { Outsourced company = (Outsourced)Inventory.SelectedPart; partSourceValue.Text = company.CompanyName; partOutsourcedRadioButton.Checked = true; partSourceLabel.Text = "Company Name"; } updatePart = true; partSaveButton.Enabled = false; }
private void modifyPartsButton_Click(object sender, EventArgs e) { ModifyPartForm mPartForm = new ModifyPartForm(); mPartForm.modifyPartIDText.Enabled = false; if (partsDataGridView.CurrentRow.DataBoundItem is InHouse) { mPartForm.modifyPartInhouseButton.Select(); mPartForm.modifyPartIDText.Text = partsDataGridView.CurrentRow.Cells[0].Value.ToString(); mPartForm.modifyPartNameText.Text = partsDataGridView.CurrentRow.Cells[1].Value.ToString(); mPartForm.modifyPartInvAmtText.Text = partsDataGridView.CurrentRow.Cells[2].Value.ToString(); mPartForm.modifyPartPriceText.Text = partsDataGridView.CurrentRow.Cells[3].Value.ToString(); mPartForm.modifyPartMinText.Text = partsDataGridView.CurrentRow.Cells[4].Value.ToString(); mPartForm.modifyPartMaxText.Text = partsDataGridView.CurrentRow.Cells[5].Value.ToString(); mPartForm.label8.Text = "Machine ID"; InHouse ih = (InHouse)partsDataGridView.CurrentRow.DataBoundItem; mPartForm.modifyPartCompanyNameOrMIDText.Text = ih.MachineID.ToString(); } else { mPartForm.modifyPartOutsourcedButton.Select(); mPartForm.modifyPartIDText.Text = partsDataGridView.CurrentRow.Cells[0].Value.ToString(); mPartForm.modifyPartNameText.Text = partsDataGridView.CurrentRow.Cells[1].Value.ToString(); mPartForm.modifyPartInvAmtText.Text = partsDataGridView.CurrentRow.Cells[2].Value.ToString(); mPartForm.modifyPartPriceText.Text = partsDataGridView.CurrentRow.Cells[3].Value.ToString(); mPartForm.modifyPartMinText.Text = partsDataGridView.CurrentRow.Cells[4].Value.ToString(); mPartForm.modifyPartMaxText.Text = partsDataGridView.CurrentRow.Cells[5].Value.ToString(); Outsourced os = (Outsourced)partsDataGridView.CurrentRow.DataBoundItem; mPartForm.modifyPartCompanyNameOrMIDText.Text = os.CompanyName; } mPartForm.ShowDialog(); }