-
Notifications
You must be signed in to change notification settings - Fork 0
/
NumberUpdate.cs
80 lines (68 loc) · 2.17 KB
/
NumberUpdate.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
75
76
77
78
79
80
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 NumberUpdate : Form
{
private readonly IDataAccess _dataAccess;
public NumberUpdate(IDataAccess _dataAccess)
{
InitializeComponent();
this._dataAccess = _dataAccess;
}
Person person = new Person();
PersonDTO personDTO = new PersonDTO();
private void MapperFilledField()
{
person.PersonId = personDTO.PersonId;
person.NameSurname = pnlNameSurname.Text;
person.Number = pnlNumber.Text;
var config = new MapperConfiguration(cfg => cfg.CreateMap<Person, PersonDTO>());
var mapper = new Mapper(config);
personDTO = mapper.Map<PersonDTO>(person);
_dataAccess.UpdatePerson(personDTO);
}
private void ResultForm()
{
personDTO = _dataAccess.SearchByNameNumber(txtNameSurname.Text, null);
if (personDTO.PersonId == 0)
{
pnlUpdate.Visible = false;
}
else
{
pnlUpdate.Visible = true;
pnlNameSurname.Text = personDTO.NameSurname;
pnlNumber.Text = personDTO.Number;
}
}
private void btnSearch_Click(object sender, EventArgs e)
{
ResultForm();
}
private void btnUpdate_Click(object sender, EventArgs e)
{
MapperFilledField();
MessageBox.Show("Process completed.");
}
private void btnCancel_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();
}
}
}