Exemple #1
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            try {
                Expense item = monthlyFee.Expense(date);


                item.Price = Convert.ToDouble(tbPrice.Text);

                eDb.Update(item);

                // Close the edit form
                this.Close();
            } catch (System.FormatException ex) {
                MessageBox.Show(ex.Message, "Confira os dados inseridos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            } finally { }
        }
Exemple #2
0
        // WINDOW CONTROL BUTTON ** WINDOW CONTROL BUTTON ** WINDOW CONTROL BUTTON ** WINDOW CONTROL BUTTON ** WINDOW CONTROL BUTTON
        private void buttonSave_Click(object sender, EventArgs e)
        {
            try {
                // Create the new Model, case don't exists
                if (item == null)
                {
                    item = new Models.Expense();
                }

                item.Description = tbDescription.Text;
                item.Price       = Double.Parse(tbPrice.Text);
                item.Count       = Double.Parse(tbCount.Text);
                item.Date        = dpDate.Value.Date;

                // Case if a new item
                if (item.Id == -1)
                {
                    db.Insert(item);
                }

                // Case is a existent item
                else
                {
                    db.Update(item);
                }

                // Close the edit form
                this.Close();
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, "Confira os dados inseridos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                // Destroy the temp item
                if (item.Id == -1)
                {
                    item = null;
                }
            } finally { }
        }