Skip to content

Commit

Permalink
Comprehensive updates for work order details
Browse files Browse the repository at this point in the history
- Added GNU Affero GPL notice to `CClosedWorkOrderDetailsTab` files.
- Updated header file inclusions and namespace usage for better organization.
- Enhanced `CClosedWorkOrderDetailsTab` with new CString member variables.
- Implemented dialog initialization and data exchange in `CClosedWorkOrderDetailsTab`.
- Added database querying for work order details in `OnInitDialog`.
- Updated version to `1.0.0.3 (Alpha)` across multiple files.
- Adjusted namespaces to align with new structure in various files.
- Improved event handling in `CReportWorkorderClosedView` for better UX.
- Made minor code adjustments for readability and maintenance.
- Corrected namespace syntax in `CWorkorderView.h`.
- Reorganized project file filters for `CReportWorkorderClosedView`.
- Added new UI control identifiers in `Resource.h` for closed workorder details.
- Updated `_APS_NEXT_CONTROL_VALUE` in `Resource.h` for future controls.
  • Loading branch information
artvabas committed Jun 28, 2024
1 parent ef024c3 commit c60f150
Show file tree
Hide file tree
Showing 12 changed files with 344 additions and 110 deletions.
184 changes: 171 additions & 13 deletions RepairCafeCureApp/CClosedWorkOrderDetailsTab.cpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,190 @@
// CClosedWordorderDetailsTab.cpp : implementation file
//
/*
Copyright (C) 2023/24 artvabas
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
To see the license for this source code, please visit:
<https://github.com/artvabas/RepairCafeCureApp/blob/master/LICENSE.txt>
For more information, please visit:
<https://artvabas.com>
<https://github.com/artvabas/RepairCafeCureApp>
For contacts, please use the contact form at:
<https://artvabas.com/contact>
*/

/*
* This file is part of RepairCafeCureApp.
* File: CClosedWorkOrderDetailsTab.h, implements class CClosedWorkOrderDetailsTab
*
* This class is the view of the Workorder-tab in the CClosedWorkorderDetailsTabCtrl class,
* which is the view of the CListCtrl created on the Closed Workorder Details dialog (CClosedWorkorderDetails)
*
* This form is used to display the workorder-details of a closed workorder.
* What is selected in the listview of the CReportWorkorderClosedView and passed to this form.
*
* Target: Windows 10/11 64bit
* Version: 1.0.0.2 (alpha)
* Created: 17-06-2024, (dd-mm-yyyy)
* Updated: 28-06-2024, (dd-mm-yyyy)
* Creator: artvabasDev / artvabas
*
* Description: Database connection class
* License: GPLv3
*/

#include "pch.h"
#include "RepairCafeCureApp.h"
#include "afxdialogex.h"
#include "CSqlNativeAVB.h"
#include "DatabaseTables.h"
#include "CClosedWorkOrderDetailsTab.h"

using namespace artvabas::rcc::ui::dialogs;
using namespace artvabas::sql;
using namespace artvabas::database::tables::workorder;

IMPLEMENT_DYNAMIC(CClosedWorkOrderDetailsTab, CDialogEx)

CClosedWorkOrderDetailsTab::CClosedWorkOrderDetailsTab(CClosedWorkorderDetailsTabCtrl* pTabControl, unsigned int unID, CWnd* pParent)
: CDialogEx(IDD_CLOSED_WORKORDER_DETAILS_TAB, pParent)
, m_pTabControl{ pTabControl }
, m_unWorkorderID{ unID }
{

}
, m_strWorkorderID{ _T("") }
, m_strWorkorderAssetID{ _T("") }
, m_strWorkorderCustomerID{ _T("") }
, m_strWorkorderInvoiceID{ _T("") }
, m_strWorkorderCreateDate{ _T("") }
, m_strWorkorderClosedDate{ _T("") }
, m_strWorkorderCreatedBy{ _T("") }
, m_strWorkorderEmployeeResponsible{ _T("") }
, m_strWorkorderDescription{ _T("") }
, m_strWorkorderStatus{ _T("") }
, m_strWorkorderHistoryLog{ _T("") }
{}

CClosedWorkOrderDetailsTab::~CClosedWorkOrderDetailsTab()
{
}
{}

void CClosedWorkOrderDetailsTab::DoDataExchange(CDataExchange* pDX)
BEGIN_MESSAGE_MAP(CClosedWorkOrderDetailsTab, CDialogEx)
END_MESSAGE_MAP()

