mini fix
This commit is contained in:
parent
9648b4210d
commit
fdfc7602b2
@ -9,6 +9,10 @@ namespace ProjectGSM.Entities.Enums
|
|||||||
[Flags]
|
[Flags]
|
||||||
public enum LicenseType
|
public enum LicenseType
|
||||||
{
|
{
|
||||||
None, Base, Novokek, Pro, Master, Guru
|
None = 0,
|
||||||
|
Base = 1 << 0,
|
||||||
|
Pro = 1 << 1,
|
||||||
|
Master = 1 << 2,
|
||||||
|
Guru = 1 << 3
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,6 @@ using ProjectGSM.Repositories;
|
|||||||
|
|
||||||
namespace ProjectGSM.Forms
|
namespace ProjectGSM.Forms
|
||||||
{
|
{
|
||||||
|
|
||||||
public partial class FormAdvocate : Form
|
public partial class FormAdvocate : Form
|
||||||
{
|
{
|
||||||
private readonly IAdvocateRepository _advocateRepository;
|
private readonly IAdvocateRepository _advocateRepository;
|
||||||
@ -38,7 +37,8 @@ namespace ProjectGSM.Forms
|
|||||||
|
|
||||||
nameTextBox.Text = advocate.Name;
|
nameTextBox.Text = advocate.Name;
|
||||||
sexCheckBox.Checked = advocate.Sex;
|
sexCheckBox.Checked = advocate.Sex;
|
||||||
dateTimePicker.Value = new DateTime(advocate.DateOfBirth.Year, advocate.DateOfBirth.Month, advocate.DateOfBirth.Day);
|
dateTimePicker.Value = new DateTime(advocate.DateOfBirth.Year, advocate.DateOfBirth.Month,
|
||||||
|
advocate.DateOfBirth.Day);
|
||||||
expNumeric.Value = advocate.Experience;
|
expNumeric.Value = advocate.Experience;
|
||||||
tasksNumeric.Value = advocate.CompletedTasks;
|
tasksNumeric.Value = advocate.CompletedTasks;
|
||||||
ratingNumeric.Value = advocate.Rating;
|
ratingNumeric.Value = advocate.Rating;
|
||||||
@ -48,7 +48,8 @@ namespace ProjectGSM.Forms
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -66,7 +67,6 @@ namespace ProjectGSM.Forms
|
|||||||
{
|
{
|
||||||
checkedListBox.Items.Add(elem);
|
checkedListBox.Items.Add(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveButton_Click(object sender, EventArgs e)
|
private void saveButton_Click(object sender, EventArgs e)
|
||||||
@ -80,6 +80,7 @@ namespace ProjectGSM.Forms
|
|||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_advocateId.HasValue)
|
if (_advocateId.HasValue)
|
||||||
{
|
{
|
||||||
_advocateRepository.UpdateAdvocate(CreateAdvocate(_advocateId.Value));
|
_advocateRepository.UpdateAdvocate(CreateAdvocate(_advocateId.Value));
|
||||||
@ -88,6 +89,7 @@ namespace ProjectGSM.Forms
|
|||||||
{
|
{
|
||||||
_advocateRepository.CreateAdvocate(CreateAdvocate(0));
|
_advocateRepository.CreateAdvocate(CreateAdvocate(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -95,17 +97,16 @@ namespace ProjectGSM.Forms
|
|||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cancelButton_Click(object sender, EventArgs e) => Close();
|
private void cancelButton_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
private Advocate CreateAdvocate(int id)
|
private Advocate CreateAdvocate(int id)
|
||||||
{
|
{
|
||||||
LicenseType licenseType = LicenseType.None;
|
int licenseType = 0;
|
||||||
foreach (var elem in checkedListBox.CheckedItems)
|
foreach (int elem in checkedListBox.CheckedItems)
|
||||||
{
|
{
|
||||||
licenseType |= (LicenseType)elem;
|
licenseType |= elem;
|
||||||
}
|
}
|
||||||
return Advocate.CreateEntity(id,
|
return Advocate.CreateEntity(id,
|
||||||
nameTextBox.Text,
|
nameTextBox.Text,
|
||||||
@ -116,8 +117,7 @@ namespace ProjectGSM.Forms
|
|||||||
Convert.ToInt32(ratingNumeric.Value),
|
Convert.ToInt32(ratingNumeric.Value),
|
||||||
emailTextBox.Text,
|
emailTextBox.Text,
|
||||||
phoneText.Text,
|
phoneText.Text,
|
||||||
adressBox.Text, licenseType);
|
adressBox.Text, (LicenseType)licenseType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user