-
Notifications
You must be signed in to change notification settings - Fork 0
/
NumberDelete.cs
74 lines (65 loc) · 2.16 KB
/
NumberDelete.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Phonebook.models;
using AutoMapper;
namespace Phonebook
{
public partial class NumberDelete : Form
{
private readonly IDataAccess _dataAccess;
public NumberDelete(IDataAccess _dataAccess)
{
InitializeComponent();
this._dataAccess = _dataAccess;
}
Person SearchDto = new Person();
PersonDTO directoryDTO;
private void MapperSearch()
{
SearchDto.NameSurname = txtNameSurname.Text;
var config = new MapperConfiguration(cfg => cfg.CreateMap<Person, PersonDTO>());
var mapper = new Mapper(config);
directoryDTO = mapper.Map<PersonDTO>(SearchDto);
ResultForm(_dataAccess.SearchPerson(directoryDTO));
}
private void ResultForm(int _resultSearch)
{
if(_resultSearch == 0)
{
MessageBox.Show("The data suitable for the " + txtNameSurname.Text + ". you are looking for could not be found in the directory. Please make a selection. End the deletion or try again!");
}
else
{
pnlDelete.Visible = true;
lblNameSurname.Text = SearchDto.NameSurname;
directoryDTO.PersonId = _resultSearch;
}
}
private void btnSearch_Click(object sender, EventArgs e)
{
MapperSearch();
}
private void btnYes_Click(object sender, EventArgs e)
{
_dataAccess.DeletePerson(directoryDTO);
MessageBox.Show("Process completed.");
}
private void btnNo_Click(object sender, EventArgs e)
{
MessageBox.Show("No action was taken.");
}
private void btnBack_Click(object sender, EventArgs e)
{
MainScreenForm mainScreenForm = new MainScreenForm();
mainScreenForm.Show();
this.Hide();
}
}
}