コード例 #1
0
        public App_RepairPart(JT_ServiceEquipmentParts part, App_RepairItem TODO)
        {
            // stub to stop errors

            _ciOptions           = App.Database.GetCIOptions();
            quantityFormatString = String.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInQty, "}");
            umFormatString       = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInUM, "}");
            costFormatString     = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInCost, "}");
            priceFormatString    = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInPrice, "}");
        }
コード例 #2
0
        public CI_Options GetCIOptions()
        {
            CI_Options ciOptions = new CI_Options();

            lock (_locker)
            {
                ciOptions = _database.Table <CI_Options>().FirstOrDefault();
            }
            return(ciOptions);
        }
コード例 #3
0
        public App_RepairPart(App_Item item, App_WorkTicket workTicket)
        {
            _ciOptions           = App.Database.GetCIOptions();
            quantityFormatString = String.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInQty, "}");
            umFormatString       = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInUM, "}");
            costFormatString     = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInCost, "}");
            priceFormatString    = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInPrice, "}");

            _workTicket = workTicket;

            _id                      = 0;
            _parentItemCode          = workTicket.DtlRepairItemCode;
            _partItemCode            = item.ItemCode;
            _partItemCodeDescription = item.ItemCodeDesc;
            _warehouse               = item.WarehouseCode;
            _problemCode             = _workTicket.DtlProblemCode;
            _quantity                = 0.0;

            // dch rkl 12/02/2016 Get Item Unit Cost based on JT_Options.DefaultPartsCost
            _unitCost = GetItemUnitCost(item.LastTotalUnitCost, item.AverageUnitCost, item.StandardUnitCost);
            //_unitCost = (double)item.StandardUnitCost;

            _unitPrice = Convert.ToDouble(item.StandardUnitPrice);

            // dch rkl 02/03/2017 Per Jeanne, Use the Sales Unit of Measure, not the Standard Unit of Measure
            //_unitOfMeasure = item.StandardUnitOfMeasure;
            _unitOfMeasure = item.SalesUnitOfMeasure;

            _comment      = string.Empty;
            _isChargeable = SetIsChargeable();
            _isPrintable  = (_isChargeable ? true : false);
            _isPurchased  = false;
            _isOverhead   = _workTicket.PartsCalculateOverheadDefault;
            _itemType     = item.ItemType;      // dch rkl 11/23/2016 add item type

            // dch rkl 11/30/2016 add quantity required
            _quantityReqd = 0;

            // dch rkl 11/23/2016 Add Item Type
            _itemType = item.ItemType;

            // dch rkl 12/05/2016 Add Item Valuation
            _valuation = item.Valuation;

            // dch rkl 12/05/2016 add qty shipped
            _quantityShipped = 0;

            // dch rkl 01/13/2017 Add Extended Description
            _itemCodeDesc = "";

            // dch rkl 01/23/2017 Sales Order Line Key
            _soLineKey = "";
        }
コード例 #4
0
        public App_RepairPart(JT_ServiceEquipmentParts part, App_WorkTicket workTicket, CI_Item item)
        {
            _ciOptions           = App.Database.GetCIOptions();
            quantityFormatString = String.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInQty, "}");
            umFormatString       = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInUM, "}");
            costFormatString     = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInCost, "}");
            priceFormatString    = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInPrice, "}");

            _workTicket              = workTicket;
            _id                      = 0;
            _parentItemCode          = workTicket.DtlRepairItemCode;
            _partItemCode            = part.ItemCode;
            _partItemCodeDescription = item.ItemCodeDesc;
            _warehouse               = item.DefaultWarehouseCode;
            _problemCode             = part.ProblemCode;
            _quantity                = part.Quantity;

            // dch rkl 12/02/2016 Get Item Unit Cost based on JT_Options.DefaultPartsCost
            _unitCost = GetItemUnitCost(item.LastTotalUnitCost, item.AverageUnitCost, item.StandardUnitCost);
            //_unitCost = (double)item.StandardUnitCost;

            _unitPrice = (double)item.StandardUnitPrice;

            // dch rkl 02/03/2017 Use the sales unit of measure instead of the standard unit of measure
            //_unitOfMeasure = item.StandardUnitOfMeasure;
            _unitOfMeasure = item.SalesUnitOfMeasure;

            _comment      = "";
            _isChargeable = part.IsChargeable;
            _isPrintable  = part.IsPrintable;
            _isPurchased  = part.IsPurchased;
            _isOverhead   = part.IsOverhead;

            // dch rkl 11/23/2016 Add Item Type
            _itemType = item.ItemType;

            // dch rkl 12/05/2016 Add Item Valuation
            _valuation = item.Valuation;

            // dch rkl 11/30/2016 add quantity required
            _quantityReqd = 0;

            // dch rkl 12/05/2016 add qty shipped
            _quantityShipped = 0;

            // dch rkl 01/13/2017 Add Extended Description
            _itemCodeDesc = "";

            // dch rkl 01/23/2017 Sales Order Line Key
            _soLineKey = "";
        }
コード例 #5
0
        public PartsListPageViewModel(App_WorkTicket workTicket)
        {
            try {
                _ciOptions           = App.Database.GetCIOptions();
                quantityFormatString = String.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInQty, "}");
                umFormatString       = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInUM, "}");
                costFormatString     = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInCost, "}");
                priceFormatString    = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInPrice, "}");

                _workTicket          = workTicket;
                _partsList           = App.Database.RetrievePartsListFromWorkTicket(workTicket);
                _observablePartsList = new ObservableCollection <App_RepairPart>();
                SetPartsList();
            } catch (Exception exception) {
                App.sendException(exception, "PartsListPageViewModel.PartsListPageViewModel");
            }
        }
コード例 #6
0
        public PartsListPageViewModel(App_WorkTicket workTicket)
        {
            // dch rkl 02/06/2017 Add try/catch here
            try
            {
                _ciOptions           = App.Database.GetCIOptions();
                quantityFormatString = String.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInQty, "}");
                umFormatString       = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInUM, "}");
                costFormatString     = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInCost, "}");
                priceFormatString    = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInPrice, "}");
                // dch rkl 12/07/2016 catch exception

                _workTicket          = workTicket;
                _partsList           = App.Database.RetrievePartsListFromWorkTicket(workTicket);
                _observablePartsList = new ObservableCollection <App_RepairPart>();
                SetPartsList();
            }
            catch (Exception ex)
            {
                // dch rkl 12/07/2016 Log Error
                ErrorReporting errorReporting = new ErrorReporting();
                errorReporting.sendException(ex, "TechDashboard.PartsListPageViewModel(App_WorkTicket workTicket)");
            }
        }
