コード例 #1
0
        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;
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }