コード例 #1
0
        private void cmdAccept_Click(object sender, EventArgs e)
        {
            DialogResult pressed = MessageBox.Show(SessionHelper.GetTranslation("SAVE_CHANGES_QUESTION"), "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (pressed == DialogResult.No)
            {
                return;
            }
            try
            {
                StockBLL stockBll = new StockBLL();
                ResultBM stockResult;

                this.Entity.Name     = txtName.Text;
                this.Entity.Quantity = int.Parse(numericQuantity.Value.ToString());
                this.Entity.itemType = (ItemTypeBM)cmbItemType.SelectedItem;
                this.Entity.donation = (DonationBM)cmbDonation.SelectedItem;
                this.Entity.depot    = (DepotBM)cmbDepot.SelectedItem;
                this.Entity.DueDate  = dtDueDate.Value;
                this.Entity.Location = txtLocation.Text;


                if (isUpdate)
                {
                    stockResult = stockBll.UpdateStock(this.Entity);
                }
                else
                {
                    stockResult = stockBll.SaveStock(this.Entity);
                }

                if (stockResult.IsValid())
                {
                    Close();
                }
                else
                {
                    MessageBox.Show(stockResult.description, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Se ha producido el siguiente error: " + exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }