Пример #1
0
        public void Edit(object sender, EventArgs e)
        {
            Model.IndexSelected(View.ListViewForm);
            var editPresenter = new EditPresenter(Model, new EditForm());

            ((Form)editPresenter.View).ShowDialog();
        }
Пример #2
0
        public void Add(object sender, EventArgs e)
        {
            Model.Id = 0;
            var editPresenter = new EditPresenter(Model, new EditForm());

            ((Form)editPresenter.View).ShowDialog();
        }
Пример #3
0
        public void EditEvent(object sender, EventArgs e)
        {
            int rowToEdit = View.DataGrid.Rows.GetFirstRow(
                DataGridViewElementStates.Selected);

            if (rowToEdit > -1 && rowToEdit < View.DataGrid.Rows.Count - 1)
            {
                Model.IndexEdit = rowToEdit;
                var editPresenter = new EditPresenter(Model, new EditForm(View.DataGrid.Rows[rowToEdit]));
                if (((Form)editPresenter.View).ShowDialog() == DialogResult.Yes)
                {
                    View.DataGrid.Rows[Model.IndexEdit].Cells[0].Value = Model.Login;
                    View.DataGrid.Rows[Model.IndexEdit].Cells[1].Value = Model.Adress;
                    View.DataGrid.Rows[Model.IndexEdit].Cells[2].Value = Model.Phone;
                    View.DataGrid.Rows[Model.IndexEdit].Cells[3].Value = Model.IsAdmin;
                }
            }
            if (rowToEdit == View.DataGrid.Rows.Count - 1)
            {
                AddEvent(sender, e);
            }
        }