Сохраненка
This commit is contained in:
parent
cd207e87e6
commit
9bdc5819b3
@ -27,34 +27,25 @@ namespace CreateVisualComponent
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!checkBoxDate.Checked)
|
||||
if (checkBoxDate.Checked)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxDate.Text))
|
||||
{
|
||||
throw new NotFilledException("The textbox is empty, fill it in or click on the checkbox!");
|
||||
}
|
||||
if (DateTime.TryParseExact(textBoxDate.Text, "dd/MM/yyyy", null, DateTimeStyles.None, out DateTime parsedDate))
|
||||
{
|
||||
return parsedDate;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IncorrectFillingException(textBoxDate.Text + " incorrect date!");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
if (string.IsNullOrEmpty(textBoxDate.Text))
|
||||
{
|
||||
throw new NotFilledException("The textbox is empty, fill it in or click on the checkbox!");
|
||||
}
|
||||
if (DateTime.TryParseExact(textBoxDate.Text, "dd/MM/yyyy", null, DateTimeStyles.None, out DateTime parsedDate))
|
||||
{
|
||||
return parsedDate;
|
||||
}
|
||||
throw new IncorrectFillingException(textBoxDate.Text + " incorrect date!");
|
||||
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value is null)
|
||||
{
|
||||
checkBoxDate.Checked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
textBoxDate.Text = value?.ToString("dd/MM/yyyy");
|
||||
checkBoxDate.Checked = false;
|
||||
}
|
||||
checkBoxDate.Checked = value is null;
|
||||
textBoxDate.Text = value?.ToString("dd/MM/yyyy") ?? string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,21 +51,13 @@ namespace CreateVisualComponent
|
||||
T val = new();
|
||||
|
||||
var propertiesObj = typeof(T).GetProperties();
|
||||
var columns = dataGridViewTable.Columns.Cast<DataGridViewColumn>().ToList();
|
||||
foreach (var property in propertiesObj)
|
||||
{
|
||||
bool propIsExist = false;
|
||||
int columnIndex = 0;
|
||||
for (; columnIndex < dataGridViewTable.Columns.Count; columnIndex++)
|
||||
var column = columns.FirstOrDefault(c => c.DataPropertyName == property.Name);
|
||||
if (column != null)
|
||||
{
|
||||
if (dataGridViewTable.Columns[columnIndex].DataPropertyName.ToString() == property.Name)
|
||||
{
|
||||
propIsExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (propIsExist)
|
||||
{
|
||||
object value = dataGridViewTable.SelectedRows[0].Cells[columnIndex].Value;
|
||||
object value = dataGridViewTable.SelectedRows[0].Cells[column.Index].Value;
|
||||
|
||||
Type propertyType = property.PropertyType;
|
||||
bool isNullable = Nullable.GetUnderlyingType(propertyType) != null;
|
||||
|
@ -55,7 +55,7 @@ namespace WinFormsTest
|
||||
{
|
||||
if (InputComponent.Value == null)
|
||||
{
|
||||
MessageBox.Show($"Pressed Checkbox");
|
||||
MessageBox.Show($"Pressed Checkbox");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user