Exemple #1
0
        protected void UpdateExpenseCategory(string category)
        {
            JT_MiscellaneousCodes categoryRecord = App.Database.GetExpenseCategory(category);

            string[] brokenDescription = App_Expense.BreakDescription(categoryRecord.AddtlDescNum);

            try
            {
                _expenseItem.ChargeCode = brokenDescription[0];
            }
            catch
            {
                _expenseItem.ChargeCode = null;
            }
            try
            {
                _expenseItem.UnitOfMeasure = brokenDescription[1];
            }
            catch
            {
                _expenseItem.UnitOfMeasure = null;
            }
            try
            {
                _expenseItem.UnitPrice = double.Parse(brokenDescription[2]);
            }
            catch
            {
                _expenseItem.UnitPrice = 0;
            }
        }
Exemple #2
0
        public ExpensesEditPage(App_Expense expense)
        {
            //_expense = expense;

            // dch rkl 10/12/2016
            workticket = expense.WorkTicket.FormattedTicketNumber;

            _vm = new ExpensesEditPageViewModel(expense);
            Initialize();
        }
Exemple #3
0
        private void _listViewExpenses_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            App_Expense expense = (App_Expense)_listViewExpenses.SelectedItem;

            //_listViewExpenses.SelectedItem = null;

            ContentControl contentArea = (ContentControl)this.Parent;

            contentArea.Content = new ExpensesEditPage(expense);
        }
        private async void ListViewExpenses_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            // Get the selected item and type it properly.
            App_Expense expense = e.Item as App_Expense;

            // Unset the selection so nothing is highlighted in the list anymore
            _listViewExpenses.SelectedItem = null;

            // Go to the edit page and pass the selected expense item.
            await Navigation.PushAsync(new ExpensesEditPage(expense));
        }
        protected void UpdateExpenseCategory(string category)
        {
            // dch rkl 12/07/2016 catch exception
            try
            {
                // dch rkl 11/21/2016 make sure category is not blank/null BEGIN
                if (category != null && category.Trim().Length > 0)
                {
                    // dch rkl 11/21/2016 make sure category is not blank/null END
                    JT_MiscellaneousCodes categoryRecord = App.Database.GetExpenseCategory(category);
                    string[] brokenDescription           = App_Expense.BreakDescription(categoryRecord.AddtlDescNum);

                    try
                    {
                        _expenseItem.ChargeCode = brokenDescription[0];
                    }
                    catch
                    {
                        _expenseItem.ChargeCode = null;
                    }
                    try
                    {
                        _expenseItem.UnitOfMeasure = brokenDescription[1];
                    }
                    catch
                    {
                        _expenseItem.UnitOfMeasure = null;
                    }
                    try
                    {
                        _expenseItem.UnitPrice = double.Parse(brokenDescription[2]);
                    }
                    catch
                    {
                        _expenseItem.UnitPrice = 0;
                    }
                    // dch rkl 11/21/2016 make sure category is not blank/null BEGIN
                }
                else
                {
                    _expenseItem.ChargeCode    = "";
                    _expenseItem.UnitOfMeasure = null;
                    _expenseItem.UnitPrice     = 0;
                }
                // dch rkl 11/21/2016 make sure category is not blank/null END
            }
            catch (Exception ex)
            {
                // dch rkl 12/07/2016 Log Error
                ErrorReporting errorReporting = new ErrorReporting();
                errorReporting.sendException(ex, "TechDashboard.ExpensesEditPageViewModel.UpdateExpenseCategory");
            }
        }
        // dch rkl 10/14/2016 Delete Expense Item
        public void DeleteExpense(App_Expense expense)
        {
            JT_TransactionImportDetail detail = new JT_TransactionImportDetail();

            lock (_locker)
            {
                detail =
                    _database.Table <JT_TransactionImportDetail>().Where(
                        tid => (tid.ID == expense.ID)
                        ).FirstOrDefault();

                _database.Delete(detail);
            }
        }
        /// <summary>
        /// Saves the provided App_Expense item to the local database
        /// </summary>
        /// <param name="expense">The App_Expense item to save</param>
        public void SaveExpense(App_Expense expense)
        {
            int rows = 0;

            JT_TransactionImportDetail txnImportDetail = new JT_TransactionImportDetail();

            txnImportDetail.RecordType        = "E";
            txnImportDetail.ID                = expense.ID;
            txnImportDetail.EmployeeNo        = App.Database.GetCurrentTechnicianFromDb().TechnicianNo;
            txnImportDetail.EmployeeDeptNo    = App.Database.GetCurrentTechnicianFromDb().TechnicianDeptNo;
            txnImportDetail.TransactionDate   = expense.Date.ToSage100DateString();
            txnImportDetail.SalesOrderNo      = expense.WorkTicket.SalesOrderNo;
            txnImportDetail.WTNumber          = expense.WorkTicket.WTNumber;
            txnImportDetail.WTStep            = expense.WorkTicket.WTStep;
            txnImportDetail.ItemCode          = expense.ChargeCode;
            txnImportDetail.UnitOfMeasure     = expense.UnitOfMeasure;
            txnImportDetail.QuantityUsed      = expense.Quantity;
            txnImportDetail.UnitCost          = expense.UnitCost;
            txnImportDetail.ReimburseEmployee = (expense.IsReimbursable ? "Y" : "N");
            txnImportDetail.UnitPrice         = expense.UnitPrice;

            // dch rkl 12/09/2016 per Chris, use ItemCodeDesc
            //txnImportDetail.BillingDescription = expense.BillingDescription;
            //txnImportDetail.ItemCodeDesc = expense.BillingDescription;
            //per Jeanne, use comment
            txnImportDetail.CommentText = expense.BillingDescription;

            txnImportDetail.ChargePart = (expense.IsChargeableToCustomer ? "Y" : "N");

            lock (_locker)
            {
                if (txnImportDetail.ID != 0)
                {
                    rows = _database.Update(txnImportDetail);
                    System.Diagnostics.Debug.WriteLine("Number of rows updated = " + rows.ToString());
                }
                else
                {
                    rows = _database.Insert(txnImportDetail);
                    System.Diagnostics.Debug.WriteLine("Number of rows inserted = " + rows.ToString());
                }
            }
        }
        public ExpensesEditPageViewModel(App_Expense expenseItem)
        {
            // dch rkl 12/07/2016 catch exception
            try
            {
                _expenseItem = expenseItem;

                _unitOfMeasureList = App.Database.GetCI_UnitOfMeasureFromDB();
                _unitOfMeasureList.Add(new CI_UnitOfMeasure()
                {
                    UnitOfMeasure = "EACH"
                });
                _unitOfMeasureList.Sort((x, y) => x.UnitOfMeasure.CompareTo(y.UnitOfMeasure));
                //_expenseItem.Category =
                Initialize();
            }
            catch (Exception ex)
            {
                // dch rkl 12/07/2016 Log Error
                ErrorReporting errorReporting = new ErrorReporting();
                errorReporting.sendException(ex, "TechDashboard.ExpensesEditPageViewModel(App_Expense expenseItem)");
            }
        }
        public ExpensesEditPageViewModel(App_WorkTicket workTicket)
        {
            // dch rkl 12/07/2016 catch exception
            try
            {
                _expenseItem = new App_Expense(new JT_TransactionImportDetail(), workTicket);

                // dch rkl 01/23/2017 added Unit of Measure List
                _unitOfMeasureList = App.Database.GetCI_UnitOfMeasureFromDB();
                _unitOfMeasureList.Add(new CI_UnitOfMeasure()
                {
                    UnitOfMeasure = "EACH"
                });
                _unitOfMeasureList.Sort((x, y) => x.UnitOfMeasure.CompareTo(y.UnitOfMeasure));

                Initialize();
            }
            catch (Exception ex)
            {
                // dch rkl 12/07/2016 Log Error
                ErrorReporting errorReporting = new ErrorReporting();
                errorReporting.sendException(ex, "TechDashboard.ExpensesEditPageViewModel(App_WorkTicket workTicket)");
            }
        }
Exemple #10
0
 public ExpensesEditPageViewModel(App_Expense expenseItem)
 {
     _expenseItem = expenseItem;
     Initialize();
 }
Exemple #11
0
        public ExpensesEditPageViewModel(App_WorkTicket workTicket)
        {
            _expenseItem = new App_Expense(new JT_TransactionImportDetail(), workTicket);

            Initialize();
        }