private void bbiSauvegarderFermer_ItemClick(object sender, ItemClickEventArgs e) { IsOrderLineModified = false; if (_newOrderLine) { OrderLine = FactoryOrder.CreateOrderLine(comboBoxStock.SelectedItem as Stock, comboBoxProduit.Text, Convert.ToInt32(textEditQuantité.EditValue.ToString())); MessageBox.Show(Resources.succesAdd); } else { var orderLineModif = new OrderLine { id = OrderLineOut.Id, Product = comboBoxProduit.SelectedItem as Product, Quantity = Convert.ToInt32(textEditQuantité.EditValue.ToString()) }; var repositoryOrder = new RepositoryOrder(); repositoryOrder.Save(OrderLineOut.IdOrder, orderLineModif); MessageBox.Show(Resources.succesUpdate); } Close(); }
private void FrmEditOrderLine_FormClosing(object sender, FormClosingEventArgs e) { if (IsOrderLineModified) { DialogResult result = XtraMessageBox.Show(this, TagResources.SaveBeforeClose, Application.ProductName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation); if (result == DialogResult.Yes) { if (_newOrderLine) { OrderLine = FactoryOrder.CreateOrderLine(comboBoxStock.SelectedItem as Stock, comboBoxProduit.Text, Convert.ToInt32(textEditQuantité.EditValue.ToString())); MessageBox.Show(Resources.succesAdd); } else { var orderLineModif = new OrderLine { id = OrderLineOut.Id, Product = comboBoxProduit.SelectedItem as Product, Quantity = Convert.ToInt32(textEditQuantité.EditValue.ToString()) }; var repositoryOrder = new RepositoryOrder(); repositoryOrder.Save(OrderLineOut.IdOrder, orderLineModif); MessageBox.Show(Resources.succesUpdate); } IsOrderLineModified = false; } if (result == DialogResult.Cancel) { e.Cancel = true; } } }