// WOTABSubRepair.cpp : implementation file // #include "stdafx.h" #include "sp.h" #include "WOTABSubRepair.h" #include "NonClientsDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //memory leak debugging help #define _CRTDBG_MAP_ALLOC #include #include ///////////////////////////////////////////////////////////////////////////// // CWOTABSubRepair dialog CWOTABSubRepair::CWOTABSubRepair(CWnd* pParent /*=NULL*/) : CDialog(CWOTABSubRepair::IDD, pParent) { //{{AFX_DATA_INIT(CWOTABSubRepair) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_pApp = (CSpApp*)AfxGetApp(); /* rs = new GZRset("Error: Standard workorder (subrepairs tab)"); rs->SetConnect(m_pApp->strConnectString); */ //Initialize recordset pointer rs=m_pApp->rsPool->GetRS("CWOTABSubRepair"); cfm = new CgzCurrencyFormatter; m_strSelectedSentTo="0"; m_strSelectedSentVia="0"; bModified=false; } CWOTABSubRepair::~CWOTABSubRepair() { m_pApp->rsPool->ReleaseRS(&rs->m_nID); delete cfm; } void CWOTABSubRepair::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CWOTABSubRepair) DDX_Control(pDX, IDC_LBLREPAIRCTRS, m_lblRepairCenters); DDX_Control(pDX, IDC_LBLMANUFACTURERS, m_lblManufacturers); DDX_Control(pDX, IDC_LBLSENTVIA, m_lblSentVia); DDX_Control(pDX, IDC_LBLETARECEIVED, m_lblEtaReceived); DDX_Control(pDX, IDC_EDWAYBILL, m_edWaybill); DDX_Control(pDX, IDC_EDRMA, m_edRMA); DDX_Control(pDX, IDC_EDNOTES, m_edNotes); DDX_Control(pDX, IDC_EDCOST, m_edCost); DDX_Control(pDX, IDC_EDCHARGE, m_edCharge); DDX_Control(pDX, IDC_DTSENT, m_dtSent); DDX_Control(pDX, IDC_DTRECETA, m_dtRecEta); DDX_Control(pDX, IDC_CKRECEIVED, m_ckReceived); DDX_Control(pDX, IDC_CBSENTVIA, m_cbSentVia); DDX_Control(pDX, IDC_CBSENTTO, m_cbSentTo); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CWOTABSubRepair, CDialog) //{{AFX_MSG_MAP(CWOTABSubRepair) ON_EN_KILLFOCUS(IDC_EDCHARGE, OnKillfocusEdcharge) ON_EN_KILLFOCUS(IDC_EDCOST, OnKillfocusEdcost) ON_BN_CLICKED(IDC_CKRECEIVED, OnCkreceived) ON_BN_CLICKED(IDC_LBLMANUFACTURERS, OnLblmanufacturers) ON_BN_CLICKED(IDC_LBLREPAIRCTRS, OnLblrepairctrs) ON_BN_CLICKED(IDC_LBLSENTVIA, OnLblsentvia) ON_CBN_CLOSEUP(IDC_CBSENTTO, OnCloseupCbsentto) ON_CBN_CLOSEUP(IDC_CBSENTVIA, OnCloseupCbsentvia) ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTRECETA, OnDatetimechangeDtreceta) ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTSENT, OnDatetimechangeDtsent) ON_EN_KILLFOCUS(IDC_EDNOTES, OnKillfocusEdnotes) ON_EN_KILLFOCUS(IDC_EDRMA, OnKillfocusEdrma) ON_EN_KILLFOCUS(IDC_EDWAYBILL, OnKillfocusEdwaybill) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CWOTABSubRepair message handlers BOOL CWOTABSubRepair::OnInitDialog() { CString q,strData; long lData; bool bData; COleCurrency crData; COleDateTime dtData; CDialog::OnInitDialog(); Security(); //"Hyperlink-o-size" labels m_lblManufacturers.SetTextColor(RGB(0,0,255)); m_lblManufacturers.SetFontUnderline(TRUE); m_lblManufacturers.SetLink(TRUE); m_lblManufacturers.SetLinkCursor(m_pApp->hcHand); m_lblManufacturers.SetLinkURL(""); m_lblRepairCenters.SetTextColor(RGB(0,0,255)); m_lblRepairCenters.SetFontUnderline(TRUE); m_lblRepairCenters.SetLink(TRUE); m_lblRepairCenters.SetLinkCursor(m_pApp->hcHand); m_lblRepairCenters.SetLinkURL(""); m_lblSentVia.SetTextColor(RGB(0,0,255)); m_lblSentVia.SetFontUnderline(TRUE); m_lblSentVia.SetLink(TRUE); m_lblSentVia.SetLinkCursor(m_pApp->hcHand); m_lblSentVia.SetLinkURL(""); //FILL PICKLISTS FillLists(); //ATTEMPT TO FILL FIELDS q.Format("SELECT subrepair.* FROM subrepair " "WHERE (((subrepair.link)=%s));",*m_pstrProblemID); rs->QueryReadOnly(q); m_lblEtaReceived.SetWindowText("Return E.T.A."); m_ckReceived.SetCheck(FALSE); if(rs->IsEmpty())//No record {//set to defaults m_cbSentTo.Select(m_strSelectedSentTo); m_cbSentVia.Select(m_strSelectedSentVia); m_dtSent.SetTime(COleDateTime::GetCurrentTime()); m_dtRecEta.SetTime(COleDateTime::GetCurrentTime()); m_edCharge.SetWindowText("$0.00"); m_edCost.SetWindowText("$0.00"); } else //there is a record { //fill the fields rs->FetchField("isback",&bData); if(bData) { m_lblEtaReceived.SetWindowText("Received back:"); m_ckReceived.SetCheck(TRUE); rs->FetchField("received",&dtData); m_dtRecEta.SetTime(dtData); } else { rs->FetchField("eta",&dtData); m_dtRecEta.SetTime(dtData); } rs->FetchField("where",&lData); m_cbSentTo.Select(lData); rs->FetchField("sentvia",&lData); m_cbSentVia.Select(lData); rs->FetchField("sent",&dtData); m_dtSent.SetTime(dtData); rs->FetchField("waybill",&strData); m_edWaybill.SetWindowText(strData); rs->FetchField("rma",&strData); m_edRMA.SetWindowText(strData); rs->FetchField("cost",&crData); m_edCost.SetWindowText(cfm->Format(crData)); rs->FetchField("charge",&crData); m_edCharge.SetWindowText(cfm->Format(crData)); rs->FetchField("notes",&strData); m_edNotes.SetWindowText(strData); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } //********************************* void CWOTABSubRepair::FillLists() { CString q,strData,strIndex; long lData; m_cbSentVia.Clear(); m_cbSentVia.AddRow(" < na/unknown >","0"); rs->QueryReadOnly("SELECT nonclients.company_person, nonclients.id " "FROM nonclients WHERE (((nonclients.type)=2));");//type 2 = couriers/shippers if(!rs->IsEmpty()) { rs->MoveFirst(); do { rs->FetchField("company_person",&strData); rs->FetchField("id",&lData); strIndex.Format("%u",lData); m_cbSentVia.AddRow(strData,strIndex); }while(rs->MoveForward()); } m_cbSentTo.Clear(); m_cbSentTo.AddRow(" < Not sent out >","0"); rs->QueryReadOnly("SELECT nonclients.company_person, nonclients.id " "FROM nonclients WHERE (((nonclients.type)=1)) OR (((nonclients.type)=3));");//type 1 = subcontractors repair centers 3=manufact if(!rs->IsEmpty()) { rs->MoveFirst(); do { rs->FetchField("company_person",&strData); rs->FetchField("id",&lData); strIndex.Format("%u",lData); m_cbSentTo.AddRow(strData,strIndex); }while(rs->MoveForward()); } m_cbSentTo.Select(m_strSelectedSentTo); m_cbSentVia.Select(m_strSelectedSentVia); } void CWOTABSubRepair::OnKillfocusEdcharge() { COleCurrency crData; CString str; if(m_edCharge.GetModify()) bModified=true; m_edCharge.GetWindowText(str); if(crData.ParseCurrency(str)!=TRUE) { AfxMessageBox("I could not interpret your entry in the charge field\r\n" "I can't save this field until a valid currency entry is made.\r\n" "If you want to leave it blank put a zero in it."); m_edCharge.SetFocus(); return; } m_edCharge.SetWindowText(cfm->Format(crData)); } void CWOTABSubRepair::OnKillfocusEdcost() { COleCurrency crData; CString str; if(m_edCost.GetModify()) bModified=true; m_edCost.GetWindowText(str); if(crData.ParseCurrency(str)!=TRUE) { AfxMessageBox("I could not interpret your entry in the cost field\r\n" "I can't save this field until a valid currency entry is made.\r\n" "If you want to leave it blank, put a zero in it."); m_edCost.SetFocus(); return; } m_edCost.SetWindowText(cfm->Format(crData)); } void CWOTABSubRepair::OnCkreceived() { if(m_ckReceived.GetCheck()==TRUE)//user has indicated receipt { m_lblEtaReceived.SetWindowText("Received back:"); m_dtRecEta.SetTime(COleDateTime::GetCurrentTime()); } else//user has indicated not received for some unknown reason { //probably just to try the patience of the programmer //and the resourcefulness of his error checking m_lblEtaReceived.SetWindowText("Return E.T.A."); m_dtRecEta.SetTime(COleDateTime::GetCurrentTime()); //bug avoidance:make sure when header saves this page //the dates are set correctly depending on user selection } bModified=true; } void CWOTABSubRepair::OnLblmanufacturers() { m_strSelectedSentTo=m_cbSentTo.GetCurrentRowID(); m_strSelectedSentVia=m_cbSentVia.GetCurrentRowID(); PopupNonClients(3); FillLists(); } void CWOTABSubRepair::OnLblrepairctrs() { m_strSelectedSentTo=m_cbSentTo.GetCurrentRowID(); m_strSelectedSentVia=m_cbSentVia.GetCurrentRowID(); PopupNonClients(1); FillLists(); } void CWOTABSubRepair::OnLblsentvia() { m_strSelectedSentVia=m_cbSentVia.GetCurrentRowID(); m_strSelectedSentTo=m_cbSentTo.GetCurrentRowID(); PopupNonClients(2); FillLists(); } void CWOTABSubRepair::PopupNonClients(long type) { CNonClientsDlg d; long ltype; ltype=type; d.SetType(<ype); d.DoModal(); } void CWOTABSubRepair::OnCloseupCbsentto() { bModified=true; } void CWOTABSubRepair::OnCloseupCbsentvia() { bModified=true; } void CWOTABSubRepair::OnDatetimechangeDtreceta(NMHDR* pNMHDR, LRESULT* pResult) { bModified=true; *pResult = 0; } void CWOTABSubRepair::OnDatetimechangeDtsent(NMHDR* pNMHDR, LRESULT* pResult) { bModified=true; COleDateTime dtData; m_dtSent.GetTime(dtData); m_dtRecEta.SetTime(dtData); *pResult = 0; } void CWOTABSubRepair::OnKillfocusEdnotes() { if(m_edNotes.GetModify()) bModified=true; } void CWOTABSubRepair::OnKillfocusEdrma() { if(m_edRMA.GetModify()) bModified=true; } void CWOTABSubRepair::OnKillfocusEdwaybill() { if(m_edWaybill.GetModify()) bModified=true; } void CWOTABSubRepair::Security() { //m_bReadOnly=false; int x=m_pApp->Allowed(RWORKORDER,false); if(x==0)//no access allowed { m_pApp->SecurityWarning(); CDialog::OnCancel(); } //modified to allow dispatch 8/28/00 //if(x==2 || (!m_pApp->m_bTech))//read only if(x==2 )//read only { //m_bReadOnly=true; m_cbSentTo.EnableWindow(FALSE); m_cbSentVia.EnableWindow(FALSE); m_ckReceived.EnableWindow(FALSE); m_dtRecEta.EnableWindow(FALSE); m_dtSent.EnableWindow(FALSE); m_edCharge.SetReadOnly(TRUE); m_edCost.SetReadOnly(TRUE); m_edNotes.SetReadOnly(TRUE); m_edRMA.SetReadOnly(TRUE); m_edWaybill.SetReadOnly(TRUE); m_lblManufacturers.EnableWindow(FALSE); m_lblRepairCenters.EnableWindow(FALSE); m_lblSentVia.EnableWindow(FALSE); } } void CWOTABSubRepair::OnOK() {//enter key avoidance hack }