public EditExpense(expense o) { InitializeComponent(); EmployeeIdComboBox.ItemsSource = db.employee.ToList(); EmployeeIdComboBox.DisplayMemberPath = "name"; e = o; EmployeeIdComboBox.SelectedValue = db.employee.ToList().First(d => d.Id == e.employee_id); dateP.SelectedDate = e.date; CostTextBox.Text = e.cost.ToString(); DescriptionTextBox.Text = e.description; }
private void EditExpense_Click(object sender, RoutedEventArgs e) { expense s = (expense)ExpenseDataGrid.SelectedItem; if (s == null) { return; } EditExpense window = new EditExpense(s); Hide(); window.ShowDialog(); Show(); UpdateExpenseDataGrid(); }
private void Button_Click(object sender, RoutedEventArgs e) { int employeeId = ((employee)EmployeeIdComboBox.SelectedItem).Id; DateTime date = (DateTime)dateP.SelectedDate; //DateTime date = dateP.DisplayDate; float cost = (float.Parse(CostTextBox.Text)); string description = DescriptionTextBox.Text; expense o = new expense(); o.employee_id = employeeId; o.date = date; o.cost = cost; o.description = description; db.expense.Add(o); db.SaveChanges(); this.Close(); }