protected override void OnLoad(EventArgs e) { base.OnLoad(e); db = new ProdContentBase(); db.Categories.Load(); this.categoryBindingSource.DataSource = db.Categories.Local.ToBindingList(); }
private void button1_Click(object sender, EventArgs e)//save customer { if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("Błędne dane"); return; } using (var db = new ProdContentBase()) { var customers = db.Customers.Select(c => c.CompanyName).ToArray(); foreach (var c in customers) { if (c == textBox1.Text) { MessageBox.Show("Istnieje już taki klient"); return; } } } var companyName = textBox1.Text; var description = textBox2.Text; using (var db = new ProdContentBase()) { var newCustomer = new Customer { CompanyName = companyName, Description = description }; db.Customers.Add(newCustomer); db.SaveChanges(); _customers.Items.Add(companyName); Hide(); DestroyHandle(); } }
public CustomersOrdersForm() { InitializeComponent(); db = new ProdContentBase(); Setup(); }
public OrderForm() { InitializeComponent(); db = new ProdContentBase(); Setup(); }