コード例 #7
0
        /// <summary>
        /// Contstructor for repair part objects using the transaction import detail records.
        /// </summary>
        /// <param name="importDetail">The JT_TransactionImportDetail record to use.</param>
        /// <param name="workTicket">The App_WorkTicket object associated with this part.</param>
        public App_RepairPart(JT_TransactionImportDetail importDetail, App_WorkTicket workTicket)
        {
            _ciOptions           = App.Database.GetCIOptions();
            quantityFormatString = String.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInQty, "}");
            umFormatString       = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInUM, "}");
            costFormatString     = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInCost, "}");
            priceFormatString    = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInPrice, "}");

            _workTicket = workTicket;

            _id                      = importDetail.ID;
            _parentItemCode          = workTicket.DtlRepairItemCode;
            _partItemCode            = importDetail.ItemCode;
            _partItemCodeDescription = importDetail.ItemCodeDesc;

            // dch rkl 11/22/2016
            CI_Item item = App.Database.GetItemFromDB(_partItemCode);

            if (_partItemCodeDescription == null)
            {
                if (item != null && item.ItemCodeDesc != null)
                {
                    _partItemCodeDescription = item.ItemCodeDesc;
                }
                else
                {
                    _partItemCodeDescription = "";
                }
            }

            // dch rkl 12/05/2016 Make sure part has a valuation value

            _warehouse     = importDetail.WarehouseCode;
            _problemCode   = importDetail.ProblemCode;
            _quantity      = importDetail.QuantityUsed;
            _unitCost      = importDetail.UnitCost;
            _unitPrice     = importDetail.UnitPrice;
            _unitOfMeasure = importDetail.UnitOfMeasure;
            _comment       = importDetail.CommentText;
            _lotSerialNo   = importDetail.LotSerialNo;
            _isChargeable  = (((importDetail.ChargePart != null) && (importDetail.ChargePart.Trim().ToUpper() == "Y")) ? true : false);
            _isPrintable   = (((importDetail.PrintPart != null) && (importDetail.PrintPart.Trim().ToUpper() == "Y")) ? true : false);
            _isPurchased   = (((importDetail.PurchasePart != null) && (importDetail.PurchasePart.Trim().ToUpper() == "Y")) ? true : false);
            _isOverhead    = (((importDetail.Overhead != null) && (importDetail.Overhead.Trim().ToUpper() == "Y")) ? true : false);

            // dch rkl 11/23/2016 Add Item Type
            if (item != null && item.ItemType != null)
            {
                _itemType = item.ItemType;
            }

            // dch rkl 12/05/2016 Add Item Valuation
            if (item != null && item.Valuation != null)
            {
                _valuation = item.Valuation;
            }

            // dch rkl 11/30/2016 add quantity required
            _quantityReqd = (decimal)importDetail.QuantityRequired;

            // dch rkl 12/05/2016 add qty shipped
            _quantityShipped = importDetail.QuantityCompleted;

            // dch rkl 01/13/2017 Add Extended Description
            if (importDetail.ItemCodeDesc != null)
            {
                _itemCodeDesc = importDetail.ItemCodeDesc;
            }
            else
            {
                _itemCodeDesc = "";
            }

            // dch rkl 01/23/2017 Sales Order Line Key
            _soLineKey = importDetail.SOLineKey;
        }
コード例 #8
0
        public App_RepairPart(CI_Item item, App_WorkTicket workTicket, string itemCode)
        {
            _ciOptions           = App.Database.GetCIOptions();
            quantityFormatString = String.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInQty, "}");
            umFormatString       = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInUM, "}");
            costFormatString     = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInCost, "}");
            priceFormatString    = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInPrice, "}");

            _workTicket = workTicket;

            _id             = 0;
            _parentItemCode = workTicket.DtlRepairItemCode;

            // dch rkl 10/31/2016 handle nulls
            if (item != null)
            {
                _partItemCode            = item.ItemCode;
                _partItemCodeDescription = item.ItemCodeDesc;
                _warehouse = item.DefaultWarehouseCode;

                // dch rkl 12/02/2016 Get Item Unit Cost based on JT_Options.DefaultPartsCost
                _unitCost = GetItemUnitCost(item.LastTotalUnitCost, item.AverageUnitCost, item.StandardUnitCost);
                //_unitCost = (double)item.StandardUnitCost;

                _unitPrice = Convert.ToDouble(item.StandardUnitPrice);

                // dch rkl 02/03/2017 Per Jeanne, Use the Sales Unit of Measure, not the Standard Unit of Measure
                //_unitOfMeasure = item.StandardUnitOfMeasure;
                _unitOfMeasure = item.SalesUnitOfMeasure;

                // dch rkl 11/23/2016 Add Item Type
                _itemType = item.ItemType;

                // dch rkl 12/05/2016 Add Item Valuation
                _valuation = item.Valuation;
            }
            else
            {
                _partItemCode            = "";
                _partItemCodeDescription = "";
                _warehouse     = "";
                _unitCost      = 0;
                _unitPrice     = 0;
                _unitOfMeasure = "";
                _itemType      = "";
                _valuation     = "";
            }

            _problemCode  = _workTicket.DtlProblemCode;
            _quantity     = 0.0;
            _comment      = string.Empty;
            _isChargeable = SetIsChargeable();
            _isPrintable  = (_isChargeable ? true : false);
            _isPurchased  = false;
            _isOverhead   = _workTicket.PartsCalculateOverheadDefault;

            //bk check existing sales order detail
            //bk use workticket item instead of item in case of null

            SO_SalesOrderDetail soDetail = App.Database.GetSalesOrderDetail(workTicket.SalesOrderNo, (item == null ? itemCode : item.ItemCode));

            if (soDetail != null)
            {
                _isChargeable = soDetail.JT158_WTChargePart == "Y" ? true : false;
                _isPrintable  = soDetail.JT158_WTPrintPart == "Y" ? true : false;
                _isPurchased  = soDetail.JT158_WTPurchase == "Y" ? true : false;
                _isOverhead   = soDetail.JT158_WTOverhead == "Y" ? true : false;
            }

            // dch rkl 11/30/2016 add quantity required
            _quantityReqd = 0;

            // dch rkl 12/05/2016 add qty shipped
            _quantityShipped = 0;

            // dch rkl 01/13/2017 Add Extended Description
            _itemCodeDesc = "";

            // dch rkl 01/23/2017 Sales Order Line Key
            _soLineKey = "";
        }