// OnintDialog is called when the dialog is created, it is used to load the data from the database
// and display it in the dialog.
BOOL CClosedWorkOrderDetailsTab::OnInitDialog()
{
CDialogEx::DoDataExchange(pDX);
}
CDialogEx::OnInitDialog();

theApp.SetStatusBarText(IDS_STATUSBAR_LOADING);
theApp.BeginWaitCursor();

BEGIN_MESSAGE_MAP(CClosedWorkOrderDetailsTab, CDialogEx)
END_MESSAGE_MAP()
CString strBuildQuery;
strBuildQuery.Format(_T("SELECT * FROM WORKORDER WHERE WORKORDER_ID = %d"), m_unWorkorderID);

CSqlNativeAVB sql{ theApp.GetDatabaseConnection()->ConnectionString() };

if (sql.CreateSQLConnection()) {

SQLCHAR szName[SQLCHARVSMAL]{};
SQLCHAR szNameLong[SQLCHARVMAX]{};
SQLLEN cbName{};
SQLRETURN retcode{};
SQLHSTMT hstmt{ sql.GetStatementHandle() };
SQLWCHAR* strQuery{ strBuildQuery.GetBuffer() };
strBuildQuery.ReleaseBuffer();

retcode = SQLExecDirectW(hstmt, strQuery, SQL_NTS);

if (retcode == SQL_SUCCESS) {
while (TRUE) {
retcode = SQLFetch(hstmt);
if (retcode == SQL_ERROR || retcode == SQL_SUCCESS_WITH_INFO)
AfxMessageBox(_T("Error fetching data from Asset Table!"), MB_ICONEXCLAMATION);
if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {

auto CheckForNull = [](SQLCHAR* szName, SQLLEN cbName) -> CString {
if (cbName == SQL_NULL_DATA) {
return _T("");
}
return static_cast<CString>(szName);
};
// Get data for columns 1, employee names
SQLGetData(hstmt, WORKORDER.WORKORDER_ID, SQL_C_CHAR, szName, SQLCHARVSMAL, &cbName);
m_strWorkorderID = CheckForNull(szName, cbName);

SQLGetData(hstmt, WORKORDER.WORKORDER_ASSET_ID, SQL_C_CHAR, szName, SQLCHARVSMAL, &cbName);
m_strWorkorderAssetID = CheckForNull(szName, cbName);

SQLGetData(hstmt, WORKORDER.WORKORDER_CUSTOMER_ID, SQL_C_CHAR, szName, SQLCHARVSMAL, &cbName);
m_strWorkorderCustomerID = CheckForNull(szName, cbName);

SQLGetData(hstmt, WORKORDER.WORKORDER_INVOICE_ID, SQL_C_CHAR, szName, SQLCHARVSMAL, &cbName);
m_strWorkorderInvoiceID = CheckForNull(szName, cbName);

SQLGetData(hstmt, WORKORDER.WORKORDER_CREATE_DATE, SQL_C_CHAR, szName, SQLCHARVSMAL, &cbName);
m_strWorkorderCreateDate = CheckForNull(szName, cbName);

SQLGetData(hstmt, WORKORDER.WORKORDER_CREATE_BY, SQL_C_CHAR, szName, SQLCHARVSMAL, &cbName);
m_strWorkorderCreatedBy = CheckForNull(szName, cbName);

SQLGetData(hstmt, WORKORDER.WORKORDER_DESCRIPTION, SQL_C_CHAR, szNameLong, SQLCHARVMAX, &cbName);
m_strWorkorderDescription = CheckForNull(szNameLong, cbName);

SQLGetData(hstmt, WORKORDER.WORKORDER_RESPONSIBLE, SQL_C_CHAR, szName, SQLCHARVSMAL, &cbName);
m_strWorkorderEmployeeResponsible = CheckForNull(szName, cbName);

SQLGetData(hstmt, WORKORDER.WORKORDER_STATUS, SQL_C_CHAR, szName, SQLCHARVSMAL, &cbName);
m_strWorkorderStatus = CheckForNull(szName, cbName);

SQLGetData(hstmt, WORKORDER.WORKORDER_CLOSED_DATE, SQL_C_CHAR, szName, SQLCHARVSMAL, &cbName);
m_strWorkorderClosedDate = CheckForNull(szName, cbName);

SQLGetData(hstmt, WORKORDER.WORKORDER_HISTORY, SQL_C_CHAR, szNameLong, SQLCHARVMAX, &cbName);
m_strWorkorderHistoryLog = CheckForNull(szNameLong, cbName);
}
else
break;
}
}
if (!sql.CheckReturnCodeForClosing(retcode))
theApp.SetStatusBarText(IDS_STATUSBAR_SELECT_FAIL);
else
theApp.SetStatusBarText(IDS_STATUSBAR_SELECT_OK);
}
sql.CloseConnection();
theApp.EndWaitCursor();
UpdateData(FALSE);

