using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace firstProject { public partial class win2 : Form { String str; dbEntities db = new dbEntities(); public win2() { InitializeComponent(); } public win2(String str) { this.str = str; InitializeComponent(); } private void win2_Load(object sender, EventArgs e) { var tmp = (from s in db.customer select s).ToList(); dataGridView1.DataSource = tmp; dataGridView1.ReadOnly = true; dataGridView1.Columns[0].Visible = false; dataGridView1.Columns[1].HeaderText = "שם פרטי"; comboBox1.DataSource = tmp; comboBox1.DisplayMember = "firstName"; comboBox1.ValueMember = "id"; } private void button1_Click(object sender, EventArgs e) { customer x = new customer(); x.firstName = textBox1.Text; x.lastName = textBox2.Text; x.phone = maskedTextBox1.Text; db.customer.AddObject(x); db.SaveChanges(); MessageBox.Show("עודכן בהצלחה"); textBox1.Text = ""; textBox2.Text = ""; win2_Load(sender, e); } private void pictureBox1_SizeChanged(object sender, EventArgs e) { } private void win2_SizeChanged(object sender, EventArgs e) { int x,y; x = this.Width; y = this.Height; } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { customer c1 = (customer) comboBox1.SelectedItem; label1.Text = c1.phone; } } }