работает проверка на изменение перед закрытием
This commit is contained in:
parent
061773baca
commit
9e1d524c2e
@ -56,6 +56,7 @@
|
||||
textBoxFIO.Name = "textBoxFIO";
|
||||
textBoxFIO.Size = new Size(346, 27);
|
||||
textBoxFIO.TabIndex = 1;
|
||||
textBoxFIO.TextChanged += valueChanged;
|
||||
//
|
||||
// labelFIO
|
||||
//
|
||||
@ -83,6 +84,7 @@
|
||||
textBoxGoodDescription.Name = "textBoxGoodDescription";
|
||||
textBoxGoodDescription.Size = new Size(378, 27);
|
||||
textBoxGoodDescription.TabIndex = 8;
|
||||
textBoxGoodDescription.TextChanged += valueChanged;
|
||||
//
|
||||
// labelOrderSum
|
||||
//
|
||||
@ -112,6 +114,7 @@
|
||||
selectComponentOrderStatus.SelectedValue = "";
|
||||
selectComponentOrderStatus.Size = new Size(189, 36);
|
||||
selectComponentOrderStatus.TabIndex = 11;
|
||||
selectComponentOrderStatus.SelectComponentChanged += valueChanged;
|
||||
//
|
||||
// buttonClose
|
||||
//
|
||||
@ -124,6 +127,7 @@
|
||||
buttonClose.TabIndex = 12;
|
||||
buttonClose.Text = "Закрыть";
|
||||
buttonClose.UseVisualStyleBackColor = false;
|
||||
buttonClose.Click += buttonClose_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
|
@ -11,12 +11,17 @@ namespace AppShopInternetOption19
|
||||
private readonly IOrderStatusLogic _orderStatusLogic;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
private bool isChanged = false;
|
||||
|
||||
public FormEdit_Add(IOrderLogic orderLogic, IOrderStatusLogic orderStatusLogic)
|
||||
{
|
||||
_orderLogic = orderLogic;
|
||||
_orderStatusLogic = orderStatusLogic;
|
||||
InitializeComponent();
|
||||
textBoxFIO.TextChanged += valueChanged;
|
||||
textBoxGoodDescription.TextChanged += valueChanged;
|
||||
textComponentOrderSum.TextChanged += valueChanged;
|
||||
selectComponentOrderStatus.SelectComponentChanged += valueChanged;
|
||||
}
|
||||
|
||||
private void FormEdit_Add_Load(object sender, EventArgs e)
|
||||
@ -38,14 +43,44 @@ namespace AppShopInternetOption19
|
||||
selectComponentOrderStatus.SelectedValue = element.OrderStatus;
|
||||
textComponentOrderSum.TextValue = Convert.ToInt32(element.OrderSumm);
|
||||
}
|
||||
|
||||
}
|
||||
isChanged = false;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private void valueChanged(object sender, EventArgs e)
|
||||
{
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
private void buttonClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (isChanged == true)
|
||||
{
|
||||
var result = MessageBox.Show(
|
||||
"Есть несохраненные изменения. Вы уверены, что хотите закрыть?",
|
||||
"Подтверждение",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question
|
||||
);
|
||||
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else if (result == DialogResult.No)
|
||||
{
|
||||
MessageBox.Show("Окей, тогда делайте дальше)", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user