// WOTABProblem.cpp : implementation file // #include "stdafx.h" #include "sp.h" #include "WOTABProblem.h" #include "UnitsDlg.h" #include "DlgTasks.h" #include "PM.h" #include "UnitsDlg.h" #include "GetAllOrXValue.h" #include "ProbStatDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CWOTABProblem dialog CWOTABProblem::CWOTABProblem(CWnd* pParent /*=NULL*/) : CDialog(CWOTABProblem::IDD, pParent) { //{{AFX_DATA_INIT(CWOTABProblem) //}}AFX_DATA_INIT m_pApp = (CSpApp*)AfxGetApp(); /* rs = new GZRset("Error: Standard workorder (problem tab)"); rs->SetConnect(m_pApp->strConnectString); rsPrint=new GZRset("standard workorder screen (unit history report / PM lbl) rsPrint error:",true); rsPrint->SetConnect(m_pApp->strConnectString); */ //Initialize recordset pointer rs=m_pApp->rsPool->GetRS("CWOTABProblem (RS)"); rsPrint=m_pApp->rsPool->GetRSPrint("CWOTABProblem (RSPRINT)"); m_strSelectedPM="0"; m_strSelectedProbStat="0"; m_strSelectedUnit="0"; m_strLastSelectedTask="0"; bModified=false; } CWOTABProblem::~CWOTABProblem() { m_pApp->rsPool->ReleaseRS(&rs->m_nID); m_pApp->rsPool->ReleaseRS(&rsPrint->m_nID); } void CWOTABProblem::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CWOTABProblem) DDX_Control(pDX, IDC_LBLWARRANTY, m_lblWarranty); DDX_Control(pDX, IDC_LBLPROBSTATUS, m_lblProbStatus); DDX_Control(pDX, IDC_EDPROBBRIEF, m_edProblemBrief); /*DDX_Control(pDX, IDC_LBLMODELINFO, m_lblModelInfo);*/ DDX_Control(pDX, IDC_EDMETERCOUNT, m_edMeter); DDX_Control(pDX, IDC_LBLMETER, m_lblMeter); DDX_Control(pDX, IDC_LBLTASKLIST, m_lblTasks); DDX_Control(pDX, IDC_CBTASKS, m_cbTasks); DDX_Control(pDX, IDC_LBLPMLIST, m_lblPMList); DDX_Control(pDX, IDC_CBPMLIST, m_cbPMList); DDX_Control(pDX, IDC_CBPROBSTAT, m_cbProbStat); DDX_Control(pDX, IDC_LBLSNLIST, m_lblSnList); DDX_Control(pDX, IDC_EDPROB, m_edProblem); DDX_Control(pDX, IDC_CKALLSN, m_ckAllSn); DDX_Control(pDX, IDC_CBSN, m_cbSNUnits); DDX_Control(pDX, IDC_BTNUNITHIST, m_btnUnitHist); //}}AFX_DATA_MAP DDX_Control(pDX, IDC_LBLWORKHEADER, m_lblTitle); } BEGIN_MESSAGE_MAP(CWOTABProblem, CDialog) //{{AFX_MSG_MAP(CWOTABProblem) ON_BN_CLICKED(IDC_CKALLSN, OnCkallsn) ON_CBN_CLOSEUP(IDC_CBSN, OnCloseupCbsn) ON_CBN_CLOSEUP(IDC_CBPMLIST, OnCloseupCbpmlist) ON_CBN_CLOSEUP(IDC_CBPROBSTAT, OnCloseupCbprobstat) ON_BN_CLICKED(IDC_LBLSNLIST, OnLblsnlist) ON_CBN_CLOSEUP(IDC_CBTASKS, OnCloseupCbtasks) ON_BN_CLICKED(IDC_LBLTASKLIST, OnLbltasklist) ON_BN_CLICKED(IDC_LBLPMLIST, OnLblpmlist) ON_BN_CLICKED(IDC_BTNUNITHIST, OnBtnunithist) ON_EN_KILLFOCUS(IDC_EDMETERCOUNT, OnKillfocusEdmetercount) ON_EN_KILLFOCUS(IDC_EDPROB, OnKillfocusEdprob) ON_EN_KILLFOCUS(IDC_EDPROBBRIEF, OnKillfocusEdprobbrief) ON_BN_CLICKED(IDC_LBLPROBSTATUS, OnLblprobstatus) ON_BN_CLICKED(IDC_LBLWARRANTY, OnLblwarranty) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CWOTABProblem message handlers BOOL CWOTABProblem::OnInitDialog() { CDialog::OnInitDialog(); CString q,strData; long lData; // float fData; bool bUnitSelected=false; _variant_t vData; //BSTR bstrValue; //"Hyperlink-o-size" labels m_lblSnList.SetTextColor(RGB(0,0,255)); m_lblSnList.SetFontUnderline(TRUE); m_lblSnList.SetLink(TRUE); m_lblSnList.SetLinkCursor(m_pApp->hcHand); m_lblSnList.SetLinkURL(""); /*m_lblPMList.SetTextColor(RGB(0,0,255)); m_lblPMList.SetFontUnderline(TRUE); m_lblPMList.SetLink(TRUE); m_lblPMList.SetLinkCursor(m_pApp->hcHand); m_lblPMList.SetLinkURL("");*/ m_lblTasks.SetTextColor(RGB(0,0,255)); m_lblTasks.SetFontUnderline(TRUE); m_lblTasks.SetLink(TRUE); m_lblTasks.SetLinkCursor(m_pApp->hcHand); m_lblTasks.SetLinkURL(""); //Added 8/28/2000 problem status list edit access m_lblProbStatus.SetTextColor(RGB(0,0,255)); m_lblProbStatus.SetFontUnderline(TRUE); m_lblProbStatus.SetLink(TRUE); m_lblProbStatus.SetLinkCursor(m_pApp->hcHand); m_lblProbStatus.SetLinkURL(""); //Added 8/30/2000 warranty details m_lblWarranty.SetTextColor(RGB(0,0,255)); m_lblWarranty.SetFontUnderline(TRUE); m_lblWarranty.SetLink(TRUE); m_lblWarranty.SetLinkCursor(m_pApp->hcHand); m_lblWarranty.SetLinkURL(""); //Added 10/12/2002 attempt to beautify the form m_lblTitle.SetFontBold(TRUE); Security(); //Fetch problem description and values for partnum pm item, unit and probstat q.Format("SELECT probs.* FROM probs " "WHERE (((probs.id)=%s));",*m_pstrProblemID); rs->QueryReadOnly(q); //should never be empty ASSERT(!rs->IsEmpty()); rs->FetchField("notes",&strData); m_edProblem.SetWindowText(strData); rs->FetchField("brief",&strData); m_edProblemBrief.SetWindowText(strData); rs->FetchField("status",&lData); m_strSelectedProbStat.Format("%u",lData); m_cbProbStat.Select(lData); rs->FetchField("taskid",&lData); m_cbTasks.Select(lData); /*rs->FetchField("pmscheduleid",&lData); m_strSelectedPM.Format("%u",lData);*/ rs->FetchField("unit",&lData); m_strSelectedUnit.Format("%u",lData); //m_cbSNUnits.Select(lData); //m_strSelectedUnit=m_cbSNUnits.GetCurrentRowID(); if(lData!=0) { bUnitSelected=true; m_lblMeter.ShowWindow(TRUE); m_edMeter.ShowWindow(TRUE); m_btnUnitHist.ShowWindow(TRUE); } //METER COUNT rs->FetchField("meter",&lData); strData.Format("%u",lData); m_edMeter.SetWindowText(strData); ////METER COUNT //rs->FetchField("meter",&fData); //vData=fData; ////format to system default for numbers ////so that guy in Bali can makes just as much ////sense of the numbers as the guy in denmark ////and the guy in TexArcana Arizona ////localization rocks!: Eee-yahh-ba-by! //VarFormatNumber(&vData,-1,-2,-2,-2,0,&bstrValue); ////on the downside will not work with NT 3.0 ////See CGZCurrencyFormatter for details why we don't ////care so far. //strData=bstrValue; //m_edMeter.SetWindowText(strData); m_edProblemBrief.SetLimitText(75); if(bUnitSelected==true) ShowExtendedUnitInfo(); rs->Close(); //FillPMList(); FillLists(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } //***************************** void CWOTABProblem::OnCkallsn() { FillLists(); } //FILL PICK LISTS void CWOTABProblem::FillLists() { /* //fill units m_cbUnit.Clear(); m_cbUnit.AddRow(" < All Units >","0"); q="SELECT units.id, [sn] & \" - \" & [company_person] & \" \" & [unitmodels].[description] & \" \" & [unitmodels].[model] AS name " "FROM (units LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id;"; rs->QueryReadOnly(q); if(!rs->IsEmpty()) { do { VERIFY(rs->FetchField("name",&strData)); VERIFY(rs->FetchField("id",&lData)); strIndex.Format("%u",lData); m_cbUnit.AddRow(strData,strIndex); }while(rs->MoveForward()); } m_cbUnit.SetCurSel(0); */ CString q,strData,strIndex; long lData; //FILL UNIT LIST: m_cbSNUnits.Clear(); m_cbSNUnits.AddRow(" < No unit >","0"); if(m_ckAllSn.GetCheck()) q.Format("SELECT units.sn, units.id FROM units ORDER BY units.sn;"); else//just this client's based on workorder number q.Format("SELECT units.id, [sn] & \" - \" & IIf(IsNull( [company_person]),\" " "\",[company_person]) & \" \" & IIf(IsNull([unitmodels].[description]),\" " "\",[unitmodels].[description]) " "& \" \" & IIf(IsNull([unitmodels].[model]),\" " "\",[unitmodels].[model]) AS name FROM ((units " "LEFT JOIN unitmodels ON units.model = unitmodels.id) " "LEFT JOIN nonclients ON unitmodels.manufacturer " "= nonclients.id) RIGHT JOIN wo ON units.client = " "wo.client WHERE (((wo.id)=%s)) ORDER BY units.sn; ",*m_pstrWorkorderID); #ifdef _DEBUG // m_pApp->ShowStuff(q); #endif rs->QueryReadOnly(q); if(!rs->IsEmpty()) { do { rs->FetchField("name",&strData); strData.TrimRight(); strData.TrimRight('-'); rs->FetchField("id",&lData); strIndex.Format("%u",lData); m_cbSNUnits.AddRow(strData,strIndex); }while(rs->MoveForward()); } m_cbSNUnits.Select(m_strSelectedUnit); //Fill problem status list FillProbStatList(); //FILL TASKS LIST m_cbTasks.Clear(); m_cbTasks.AddRow(" < No task >","0"); rs->QueryReadOnly("SELECT tasks.description, tasks.id FROM tasks ORDER BY tasks.description;"); if(!rs->IsEmpty()) { do { rs->FetchField("description",&strData); rs->FetchField("id",&lData); strIndex.Format("%u",lData); m_cbTasks.AddRow(strData,strIndex); }while(rs->MoveForward()); } m_cbTasks.Select("0"); rs->Close(); FillPMList(); } //****************************** void CWOTABProblem::FillPMList() { //no longer used 10/12/2002 return; CString q,strData,strIndex; long lData; m_cbPMList.Clear(); m_cbPMList.AddRow(" < Not a P.M. item >","0"); strData=m_cbSNUnits.GetCurrentRowID(); if(strData.IsEmpty()) strData="0"; //FILL PM LIST q.Format("SELECT pmhead.id, pmhead.description " "FROM pmhead INNER JOIN units ON pmhead.link = units.id " "WHERE (((pmhead.isclient)=False) AND ((units.id)=%s)) " "UNION (SELECT pmhead.id, pmhead.description " "FROM pmhead INNER JOIN (wo INNER JOIN clients ON wo.client = clients.id) ON pmhead.link = clients.id " "WHERE (((pmhead.isclient)=True) AND ((wo.id)=%s))) " "ORDER BY description;",strData,*m_pstrWorkorderID); //// m_pApp->ShowStuff(q); rs->QueryReadOnly(q); if(!rs->IsEmpty()) { do { rs->FetchField("description",&strData); rs->FetchField("id",&lData); strIndex.Format("%u",lData); m_cbPMList.AddRow(strData,strIndex); }while(rs->MoveForward()); } m_cbPMList.Select(m_strSelectedPM); rs->Close(); } //***************************************************** void CWOTABProblem::OnCloseupCbsn() { m_strSelectedUnit=m_cbSNUnits.GetCurrentRowID(); CString q; //m_lblModelInfo.SetWindowText(""); if(m_strSelectedUnit=="0") { m_lblMeter.ShowWindow(FALSE); m_edMeter.ShowWindow(FALSE); m_btnUnitHist.ShowWindow(FALSE); m_lblWarranty.SetWindowText(""); } else { m_lblMeter.ShowWindow(TRUE); m_edMeter.ShowWindow(TRUE); m_btnUnitHist.ShowWindow(TRUE); ShowExtendedUnitInfo(); } FillPMList(); bModified=true; } //***************************************************** void CWOTABProblem::OnCloseupCbpmlist() { /*m_strSelectedPM=m_cbPMList.GetCurrentRowID(); bModified=true;*/ } //***************************************************** void CWOTABProblem::OnCloseupCbprobstat() { m_strSelectedProbStat=m_cbProbStat.GetCurrentRowID(); bModified=true; } //***************************************** void CWOTABProblem::OnLblsnlist() {//m_strSelectedUnit CUnitsDlg d; if(m_strSelectedUnit!="0" && !m_strSelectedUnit.IsEmpty()) d.m_strSelectedUnit=m_strSelectedUnit; d.DoModal(); FillLists();//BUGBUG: NOT FILLING UNIT LIST? } void CWOTABProblem::OnOK() { //HACK to work around default enter key behaviour and do nothing } void CWOTABProblem::OnCloseupCbtasks() { CString id,q,strData, strTemp1, strTemp2; id=m_cbTasks.GetCurrentRowID(); if(id=="0") return; //was firing twice, once on killfocus and //once on close up. FUTURE: fix control if(id==m_strLastSelectedTask) return; m_strLastSelectedTask=id; //confirm user wants to overwrite if the existing fields are not empty m_edProblem.GetWindowText(strTemp2); m_edProblemBrief.GetWindowText(strTemp1); if(!strTemp1.IsEmpty() || !strTemp2.IsEmpty()) { if(AfxMessageBox( "Caution:\r\n" "You are about to overwrite the existing brief description\r\n" "and detailed description with the task information\r\n\r\n" "Continue?",MB_YESNO|MB_DEFBUTTON2)==IDNO) return; } m_edProblemBrief.SetWindowText(m_cbTasks.GetCurrentRowText()); //m_edProblem.GetWindowText(existtext); //addtext=m_cbTasks.GetCurrentRowText(); //addtext=addtext+"\r\n"+existtext; //m_edProblem.SetWindowText(addtext); //Added 10/11/2002 //Put detailed task description at bottom of details q.Format("SELECT tasks.* FROM tasks WHERE (((tasks.id)=%s));",id); if(rs->QueryReadOnly(q)) { if(rs->FetchField("details",&strData)) { m_edProblem.SetWindowText(strData); } } bModified=true; } void CWOTABProblem::OnLbltasklist() { CDlgTasks d; d.DoModal(); FillLists(); } //=========================== void CWOTABProblem::OnLblpmlist() { AfxMessageBox("Note: this will take you to the P.M. screen where you can\r\n" "edit the displayed item only.\r\n\r\n" "If you want to setup a new P.M. schedule for a unit or client you need to\r\n" "go through Edit->Clients or Edit->Units or Edit->Models instead\r\n"); //get needed info for this item //this is !@#$ed, should have made a //way to call up the pmedit dialog with //just the pmheads id number CString q,strLink; long lLink; bool bClient,bModel; q.Format("SELECT pmhead.isclient, pmhead.ismodel, pmhead.link " "FROM pmhead WHERE (((pmhead.id)=%s));",m_strSelectedPM); rsPrint->QueryReadOnly(q); if(rsPrint->IsEmpty()) { AfxMessageBox("Error opening PM record"); return; } rsPrint->FetchField("isclient",&bClient); rsPrint->FetchField("ismodel",&bModel); rsPrint->FetchField("link",&lLink); strLink.Format("%u",lLink); //Open the PM dialog for this client CPM d; d.PreInitialize(bClient,bModel,strLink,"Edit scheduled item"); d.DoModal(); rs->Close(); FillPMList(); } void CWOTABProblem::OnBtnunithist() { CString q,str,parameters; CGetAllOrXValue d; long top; if(m_strSelectedUnit=="0") return; d.m_strPrompt="How many incidents?"; d.m_plValueReturn=⊤ if(d.DoModal()!=IDOK) return; if(top==0) return; if(top!=-1) str.Format(" TOP %u ",top); //PARAMETERS parameters=str; str.Format("\"%s\" AS zCurrentUser, ",m_pApp->m_strCurrentUserName); parameters=parameters + str; /* q.Format("SELECT %s probs.id, probs.wolink AS WORKORDERID, probs.brief AS PROBBRIEF, probs.notes AS PROBNOTES, Format([start],\"Short Date\") AS servdate, " "[labor].[details], clients.company AS clientcompany, [units].[sn], [unitmodels].[model], [users].[initials], [probs].[meter], [ztotalparts].[totalparts], [ztotallabor].[totallabor] " "FROM [SELECT Sum((labor.hours*rates.rate)+(labor.travhours*travrates.rate)) AS totallabor " "FROM probs INNER JOIN (rates INNER JOIN (rates AS travrates INNER JOIN labor ON travrates.id = labor.rate) ON rates.id = labor.rate) ON probs.id = labor.link " "GROUP BY probs.id]. AS ztotallabor RIGHT JOIN ([SELECT IIf(IsNull(Sum(woparts.quantity*woparts.price)),0,Sum(woparts.quantity*woparts.price)) AS totalparts, probs.id " "FROM probs LEFT JOIN woparts ON probs.id = woparts.link " "GROUP BY probs.id]. AS ztotalparts RIGHT JOIN (users RIGHT JOIN ((labor RIGHT JOIN (((wo RIGHT JOIN probs ON [wo].[id]=[probs].[wolink]) LEFT JOIN units ON [probs].[unit]=[units].[id]) LEFT JOIN unitmodels ON [units].[model]=[unitmodels].[id]) ON [labor].[link]=[probs].[id]) LEFT JOIN clients ON [wo].[client]=[clients].[id]) ON [users].[id]=[labor].[tech]) ON [ztotalparts].[id]=[probs].[id]) ON [ztotallabor].[id]=[probs].[id] " "WHERE ((([probs].[unit])=%s)) " "ORDER BY [labor].[start] DESC;",parameters, m_strSelectedUnit); */ q.Format("SELECT %s probs.id, probs.wolink AS WORKORDERID, probs.brief AS PROBBRIEF, probs.notes AS " "PROBNOTES, Format([start],\"Short Date\") AS servdate, labor.details, clients.company AS " "clientcompany, units.sn, unitmodels.model, users.initials, probs.meter, ztotalparts.totalparts, ztotallabor.totallabor " "FROM [SELECT Sum((labor.hours*rates.rate)+(labor.travhours*travrates.rate)) AS totallabor, " "probs.id FROM probs INNER JOIN (rates INNER JOIN (rates AS travrates INNER JOIN labor ON " "travrates.id = labor.travrate) ON rates.id = labor.rate) ON probs.id = labor.link GROUP BY " "probs.id]. AS ztotallabor RIGHT JOIN ([SELECT IIf(IsNull(Sum(woparts.quantity*woparts.price)), " "0,Sum(woparts.quantity*woparts.price)) AS totalparts, probs.id FROM probs LEFT JOIN woparts ON " "probs.id = woparts.link GROUP BY probs.id]. AS ztotalparts RIGHT JOIN (users RIGHT JOIN ((labor " "RIGHT JOIN (((wo RIGHT JOIN probs ON wo.id = probs.wolink) LEFT JOIN units ON probs.unit = units.id) " "LEFT JOIN unitmodels ON units.model = unitmodels.id) ON labor.link = probs.id) LEFT JOIN clients ON " "wo.client = clients.id) ON users.id = labor.tech) ON ztotalparts.id = probs.id) ON ztotallabor.id = probs.id " "WHERE (((probs.unit)=%s) AND ((units.sn) Is Not Null)) " "ORDER BY labor.start DESC;",parameters, m_strSelectedUnit); #ifdef _DEBUG m_pApp->ShowStuff(q); #endif rsPrint->QueryReadOnly(q); rsPrint->Close(); rsPrint->QueryReadOnly(q); rsPrint->QueryReadOnly(q); if(rsPrint->IsEmpty()) AfxMessageBox("There is no historical data for this unit"); else { m_pApp->PrintCMReportRDC("Unit history report",rsPrint->RecordSetPointer()); //m_pApp->CreateTTX("unithist.ttx",rsPrint->RecordSetPointer()); } rsPrint->Close(); } void CWOTABProblem::OnKillfocusEdmetercount() { CString strTemp; m_edMeter.GetWindowText(strTemp); if(strTemp.GetLength()>10) { AfxMessageBox("Maximum value for meter count is: 2,147,483,647"); m_edMeter.SetFocus(); return; } if(strTemp.GetLength()==10) { double dbData=atof(strTemp); if(dbData>2147483647) { AfxMessageBox("Maximum value for meter count is: 2,147,483,647"); m_edMeter.SetFocus(); return; } } if(m_edMeter.GetModify()) bModified=true; } void CWOTABProblem::OnKillfocusEdprob() { if(m_edProblem.GetModify()) bModified=true; } void CWOTABProblem::OnKillfocusEdprobbrief() { if(m_edProblemBrief.GetModify()) bModified=true; } void CWOTABProblem::Security() { //m_bReadOnly=false; int x=m_pApp->Allowed(RWORKORDER,false); if(x==0)//no access allowed { m_pApp->SecurityWarning(); CDialog::OnCancel(); } //modified 8/28/00 to allow non-tech dispatch //if(x==2 || (!m_pApp->m_bTech))//read only if(x==2)//read only { //m_bReadOnly=true; //m_cbPMList.EnableWindow(FALSE); m_cbProbStat.EnableWindow(FALSE); m_cbSNUnits.EnableWindow(FALSE); m_cbTasks.EnableWindow(FALSE); m_ckAllSn.EnableWindow(FALSE); m_edMeter.SetReadOnly(TRUE); m_edProblem.SetReadOnly(TRUE); m_edProblemBrief.SetReadOnly(TRUE); //m_lblPMList.EnableWindow(FALSE); m_lblTasks.EnableWindow(FALSE); m_lblSnList.EnableWindow(FALSE); } } //Added 8/28/00 void CWOTABProblem::OnLblprobstatus() { CProbStatDlg d; d.DoModal(); FillProbStatList(); } void CWOTABProblem::FillProbStatList() { CString q,strData,strIndex; long lData; //FILL STATUS LIST m_cbProbStat.Clear(); //1.9.3.0 changed to order by notes instead of by ID rs->QueryReadOnly("SELECT probstat.id, probstat.notes FROM probstat ORDER BY probstat.notes;"); if(!rs->IsEmpty()) { do { rs->FetchField("notes",&strData); rs->FetchField("id",&lData); strIndex.Format("%u",lData); m_cbProbStat.AddRow(strData,strIndex); }while(rs->MoveForward()); } m_cbProbStat.Select(m_strSelectedProbStat); rs->Close(); } void CWOTABProblem::ShowExtendedUnitInfo() { m_strSelectedUnit;//=m_cbSNUnits.GetCurrentRowID(); CString q,UnitNotes,terms,ModelNotes; COleDateTime dtPurchased; long lMonths; bool bLifetime; bool bWarrantyOverride=false; q.Format("SELECT units.specialwarranty FROM units WHERE (((units.id)=%s) " "AND (Len([specialwarranty])>\"1\"));",m_strSelectedUnit); if(rs->QueryReadOnly(q)) if(!rs->IsEmpty())//It has overridden warranty terms!! { bWarrantyOverride=true; rs->FetchField("specialwarranty",&terms); } q.Format("SELECT units.id, unitmodels.lifetimewarranty, [unitmodels].[warranty]-DateDiff(\"m\",[units].[purchasedate],Now()) AS months_remaining, " "unitmodels.warrantyterms, unitmodels.notes AS MODELNOTES, units.notes AS UNITNOTES, units.purchasedate FROM units LEFT JOIN unitmodels ON units.model = unitmodels.id " "WHERE (((units.id)=%s));",m_strSelectedUnit); //#ifdef _DEBUG // m_pApp->ShowStuff(q); //#endif if(rs->QueryReadOnly(q)) if(!rs->IsEmpty()) { rs->FetchField("months_remaining",&lMonths); rs->FetchField("lifetimewarranty",&bLifetime); rs->FetchField("purchasedate",&dtPurchased); if(!bWarrantyOverride) rs->FetchField("warrantyterms",&terms);//fetch standard terms rs->FetchField("UNITNOTES",&UnitNotes); rs->FetchField("MODELNOTES",&ModelNotes); if(!bWarrantyOverride) m_strWarrantyInfo.Format( "Warranty information:\r\n" "Unit purchased: %s\r\n\r\n" "Warranty terms:\r\n%s\r\n\r\n" "Unit notes:\r\n%s\r\n\r\n" "Unit model notes:\r\n%s", dtPurchased.Format(VAR_DATEVALUEONLY),terms,UnitNotes,ModelNotes); else m_strWarrantyInfo.Format( "Warranty information:\r\n" "Unit purchased: %s\r\n\r\n" "Warranty (CUSTOM TO THIS UNIT):\r\n%s\r\n\r\n" "Unit notes:\r\n%s\r\n\r\n" "Unit model notes:\r\n%s", dtPurchased.Format(VAR_DATEVALUEONLY),terms,UnitNotes,ModelNotes); if(bLifetime) { m_lblWarranty.SetTextColor(RGB(0,0,255)); m_lblWarranty.SetWindowText("Lifetime warranty. < warranty info.>"); } else { if(lMonths<0) { m_lblWarranty.SetTextColor(RGB(255,0,0)); q.Format("Warranty expired %u months ago. < warranty info.>",abs(lMonths)); m_lblWarranty.SetWindowText(q); } else { m_lblWarranty.SetTextColor(RGB(0,0,255)); q.Format("Warrantied for %u more months. < warranty info.>",lMonths); m_lblWarranty.SetWindowText(q); } } } else { m_lblWarranty.SetWindowText("Warranty: no information available"); } if(bWarrantyOverride) m_lblWarranty.SetWindowText(" < CUSTOM WARRANTY >"); } //********************************** void CWOTABProblem::OnLblwarranty() { AfxMessageBox(m_strWarrantyInfo ); }