protected App_ScheduledAppointment RetrieveCurrentScheduledAppointment(JT_Technician technician) { JT_TechnicianScheduleDetail currentDetail = null; SO_SalesOrderHeader salesOrderHeader = null; lock (_locker) { if ((technician != null) && (IsClockedIn())) { currentDetail = _database.Table <JT_TechnicianScheduleDetail>().Where( sd => (sd.SalesOrderNo == technician.CurrentSalesOrderNo) && (sd.WTNumber == technician.CurrentWTNumber) && (sd.WTStep == technician.CurrentWTStep) ).FirstOrDefault(); salesOrderHeader = GetSalesOrderHeader(currentDetail); } if (currentDetail == null) { return(null); } else { // if we found it, it must really be current currentDetail.IsCurrent = true; return(new App_ScheduledAppointment(currentDetail, salesOrderHeader)); } } }
public App_ScheduledAppointment GetScheduledAppointment() { JT_TechnicianScheduleDetail scheduledDetail = GetTechnicianScheduleDetailFromDB().Where(x => x.IsCurrent).FirstOrDefault(); SO_SalesOrderHeader soHeader = GetSalesOrderHeader(scheduledDetail); return(new App_ScheduledAppointment(scheduledDetail, soHeader)); }
public App_Customer GetCustomerFromCurrentWorkTicket() { AR_Customer currentCustomer = null; lock (_locker) { SO_SalesOrderHeader salesOrderHeader = RetrieveSalesOrderHeaderFromCurrentWorkTicket(); if (salesOrderHeader != null) { currentCustomer = _database.Table <AR_Customer>().Where( c => c.CustomerNo == salesOrderHeader.CustomerNo ).FirstOrDefault(); } } if (currentCustomer == null) { return(null); } else { return(new App_Customer(currentCustomer)); } }
public App_WorkTicket GetCurrentWorkTicket() { App_WorkTicket currentWorkTicket = null; lock (_locker) { //App_CurrentSelectionData currentData = _database.Table<App_CurrentSelectionData>().FirstOrDefault(); //return _database.Table<JT_WorkTicket>().Where( // wt => (wt.SalesOrderNo == currentData.SalesOrderNo) && // (wt.WTNumber == currentData.WTNumber) && // (wt.WTStep == currentData.WTStep) // ).FirstOrDefault(); JT_TechnicianScheduleDetail scheduleDetail = RetrieveCurrentScheduleDetail(); if (scheduleDetail != null) { SO_SalesOrderHeader salesOrderHeader = GetSalesOrderHeader(scheduleDetail); if (salesOrderHeader != null) { App_ScheduledAppointment scheduledAppointment = new App_ScheduledAppointment(scheduleDetail, salesOrderHeader); currentWorkTicket = GetWorkTicket(scheduledAppointment); } } } return(currentWorkTicket); }
protected void SetDataItems() { _workTicket = App.Database.GetCurrentWorkTicket(); _salesOrderHeader = App.Database.RetrieveSalesOrderHeaderFromCurrentWorkTicket(); _customer = App.Database.GetCustomerFromCurrentWorkTicket(); _repairItem = App.Database.RetrieveRepairItemFromCurrentWorkTicket(); }
protected void SetDataItems() { // dch rkl 12/07/2016 catch exception try { _workTicket = App.Database.GetCurrentWorkTicket(); _salesOrderHeader = App.Database.RetrieveSalesOrderHeaderFromCurrentWorkTicket(); _customer = App.Database.GetCustomerFromCurrentWorkTicket(); _repairItem = App.Database.RetrieveRepairItemFromCurrentWorkTicket(); } catch (Exception ex) { // dch rkl 12/07/2016 Log Error ErrorReporting errorReporting = new ErrorReporting(); errorReporting.sendException(ex, "TechDashboard.RootPageViewModel.SetDataItems"); } }
protected SO_SalesOrderHeader GetSalesOrderHeader(JT_WorkTicket workTicket) { SO_SalesOrderHeader salesOrderHeader = null; lock (_locker) { if (workTicket != null) { salesOrderHeader = _database.Table <SO_SalesOrderHeader>().Where( so => (so.SalesOrderNo == workTicket.SalesOrderNo) ).FirstOrDefault(); } } return(salesOrderHeader); }
protected SO_SalesOrderHeader GetSalesOrderHeader(JT_TechnicianScheduleDetail scheduleDetail) { SO_SalesOrderHeader salesOrderHeader = null; lock (_locker) { if (scheduleDetail != null) { salesOrderHeader = _database.Table <SO_SalesOrderHeader>().Where( so => (so.SalesOrderNo == scheduleDetail.SalesOrderNo) ).FirstOrDefault(); } } return(salesOrderHeader); }
protected SO_SalesOrderHeader GetSalesOrderHeader(App_ScheduledAppointment scheduledAppointment) { SO_SalesOrderHeader salesOrderHeader = null; lock (_locker) { if (scheduledAppointment != null) { salesOrderHeader = _database.Table <SO_SalesOrderHeader>().Where( so => (so.SalesOrderNo == scheduledAppointment.SalesOrderNumber) ).FirstOrDefault(); } } return(salesOrderHeader); }
protected SO_ShipToAddress GetShipToAddress(SO_SalesOrderHeader salesOrderHeader) { SO_ShipToAddress returnData = null; if (salesOrderHeader != null) { lock (_locker) { returnData = _database.Table <SO_ShipToAddress>().Where( sta => ((sta.ARDivisionNo == salesOrderHeader.ARDivisionNo) && (sta.CustomerNo == salesOrderHeader.CustomerNo) && (sta.ShipToCode == salesOrderHeader.ShipToCode)) ).FirstOrDefault(); } } return(returnData); }
public SO_SalesOrderHeader RetrieveSalesOrderHeaderFromCurrentWorkTicket() { SO_SalesOrderHeader salesOrderHeader = null; lock (_locker) { JT_TechnicianScheduleDetail currentDetail = RetrieveCurrentScheduleDetail(); if (currentDetail != null) { salesOrderHeader = _database.Table <SO_SalesOrderHeader>().Where( so => so.SalesOrderNo == currentDetail.SalesOrderNo ).FirstOrDefault(); } } return(salesOrderHeader); }
public App_SalesOrder GetSalesOrder(App_ScheduledAppointment scheduledAppointment, App_Customer customer) { App_SalesOrder returnData = null; SO_SalesOrderHeader salesOrderHeader = null; SO_ShipToAddress shipToAddress = null; if (scheduledAppointment != null) { lock (_locker) { salesOrderHeader = GetSalesOrderHeader(scheduledAppointment); if (salesOrderHeader != null) { shipToAddress = GetShipToAddress(salesOrderHeader); } } } returnData = new App_SalesOrder(customer, salesOrderHeader, shipToAddress); return(returnData); }
public App_SalesOrder GetSalesOrder(App_WorkTicket workTicket, App_Customer customer) { App_SalesOrder returnData = null; SO_SalesOrderHeader salesOrderHeader = null; SO_ShipToAddress shipToAddress = null; if (workTicket != null) { lock (_locker) { salesOrderHeader = GetSalesOrderHeader(workTicket); if (salesOrderHeader != null) { shipToAddress = GetShipToAddress(salesOrderHeader); } } } returnData = new App_SalesOrder(customer, salesOrderHeader, shipToAddress); return(returnData); }
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)); }
public void FillServiceAgreementHeaderTable() { // Fill Service Agreement Details based on Tickets //FillLocalTable<JT_ServiceAgreementHeader>(); // TODO filter // dch rkl 01/31/2017 prevent duplicate filters, which generates long query string DataTable dtFilter = new DataTable("Filter"); dtFilter.Columns.Add("ContractCode", typeof(string)); dtFilter.Columns.Add("CustomerNo", typeof(string)); dtFilter.Columns.Add("ARDivisionNo", typeof(string)); StringBuilder sbH = new StringBuilder(); List <JT_TechnicianScheduleDetail> scheduledTickets = GetTechnicianScheduleDetailFromDB(); List <JT_WorkTicket> tickets = GetWorkTicketsFromDB(); List <SO_SalesOrderHeader> sohs = GetSalesOrderHeadersFromDB(); for (int i = 0; i < scheduledTickets.Count; i++) { JT_WorkTicket ticket = tickets.FirstOrDefault(s => s.SalesOrderNo == scheduledTickets[i].SalesOrderNo && s.WTNumber == scheduledTickets[i].WTNumber && s.WTStep == "000" && s.HdrServiceContractCode != null); if (ticket != null) { SO_SalesOrderHeader soHdr = sohs.FirstOrDefault(s => s.SalesOrderNo == scheduledTickets[i].SalesOrderNo); if (soHdr != null) { // dch rkl 01/31/2017 prevent duplicate filters, which generates long query string DataView dvFilter = new DataView(dtFilter); dvFilter.RowFilter = "ContractCode = '" + ticket.HdrServiceContractCode + "' and CustomerNo = '" + soHdr.CustomerNo + "' and ARDivisionNo = '" + soHdr.ARDivisionNo + "'"; if (dvFilter.Count == 0) { dtFilter.Rows.Add(ticket.HdrServiceContractCode, soHdr.CustomerNo, soHdr.ARDivisionNo); } //if (sbH.Length > 0) //{ // sbH.Append(" or "); //} //sbH.Append("(ContractCode eq '"); //sbH.Append(ticket.HdrServiceContractCode); //sbH.Append("' and CustomerNo eq '"); //sbH.Append(soHdr.CustomerNo); //sbH.Append("' and ARDivisionNo eq '"); //sbH.Append(soHdr.ARDivisionNo); //sbH.Append("')"); // dch rkl 01/31/2017 prevent duplicate filters, which generates long query string END } } } // dch rkl 01/31/2017 prevent duplicate filters, which generates long query string BEGIN foreach (DataRow row in dtFilter.Rows) { if (sbH.Length > 0) { sbH.Append(" or "); } sbH.Append("(ContractCode eq '"); sbH.Append(row["ContractCode"].ToString()); sbH.Append("' and CustomerNo eq '"); sbH.Append(row["CustomerNo"].ToString()); sbH.Append("' and ARDivisionNo eq '"); sbH.Append(row["ARDivisionNo"].ToString()); sbH.Append("')"); } // dch rkl 01/31/2017 prevent duplicate filters, which generates long query string END FillLocalTable <JT_ServiceAgreementHeader>("where", sbH.ToString()); FillLocalTable <JT_ServiceAgreementDetail>("where", sbH.ToString()); FillLocalTable <JT_ServiceAgreementPMDetail>("where", sbH.ToString()); }