public HistoryPageViewModel(string formattedTicketNumber) { _TicketNumber = formattedTicketNumber; _workTicket = App.Database.GetWorkTicket2(formattedTicketNumber); _history = new List <App_History>(); CI_Item item = App.Database.GetItemFromDB(_workTicket.DtlRepairItemCode); _item = item; JT_EquipmentAsset equipmentAsset = App.Database.GetEquipmentAsset(_workTicket.DtlRepairItemCode); //get any possible work tickets and associated work tickets List <JT_WorkTicket> workTickets = App.Database.GetWorkTickets(_workTicket.DtlRepairItemCode, _workTicket.DtlMfgSerialNo); foreach (var workTicket in workTickets) { List <JT_Transaction> transactionCode = App.Database.GetTransactions(workTicket.SalesOrderNo, workTicket.WTNumber, workTicket.WTStep); List <JT_TransactionHistory> transactionHistoryCode = App.Database.GetTransactionHistory(workTicket.SalesOrderNo, workTicket.WTNumber, workTicket.WTStep); JT_ServiceAgreementHeader serviceAgreementHeader; JT_ServiceAgreementDetail serviceAgreementDetail; if (equipmentAsset != null && equipmentAsset.ContractCode != null) { serviceAgreementHeader = App.Database.GetServiceAgreementHeader(equipmentAsset.ContractCode); serviceAgreementDetail = App.Database.GetServiceAgreementDetail(equipmentAsset.ContractCode); } else { serviceAgreementHeader = new JT_ServiceAgreementHeader(); serviceAgreementDetail = new JT_ServiceAgreementDetail(); } foreach (var transaction in transactionCode) { JT_LaborText laborText = App.Database.GetLaborText(transaction); var history = new App_History( _workTicket, item, equipmentAsset, serviceAgreementHeader, serviceAgreementDetail, transaction, laborText); _history.Add(history); } foreach (var transaction in transactionHistoryCode) { JT_LaborText laborText = App.Database.GetLaborText(transaction); var history = new App_History( _workTicket, item, equipmentAsset, serviceAgreementHeader, serviceAgreementDetail, transaction, laborText); _history.Add(history); } } _history = _history.OrderBy(x => x.TransactionDate).ToList(); }
public App_Item GetItem(string itemCode, string warehouseCode, string manufacturerSerialNumber) { App_Item appItem = null; CI_Item item = null; IM_ItemWarehouse itemWarehouse = null; JT_EquipmentAsset equipmentAsset = null; lock (_locker) { item = GetItemFromDB(itemCode); itemWarehouse = GetItemWarehouseFromDB(itemCode, warehouseCode); if ((item != null) && (itemWarehouse != null)) { if (manufacturerSerialNumber != null) { equipmentAsset = GetEquipmentAsset(item.ItemCode, manufacturerSerialNumber); } appItem = new App_Item(item, itemWarehouse, equipmentAsset); } } return appItem; }
private void ButtonSearch_Click(object sender, RoutedEventArgs e) { if (searchBarText.Text == null || searchBarText.Text.Length == 0) { _vm.FilterItemList(null); } else { // dch rkl 11/15/2016 add miscellaneous part if (searchBarText.Text.Trim().Substring(0, 1) == "*") { CI_Item ciItem = new CI_Item(); ciItem.ItemCode = searchBarText.Text.Trim(); ciItem.ItemCodeDesc = ""; ciItem.StandardUnitOfMeasure = "EACH"; IM_ItemWarehouse imWhse = new IM_ItemWarehouse(); JT_EquipmentAsset jtAsst = new JT_EquipmentAsset(); App_Item appItem = new App_Item(ciItem, imWhse, jtAsst); App_RepairPart part = new App_RepairPart(appItem, _vm.WorkTicket); ContentControl contentArea = (ContentControl)this.Parent; contentArea.Content = new PartsEditPage(_vm.WorkTicket, part, PartsEditPage.PageMode.Add, _scheduledAppointment); } else { _vm.FilterItemList(searchBarText.Text); } } }
protected JT_EquipmentAsset GetEquipmentAsset(string itemCode, string manufacturerSerialNumber) { JT_EquipmentAsset equipmentAsset = _database.Table<JT_EquipmentAsset>().Where( ea => (ea.ItemCode == itemCode) && (ea.MfgSerialNo == manufacturerSerialNumber) ).FirstOrDefault(); return equipmentAsset; }
public App_WorkTicket GetWorkTicket(App_ScheduledAppointment scheduledAppointment) { JT_WorkTicket workTicket = null; JT_WorkTicket workTicketStepZero = null; JT_WorkTicketClass workTicketClass = null; CI_Item repairItem = null; JT_EquipmentAsset equipmentAsset = null; App_ServiceAgreement serviceAgreement = null; JT_ClassificationCode problemCode = null; JT_ClassificationCode exceptionCode = null; lock (_locker) { if (scheduledAppointment != null) { workTicket = _database.Table <JT_WorkTicket>().Where( wt => (wt.SalesOrderNo == scheduledAppointment.SalesOrderNumber) && (wt.WTNumber == scheduledAppointment.WorkTicketNumber) && (wt.WTStep == scheduledAppointment.WorkTicketStep) ).FirstOrDefault(); // dch rkl 11/30/2016 If JT_WorkTicket.HdrWTClass is null, populate it from SO_SalesOrderHeader.JT158_WTClass if (workTicket.HdrWtClass == null) { SO_SalesOrderHeader soHeader = _database.Table <SO_SalesOrderHeader>().Where( soh => (soh.SalesOrderNo == workTicket.SalesOrderNo)).FirstOrDefault(); if (soHeader != null) { workTicket.HdrWtClass = soHeader.JT158_WTClass; } } workTicketStepZero = _database.Table <JT_WorkTicket>().Where( wt => (wt.SalesOrderNo == scheduledAppointment.SalesOrderNumber) && (wt.WTNumber == scheduledAppointment.WorkTicketNumber) && (wt.WTStep == "000") ).FirstOrDefault(); workTicketClass = _database.Table <JT_WorkTicketClass>().Where( wtc => (workTicket.HdrWtClass == wtc.WorkTicketClass) ).FirstOrDefault(); repairItem = GetItemFromDB(workTicket.DtlRepairItemCode); if (workTicket.DtlMfgSerialNo != null) { equipmentAsset = _database.Table <JT_EquipmentAsset> ().Where( ea => (ea.ItemCode == repairItem.ItemCode) && (ea.MfgSerialNo == workTicket.DtlMfgSerialNo) ).FirstOrDefault(); } else { equipmentAsset = new JT_EquipmentAsset(); } serviceAgreement = GetServiceAgreement(workTicketStepZero); //serviceAgreement = GetServiceAgreement(workTicket); problemCode = _database.Table <JT_ClassificationCode>().Where( pc => (pc.ClassificationCode == workTicket.DtlProblemCode) ).FirstOrDefault(); exceptionCode = _database.Table <JT_ClassificationCode>().Where( pc => (pc.ClassificationCode == workTicket.DtlCoverageExceptionCode) ).FirstOrDefault(); } } return(new App_WorkTicket(workTicket, workTicketStepZero, workTicketClass, new App_RepairItem(repairItem, equipmentAsset), serviceAgreement, problemCode, exceptionCode)); }
// dch rkl 11/22/2016 Add filter by parts or labor //public HistoryPageViewModel (string formattedTicketNumber) public HistoryPageViewModel(string formattedTicketNumber, string partsLaborAll) { // dch rkl 12/07/2016 catch exception try { _TicketNumber = formattedTicketNumber; _workTicket = App.Database.GetWorkTicket2(formattedTicketNumber); _history = new List <App_History>(); CI_Item item = App.Database.GetItemFromDB(_workTicket.DtlRepairItemCode); _item = item; JT_EquipmentAsset equipmentAsset = App.Database.GetEquipmentAsset(_workTicket.DtlRepairItemCode); //get any possible work tickets and associated work tickets List <JT_WorkTicket> workTickets = App.Database.GetWorkTickets(_workTicket.DtlRepairItemCode, _workTicket.DtlMfgSerialNo); //, _workTicket.SalesOrderNo); foreach (var workTicket in workTickets) { List <JT_Transaction> transactionCode = App.Database.GetTransactions(workTicket.SalesOrderNo, workTicket.WTNumber, workTicket.WTStep); List <JT_TransactionHistory> transactionHistoryCode = App.Database.GetTransactionHistory(workTicket.SalesOrderNo, workTicket.WTNumber, workTicket.WTStep); //List<JT_Transaction> transactionCode = App.Database.GetTransactions(workTicket.SalesOrderNo); JT_ServiceAgreementHeader serviceAgreementHeader; JT_ServiceAgreementDetail serviceAgreementDetail; if (equipmentAsset != null && equipmentAsset.ContractCode != null) { serviceAgreementHeader = App.Database.GetServiceAgreementHeader(equipmentAsset.ContractCode); serviceAgreementDetail = App.Database.GetServiceAgreementDetail(equipmentAsset.ContractCode); } else { serviceAgreementHeader = new JT_ServiceAgreementHeader(); serviceAgreementDetail = new JT_ServiceAgreementDetail(); } foreach (var transaction in transactionCode) { JT_LaborText laborText = App.Database.GetLaborText(transaction); var history = new App_History( _workTicket, item, equipmentAsset, serviceAgreementHeader, serviceAgreementDetail, transaction, laborText); // dch rkl 11/22/2016 Add filter by parts or labor BEGIN if ((partsLaborAll == "L" && transaction.RecordType == "LD") || (partsLaborAll == "P" && transaction.RecordType != "LD") || partsLaborAll == "A" || partsLaborAll == "") { // dch rkl 01/16/2017 only if qty used <> 0 if (transaction.QuantityUsed != 0) { _history.Add(history); } //_history.Add(history); } //_history.Add(history); // dch rkl 11/22/2016 Add filter by parts or labor END } foreach (var transaction in transactionHistoryCode) { JT_LaborText laborText = App.Database.GetLaborText(transaction); var history = new App_History( _workTicket, item, equipmentAsset, serviceAgreementHeader, serviceAgreementDetail, transaction, laborText); // dch rkl 11/22/2016 Add filter by parts or labor BEGIN if ((partsLaborAll == "L" && transaction.RecordType == "LD") || (partsLaborAll == "P" && transaction.RecordType != "LD") || partsLaborAll == "A" || partsLaborAll == "") { // dch rkl 01/16/2017 only if qty used <> 0 if (transaction.QuantityUsed != 0) { _history.Add(history); } //_history.Add(history); } //_history.Add(history); // dch rkl 11/22/2016 Add filter by parts or labor BEGIN } } } catch (Exception ex) { // dch rkl 12/07/2016 Log Error ErrorReporting errorReporting = new ErrorReporting(); errorReporting.sendException(ex, "TechDashboard.HistoryPageViewModel()"); } _history = _history.OrderBy(x => x.TransactionDate).ToList(); }
// dch rkl 01/16/2017 Return List of Previously Used Serial Numbers for this Mfg Serial Nbr / Part Nbr private List <LotQavl> GetHistParts(string partNbr) { List <LotQavl> lsLotQ = new List <LotQavl>(); List <App_History> lsHistory = new List <App_History>(); CI_Item item = App.Database.GetItemFromDB(_workTicket.DtlRepairItemCode); JT_EquipmentAsset equipmentAsset = App.Database.GetEquipmentAsset(_workTicket.DtlRepairItemCode); //get any possible work tickets and associated work tickets List <JT_WorkTicket> workTickets = App.Database.GetWorkTickets(_workTicket.DtlRepairItemCode, _workTicket.DtlMfgSerialNo); //, _workTicket.SalesOrderNo); foreach (var workTicket in workTickets) { List <JT_Transaction> transactionCode = App.Database.GetTransactions(workTicket.SalesOrderNo, workTicket.WTNumber, workTicket.WTStep); List <JT_TransactionHistory> transactionHistoryCode = App.Database.GetTransactionHistory(workTicket.SalesOrderNo, workTicket.WTNumber, workTicket.WTStep); foreach (var transaction in transactionCode) { if (transaction.RecordType != "LD" && transaction.ItemCode != null && transaction.ItemCode == partNbr) { if (transaction.QuantityUsed != 0) { // Do not add duplicate lot numbers LotQavl exists = lsLotQ.Where(p => p.LotNo == transaction.LotSerialNo).FirstOrDefault(); // dch rkl 01/20/2017 include unit cost //if (exists == null) { lsLotQ.Add(new LotQavl(transaction.LotSerialNo, 0, 0)); } decimal UnitCost = 0; if (transaction.UnitCost != null) { decimal.TryParse(transaction.UnitCost, out UnitCost); } if (exists == null) { lsLotQ.Add(new LotQavl(transaction.LotSerialNo, 0, 0, UnitCost)); } } } } foreach (var transaction in transactionHistoryCode) { if (transaction.RecordType != "LD" && transaction.ItemCode != null && transaction.ItemCode == partNbr) { if (transaction.QuantityUsed != 0) { // Do not add duplicate lot numbers LotQavl exists = lsLotQ.Where(p => p.LotNo == transaction.LotSerialNo).FirstOrDefault(); // dch rkl 01/20/2017 include unit cost //if (exists == null) { lsLotQ.Add(new LotQavl(transaction.LotSerialNo, 0, 0)); } decimal UnitCost = 0; if (transaction.UnitCost != null) { decimal.TryParse(transaction.UnitCost, out UnitCost); } if (exists == null) { lsLotQ.Add(new LotQavl(transaction.LotSerialNo, 0, 0, UnitCost)); } } } } } return(lsLotQ); }