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

            if (currentRow != null)
            {
                FormElementNomenclature formElementNomenclature = new FormElementNomenclature();
                int          idNomenclature = Int32.Parse(currentRow.Cells["id"].Value.ToString());
                Nomenclature nomenclature   = db.Nomenclature.Find(idNomenclature);

                formElementNomenclature.textBoxId.Text           = currentRow.Cells["id"].Value.ToString();
                formElementNomenclature.textBoxName.Text         = currentRow.Cells["name"].Value.ToString();
                formElementNomenclature.textBoxManufacturer.Text = currentRow.Cells["manufacturer"].Value.ToString();
                formElementNomenclature.textBoxCountry.Text      = currentRow.Cells["country"].Value.ToString();


                DialogResult result = formElementNomenclature.ShowDialog(this);
                if (result == DialogResult.OK && nomenclature != null)
                {
                    nomenclature.name         = formElementNomenclature.textBoxName.Text.ToString();
                    nomenclature.manufacturer = formElementNomenclature.textBoxManufacturer.Text.ToString();
                    nomenclature.country      = formElementNomenclature.textBoxCountry.Text.ToString();
                    db.SaveChanges();
                    checkFilterNomenclature();
                    dataGridView.Refresh();
                }
            }
        }
Exemplo n.º 2
0
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            FormElementNomenclature formElementNomenclature = new FormElementNomenclature();
            DialogResult            result = formElementNomenclature.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                Nomenclature nomenclature = new Nomenclature();
                nomenclature.name         = formElementNomenclature.textBoxName.Text.ToString();
                nomenclature.manufacturer = formElementNomenclature.textBoxManufacturer.Text.ToString();
                nomenclature.country      = formElementNomenclature.textBoxCountry.Text.ToString();

                db.Nomenclature.Add(nomenclature);
                db.SaveChanges();
                checkFilterNomenclature();
                dataGridView.Refresh();
            }
        }