public void BindDataGrid()
        {
            List <Transaction> transactions = new TransactionCRUD().GetTransactions();

            if (transactions.Count > 0)
            {
                foreach (Transaction trans in transactions)
                {
                    if (trans.JobId > 0)
                    {
                        trans.JobName = new JobCRUD().GetJobs().Where(x => x.JobId == trans.JobId).First().Name;
                    }
                    else
                    {
                        trans.JobName = "";
                    }

                    if (trans.UserId > 0)
                    {
                        trans.UserName = new UserCRUD().GetUsers().Where(x => x.UserId == trans.UserId).First().Name;
                    }
                    else
                    {
                        trans.UserName = "";
                    }
                }
            }

            dgData.ItemsSource = transactions;
        }
Exemplo n.º 2
0
        private void BtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            Transaction transaction = (Transaction)this.DataContext;
            int         result      = new TransactionCRUD().Create(transaction);

            if (result > 0)
            {
                MessageBox.Show("Transaction was created", "Success");
                this.Close();
            }
            else
            {
                MessageBox.Show("Unable to create transaction", "Failure");
            }
        }