コード例 #9
0
        // dch rkl 10/26/2016 include schedule detail
        //public ClockOutPage(App_WorkTicket workTicket)
        public ClockOutPage(App_WorkTicket workTicket, App_ScheduledAppointment scheduleDetail)
        {
            InitializeComponent();

            _vm = new ClockOutPageViewModel(workTicket);

            _ciOptions = App.Database.GetCIOptions();

            // dch rkl 10/26/2016 return to ticket details instead of scheduled ticket list on cancel
            _scheduleDetail = scheduleDetail;

            // dch rkl 11/30/2016 display coverage checkboxes
            _workTicket = workTicket;

            // dch rkl 12/02/2016 Ticket Details

            // Get Current Technician
            JT_Technician technician = App.Database.GetCurrentTechnicianFromDb();

            // Service Ticket
            textServiceTicket.Content = _scheduleDetail.ServiceTicketNumber;

            // Employee Number and Name
            textEmployeeNumber.Content = technician.FormattedTechnicianNo;
            textEmployeeName.Content   = string.Format("{0} {1}", technician.FirstName, technician.LastName);

            // Set Coverage Checkboxes
            // Warranty Repair
            if (_workTicket.DtlWarrantyRepair == "Y")
            {
                switchWarrRepair.IsChecked = true;
            }

            // Labor Coverred on Warranty
            bool bIsChkd = false;

            if (_workTicket.StatusDate != null && _workTicket.RepairItem.MfgLaborWarrantyPeriod != null)
            {
                TimeSpan tsDateDiff = _workTicket.RepairItem.MfgLaborWarrantyPeriod.Subtract(_workTicket.StatusDate);
                if (tsDateDiff.TotalDays > 0 && _workTicket.DtlWarrantyRepair == "Y")
                {
                    switchLaborCovWarr.IsChecked = true;
                    bIsChkd = true;
                }
            }
            if (_workTicket.StatusDate != null && _workTicket.RepairItem.IntLaborWarrantyPeriod != null)
            {
                TimeSpan tsDateDiff = _workTicket.RepairItem.IntLaborWarrantyPeriod.Subtract(_workTicket.StatusDate);
                if (tsDateDiff.TotalDays > 0 && _workTicket.DtlWarrantyRepair == "Y")
                {
                    switchLaborCovWarr.IsChecked = true;
                    bIsChkd = true;
                }
            }

            // Service Agreement Repair
            if (_workTicket.DtlCoveredOnContract == "Y")
            {
                switchSvcAgrRepair.IsChecked = true;
            }

            // LLabor Covered on Service Agreement
            if (_workTicket.IsPreventativeMaintenance && _workTicket.ServiceAgreement.IsPMLaborCovered)
            {
                switchLaborCovSvcAgr.IsChecked = true;
            }
            else if (_workTicket.IsPreventativeMaintenance == false && _workTicket.IsServiceAgreementRepair && _workTicket.ServiceAgreement.IsLaborCovered)
            {
                switchLaborCovSvcAgr.IsChecked = true;
            }

            // Billable Picker
            pickerBillable.ItemsSource = _vm.BillableList;

            // Start Time
            DateTime dtStartDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day) + _vm.StartTime;

            if (App.Database.GetApplicationSettings().TwentyFourHourTime)
            {
                textStartTime.Text = dtStartDateTime.ToString("HH:mm");
            }
            else
            {
                textStartTime.Text = dtStartDateTime.ToString("hh:mm tt");
            }

            // Start Date
            textStartDate.Text = technician.CurrentStartDate.ToShortDateString();

            // Depart Time
            textEndDate.Text = DateTime.Now.ToShortDateString();
            if (App.Database.GetApplicationSettings().TwentyFourHourTime)
            {
                textDepartTime.Text = DateTime.Now.ToString("HH:mm");
            }
            else
            {
                textDepartTime.Text = DateTime.Now.ToString("hh:mm tt");
            }

            // dch rkl 01/23/2017 If Time Tracker Options is "Y", they enter start / end time.If "N", they enter hours. BEGIN
            // bk rkl 02/01/2017 moving north of sethoursbilled call
            _captureTimeInTimeTracker = "N";
            _MinHourlyCostIncrement   = 0;
            JT_TimeTrackerOptions tto = App.Database.GetTimeTrackerOptions();

            if (tto != null && tto.CaptureTimeInTimeTracker != null)
            {
                _captureTimeInTimeTracker = tto.CaptureTimeInTimeTracker;
                _MinHourlyCostIncrement   = tto.MinHourlyCostIncrement;
                if (_captureTimeInTimeTracker == "O")
                {
                    _captureTimeInTimeTracker = "Y";
                }
            }
            // Set Hours Billed
            if (textStartTime.Text != null && textDepartTime.Text != null)
            {
                SetHoursBilled();
            }

            // Technician Status
            // dch rkl 01/16/2017 If there is no value for the Default Depart Status Code, use the technician's current status BEGIN
            string statusCode = _vm.DefaultDepartStatusCode;

            if (statusCode == null || statusCode.Trim().Length == 0)
            {
                statusCode = technician.CurrentStatus;
            }
            // dch rkl 01/16/2017 If there is no value for the Default Depart Status Code, use the technician's current status END
            pickerTechnicianStatus.ItemsSource = _vm.TechnicianStatusList;
            for (int i = 0; i < pickerTechnicianStatus.Items.Count; i++)
            {
                // dch rkl 01/16/2017 If there is no value for the Default Depart Status Code, use the technician's current status BEGIN
                //if (((JT_TechnicianStatus)pickerTechnicianStatus.Items[i]).StatusDescription == _vm.DefaultDepartStatusCodeDescription)
                if (((JT_TechnicianStatus)pickerTechnicianStatus.Items[i]).StatusCode == statusCode)
                // dch rkl 01/16/2017 If there is no value for the Default Depart Status Code, use the technician's current status END
                {
                    pickerTechnicianStatus.SelectedIndex = i;
                    break;
                }
            }

            // Ticket Status
            pickerTicketStatus.ItemsSource   = _vm.ServiceTicketStatusList;
            pickerTicketStatus.SelectedValue = _vm.DefaultServiceTicketStatusCode;

            // Activity Code
            pickerActivityCode.ItemsSource   = _vm.ActivityCodeList;
            pickerActivityCode.SelectedValue = _vm.DefaultActivityCode;

            // Department
            pickerDepartment.ItemsSource = _vm.DepartmentCodesList;
            JT_ActivityCode dfltActCode = new JT_ActivityCode();

            if (_vm.DefaultActivityCode != null)
            {
                dfltActCode = App.Database.GetActivityCodeFromDB(_vm.DefaultActivityCode);
            }
            if (dfltActCode != null)
            {
                pickerDepartment.SelectedValue = dfltActCode.DeptWorkedIn;
            }

            // Earnings Code
            List <JT_EarningsCode> lsEarnCd = new List <Models.JT_EarningsCode>();

            foreach (JT_EarningsCode earncd in _vm.EarningsCodeList)
            {
                // Only include types of Regular or Overtime
                if (earncd.TypeOfEarnings == "O" || earncd.TypeOfEarnings == "R")
                {
                    earncd.EarningsDeductionDesc = string.Format("{0} - {1}", earncd.EarningsCode, earncd.EarningsDeductionDesc);
                    lsEarnCd.Add(earncd);
                }
            }
            pickerEarningsCode.ItemsSource = lsEarnCd;

            // dch rkl 11/01/2016 make sure default earning code is not null
            if (_vm.DefaultEarningCode != null)
            {
                pickerEarningsCode.SelectedValue = _vm.DefaultEarningCode;
            }
            else
            {
                pickerEarningsCode.SelectedIndex = 0;
            }

            // Meter Reading
            // dch rkl 11/1/2016 per Jeanne, hide the meter reading if JT_ServiceAgreementPMDetail.Basis = "M" BEGIN
            if (_vm.WorkTicket.ServiceAgreement != null && _vm.WorkTicket.ServiceAgreement.PmDetail != null &&
                _vm.WorkTicket.ServiceAgreement.PmDetail.Basis != null && _vm.WorkTicket.ServiceAgreement.PmDetail.Basis == "M")
            {
                labelMeterReading.Visibility  = Visibility.Visible;
                editorMeterReading.Visibility = Visibility.Visible;
            }
            else
            {
                labelMeterReading.Visibility  = Visibility.Hidden;
                editorMeterReading.Visibility = Visibility.Hidden;
            }
            // dch rkl 11/1/2016 per Jeanne, hide the meter reading if JT_ServiceAgreementPMDetail.Basis = "M" END

            // Set Ref Rate
            SetRefRate();

            // Work Performed
            editorWorkPerformed.MaxHeight = editorWorkPerformed.MinHeight;


            if (_captureTimeInTimeTracker == "Y")
            {
                // Enter start/end time
                textStartDate.IsEnabled     = true;
                textStartTime.IsEnabled     = true;
                textEndDate.IsEnabled       = true;
                textDepartTime.IsEnabled    = true;
                editorHoursWorked.IsEnabled = false;
            }
            else
            {
                // Enter hours
                textStartDate.IsEnabled     = false;
                textStartDate.Text          = "";
                textStartTime.IsEnabled     = false;
                textStartTime.Text          = "";
                textEndDate.IsEnabled       = false;
                textEndDate.Text            = "";
                textDepartTime.IsEnabled    = false;
                textDepartTime.Text         = "";
                editorHoursWorked.IsEnabled = true;
            }
            // dch rkl 01/23/2017 If Time Tracker Options is "Y", they enter start / end time.If "N", they enter hours. END

            // dch rkl 01/12/2017 Set Tab Indexes
            textStartDate.TabIndex          = 0;
            textStartTime.TabIndex          = 1;
            textEndDate.TabIndex            = 2;
            textDepartTime.TabIndex         = 3;
            editorHoursWorked.TabIndex      = 4;
            pickerBillable.TabIndex         = 5;
            editorHoursBilled.TabIndex      = 6;
            editorBillableRate.TabIndex     = 7;
            pickerTechnicianStatus.TabIndex = 8;
            pickerTicketStatus.TabIndex     = 9;
            pickerActivityCode.TabIndex     = 10;
            pickerDepartment.TabIndex       = 11;
            pickerEarningsCode.TabIndex     = 12;
            editorMeterReading.TabIndex     = 13;
            editorWorkPerformed.TabIndex    = 14;
            buttonClockout.TabIndex         = 15;
            buttonCancel.TabIndex           = 16;
        }
