private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { listBox1.Items.Clear(); int whID = int.Parse(comboBox1.Text); warehouse wh = (from it in ent.warehouses where it.warehouse_id == whID select it).First(); var supplying_permits = (from it in wh.supplying_permit select it); foreach (supplying_permit s in supplying_permits) { var items = (from it in s.supplying_permit_items select it); foreach (supplying_permit_items i in items) { listBox1.Items.Add(" item " + i.item_name.Trim() + " supplied with amount " + i.amout); } } var sell_per = (from it in wh.selling_permit select it); foreach (selling_permit s in sell_per) { var items = (from it in s.selling_permit_items select it); foreach (selling_permit_items i in items) { listBox1.Items.Add(" item " + i.item_name.Trim() + " sold with amount " + i.amount); } } var ex_permit = (from it in wh.exchang_permit select it); foreach (exchang_permit s in ex_permit) { var items = (from it in s.exchane_permit_items select it); foreach (exchane_permit_items i in items) { listBox1.Items.Add("item " + i.item_name.Trim() + " exchanged into with amount " + i.amount); } } var ex_permit_out = (from it in wh.exchang_permit1 select it); foreach (exchang_permit s in ex_permit_out) { var items = (from it in s.exchane_permit_items select it); foreach (exchane_permit_items i in items) { listBox1.Items.Add("item " + i.item_name.Trim() + " exchanged from with amount " + i.amount); } } }
private void button2_Click(object sender, EventArgs e) { try { warehouse w = new warehouse(); int id = int.Parse(textBox1.Text); entities ent = new entities(); w = (from wa in ent.warehouses where wa.warehouse_id == id select wa).First(); w.warehouse_name = textBox2.Text; w.address = textBox3.Text; w.mgr_id = int.Parse(textBox4.Text); ent.SaveChanges(); MessageBox.Show("warehouse updated"); textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text = string.Empty; } catch { MessageBox.Show("no warehouse with this id"); } }
private void button1_Click(object sender, EventArgs e) { try { entities ent = new entities(); warehouse w = new warehouse(); w.warehouse_id = int.Parse(textBox1.Text); w.warehouse_name = textBox2.Text; w.mgr_id = int.Parse(textBox4.Text); w.address = textBox3.Text; ent.warehouses.Add(w); ent.SaveChanges(); MessageBox.Show("warehouse added"); textBox1.Text = textBox2.Text = textBox3.Text = textBox4.Text = string.Empty; } catch { MessageBox.Show("ID can't take this value"); } }