56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using GtaVUsersInfo.Controls;
|
|
using GtaVUsersInfo.Helpers;
|
|
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;
|
|
|
|
namespace GtaVUsersInfo.Forms
|
|
{
|
|
public partial class AddParameter : Form
|
|
{
|
|
List<ParameterControl> listControls;
|
|
ParameterControl parameter;
|
|
|
|
public AddParameter(List<ParameterControl> listControls, ParameterControl parameter)
|
|
{
|
|
InitializeComponent();
|
|
|
|
this.listControls = listControls;
|
|
this.parameter = parameter;
|
|
}
|
|
|
|
private void saveItem_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(nameTextBox.Text))
|
|
{
|
|
ErrorsShow.ShowErrorMessage($"Вы не ввели ни одни символ!");
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
Control foundParam = listControls.FirstOrDefault(p => (p as ParameterControl).ParamName == nameTextBox.Text);
|
|
if (foundParam == null)
|
|
{
|
|
parameter.ParamName = nameTextBox.Text;
|
|
this.Close();
|
|
return;
|
|
}
|
|
|
|
throw new Exception("Такой параметр уже есть!");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorsShow.ShowErrorMessage($"Произошла неожиданная ошибка: {ex.Message}");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|