コード例 #10
0
        protected void Initialize()
        {
            // Set the page title.
            //Title = "Add Expense";
            SolidColorBrush asbestos = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#7f8C8d"));

            //_labelHeading = new Xamarin.Forms.Label();

            //  Create a label for the expense page
            _labelTitle = new Label();
            if (_vm.ExpenseId > 0)
            {
                _labelTitle.Content = "EDIT EXPENSE";
            }
            else
            {
                _labelTitle.Content = "ADD EXPENSE";
            }

            _labelTitle.FontWeight          = FontWeights.Bold;
            _labelTitle.FontSize            = 22;
            _labelTitle.Foreground          = new SolidColorBrush(Colors.White);
            _labelTitle.HorizontalAlignment = HorizontalAlignment.Center;
            _labelTitle.VerticalAlignment   = VerticalAlignment.Center;

            Grid titleLayout = new Grid()
            {
                Background          = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#3498db")),
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Height = 80
            };

            titleLayout.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            titleLayout.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            titleLayout.Children.Add(_labelTitle);
            Grid.SetColumn(_labelTitle, 0);
            Grid.SetRow(_labelTitle, 0);

            _datePickerExpenseDate = new DatePicker();
            _datePickerExpenseDate.SelectedDate = _vm.ExpenseDate;
            _datePickerExpenseDate.Width        = 100; // dch rkl 11/22/2016

            Label labelCategory = new Label()
            {
                Content    = "CATEGORY",
                Foreground = asbestos,
                FontWeight = FontWeights.Bold
            };

            _pickerCategory = new ComboBox {
            };

            // dch rkl 10/14/2016 Show Code + Description in Expense Category Dropdown BEGIN
            List <JT_MiscellaneousCodes> lsMiscCodes = App.Database.GetExpenseCategoriesWithDesc();

            foreach (JT_MiscellaneousCodes code in lsMiscCodes)
            {
                _pickerCategory.Items.Add(string.Format("{0} - {1}", code.MiscellaneousCode, code.Description));
            }
            //foreach (string s in _vm.ExpenseCategories)
            //{
            //    _pickerCategory.Items.Add(s);
            //}
            // dch rkl 10/14/2016 Show Code + Description in Expense Category Dropdown END
            //_pickerCategory.BindingContext = _vm.ExpenseCategory;
            _pickerCategory.SelectionChanged += _pickerCategory_SelectionChanged;

            Label labelChargeCode = new Label()
            {
                Content    = "CHARGE CODE",
                Foreground = asbestos,
                FontWeight = FontWeights.Bold
            };

            _pickerChargeCode = new ComboBox()
            {
            };

            // dch rkl 10/14/2016 Show Code + Description in Charge Code Dropdown BEGIN
            List <string> lsChgCodes = App.Database.GetExpenseChargeCodesWithDesc();

            foreach (string chgCode in lsChgCodes)
            {
                _pickerChargeCode.Items.Add(chgCode);
            }
            //foreach (string s in _vm.ExpenseChargeCodes)
            //{
            //    _pickerChargeCode.Items.Add(s);
            //}
            //_pickerChargeCode.BindingContext = _vm.ExpenseChargeCode;
            _pickerChargeCode.SelectionChanged += _pickerChargeCode_SelectionChanged;

            //         _labelHeading.Text = "ADD EXPENSE";
            //_labelHeading.FontFamily = Device.OnPlatform("OpenSans-Bold", null, null);
            //_labelHeading.TextColor = asbestos;

            Label labelQuantity = new Label()
            {
                Content    = "QTY",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };

            _entryQuantity              = new TextBox();
            _entryQuantity.TextChanged += EntryQuantity_TextChanged;
            _entryQuantity.GotFocus    += textbox_GotFocus;     // dch rkl 11/22/2016 select full text on focus

            Label labelUoM = new Label()
            {
                Content    = "U/M",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };

            _entryUnitOfMeasure = new ComboBox();
            //_entryUnitOfMeasure.MaxLength = 4;
            //_entryUnitOfMeasure.GotFocus += textbox_GotFocus;        // dch rkl 11/22/2016 select full text on focus
            _entryUnitOfMeasure.ItemsSource       = _vm.UnitOfMeasureList;
            _entryUnitOfMeasure.DisplayMemberPath = "UnitOfMeasure";
            _entryUnitOfMeasure.SelectedValuePath = "UnitOfMeasure";


            Label labelUnitCost = new Label()
            {
                Content    = "Unit Cost",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };

            _entryUnitCost              = new TextBox();
            _entryUnitCost.TextChanged += EntryUnitCost_TextChanged;
            _entryUnitCost.GotFocus    += textbox_GotFocus;     // dch rkl 11/22/2016 select full text on focus

            _entryTotalCost           = new TextBox();
            _entryTotalCost.Text      = "0.00";
            _entryTotalCost.IsEnabled = false;

            _entryUnitPrice              = new TextBox();
            _entryUnitPrice.Text         = "0.00";
            _entryUnitPrice.TextChanged += EntryUnitPrice_TextChanged;
            _entryUnitPrice.GotFocus    += textbox_GotFocus;     // dch rkl 11/22/2016 select full text on focus

            _entryTotalPrice           = new TextBox();
            _entryTotalPrice.Text      = "";
            _entryTotalPrice.IsEnabled = false;

            _entryMarkupPercentage              = new TextBox();
            _entryMarkupPercentage.Text         = "0.00";
            _entryMarkupPercentage.TextChanged += EntryMarkupPercentage_TextChanged;
            _entryMarkupPercentage.GotFocus    += textbox_GotFocus;     // dch rkl 11/22/2016 select full text on focus

            _switchIsReimbursable = new CheckBox();
            //_switchIsReimbursable.IsToggled = _vm.ExpenseIsReimbursable;

            _switchIsChargeCustomer        = new CheckBox();
            _switchIsChargeCustomer.Click += _switchIsChargeCustomer_Checked;


            _editorDescription = new TextBox();
            _editorDescription.AcceptsReturn = true;
            _editorDescription.TextWrapping  = TextWrapping.WrapWithOverflow;
            //_editorDescription.Text = _vm.ExpenseBillingDescription;
            if (_switchIsChargeCustomer.IsChecked == false)
            {
                _entryMarkupPercentage.IsEnabled = false;
                _editorDescription.IsEnabled     = false;
                _entryTotalPrice.Text            = "0.00";
            }
            else
            {
                _entryMarkupPercentage.IsEnabled = true;
                _editorDescription.IsEnabled     = true;
            }

            _buttonAddEditExpense            = new Button();
            _buttonAddEditExpense.Click     += ButtonAddEditExpense_Click;
            _buttonAddEditExpense.FontWeight = FontWeights.Bold;
            TextBlock addEditExpenseText = new TextBlock();

            addEditExpenseText.Text                   = "ADD";
            _buttonAddEditExpense.Background          = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2ECC71"));
            addEditExpenseText.Foreground             = new SolidColorBrush(Colors.White);
            _buttonAddEditExpense.HorizontalAlignment = HorizontalAlignment.Stretch;
            _buttonAddEditExpense.Margin              = new Thickness(10);
            _buttonAddEditExpense.Content             = addEditExpenseText;
            _buttonAddEditExpense.Height              = 40;  // dch rkl 11/22/2016
            _buttonAddEditExpense.Width               = 175; // dch rkl 11/22/2016

            _buttonCancel        = new Button();
            _buttonCancel.Click += ButtonCancel_Click;
            TextBlock buttonCancelText = new TextBlock();

            buttonCancelText.Text             = "CANCEL";
            buttonCancelText.FontWeight       = FontWeights.Bold;
            buttonCancelText.Foreground       = new SolidColorBrush(Colors.White);
            _buttonCancel.Background          = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E74C3C"));
            _buttonCancel.HorizontalAlignment = HorizontalAlignment.Stretch;
            _buttonCancel.Margin  = new Thickness(10);
            _buttonCancel.Content = buttonCancelText;
            _buttonCancel.Height  = 40;  // dch rkl 11/22/2016
            _buttonCancel.Width   = 175; // dch rkl 11/22/2016

            // dch rkl 10/14/2016 When updating, add option to delete expense, only if it is in the JT_TransactionImportDetail table
            _buttonDelete        = new Button();
            _buttonDelete.Click += ButtonDelete_Click;
            TextBlock buttonDeleteText = new TextBlock();

            buttonDeleteText.Text             = "DELETE";
            buttonDeleteText.FontWeight       = FontWeights.Bold;
            buttonDeleteText.Foreground       = new SolidColorBrush(Colors.White);
            _buttonDelete.Background          = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E74C3C"));
            _buttonDelete.HorizontalAlignment = HorizontalAlignment.Stretch;
            _buttonDelete.Margin  = new Thickness(10);
            _buttonDelete.Content = buttonDeleteText;
            _buttonDelete.Height  = 40;  // dch rkl 11/22/2016
            _buttonDelete.Width   = 175; // dch rkl 11/22/2016
            if (_vm.ExpenseId == 0)
            {
                _buttonDelete.Visibility = Visibility.Hidden;
            }

            if (_vm.ExpenseId > 0)
            {
                addEditExpenseText.Text = "UPDATE";

                //u/m addition
                try { _entryUnitOfMeasure.SelectedValue = _vm.ExpenseUnitOfMeasure; }
                catch (Exception ex) { }

                /*if (_entryUnitOfMeasure.SelectedIndex == -1 && _vm.PartToEdit.PartItemCode.Trim().Substring(0, 1) == "*" || _vm.PartToEdit.ItemType == "4" || _vm.PartToEdit.ItemType == "5")
                 * {
                 *  AddItemToUMList(_vm.PartToEdit.UnitOfMeasure);
                 * }*/

                for (int i = 0; i < _pickerCategory.Items.Count; i++)
                {
                    // dch rkl 10/14/2016 Show Code + Description in Expense Category Dropdown BEGIN
                    string pickerCategory = "";
                    try { pickerCategory = _pickerCategory.Items[i].ToString().Split(' ')[0].ToString().Trim(); }
                    catch (Exception ex) { }
                    //if ((string)_pickerCategory.Items[i] == _vm.ExpenseCategory)
                    if (pickerCategory == _vm.ExpenseCategory)
                    // dch rkl 10/14/2016 Show Code + Description in Expense Category Dropdown END
                    {
                        _pickerCategory.SelectedIndex = i;
                        break;
                    }
                }

                for (int i = 0; i < _pickerChargeCode.Items.Count; i++)
                {
                    // dch rkl 10/14/2016 Show Code + Description in Charge Code Dropdown BEGIN
                    string pickerChargeCode = "";
                    try { pickerChargeCode = _pickerChargeCode.Items[i].ToString().Split(' ')[0].ToString().Trim(); }
                    catch (Exception ex) { }
                    //if ((string)_pickerChargeCode.Items[i] == _vm.ExpenseChargeCode)
                    if (pickerChargeCode == _vm.ExpenseChargeCode)
                    // dch rkl 10/14/2016 Show Code + Description in Charge Code Dropdown END
                    {
                        _pickerChargeCode.SelectedIndex = i;
                        break;
                    }
                }
                // get our ci_options first
                _ciOptions = App.Database.GetCIOptions();
                string quantityFormatString = String.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInQty, "}");
                string umFormatString       = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInUM, "}");
                string costFormatString     = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInCost, "}");
                string priceFormatString    = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInPrice, "}");

                _entryQuantity.Text             = string.Format(quantityFormatString, _vm.ExpenseQuantity); //_vm.ExpenseQuantity.ToString();
                _entryUnitOfMeasure.Text        = _vm.ExpenseUnitOfMeasure;
                _entryUnitCost.Text             = string.Format(costFormatString, _vm.ExpenseUnitCost);     // _vm.ExpenseUnitCost.ToString();
                _entryUnitPrice.Text            = string.Format(priceFormatString, _vm.ExpenseUnitPrice);   // _vm.ExpenseUnitPrice.ToString();
                _switchIsReimbursable.IsChecked = _vm.ExpenseIsReimbursable;
                _editorDescription.Text         = _vm.ExpenseBillingDescription;
            }

            Grid topGrid = new Grid();

            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });                                                                         // dch rkl 10/12/2016 service ticket row 0
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });                                                                         // date 1
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });                                                                         // expense category 2
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });                                                                         // charge code 3
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });                                                                         // quantity and U/M 4
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });                                                                         // unit cost and total cost 5
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });                                                                         // unit price and total price 6
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });                                                                         // markup 7
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });                                                                         // reimburse employee 8
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });                                                                         // charge customer 9
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = GridLength.Auto
            });                                                                             // dch rkl 10/12/1016 billing description label 10
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(150)
            });                                                                             // description 11
            topGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(200, GridUnitType.Pixel)
            });
            topGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(100, GridUnitType.Pixel)
            });
            topGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(150, GridUnitType.Pixel)
            });
            topGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(100, GridUnitType.Pixel)
            });

            // dch rkl 10/12/2016 Make all labels lower case instead of upper case

            // dch rkl 10/12/2016 display Service Ticket at top. BEGIN
            Label labelSvcTicket = new Label()
            {
                Content    = "Service Ticket",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };
            Label labelSvcTicketData = new Label()
            {
                Content    = workticket,
                Foreground = asbestos
            };

            topGrid.Children.Add(labelSvcTicket);
            Grid.SetColumn(labelSvcTicket, 0);
            Grid.SetRow(labelSvcTicket, 0);
            topGrid.Children.Add(labelSvcTicketData);
            Grid.SetColumn(labelSvcTicketData, 1);
            Grid.SetRow(labelSvcTicketData, 0);
            Grid.SetColumnSpan(labelSvcTicketData, 3);
            // dch rkl 10/12/2016 display Service Ticket at top. END

            Label labelDate = new Label()
            {
                Content    = "Date",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };

            topGrid.Children.Add(labelDate);
            Grid.SetColumn(labelDate, 0);
            Grid.SetRow(labelDate, 1);
            topGrid.Children.Add(_datePickerExpenseDate);
            Grid.SetColumn(_datePickerExpenseDate, 1);
            Grid.SetRow(_datePickerExpenseDate, 1);
            Grid.SetColumnSpan(_datePickerExpenseDate, 3);

            Label labelExpenseCat = new Label()
            {
                Content    = "Expense Category",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };

            topGrid.Children.Add(labelExpenseCat);
            Grid.SetColumn(labelExpenseCat, 0);
            Grid.SetRow(labelExpenseCat, 2);
            topGrid.Children.Add(_pickerCategory);
            Grid.SetColumn(_pickerCategory, 1);
            Grid.SetRow(_pickerCategory, 2);
            Grid.SetColumnSpan(_pickerCategory, 3);

            Label labelChargeCodeTitle = new Label()
            {
                Content    = "Charge Code",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };

            topGrid.Children.Add(labelChargeCodeTitle);
            Grid.SetColumn(labelChargeCodeTitle, 0);
            Grid.SetRow(labelChargeCodeTitle, 3);
            topGrid.Children.Add(_pickerChargeCode);
            Grid.SetColumn(_pickerChargeCode, 1);
            Grid.SetRow(_pickerChargeCode, 3);
            Grid.SetColumnSpan(_pickerChargeCode, 3);

            Label labelQuantityTitle = new Label()
            {
                Content    = "Quantity",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };

            topGrid.Children.Add(labelQuantityTitle);
            Grid.SetColumn(labelQuantityTitle, 0);
            Grid.SetRow(labelQuantityTitle, 4);
            topGrid.Children.Add(_entryQuantity);
            Grid.SetColumn(_entryQuantity, 1);
            Grid.SetRow(_entryQuantity, 4);
            topGrid.Children.Add(labelUoM);
            Grid.SetColumn(labelUoM, 2);
            Grid.SetRow(labelUoM, 4);
            topGrid.Children.Add(_entryUnitOfMeasure);
            Grid.SetColumn(_entryUnitOfMeasure, 3);
            Grid.SetRow(_entryUnitOfMeasure, 4);

            topGrid.Children.Add(labelUnitCost);
            Grid.SetColumn(labelUnitCost, 0);
            Grid.SetRow(labelUnitCost, 5);
            topGrid.Children.Add(_entryUnitCost);
            Grid.SetColumn(_entryUnitCost, 1);
            Grid.SetRow(_entryUnitCost, 5);

            Label labelTotalCost = new Label()
            {
                Content    = "Total Cost",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };

            topGrid.Children.Add(labelTotalCost);
            Grid.SetColumn(labelTotalCost, 2);
            Grid.SetRow(labelTotalCost, 5);
            topGrid.Children.Add(_entryTotalCost);
            Grid.SetColumn(_entryTotalCost, 3);
            Grid.SetRow(_entryTotalCost, 5);

            Label labelUnitPrice = new Label()
            {
                Content    = "Unit Price",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };

            topGrid.Children.Add(labelUnitPrice);
            Grid.SetColumn(labelUnitPrice, 0);
            Grid.SetRow(labelUnitPrice, 6);
            topGrid.Children.Add(_entryUnitPrice);
            Grid.SetColumn(_entryUnitPrice, 1);
            Grid.SetRow(_entryUnitPrice, 6);

            Label labelTotalPrice = new Label()
            {
                Content    = "Billing Amount",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };

            topGrid.Children.Add(labelTotalPrice);
            Grid.SetColumn(labelTotalPrice, 2);
            Grid.SetRow(labelTotalPrice, 6);
            topGrid.Children.Add(_entryTotalPrice);
            Grid.SetColumn(_entryTotalPrice, 3);
            Grid.SetRow(_entryTotalPrice, 6);

            Label labelMarkup = new Label()
            {
                Content    = "Markup",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };

            topGrid.Children.Add(labelMarkup);
            Grid.SetColumn(labelMarkup, 0);
            Grid.SetRow(labelMarkup, 7);
            topGrid.Children.Add(_entryMarkupPercentage);
            Grid.SetColumn(_entryMarkupPercentage, 1);
            Grid.SetRow(_entryMarkupPercentage, 7);

            Label labelMarkUpPercent = new Label()
            {
                Content    = "%",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };

            topGrid.Children.Add(labelMarkUpPercent);
            Grid.SetColumn(labelMarkUpPercent, 2);
            Grid.SetRow(labelMarkUpPercent, 7);

            Label labelReimbursableHdg = new Label
            {
                Content    = "Reimburse Employee",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };

            topGrid.Children.Add(labelReimbursableHdg);
            Grid.SetColumn(labelReimbursableHdg, 0);
            Grid.SetRow(labelReimbursableHdg, 8);
            Grid.SetColumnSpan(labelReimbursableHdg, 2);
            topGrid.Children.Add(_switchIsReimbursable);
            Grid.SetColumn(_switchIsReimbursable, 2);
            Grid.SetRow(_switchIsReimbursable, 8);

            Label labelChargeCustomer = new Label
            {
                Content    = "Charge Customer",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };

            topGrid.Children.Add(labelChargeCustomer);
            Grid.SetColumn(labelChargeCustomer, 0);
            Grid.SetRow(labelChargeCustomer, 9);
            Grid.SetColumnSpan(labelChargeCustomer, 2);
            topGrid.Children.Add(_switchIsChargeCustomer);
            Grid.SetColumn(_switchIsChargeCustomer, 2);
            Grid.SetRow(_switchIsChargeCustomer, 9);

            Label labelDescription = new Label
            {
                Content    = "Billing Description",
                FontWeight = FontWeights.Bold,
                Foreground = asbestos
            };

            topGrid.Children.Add(labelDescription);
            Grid.SetColumn(labelDescription, 0);
            Grid.SetRow(labelDescription, 10);
            Grid.SetColumnSpan(labelDescription, 4);

            topGrid.Children.Add(_editorDescription);
            Grid.SetColumn(_editorDescription, 0);
            Grid.SetRow(_editorDescription, 11);
            Grid.SetColumnSpan(_editorDescription, 4);

            gridMain.Children.Add(new StackPanel
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                Children            =
                {
                    titleLayout,
                    topGrid,
                    new StackPanel
                    {
                        Margin              = new Thickness(30),
                        Orientation         = Orientation.Horizontal,
                        HorizontalAlignment = HorizontalAlignment.Stretch,
                        Children            =
                        {
                            _buttonAddEditExpense,
                            _buttonCancel,
                            _buttonDelete           // dch rkl 10/14/2016
                        }
                    }
                }
            });
        }
