コード例 #1
0
        private void LecturerForm_Closed(object sender, FormClosedEventArgs e)
        {
            LecturerForm form = (LecturerForm)sender;

            if (form.InsertedLecturers.Count > 0)
            {
                foreach (Lecturer lecturer in form.InsertedLecturers)
                {
                    all_lecturers.Rows.Add(lecturer.Id, lecturer.Name);
                }
                LecturersGridView["Select", LecturersGridView.Rows.Count - 1].Selected = true;
            }
            else if (!form.New)
            {
                int index = LecturersGridView.CurrentCell.RowIndex;
                foreach (DataRow row in all_lecturers.Rows)
                {
                    if (Convert.ToInt32(row["Id"])
                        == Convert.ToInt32(LecturersGridView["Id", index].Value))
                    {
                        if (form.Deleted)
                        {
                            all_lecturers.Rows.Remove(row);
                        }
                        else
                        {
                            row["Name"] = form.deep_copy.Name;
                        }
                        break;
                    }
                }
            }
        }
コード例 #2
0
        private void newLecturerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LecturerForm form = new LecturerForm();

            form.SetLecturer(new Lecturer());
            form.Show(this);

            form.FormClosed += LecturerForm_Closed;
        }
コード例 #3
0
        private void editLecturerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LecturerForm form  = new LecturerForm();
            int          index = LecturersGridView.CurrentCell.RowIndex;

            form.SetLecturer(new Lecturer()
            {
                Id   = (int)LecturersGridView["Id", index].Value,
                Name = LecturersGridView["Name", index].Value.ToString()
            });
            form.Show(this);

            form.FormClosed += LecturerForm_Closed;
        }