private void changeMarkToolStripMenuItem_Click(object sender, EventArgs e) { try { if (dataListView.Items.Count > 0) { if (m_FormToChangeTheMark == null) { m_FormToChangeTheMark = FormChangeMark.GetInstanceOfFormChangeMark(); } ListViewItem itemToChange = dataListView.SelectedItems[0]; string chosenCourseName = itemToChange.SubItems[(int)eSubItem.CourseName].Text; string chosenCourePoints = itemToChange.SubItems[(int)eSubItem.Points].Text; byte markToChange = byte.Parse(itemToChange.SubItems[(int)eSubItem.Mark].Text); if (m_FormToChangeTheMark.ShowDialog(chosenCourseName, markToChange, m_CalAvg, chosenCourePoints) == DialogResult.OK) { short totalOffset = (short)(m_FormToChangeTheMark.LastValue - markToChange); itemToChange.SubItems[(int)eSubItem.Mark].Text = m_FormToChangeTheMark.LastValue.ToString(); m_CalAvg.ChangeMarkAndTotal(totalOffset.ToString(), itemToChange.SubItems[(int)eSubItem.Points].Text); updateMarkAverageLabel(); updateTotalPoints(); m_ChangedListView = true; } } } catch (Exception) { MessageBox.Show("Error , try to pick a row .(Row will be in blue.)"); } }
public static FormChangeMark GetInstanceOfFormChangeMark() { if (s_Instance == null) { s_Instance = new FormChangeMark(); } return(s_Instance); }