Esempio n. 1
0
        private void dataGridView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            var currentRow = dataGridView.CurrentRow;

            if (currentRow != null)
            {
                FormElementBills formElementBills = new FormElementBills();
                int   idBills = Int32.Parse(currentRow.Cells["id"].Value.ToString());
                Bills Bills   = db.Bills.Find(idBills);

                formElementBills.textBoxId.Text         = currentRow.Cells["id"].Value.ToString();
                formElementBills.textBoxCurrency.Text   = db.Currencies.Find(currentRow.Cells["id_currency"].Value).name;
                formElementBills.textBoxNumberBill.Text = Bills.number_bill;


                DialogResult result = formElementBills.ShowDialog(this);
                if (result == DialogResult.OK && Bills != null)
                {
                    Bills.id_currency = Int32.Parse(formElementBills.textBoxCurrency.Text.ToString());
                    Bills.number_bill = formElementBills.textBoxNumberBill.Text.ToString();

                    db.SaveChanges();
                    checkFilter();
                    dataGridView.Refresh();
                }
            }
        }
Esempio n. 2
0
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            FormElementBills formElementBills = new FormElementBills();
            DialogResult     result           = formElementBills.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                Bills Bills = new Bills();
                Bills.id_currency = Int32.Parse(formElementBills.textBoxCurrency.Text.ToString());
                Bills.number_bill = formElementBills.textBoxNumberBill.Text.ToString();

                db.Bills.Add(Bills);
                db.SaveChanges();
                checkFilter();
                dataGridView.Refresh();
            }
        }