return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

// DoDataExchange is used to exchange and validate data between the dialog and variables
// - DDX_Text is used to exchange data between the dialog and variables
void CClosedWorkOrderDetailsTab::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_CLOSED_WORKORDER_TAB_WORKORDER_ID, m_strWorkorderID);
DDX_Text(pDX, IDC_CLOSED_WORKORDER_TAB_ASSET_ID, m_strWorkorderAssetID);
DDX_Text(pDX, IDC_CLOSED_WORKORDER_TAB_CUSTOMER_ID, m_strWorkorderCustomerID);
DDX_Text(pDX, IDC_CLOSED_WORKORDER_TAB_INVOICE_ID, m_strWorkorderInvoiceID);
DDX_Text(pDX, IDC_CLOSED_WORKORDER_TAB_CREATE_DATE, m_strWorkorderCreateDate);
DDX_Text(pDX, IDC_CLOSED_WORKORDER_TAB_CLOSED_DATE, m_strWorkorderClosedDate);
DDX_Text(pDX, IDC_CLOSED_WORKORDER_TAB_CREATED_BY, m_strWorkorderCreatedBy);
DDX_Text(pDX, IDC_CLOSED_WORKORDER_TAB_RESPONIBLE_BY, m_strWorkorderEmployeeResponsible);
DDX_Text(pDX, IDC_CLOSED_WORKORDER_TAB_DESCRIPTION, m_strWorkorderDescription);
DDX_Text(pDX, IDC_CLOSED_WORKORDER_TAB_STATUS, m_strWorkorderStatus);
DDX_Text(pDX, IDC_CLOSED_WORKORDER_TAB_HISTORY_LOG, m_strWorkorderHistoryLog);
}
93 changes: 78 additions & 15 deletions RepairCafeCureApp/CClosedWorkOrderDetailsTab.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,89 @@
/*
Copyright (C) 2023/24 artvabas
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>
To see the license for this source code, please visit:
<https://github.com/artvabas/RepairCafeCureApp/blob/master/LICENSE.txt>
For more information, please visit:
<https://artvabas.com>
<https://github.com/artvabas/RepairCafeCureApp>
For contacts, please use the contact form at:
<https://artvabas.com/contact>
*/

/*
* This file is part of RepairCafeCureApp.
* File: CClosedWorkOrderDetailsTab.h, defines class CClosedWorkOrderDetailsTab
*
* This class is the view of the Workorder-tab in the CClosedWorkorderDetailsTabCtrl class,
* which is the view of the CListCtrl created on the Closed Workorder Details dialog (CClosedWorkorderDetails)
*
* This form is used to display the workorder-details of a closed workorder.
* What is selected in the listview of the CReportWorkorderClosedView and passed to this form.
*
* Target: Windows 10/11 64bit
* Version: 1.0.0.2 (alpha)
* Created: 17-06-2024, (dd-mm-yyyy)
* Updated: 28-06-2024, (dd-mm-yyyy)
* Creator: artvabasDev / artvabas
*
* Description: Database connection class
* License: GPLv3
*/
#pragma once
#include "CClosedWorkorderDetailsTabCtrl.h"

