private void CustomersGrid_CellClick(object sender, DataGridViewCellEventArgs e) { using (OrdersDBEntities db = new OrdersDBEntities()) { if (textOperator.Words.Count != 0) { textOperator.Words.Clear(); } var properties = db.Customers.EntitySet.ElementType.Properties; for (int i = 0; i < CustomersGrid.ColumnCount; i++) { if (CustomersGrid[i, e.RowIndex].Value != null) { textOperator.Words.Add(properties[i].Name, CustomersGrid[i, e.RowIndex].Value.ToString()); } } try //получить директора { textOperator.Head = db.People.Where(person => person.PositionId == "Директор").First(); } catch { MessageBox.Show("Warning: Head not found"); textOperator.Head = null; } } TableIsReady = true; }
public MyForm() { InitializeComponent(); TableIsReady = TemplateIsReady = false; textOperator = new TextOperator(); try { using (OrdersDBEntities db = new OrdersDBEntities()) { CustomersGrid.DataSource = db.Customers; MessageBox.Show("Choose customer and template"); } } catch { MessageBox.Show("Database not found"); System.Environment.Exit(0); } }
private void CustomersGrid_CellClick(object sender, DataGridViewCellEventArgs e) { using (OrdersDBEntities db = new OrdersDBEntities()) { if (textOperator.Words.Count != 0) textOperator.Words.Clear(); var properties = db.Customers.EntitySet.ElementType.Properties; for (int i = 0; i < CustomersGrid.ColumnCount; i++) { if (CustomersGrid[i, e.RowIndex].Value != null) textOperator.Words.Add(properties[i].Name, CustomersGrid[i, e.RowIndex].Value.ToString()); } try //получить директора { textOperator.Head = db.People.Where(person => person.PositionId == "Директор").First(); } catch { MessageBox.Show("Warning: Head not found"); textOperator.Head = null; } } TableIsReady = true; }