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

            if (currentRow != null)
            {
                FormElementCurrencies formElementCurrencies = new FormElementCurrencies();
                int        idCurrencies = Int32.Parse(currentRow.Cells["id"].Value.ToString());
                Currencies Currencies   = db.Currencies.Find(idCurrencies);

                formElementCurrencies.textBoxId.Text   = currentRow.Cells["id"].Value.ToString();
                formElementCurrencies.textBoxName.Text = currentRow.Cells["name"].Value.ToString();


                DialogResult result = formElementCurrencies.ShowDialog(this);
                if (result == DialogResult.OK && Currencies != null)
                {
                    Currencies.name = formElementCurrencies.textBoxName.Text.ToString();

                    db.SaveChanges();
                    checkFilter();
                    dataGridView.Refresh();
                }
            }
        }
Exemple #2
0
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            FormElementCurrencies formElementCurrencies = new FormElementCurrencies();
            DialogResult          result = formElementCurrencies.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                Currencies Currencies = new Currencies();
                Currencies.name = formElementCurrencies.textBoxName.Text.ToString();

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