public ClientInfo(Data.Models.BlackList user) : this() { _user = user; tbPhone.Text = user.Phone; tbFIO.Text = user.Client; tbAdr.Text = user.Address; tbDoc.Text = user.Document; }
private void deleteUser_Click(object sender, EventArgs e) { if (CurrentUser == null) { return; } if (MessageBox.Show("Вы уверенны, что хотите удалить клиента " + CurrentUser.Client + " из чёрного списка?", "Удаление клиента", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _blackListRepository.Delete(CurrentUser); CurrentUser = null; LoadGrid(); } }
private void btnDelete_Click(object sender, EventArgs e) { if (gridUsers.SelectedRows.Count != 0) { CurrentUser = gridUsers.SelectedRows[0].Tag as Data.Models.BlackList; } if (CurrentUser == null) { return; } if (MessageBox.Show("Вы уверенны, что хотите удалить клиента " + CurrentUser.Client + " из чёрного списка?", "Удаление клиента", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _blackListRepository.Delete(CurrentUser); CurrentUser = null; LoadGrid(); } }
private void btnEdit_Click(object sender, EventArgs e) { if (gridUsers.SelectedRows.Count != 0) { CurrentUser = gridUsers.SelectedRows[0].Tag as Data.Models.BlackList; } if (CurrentUser == null) { return; } var form = new ClientInfo(CurrentUser); if (form.ShowDialog() != DialogResult.Ignore) { LoadGrid(); } }
private void gridUsers_MouseClick(object sender, MouseEventArgs e) { try { if (e.Button == MouseButtons.Right) { int currentMouseOverRow = gridUsers.HitTest(e.X, e.Y).RowIndex; CurrentUser = gridUsers.Rows[currentMouseOverRow].Tag as Data.Models.BlackList; if (CurrentUser != null) { gridContextMenu.Show(gridUsers, e.Location); } } } catch { //nothing to do, wait for next user actions } }
private void btnSave_Click(object sender, EventArgs e) { if (_user == null) { _user = new Data.Models.BlackList(); } if (string.IsNullOrEmpty(tbFIO.Text)) { MessageBox.Show("Введите имя клиента!", "Введите имя клиента!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } _user.Address = tbAdr.Text; _user.Phone = tbPhone.Text; _user.Document = tbDoc.Text; _user.Client = tbFIO.Text; _blackListRepository.AddOrUpdate(_user); Close(); }