コード例 #11
0
        protected void SetPageLayout()
        {
            // Set the page title.
            switch (_pageMode)
            {
            case PageMode.Add:
                _labelTitle.Content = "ADD PART";
                break;

            case PageMode.Edit:
                _labelTitle.Content = "EDIT PART";
                break;

            default:
                _labelTitle.Content = "ADD/EDIT PART";
                break;
            }
            // get our ci_options first
            _ciOptions           = App.Database.GetCIOptions();
            quantityFormatString = String.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInQty, "}");
            umFormatString       = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInUM, "}");
            costFormatString     = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInCost, "}");
            priceFormatString    = string.Concat("{0:F", _ciOptions.NumberOfDecimalPlacesInPrice, "}");

            gridMain.DataContext = _vm.PartToEdit;

            SolidColorBrush asbestos = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#7f8C8d"));

            // Set Bindings
            _labelPartNumber.SetBinding(ContentProperty, "PartItemCode");
            _labelPartNumber.Text = _vm.PartToEdit.PartItemCode;

            var ciOptions = App.Database.GetCIOptions();

            _labelPartDescription.SetBinding(ContentProperty, "PartItemCodeDescription");
            _labelPartDescription.Text = _vm.PartToEdit.PartItemCodeDescription;

            _pickerWarehouse.ItemsSource = _vm.WarehouseList;
            try { _pickerWarehouse.SelectedValue = _vm.PartToEdit.Warehouse; } catch { }

            if (_pageMode == PageMode.Edit)
            {
                _entryQuantity.Text = _vm.PartToEdit.Quantity.ToString();
            }
            else
            {
                _entryQuantity.Text = "1";
            }

            // dch rkl 01/23/2017 Change U/M to picklist
            _pickerUnitOfMeasure.ItemsSource = _vm.UnitOfMeasureList;
            try { _pickerUnitOfMeasure.SelectedValue = _vm.PartToEdit.UnitOfMeasure; }
            catch (Exception ex) { }
            if (_pickerUnitOfMeasure.SelectedIndex == -1 && _vm.PartToEdit.PartItemCode.Trim().Substring(0, 1) == "*" || _vm.PartToEdit.ItemType == "4" || _vm.PartToEdit.ItemType == "5")
            {
                AddItemToUMList(_vm.PartToEdit.UnitOfMeasure);
            }
            //_entryUnitOfMeasure.SetBinding(ContentProperty, "UnitOfMeasure");
            //_entryUnitOfMeasure.Text = _vm.PartToEdit.UnitOfMeasure;
            //_entryUnitOfMeasure.Style = (Style)this.Resources["styleUOM"];

            // dch rkl 12/05/2016 if qty shipped > 0, cannot edit warehouse or u/m
            if (_vm.PartToEdit.QuantityShipped > 0)
            {
                _pickerWarehouse.IsEnabled = false;

                // dch rkl 01/23/2017 Change U/M to picklist
                //_entryUnitOfMeasure.IsEnabled = false;
                _pickerUnitOfMeasure.IsEnabled = false;
            }

            // dch rkl 11/23/2016 If Edit Mode, and a Quantity has been entered, disable U/M
            if (_pageMode == PageMode.Edit && _vm.PartToEdit.Quantity != 0)
            {
                // dch rkl 01/23/2017 Change U/M to picklist
                //_entryUnitOfMeasure.IsEnabled = false;
                _pickerUnitOfMeasure.IsEnabled = false;
            }

            _entryUnitCost.Text = _vm.PartToEdit.UnitCost.ToString("C2");

            // dch rkl 11/23/2016 if misc part, allow entry of unit cost
            if (_vm.PartToEdit.PartItemCode.Trim().Substring(0, 1) == "*" || _vm.PartToEdit.ItemType == "4" || _vm.PartToEdit.ItemType == "5")
            {
                _entryUnitCost.IsEnabled = true;
                // dch rkl 01/23/2017 if miscellaneous, allow entry of U/M
                _pickerUnitOfMeasure.IsEditable = true;
            }
            else
            {
                _entryUnitCost.IsEnabled = false;
                // dch rkl 01/23/2017 if miscellaneous, allow entry of U/M
                _pickerUnitOfMeasure.IsEditable = false;
            }

            // dch rkl 01/18/2017 If not chargeable, set Unit Price and Ext Price to zero.
            if (_vm.PartToEdit.IsChargeable)
            {
                //_entryUnitPrice.Text = _vm.PartToEdit.UnitPrice.ToString("C2");
                _entryUnitPrice.Text = string.Format(priceFormatString, _vm.PartToEdit.UnitPrice);
                if (_pageMode == PageMode.Edit)
                {
                    _labelExtensionPrice.Content = string.Format(priceFormatString, (_vm.PartToEdit.UnitPrice * _vm.PartToEdit.Quantity));
                    //(_vm.PartToEdit.UnitPrice * _vm.PartToEdit.Quantity).ToString("C2"); }
                }
                else
                {
                    _labelExtensionPrice.Content = string.Format(priceFormatString, (_vm.PartToEdit.UnitPrice * 1));
                    //(_vm.PartToEdit.UnitPrice * 1).ToString("C2");
                }
            }
            else
            {
                _labelExtensionPrice.Content = string.Format(priceFormatString, 0);
                _entryUnitPrice.Text         = string.Format(priceFormatString, 0);
            }

            _entryComments.SetBinding(ContentProperty, "Comment");
            _entryComments.Style = (Style)this.Resources["styleComments"];
            _entryComments.Text  = _vm.PartToEdit.Comment;

            if (_pageMode == PageMode.Edit)
            {
                _switchIsChargeable.SetBinding(CheckBox.IsCheckedProperty, "IsChargeable");
                _switchIsPrintable.SetBinding(CheckBox.IsCheckedProperty, "IsPrintable");
                _switchIsPurchased.SetBinding(CheckBox.IsCheckedProperty, "IsPurchased");
                _switchIsOverhead.SetBinding(CheckBox.IsCheckedProperty, "IsOverhead");
            }

            // dch rkl 11/21/2016 if part is purchased, do not allow editing of quantity
            if (_vm.PartToEdit.IsPurchased)
            {
                _entryQuantity.IsEnabled = false;
            }
            else
            {
                _entryQuantity.IsEnabled = true;
            }

            // dch rkl 11/22/2016 if chargeable is checked, allow unit price to be updated.
            // If chargeable is not checked, unit price cannot be updated.
            if (_vm.PartToEdit.IsChargeable)
            {
                _entryUnitPrice.IsEnabled = true;
            }
            else
            {
                _entryUnitPrice.IsEnabled = false;
                _entryUnitPrice.Text      = string.Format(priceFormatString, 0);
            }

            // dch rkl 11/23/2016 if misc part, hide warehouse dropdown
            bool bShowWhse = true;

            if (_vm.PartToEdit.PartItemCode.Trim().Substring(0, 1) == "*" || _vm.PartToEdit.ItemType == "4" || _vm.PartToEdit.ItemType == "5")
            {
                bShowWhse = false;
            }
            if (bShowWhse)
            {
                _pickerWarehouse.Visibility = Visibility.Visible;
                labelWarehouse.Visibility   = Visibility.Visible;
            }
            else
            {
                _pickerWarehouse.Visibility = Visibility.Hidden;
                labelWarehouse.Visibility   = Visibility.Hidden;
            }

            // dch rkl 01/13/2017 if extended description exists, display button to view/edit it BEGIN
            if (_vm.ExtendedDescriptionKey > 0 && _vm.ExtendedDescriptionText.Trim().Length > 0)
            {
                _buttonExtdDesc.Visibility = Visibility.Visible;
            }
            else
            {
                _buttonExtdDesc.Visibility = Visibility.Hidden;
            }
            // dch rkl 01/13/2017 if extended description exists, display button to view/edit it END

            switch (_pageMode)
            {
            case PageMode.Add:
                buttonAddPartText.Text = "ADD";
                break;

            case PageMode.Edit:
                buttonAddPartText.Text = "UPDATE";
                break;
            }

            if (_pageMode == PageMode.Add)
            {
                _buttonDeletePart.Visibility = Visibility.Hidden;
            }
            else
            {
                _buttonDeletePart.Visibility = Visibility.Visible;
            }

            // dch rkl 01/23/2017 If SO_SalesOrderDetail.JT158_WTBillFlag is set to "R" or "B", do not allow edit of the part
            int iSOLineKey;

            int.TryParse(_vm.PartToEdit.SoLineKey, out iSOLineKey);
            if (_vm.PartToEdit.SoLineKey != null)
            {
                if (iSOLineKey > 0)
                {
                    List <SO_SalesOrderDetail> lsSODtl = App.Database.GetSalesOrderDetails(_vm.WorkTicket.SalesOrderNo);
                    SO_SalesOrderDetail        soDtl   = lsSODtl.FirstOrDefault(s => s.LineKey == _vm.PartToEdit.SoLineKey);
                    if (soDtl != null && soDtl.JT158_WTBillFlag != null && (soDtl.JT158_WTBillFlag == "R" || soDtl.JT158_WTBillFlag == "B"))
                    {
                        _buttonAddPart.Visibility    = Visibility.Hidden;
                        _buttonDeletePart.Visibility = Visibility.Hidden;
                    }
                }
            }

            // dch rkl 02/03/2017 Do not allow existing parts to be deleted
            if (iSOLineKey > 0)
            {
                _buttonDeletePart.Visibility = Visibility.Hidden;
            }
        }