namespace artvabas::rcc::ui::dialogs {

using namespace artvabas::rcc::ui::controls;
using namespace artvabas::rcc::ui::controls;

class CClosedWorkOrderDetailsTab : public CDialogEx
{
class CClosedWorkOrderDetailsTab : public CDialogEx
{
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_CLOSED_WORKORDER_DETAILS_TAB };
enum { IDD = IDD_CLOSED_WORKORDER_DETAILS_TAB };
#endif
DECLARE_DYNAMIC(CClosedWorkOrderDetailsTab)
DECLARE_DYNAMIC(CClosedWorkOrderDetailsTab)

private:
CClosedWorkorderDetailsTabCtrl* m_pTabControl;
unsigned int m_unWorkorderID;

private:
CClosedWorkorderDetailsTabCtrl* m_pTabControl;
unsigned int m_unWorkorderID;
CString m_strWorkorderID;
CString m_strWorkorderAssetID;
CString m_strWorkorderCustomerID;
CString m_strWorkorderInvoiceID;
CString m_strWorkorderCreateDate;
CString m_strWorkorderClosedDate;
CString m_strWorkorderCreatedBy;
CString m_strWorkorderEmployeeResponsible;
CString m_strWorkorderDescription;
CString m_strWorkorderStatus;
CString m_strWorkorderHistoryLog;

public:
CClosedWorkOrderDetailsTab(CClosedWorkorderDetailsTabCtrl* pTabControl, unsigned int unID, CWnd* pParent = nullptr); // standard constructor
virtual ~CClosedWorkOrderDetailsTab();
public:
CClosedWorkOrderDetailsTab(CClosedWorkorderDetailsTabCtrl* pTabControl, unsigned int unID, CWnd* pParent = nullptr); // standard constructor
virtual ~CClosedWorkOrderDetailsTab();

protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support

DECLARE_MESSAGE_MAP()
};
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
};
}
8 changes: 4 additions & 4 deletions RepairCafeCureApp/CClosedWorkorderDetails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* which is the view of the CListCtrl created on the closed workorder details dialog
*
* Target: Windows 10/11 64bit
* Version: 1.0.0.2 (Alpha)
* Version: 1.0.0.3 (Alpha)
* Created: 17-06-2024, (dd-mm-yyyy)
* Updated: 18-06-2024, (dd-mm-yyyy)
* Creator: artvabasDev / artvabas
Expand All @@ -60,15 +60,15 @@ CClosedWorkorderDetails::CClosedWorkorderDetails(unsigned int& unCustomerID, uns
CClosedWorkorderDetails::~CClosedWorkorderDetails()
{}

// DoDataExchange mothod is used for binding ID's with their controls
// - pDx
// DoDataExchange method is used for binding ID's with their controls
// - DDX_Control binds the control with the ID
void CClosedWorkorderDetails::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_CLOSED_WORKORDER_DETAILS_TAB_CONTROL, m_ctrTabClosedWorkorderDetails);
}

// OnInitDialog method is called by the framework when dialog is buid and needs to be initialized
// OnInitDialog method is called by the framework when dialog is created
BOOL CClosedWorkorderDetails::OnInitDialog()
{
CDialogEx::OnInitDialog();
Expand Down
4 changes: 2 additions & 2 deletions RepairCafeCureApp/CClosedWorkorderDetails.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
* which is the view of the CListCtrl created on the closed workorder details dialog
*
* Target: Windows 10/11 64bit
* Version: 1.0.0.2 (Alpha)
* Version: 1.0.0.3 (Alpha)
* Created: 17-06-2024, (dd-mm-yyyy)
* Updated: 18-06-2024, (dd-mm-yyyy)
* Updated: 28-06-2024, (dd-mm-yyyy)
* Creator: artvabasDev / artvabas
*
* Description: Database connection class
Expand Down
5 changes: 3 additions & 2 deletions RepairCafeCureApp/CClosedWorkorderDetailsTabCtrl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
* The asset details tab contains the asset details form, the workorder tab contains the workorder form.
*
* Target: Windows 10/11 64bit
* Version: 1.0.0.2 (Alpha)
* Version: 1.0.0.3 (Alpha)
* Created: 17-06-2024, (dd-mm-yyyy)
* Updated: 17-06-2024, (dd-mm-yyyy)
* Updated: 28-06-2024, (dd-mm-yyyy)
* Creator: artvabasDev / artvabas
*
* Description: Database connection class
Expand All @@ -53,6 +53,7 @@
#include "CClosedWorkorderInvoiceDetailsTab.h"
#include "CClosedWorkorderCustomerDetailsTab.h"

using namespace artvabas::rcc::ui::dialogs;
using namespace artvabas::rcc::ui::controls;

IMPLEMENT_DYNAMIC(CClosedWorkorderDetailsTabCtrl, CTabCtrl)
Expand Down
2 changes: 1 addition & 1 deletion RepairCafeCureApp/CClosedWorkorderDetailsTabCtrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* the third tab is the customer details tab and the fourth tab is the invoice details tab.
*
* Target: Windows 10/11 64bit
* Version: 0.0.1.0 (Alpha)
* Version: 1.0.0.3 (Alpha)
* Created: 04-11-2023, (dd-mm-yyyy)
* Updated: 28-04-2024, (dd-mm-yyyy)
* Creator: artvabasDev / artvabas
Expand Down
Loading

0 comments on commit c60f150

Please sign in to comment.