Professional Documents
Culture Documents
#include"Resource.h"
//{{AFX_VIRTUAL (CCRMProject)
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
//{{AFX_MSG
afx_msg void OnHelpMe();
afx_msg void OnHelpCRM();
afx_msg void OnHelpUse();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"CRMProject.h"
#include"MainFrame.h"
#include"HelpDlg.h"
#include"SplashWnd.h"
#include"UserLogin.h"
// Windows Allows Several Copies of the Same Program to Run at the Same Time.
BOOL CCRMProject :: InitInstance()
{
// Enable the SPLASH SCREEN Component Based on the Command Line Information.
CSplashWnd :: ShowSplashScreen(IDB_SPLASH24, NULL);
AfxEnableControlContainer();
// Change the Registry Key Under Which Our Settings are Stored.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
CUserLogin Dlg(IDD_LOGON);
int nResponse = Dlg.DoModal();
93
if (nResponse == IDOK)
{
AfxMessageBox(_T("Succesfull Login."), MB_OK|MB_ICONINFORMATION);
94
AfxMessageBox(_T("Under Construction"), MB_OK | MB_ICONEXCLAMATION);
}
BEGIN_MESSAGE_MAP(CCRMProject, CWinApp)
//{{AFX_MSG_MAP (CCRMProject)
ON_COMMAND(ID_HELP_ABOUTME, OnHelpMe)
ON_COMMAND(ID_HELP_ABBOUTCRM, OnHelpCRM)
ON_COMMAND(ID_HELP_HOWTOUSE, OnHelpUse)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
95
// THIS FILE GENARATE A INTERFACE OF THE WINDOW
// MainFrame.h : Interface of the CMainFrame class
#include"ChildView.h"
protected:
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
CChildView m_wndView;
CString strReportFile;
CString strReportTitle;
public:
CMainFrame();
virtual ~CMainFrame();
//{{AFX_VIRTUAL (CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
//}}AFX_VIRTUAL
//{{AFX_MSG (CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSetFocus(CWnd *pOldWnd);
96
afx_msg void OnAddNewSalesman();
afx_msg void OnUpdateSalesman();
afx_msg void OnViewSalesman();
afx_msg void OnReportSalesman();
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"CRMProject.h"
#include"MainFrame.h"
#include"StatusBar.h"
#include"UserLogin.h"
#include"AddNewCustomer.h"
#include"ViewCustomer.h"
#include"AddNewProduct.h"
#include"UpdateProduct.h"
#include"ViewProduct.h"
#include"AddNewOffer.h"
#include"ViewOffer.h"
#include"AddNewComplain.h"
#include"PendingComplain.h"
#include"ViewComplain.h"
#include"AddNewOrder.h"
#include"AddNewSalesman.h"
#include"UpdateSalesman.h"
#include"ViewSalesman.h"
#include"QuotaManager.h"
#include"UpdateStock.h"
#include"ViewStock.h"
#include"ReportViewer.h"
IMPLEMENT_DYNAMIC(CMainFrame, CFrameWnd)
97
ID_PANE_FOUR,
};
// To ROUTE and DISPATCH Command Messages and to Handle the Update of Command USER-INTERFACE
objects.
BOOL CMainFrame :: OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// The View Have First Crack at the Command
if (m_wndView.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
// The Windows Window be CREATED by Calling the Create or CreateEx Member Function
int CMainFrame :: OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd :: OnCreate(lpCreateStruct) == -1)
return -1;
98
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1;
}
// Delete these three lines if you don't want the TOOLBAR to be DOCKABLE
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
99
// CUSTOMER(Update) Dialog Box is Open
void CMainFrame :: OnUpdateCustomer()
{
CAddNewCustomer Dlg(IDD_MODIFYCUSTOMER);
Dlg.DoModal();
}
100
}
101
}
102
strReportFile = _T("\\Report\\Quota.rpt");
strReportTitle = _T("Quota Information");
CReportViewer Dlg(strReportFile, strReportTitle);
Dlg.DoModal();
}
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP
ON_WM_CREATE()
ON_WM_SETFOCUS()
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP (Login)
ON_COMMAND(ID_APP_LOGON, OnLogOn)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP (Customer)
ON_COMMAND(ID_CUSTOMERDATA_NEW, OnAddNewCustomer)
ON_COMMAND(ID_CUSTOMERDATA_UPDATE, OnUpdateCustomer)
ON_COMMAND(ID_CUSTOMERDATA_VIEW, OnViewCustomer)
ON_COMMAND(ID_REPORT_CUSTOMER, OnReportCustomer)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP (Product)
ON_COMMAND(ID_PRODUCTDATA_NEW, OnAddNewProduct)
ON_COMMAND(ID_PRODUCTDATA_UPDATE, OnUpdateProduct)
ON_COMMAND(ID_PRODUCTDATA_VIEW, OnViewProduct)
ON_COMMAND(ID_REPORT_PRODUCT, OnReportProduct)
103
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP (OfferLetter)
ON_COMMAND(ID_OFFERLETTER_NEW, OnAddNewOffer)
ON_COMMAND(ID_OFFERLETTER_PRINT, OnViewOffer)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP (Order)
ON_COMMAND(ID_ORDER_NEWORDER, OnAddNewOrder)
ON_COMMAND(ID_ORDER_VIEWBILL, OnViewBill)
ON_COMMAND(ID_REPORT_SALES, OnReportSales)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP (Salesman)
ON_COMMAND(ID_SALESMANDATA_NEW, OnAddNewSalesman)
ON_COMMAND(ID_SALESMANDATA_UPDATE, OnUpdateSalesman)
ON_COMMAND(ID_SALESMANDATA_VIEW, OnViewSalesman)
ON_COMMAND(ID_REPORT_SALESMAN, OnReportSalesman)
//}}AFX_MSG_MAP
//{{AFX_MSG_MAP (Stock)
ON_COMMAND(ID_STOCK_UPDATE, OnUpdateStock)
ON_COMMAND(ID_STOCK_VIEW, OnViewStock)
ON_COMMAND(ID_REPORT_INVENTORY, OnReportInventory)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
104
// THIS FILE GENARATE A CHILD WINDOW
// ChildView.h : Interface of the CChildView class
//{{AFX_MSG (Complain)
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"CRMProject.h"
#include"ChildView.h"
cs.dwExStyle |= WS_EX_CLIENTEDGE;
cs.style &= ~WS_BORDER;
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL);
return TRUE;
}
105
void CChildView :: OnPaint()
{
CPaintDC dc(this);
}
BEGIN_MESSAGE_MAP(CChildView,CWnd )
//{{AFX_MSG_MAP (CChildView)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
106
// THIS FILE IS USED FOR USER LOGIN
// UserLogin.h : Interface of the CUserLogin class
public:
CUserLogin(int nID, CWnd* pParent = NULL);
protected:
//{{AFX_VIRTUAL (CUserLogin)
virtual afx_msg void OnOK();
virtual afx_msg void OnCancel();
virtual BOOL OnInitDialog();
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL
DECLARE_MESSAGE_MAP()
};
#include"Stdafx.h"
#include"UserLogin.h"
107
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUserLogin)
DDX_Text(pDX, IDC_PASSWORD, strPassword);
DDX_Text(pDX, IDC_USERNAME, strUserName);
//}}AFX_DATA_MAP
}
108
ULRec.Close();
AfxMessageBox(_T("Unable to Check User Name and Password. Please Try Again."),
MB_OK|MB_ICONERROR);
}
END_CATCH_ALL
}
}
BEGIN_MESSAGE_MAP(CUserLogin, CDialog)
//{{AFX_MSG_MAP(CUserLogin)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
109
// THIS FILE IS A RECORD SOURCE OF A USER_LOGIN
// RecUserLogin.h : Interface of the CRecUserLogin class
public:
// Variable of the USER_LOGIN Data Source Fields
//{{AFX_FIELD (USER_LOGIN)
CString m_USER_LOGIN_ID;
CString m_USER_PASSWORD;
CString m_USER_CATEGORY;
//}}AFX_FIELD
public:
CRecUserLogin(CDatabase* pDatabase = NULL);
//{{AFX_VIRTUAL (CRecUserLogin)
virtual CString GetDefaultConnect(); // Default connection string
virtual CString GetDefaultSQL(); // Default SQL for Recordset
virtual void DoFieldExchange(CFieldExchange* pFX); // RFX support
//}}AFX_VIRTUAL
};
#include"Stdafx.h"
#include"RecUserLogin.h"
IMPLEMENT_DYNAMIC(CRecUserLogin, CRecordset)
m_nFields = 3;
m_nDefaultType = snapshot;
}
110
// Used to Default SQL for Recordset
CString CRecUserLogin::GetDefaultSQL()
{
return _T("[CRM].[USER_LOGIN]");
}
// To Exchange Data (IN BOTH DIRECTION) Between the Record Source Data Members
// and the Corresponding Record on the Data Variable.
void CRecUserLogin::DoFieldExchange(CFieldExchange* pFX)
{
pFX->SetFieldType(CFieldExchange::outputColumn);
//{{AFX_FIELD_MAP(CRecUserLogin)
RFX_Text(pFX, _T("[USER_LOGIN_ID]"), m_USER_LOGIN_ID);
RFX_Text(pFX, _T("[USER_PASSWORD]"), m_USER_PASSWORD);
RFX_Text(pFX, _T("[USER_CATEGORY]"), m_USER_CATEGORY);
//}}AFX_FIELD_MAP
}
111
// THIS FILE IS USED FOR ADD NEW CUSTOMER
// AddNewCustomer.h : Interface of the CAddNewCustomer Class
class CRecCustomerMaster;
//{{AFX_DATA (CAddNewCustomer)
CString strCustomerID;
CString strCustomerName;
CString strAddress;
CString strCity;
CString strPhone;
CString strMobile;
CString strEmail;
CString strSalary;
CString strOccupation;
CTime tDOB;
CDateTimeCtrl *wndDateTime;
//}}AFX_DATE
public:
CAddNewCustomer(int nID);
void InitiatVariables();
void InitiatFields(CRecCustomerMaster &rec);
void ReadOnlyIDControl(BOOL bFlag);
protected:
//{{AFX_VIRTUAL (CAddNewCustomer)
virtual afx_msg void OnCancel();
virtual BOOL OnInitDialog();
virtual void DoDataExchange(CDataExchange *pDX);
//}}AFX_VIRTUAL
//{{AFX_MSG (IDD_ADDNEWCUSTOMER)
afx_msg void OnRefresh();
afx_msg void OnSave();
//}}AFX_MSG
//{{AFX_MSG (IDD_MODIFYCUSTOMER)
void OnFirst();
void OnPrevious();
112
void OnNext();
void OnLast();
void OnSearch();
void OnModify();
void OnDelete();
void OnMCancel();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"AddNewCustomer.h"
#include"RecCustomerMaster.h"
113
// Read MAX_ID of the PRODUCT_OFFER Data Source.
strCustomerID = "CM" + Max_ID(CMRec, strFile, strField);
}
114
wndButton[4]->ShowWindow(Show); // IDC_SEARCH
wndButton[5]->ShowWindow(Show); // IDC_MODIFY
wndButton[6]->ShowWindow(Show); // IDC_DELETE
wndButton[7]->ShowWindow(Show); // IDCANCEL
wndButton[8]->ShowWindow(Hide); // IDC_SAVE
wndButton[9]->ShowWindow(Hide); // IDC_CANCEL
}
if(ModifyDialog == TRUE)
{
// Get the address of the DialogBox Edit Window
wndEdit[0] = (CEdit*)GetDlgItem(IDC_ID);
wndEdit[1] = (CEdit*)GetDlgItem(IDC_NAME);
wndEdit[2] = (CEdit*)GetDlgItem(IDC_ADDRESS);
wndEdit[3] = (CEdit*)GetDlgItem(IDC_CITY);
wndEdit[4] = (CEdit*)GetDlgItem(IDC_PHONE);
wndEdit[5] = (CEdit*)GetDlgItem(IDC_MOBILE);
wndEdit[6] = (CEdit*)GetDlgItem(IDC_EMAIL);
wndDateTime = (CDateTimeCtrl*)GetDlgItem(IDC_DATEOFBIRTH);
wndEdit[7] = (CEdit*)GetDlgItem(IDC_SALARY);
wndEdit[8] = (CEdit*)GetDlgItem(IDC_OCCUPATION);
//{{AFX_DATA_MAP (CAddNewCustomer)
115
// Do Data Exchange (DDX) Funtion
DDX_Text(pDX, IDC_ID, strCustomerID);
DDX_Text(pDX, IDC_NAME, strCustomerName);
116
}
else if(strAddress.IsEmpty())
{
AfxMessageBox("Please Enter Address.");
GetDlgItem(IDC_ADDRESS)->SetFocus();
bTest = FALSE;
}
else if(strCity.IsEmpty())
{
AfxMessageBox("Please Enter City.");
GetDlgItem(IDC_CITY)->SetFocus();
bTest = FALSE;
}
else if(strSalary.IsEmpty())
{
AfxMessageBox("Please Enter Salary.");
GetDlgItem(IDC_SALARY)->SetFocus();
bTest = FALSE;
}
else if(strOccupation.IsEmpty())
{
AfxMessageBox("Please Enter Occupation.");
GetDlgItem(IDC_OCCUPATION)->SetFocus();
bTest = FALSE;
}
if(bTest)
{
BOOL bOpen = FALSE;
CRecCustomerMaster CMRec(&db);
117
CMRec.Close();
}
END_CATCH_ALL
}
else
{
TRY
{
// If IDD_ADDNEWCUSTOMER DialogBox is OPEN Then RecordSet is
Open
if(CMRec.Open())
CMRec.AddNew();
bOpen = TRUE;
}
CATCH_ALL(e)
{
AfxMessageBox(_T("Unable to Open Record Source."), MB_OK |
MB_ICONERROR);
CMRec.Close();
}
END_CATCH_ALL
}
118
InitiatVariables();
CEdit *txtName = (CEdit*)GetDlgItem(IDC_NAME);
txtName->SetFocus();
UpdateData(FALSE);
}
}
}
}
}
}
119
// Click NEXT Button Then GoTo NEXT Record
void CAddNewCustomer :: OnNext()
{
CRecCustomerMaster CMRec(&db);
strSQL = _T("SELECT * FROM CUSTOMER_MASTER ORDER BY TO_NUMBER(SUBSTR(CUSTOMER_ID, 3))");
if(CMRec.Open(CRecordset::snapshot, strSQL))
{
for(CMRec.MoveFirst(); !CMRec.IsEOF(); CMRec.MoveNext())
{
if(strCustomerID == CMRec.m_CUSTOMER_ID)
break;
}
CMRec.MoveNext();
InitiatFields(CMRec);
UpdateData(FALSE);
}
CMRec.Close();
}
120
if(bFound)
{
InitiatFields(CMRec);
UpdateData(FALSE);
CMRec.Close();
}
else
{
AfxMessageBox(_T("Record not found. Please try again."), MB_OK |
MB_ICONEXCLAMATION);
SetDlgItemText(IDC_ID, strCustomerID);
}
}
}
121
// Click CANCEL Button After MODIFY Button
void CAddNewCustomer :: OnMCancel()
{
ReadOnlyIDControl(TRUE);
122
}
BEGIN_MESSAGE_MAP(CAddNewCustomer, CDialog)
//{{AFX_MSG (IDD_ADDNEWCUSTOMER)
ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
ON_BN_CLICKED(IDC_SAVE, OnSave)
//}}AFX_MSG
//{{AFX_MSG (IDD_MODIFYCUSTOMER)
ON_BN_CLICKED(IDC_FIRST, OnFirst)
ON_BN_CLICKED(IDC_PRE, OnPrevious)
ON_BN_CLICKED(IDC_NEXT, OnNext)
ON_BN_CLICKED(IDC_LAST, OnLast)
ON_BN_CLICKED(IDC_SEARCH, OnSearch)
ON_BN_CLICKED(IDC_MODIFY, OnModify)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
ON_BN_CLICKED(IDC_CANCEL, OnMCancel)
//}}AFX_MSG
END_MESSAGE_MAP()
123
// THIS FILE IS USED FOR VIEW ALL CUSTOMER
// ViewCustomer.h : Interface of the CViewCustomer class
public:
CViewCustomer(CWnd* pParent = NULL);
void GridFormating();
protected:
//{{AFX_VIRTUAL (CViewCustomer)
virtual afx_msg void OnCancel();
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
//{{AFX_MAP (CViewCustomer)
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MAP
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"ViewCustomer.h"
#include"RecCustomerMaster.h"
RECT rc;
GetClientRect(&rc);
InflateRect(&rc, 0, -50);
rc.top = 0;
124
// This Member Function to Create an ActiveX Control
wndGrid.CreateControl("VSFlexGrid8.VSFlexGridL.1", NULL, WS_VISIBLE, rc, this, IDC_GRID);
CRecCustomerMaster CMRec(&db);
TRY
{
strSQL = _T("SELECT * FROM CUSTOMER_MASTER ORDER BY
TO_NUMBER(SUBSTR(CUSTOMER_ID, 3))");
CMRec.Open(CRecordset::snapshot, strSQL);
if(!CMRec.IsEOF())
{
int nRW = 0;
CString strRW, strDOB;
125
VSGrid->PutTextMatrix(nRW, 8,
_bstr_t(CMRec.m_CUSTOMER_OCCUPATION));
}
}
else
{
AfxMessageBox(_T("Record(s) are not present."), MB_OK |
MB_ICONINFORMATION);
CMRec.Close();
CDialog::OnCancel();
}
}
CATCH_ALL(e)
{
CMRec.Close();
AfxMessageBox(_T("Unable to Open Record Source."), MB_OK | MB_ICONERROR);
}
END_CATCH_ALL
126
// Move the BUTTON Control
CWnd *wndButton = GetDlgItem(IDCANCEL);
rc.left = rc.right - 100;
rc.top = rc.bottom + 10;
rc.right = rc.right - 12;
rc.bottom = rc.bottom + 40;
wndButton->MoveWindow(&rc);
GridFormating();
}
BEGIN_MESSAGE_MAP(CViewCustomer, CDialog)
//{{AFX_MSG_MAP(CViewProduct)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
127
// THIS FILE IS A RECORD SOURCE OF THE SALESMAN_MASTER
// RecSalesmanMaster.h : Interface of the CRecSalesmanMaster class
public:
// Variable of the SALESMAN_MASTER Data Source Fields
//{{AFX_FIELD (SALESMAN_MASTER)
CString m_SALESMAN_ID;
CString m_SALESMAN_NAME;
CString m_SALESMAN_ADDRESS;
CString m_SALESMAN_CITY;
CString m_SALESMAN_PHONE;
CString m_SALESMAN_MOBILE;
CString m_SALESMAN_EMAIL;
CTime m_SALESMAN_DOB;
CTime m_SALESMAN_DATE_OF_JOIN;
CString m_SALESMAN_MANAGER;
CString m_SALESMAN_DESIGNATION;
//}}AFX_FIELD
public:
CRecSalesmanMaster(CDatabase* pDatabase = NULL);
//{{AFX_VIRTUAL (CRecSalesmanMaster)
virtual CString GetDefaultConnect();
virtual CString GetDefaultSQL();
virtual void DoFieldExchange(CFieldExchange* pFX);
//}}AFX_VIRTUAL
};
#include"StdAfx.h"
#include"RecSalesmanMaster.h"
IMPLEMENT_DYNAMIC(CRecSalesmanMaster, CRecordset)
128
m_SALESMAN_DESIGNATION = _T("");
m_SALESMAN_MANAGER = _T("");
//}}AFX_FIELD_INIT
m_nFields = 11;
m_nDefaultType = snapshot;
}
// To Exchange Data (IN BOTH DIRECTION) Between the Record Source Data Members
// and the Corresponding Record on the Data Variable.
void CRecSalesmanMaster::DoFieldExchange(CFieldExchange* pFX)
{
pFX->SetFieldType(CFieldExchange::outputColumn);
//{{AFX_FIELD_MAP(SALESMAN_MASTER)
RFX_Text(pFX, _T("[SALESMAN_ID]"), m_SALESMAN_ID);
RFX_Text(pFX, _T("[SALESMAN_NAME]"), m_SALESMAN_NAME);
RFX_Text(pFX, _T("[SALESMAN_ADDRESS]"), m_SALESMAN_ADDRESS);
RFX_Text(pFX, _T("[SALESMAN_CITY]"), m_SALESMAN_CITY);
RFX_Text(pFX, _T("[SALESMAN_PHONE]"), m_SALESMAN_PHONE);
RFX_Text(pFX, _T("[SALESMAN_MOBILE]"), m_SALESMAN_MOBILE);
RFX_Text(pFX, _T("[SALESMAN_EMAIL]"), m_SALESMAN_EMAIL);
RFX_Date(pFX, _T("[SALESMAN_DOB]"), m_SALESMAN_DOB);
RFX_Text(pFX, _T("[SALESMAN_DESIGNATION]"), m_SALESMAN_DESIGNATION);
RFX_Date(pFX, _T("[SALESMAN_DATE_OF_JOIN]"), m_SALESMAN_DATE_OF_JOIN);
RFX_Text(pFX, _T("[SALESMAN_MANAGER]"), m_SALESMAN_MANAGER);
//}}AFX_FIELD_MAP
}
129
// THIS FILE IS USED FOR ADD NEW PRODUCT
// AddNewProduct.h : Interface of the CAddNewProduct class
//{{AFX_DATA (CAddNewProduct)
CString strProductID;
CString strProductName;
CString strBrand;
CString strType;
CString strModelNo;
CString strSize;
CString strColor;
CString strGaurentee;
int nStock;
int nLevel;
int nPrice;
int nMRP;
int nMax;
int nMin;
CString strDeatils;
//}}AFX_DATA
public:
CAddNewProduct(CWnd* pParent = NULL);
void InitiatVariables();
protected:
//{{AFX_VIRTUAL (CAddNewProduct)
virtual afx_msg void OnOK();
virtual afx_msg void OnCancel();
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
//{{AFX_MSG (CAddNewProduct)
afx_msg void OnRefresh();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
130
#include"AddNewProduct.h"
#include"RecProductMaster.h"
#include"RecProductDiscount.h"
#include"RecProductInventory.h"
131
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAddNewProduct)
DDX_Text(pDX, IDC_PRODUCTID, strProductID);
DDX_Text(pDX, IDC_PRODUCTNAME, strProductName);
DDV_MaxChars(pDX, strProductName, 20);
DDX_Text(pDX, IDC_BRAND, strBrand);
DDV_MaxChars(pDX, strBrand, 50);
DDX_Text(pDX, IDC_TYPE, strType);
DDV_MaxChars(pDX, strType, 20);
DDX_Text(pDX, IDC_MODELNO, strModelNo);
DDV_MaxChars(pDX, strModelNo, 20);
DDX_Text(pDX, IDC_PSIZE, strSize);
DDV_MaxChars(pDX, strSize, 20);
DDX_Text(pDX, IDC_COLOR, strColor);
DDV_MaxChars(pDX, strColor, 20);
DDX_CBString(pDX, IDC_GAURENTEE, strGaurentee);
DDX_Text(pDX, IDC_STOCK, nStock);
DDV_MinMaxInt(pDX, nStock, 1, 99999);
DDX_Text(pDX, IDC_LEVEL, nLevel);
DDV_MinMaxInt(pDX, nLevel, 1, 99999);
DDX_Text(pDX, IDC_PRICE, nPrice);
DDV_MinMaxInt(pDX, nPrice, 1, 99999);
DDX_Text(pDX, IDC_MRP, nMRP);
DDV_MinMaxInt(pDX, nMRP, 1, 99999);
DDX_Text(pDX, IDC_MAX, nMax);
DDV_MinMaxInt(pDX, nMax, 1, 99999);
DDX_Text(pDX, IDC_MIN, nMin);
DDV_MinMaxInt(pDX, nMin, 1, 99999);
DDX_Text(pDX, IDC_DEATILS, strDeatils);
DDV_MaxChars(pDX, strDeatils, 200);
//}}AFX_DATA_MAP
}
132
// Call This Member to Retrive Data From a DialogBox Using DoDataExchange()
if(UpdateData(TRUE))
{
if(strProductName.IsEmpty())
{
AfxMessageBox("Please Enter Product Name.");
GetDlgItem(IDC_PRODUCTNAME)->SetFocus();
bTest = FALSE;
}
else if(strBrand.IsEmpty())
{
AfxMessageBox("Please Enter Product Brand.");
GetDlgItem(IDC_BRAND)->SetFocus();
bTest = FALSE;
}
if(bTest)
{
// ERROR Handling in VISUAL C++
TRY
{
db.BeginTrans();
CRecProductMaster PMRec(&db);
if(PMRec.Open(CRecordset::snapshot))
{
PMRec.AddNew();
133
PDRec.m_PRODUCT_MIN_DISCOUNT = nMin;
if(PDRec.Update())
{
PDRec.Close();
CRecProductMaster PMRec(&db);
CString strFile = _T("PRODUCT_MASTER");
CString strField = _T("PRODUCT_ID");
PMRec.Close();
InitiatVariables();
CEdit *txtName =
(CEdit*)GetDlgItem(IDC_PRODUCTNAME);
txtName->SetFocus();
UpdateData(FALSE);
}
}
}
}
}
}
}
CATCH_ALL(e)
{
db.Rollback();
AfxMessageBox(_T("Unable to Open Record Source."), MB_OK |
MB_ICONERROR);
}
END_CATCH_ALL
}
}
}
134
// Click CANCEL Button Then It is Called to Close the Interface
void CAddNewProduct :: OnCancel()
{
db.Close();
CDialog::OnCancel();
}
BEGIN_MESSAGE_MAP(CAddNewProduct, CDialog)
//{{AFX_MSG_MAP(CAddNewProduct)
ON_BN_CLICKED(IDC_PREFRESH, OnRefresh)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
135
// THIS FILE IS UDSED FOR UPDATE PRODUCT INFORMATION
// UpdateProduct.h : interface of the CUpdateProduct class
class CRecProductMaster;
//{{AFX_DATA (CUpdateProduct)
CString strProductID;
CString strProductName;
CString strBrand;
CString strType;
CString strModelNo;
int nPrice;
CString strSize;
CString strColor;
CString strGaurentee;
CString strDeatils;
//}}AFX_DATA
public:
CUpdateProduct(CWnd* pParent = NULL);
void InitiatVariables();
void InitiatFields(CRecProductMaster &rec);
void EnableControl(BOOL bEdit, UINT bCmd);
protected:
//{{AFX_VIRTUAL (CUpdateProduct)
virtual BOOL OnInitDialog();
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL
protected:
//{{AFX_MSG (IDD_UpdateProduct)
afx_msg void OnFirst();
afx_msg void OnPre();
afx_msg void OnNext();
afx_msg void OnLast();
136
afx_msg void OnFind();
afx_msg void OnSelChangeProductID();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"UpdateProduct.h"
#include"RecProductMaster.h"
137
// This Fuction Set the Control Properties (ReadOnly, Hide, Show)
void CUpdateProduct :: EnableControl(BOOL bEdit, UINT bCmd)
{
UINT Show, Hide;
if(bCmd == SW_HIDE)
{
Show = SW_SHOW;
Hide = SW_HIDE;
}
else
{
Show = SW_HIDE;
Hide = SW_SHOW;
}
138
strSQL = _T("SELECT * FROM PRODUCT_MASTER ORDER BY TO_NUMBER(SUBSTR(PRODUCT_ID,
3))");
if(PMRec.Open(CRecordset::snapshot, strSQL))
{
for(PMRec.MoveFirst(); !PMRec.IsEOF(); PMRec.MoveNext())
//{{AFX_DATA_MAP (CUpdateProduct)
DDX_Text(pDX, IDC_PRODUCTID, strProductID);
DDX_Text(pDX, IDC_PRODUCTNAME, strProductName);
DDV_MaxChars(pDX, strProductName, 20);
DDX_Text(pDX, IDC_BRAND, strBrand);
DDV_MaxChars(pDX, strBrand, 50);
DDX_Text(pDX, IDC_TYPE, strType);
DDV_MaxChars(pDX, strType, 20);
DDX_Text(pDX, IDC_MODELNO, strModelNo);
DDV_MaxChars(pDX, strModelNo, 20);
DDX_Text(pDX, IDC_PSIZE, strSize);
DDV_MaxChars(pDX, strSize, 20);
DDX_Text(pDX, IDC_COLOR, strColor);
DDV_MaxChars(pDX, strColor, 20);
DDX_Text(pDX, IDC_GAURENTEE, strGaurentee);
DDX_Text(pDX, IDC_PRICE, nPrice);
DDV_MinMaxInt(pDX, nPrice, 1, 9999);
DDX_Text(pDX, IDC_DEATILS, strDeatils);
DDV_MaxChars(pDX, strDeatils, 200);
//}}AFX_DATA_MAP
}
139
CString strTempPID = _T("");
GetDlgItemText(IDC_PID, strTempPID);
CRecProductMaster PMRec(&db);
PMRec.m_strFilter = "PRODUCT_ID = '" + strTempPID + "' ";
if(PMRec.Open())
{
if(!PMRec.IsEOF())
{
InitiatFields(PMRec);
UpdateData(FALSE);
}
}
PMRec.Close();
GetDlgItem(IDC_PRODUCTID)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_PID)->ShowWindow(SW_HIDE);
}
140
for(PMRec.MoveFirst(); !PMRec.IsEOF(); PMRec.MoveNext())
{
if(strProductID == PMRec.m_PRODUCT_ID)
break;
}
PMRec.MovePrev();
InitiatFields(PMRec);
UpdateData(FALSE);
}
PMRec.Close();
}
141
CString strPID;
GetDlgItemText(IDC_PRODUCTID, strPID);
CRecProductMaster PMRec(&db);
if(PMRec.Open(CRecordset::snapshot))
{
if(!PMRec.IsEOF())
{
InitiatFields(PMRec);
UpdateData(FALSE);
PMRec.Close();
}
else
{
AfxMessageBox(_T("Record not Found. Please try again."), MB_OK |
MB_ICONINFORMATION);
SetDlgItemText(IDC_PRODUCTID, strProductID);
}
}
}
// Click MODIFY Button Then Enable the Controls For Editing Records.
void CUpdateProduct :: OnModify()
{
EnableControl(TRUE, SW_HIDE);
}
142
PMRec.m_PRODUCT_BRAND = strBrand;
PMRec.m_PRODUCT_TYPE = strType;
PMRec.m_PRODUCT_SIZE = strSize;
PMRec.m_PRODUCT_COLOR_AVAILABLE = strColor;
PMRec.m_PRODUCT_MODEL_NO = strModelNo;
PMRec.m_PRODUCT_DETAIL = strDeatils;
PMRec.m_PRODUCT_GUARANTEE = strGaurentee;
PMRec.m_PRODUCT_PRICE = nPrice;
if(PMRec.Update())
{
PMRec.Close();
143
InitiatFields(PMRec);
UpdateData(FALSE);
if(AfxMessageBox("Do You Want to Sure Delete Record.", MB_YESNO |
MB_ICONQUESTION) == IDYES)
{
// DELETE Record From Record Source
PMRec.Delete();
db.CommitTrans();
PMRec.Close();
}
else
{
PMRec.Close();
}
}
else
{
AfxMessageBox(_T("Record not Found. Please try again."), MB_OK |
MB_ICONINFORMATION);
SetDlgItemText(IDC_PRODUCTID, strPID);
}
}
}
BEGIN_MESSAGE_MAP(CUpdateProduct, CDialog)
//{{AFX_MSG_MAP(CUpdateProduct)
ON_BN_CLICKED(IDC_FIRST, OnFirst)
ON_BN_CLICKED(IDC_PRE, OnPre)
ON_BN_CLICKED(IDC_NEXT, OnNext)
ON_BN_CLICKED(IDC_LAST, OnLast)
ON_BN_CLICKED(IDC_SEARCH, OnSearch)
ON_BN_CLICKED(IDC_MODIFY, OnModify)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
ON_BN_CLICKED(IDC_MCANCEL, OnMCancel)
ON_BN_CLICKED(IDC_SAVE, OnSave)
ON_BN_CLICKED(IDC_FIND, OnFind)
ON_CBN_SELCHANGE(IDC_PID, OnSelChangeProductID)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
144
// THIS FILE IS USED FOR VIEW ALL PRODUCT
// ViewProduct.h : Interface of the CViewProduct class
public:
CViewProduct(CWnd* pParent = NULL);
void GridFormating();
protected:
//{{AFX_VIRTUAL (CViewProduct)
virtual afx_msg void OnCancel();
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
//{{AFX_MAP (CViewProduct)
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MAP
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"RecProductMaster.h"
#include"ViewProduct.h"
RECT rc;
GetClientRect(&rc);
InflateRect(&rc, 0, -50);
145
rc.top = 0;
CRecProductMaster PMRec(&db);
TRY
{
strSQL = _T("SELECT * FROM PRODUCT_MASTER ORDER BY
TO_NUMBER(SUBSTR(PRODUCT_ID, 3))");
PMRec.Open(CRecordset::snapshot, strSQL);
if(!PMRec.IsEOF())
{
int nRW = 0;
CString strRW, strPrice;
146
}
else
{
AfxMessageBox(_T("Record(s) are not present."), MB_OK |
MB_ICONINFORMATION);
PMRec.Close();
CDialog::OnCancel();
}
}
CATCH_ALL(e)
{
PMRec.Close();
AfxMessageBox(_T("Unable to Open Record Source."), MB_OK | MB_ICONERROR);
}
END_CATCH_ALL
147
rc.left = rc.right - 100;
rc.top = rc.bottom + 10;
rc.right = rc.right - 12;
rc.bottom = rc.bottom + 40;
wndButton->MoveWindow(&rc);
GridFormating();
}
BEGIN_MESSAGE_MAP(CViewProduct, CDialog)
//{{AFX_MSG_MAP(CViewProduct)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
148
// THIS FILE IS RECORD SOURCE OF THE PRODUCT_MASTER
// RecProductMaster.h : Interface of the CRecProductMaster class
public:
CRecProductMaster(CDatabase* pDatabase = NULL);
public:
//{{AFX_VIRTUAL (CRecProductMaster)
virtual CString GetDefaultConnect();
virtual CString GetDefaultSQL();
virtual void DoFieldExchange(CFieldExchange* pFX);
//}}AFX_VIRTUAL
};
#include"StdAfx.h"
#include"CRMProject.h"
#include"RecProductMaster.h"
IMPLEMENT_DYNAMIC(CRecProductMaster, CRecordset)
149
m_PRODUCT_DETAIL = _T("");
m_PRODUCT_GUARANTEE = _T("");
m_PRODUCT_PRICE = 0.0;
//}}AFX_FIELD_INIT
m_nFields = 10;
m_nDefaultType = snapshot;
}
// To Exchange Data (IN BOTH DIRECTION) Between the Record Source Data Members
// and the Corresponding Record on the Data Variable.
void CRecProductMaster :: DoFieldExchange(CFieldExchange* pFX)
{
pFX->SetFieldType(CFieldExchange::outputColumn);
//{{AFX_FIELD_MAP (PRODUCT_MASTER)
RFX_Text(pFX, _T("[PRODUCT_ID]"), m_PRODUCT_ID);
RFX_Text(pFX, _T("[PRODUCT_NAME]"), m_PRODUCT_NAME);
RFX_Text(pFX, _T("[PRODUCT_BRAND]"), m_PRODUCT_BRAND);
RFX_Text(pFX, _T("[PRODUCT_TYPE]"), m_PRODUCT_TYPE);
RFX_Text(pFX, _T("[PRODUCT_SIZE]"), m_PRODUCT_SIZE);
RFX_Text(pFX, _T("[PRODUCT_COLOR_AVAILABLE]"), m_PRODUCT_COLOR_AVAILABLE);
RFX_Text(pFX, _T("[PRODUCT_MODEL_NO]"), m_PRODUCT_MODEL_NO);
RFX_Text(pFX, _T("[PRODUCT_DETAIL]"), m_PRODUCT_DETAIL);
RFX_Text(pFX, _T("[PRODUCT_GUARANTEE]"), m_PRODUCT_GUARANTEE);
RFX_Double(pFX, _T("[PRODUCT_PRICE]"), m_PRODUCT_PRICE);
//}}AFX_FIELD_MAP
}
150
// THIS FILE IS USED FOR ADD NEW OFFER
// AddNewOffer.h : Interface of the CAddNewOffer
public:
CAddNewOffer(CWnd* pParent = NULL);
void InitiatVariables();
//{{AFX_DATA (CAddNewOffer)
CString strLetterID;
CString strProductID;
CString strGroup;
CTime tValidDate;
CString strLetter;
CString strLetterDescription;
//}}AFX_DATA
protected:
//{{AFX_VIRTUAL (CAddNewOffer)
virtual BOOL OnInitDialog();
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL
//{{AFX_MSG (IDD_ADDNEWOFFER)
afx_msg void OnOK();
afx_msg void OnCancel();
//}}AFX_MSG
#include"StdAfx.h"
#include"AddNewOffer.h"
#include"RecProductOffer.h"
#include"RecProductMaster.h"
151
}
152
else
{
AfxMessageBox(_T("Unable to Open Record Source. Please try again."),MB_OK |
MB_ICONSTOP);
return FALSE;
}
}
//{{AFX_DATA_MAP (CAddNewOffer)
DDX_Text(pDX, IDC_LETTERID, strLetterID);
DDX_Control(pDX, IDC_PRODUCTID, cmbProductID);
DDX_Text(pDX, IDC_GROUP, strGroup);
DDV_MaxChars(pDX, strGroup, 20);
DDX_DateTimeCtrl(pDX, IDC_VALIDDATE, tValidDate);
DDX_Text(pDX, IDC_LETTER, strLetter);
DDV_MaxChars(pDX, strLetter, 50);
DDX_Text(pDX, IDC_OFFERDESC, strLetterDescription);
DDV_MaxChars(pDX, strLetterDescription, 200);
//}}AFX_DATA_MAP
}
153
{
TRY
{
// To Begin a Transaction With the Connected Data Source.
db.BeginTrans();
154
AfxMessageBox(_T("Unable to Open Record Source. Please try again"),
MB_OK | MB_ICONSTOP);
}
}
}
}
// Click CANCEL Button then CLOSE the DATABASE Connection and Interface
void CAddNewOffer :: OnCancel()
{
db.Close();
CDialog::OnCancel();
}
155
// THIS FILE IS USED FOR VIEW ALL OFFER
// ViewOffer.h : Interface of the CViewOffer class
//{{AFX_INCLUDES()
#include"CrystalReportViewer10.h"
//}}AFX_INCLUDES
public:
CViewOffer(CWnd* pParent = NULL);
void HandleError(_com_error &e);
void ResizeViewer(CRect crRect);
protected:
//{{AFX_VIRTUAL (CViewOffer)
virtual BOOL OnInitDialog();
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL
//{{AFX_MSG (CViewOffer)
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#include "stdafx.h"
#include "ViewOffer.h"
156
{
// if errors occur, handle and display errors
HandleError(e);
}
// initialise the m_Report variable to NULL
m_Report = NULL;
}
BOOL CViewOffer::OnInitDialog()
{
CDialog::OnInitDialog();
// A dummy variant
VariantInit (&dummy);
CString strPath;
char lpPath[BUFFER_LENGTH];
CRect rect;
dummy.vt = VT_EMPTY;
::GetCurrentDirectory(BUFFER_LENGTH, lpPath);
strPath.Format(_T("%s"), lpPath);
_bstr_t ReportPath(strPath);
_variant_t vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
return TRUE;
}
157
// test to see if the viewer has been drawn yet or not...
if( !::IsWindow(m_Viewer.m_hWnd ) )
{
return;
}
try
{
// move and redraw the viewer's window
CRect rect(0, 0, cx, cy);
ResizeViewer(rect);
}
catch (_com_error& e)
{
HandleError(e);
}
}
BEGIN_MESSAGE_MAP(CViewOffer, CDialog)
//{{AFX_MSG_MAP(CViewOffer)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
158
// THIS FILE IS RECORD SOURCE OF THE PRODUCT_OFFER
// RecProductOffer.h : Interface of the COfferRecord class
public:
CRecProductOffer(CDatabase* pDatabase = NULL);
public:
//{{AFX_VIRTUAL (CRecProductOffer)
virtual CString GetDefaultConnect();
virtual CString GetDefaultSQL();
virtual void DoFieldExchange(CFieldExchange* pFX);
//}}AFX_VIRTUAL
};
#include"StdAfx.h"
#include "RecProductOffer.h"
IMPLEMENT_DYNAMIC(CRecProductOffer, CRecordset)
m_nFields = 6;
m_nDefaultType = snapshot;
}
159
// Default Connection String
CString CRecProductOffer :: GetDefaultConnect()
{
return _T("ODBC;DSN=CRM;UID=CRM;PWD=CRM;");
}
// To Exchange Data (IN BOTH DIRECTION) Between the Record Source Data Members
// and the Corresponding Record on the Data Variable.
void CRecProductOffer :: DoFieldExchange(CFieldExchange* pFX)
{
pFX->SetFieldType(CFieldExchange::outputColumn);
//{{AFX_FIELD_MAP (PRODUCT_OFFER)
RFX_Text(pFX, _T("[OFFER_LETTER_ID]"), m_OFFER_LETTER_ID);
RFX_Text(pFX, _T("[CRM].[PRODUCT_OFFER].[PRODUCT_ID]"), m_OFFER_PRODUCT_ID);
RFX_Text(pFX, _T("[PRODUCT_ID]"), m_OFFER_PRODUCT_ID);
RFX_Text(pFX, _T("[OFFER_TARGET_GROUP]"), m_OFFER_TARGET_GROUP);
RFX_Date(pFX, _T("[OFFER_DATE_VALIDITY]"), m_OFFER_DATE_VALIDITY);
RFX_Text(pFX, _T("[OFFER_LETTER]"), m_OFFER_SUMMARY);
RFX_Text(pFX, _T("[OFFER_DESCRIPTION]"), m_OFFER_DESCRIPTION);
//}}AFX_FIELD_MAP
}
160
// THIS FILE IS USED FOR ADD NEW COMPLAIN
// AddNewComplain.h : Interface of the CAddNewComplain class
//{{AFX_DATA (CAddNewComplain)
CString strComplainID;
CComboBox cmbProductID;
CString strProductID;
CString strProductName;
CString strCustomerID;
CString strCustomerName;
int nComplexcity;
CTime tDate;
CString strDate;
CString strDescription;
//}}AFX_DATA
public:
CAddNewComplain(CWnd* pParent = NULL);
void InitiatVariables();
protected:
//{{AFX_VIRTUAL(CAddNewComplain)
virtual BOOL OnInitDialog();
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL
//{{AFX_MSG (CAddNewComplain)
afx_msg void OnRefresh();
afx_msg void OnOK();
afx_msg void OnCancel();
afx_msg void OnSelChangeProductID();
afx_msg void OnSelChangeCustomerID();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"AddNewComplain.h"
#include"RecProductMaster.h"
161
#include"RecCustomerMaster.h"
#include"RecCustomerComplain.h"
162
Rec.Close();
}
else
AfxMessageBox(_T("Product is not present."), MB_OK|MB_ICONSTOP);
}
return TRUE;
}
//{{AFX_DATA_MAP (CAddNewComplain)
DDX_Text(pDX, IDC_COMPLAINID, strComplainID);
DDX_Control(pDX, IDC_PRODUCTID, cmbProductID);
DDX_Text(pDX, IDC_PRODUCTNAME, strProductName);
DDX_Text(pDX, IDC_CUSTOMERID, strCustomerID);
DDV_MaxChars(pDX, strCustomerID, 10);
DDX_Text(pDX, IDC_CUSTOMERNAME, strCustomerName);
DDX_CBIndex(pDX, IDC_COMPLEXCITY, nComplexcity);
DDX_Text(pDX, IDC_DATE, strDate);
DDX_Text(pDX, IDC_DESCRIPTION, strDescription);
DDV_MaxChars(pDX, strDescription, 50);
//}}AFX_DATA_MAP
}
// Use This DATA MEMBER (m_strFilter) to Store a CString Containing a SQL WHERE clause.
Rec.m_strFilter = "PRODUCT_ID = '" + strTempPID + "' ";
if(Rec.Open())
{
strProductName = _T(Rec.m_PRODUCT_NAME);
UpdateData(FALSE);
}
else
{
AfxMessageBox(_T("Product not found."), MB_OK|MB_ICONINFORMATION);
}
}
163
// Enter CUSTOMER_ID then Select Corresponding CUSTOMER_NAME From CUSTOMER_MASTER
void CAddNewComplain :: OnSelChangeCustomerID()
{
CString strTempCID = _T("");;
GetDlgItemText(IDC_CUSTOMERID, strTempCID);
CRecCustomerMaster Rec(&db);
Rec.m_strFilter = "CUSTOMER_ID = '" + strTempCID + "' ";
if(Rec.Open())
{
if(!Rec.IsEOF())
{
strCustomerName = _T(Rec.m_CUSTOMER_NAME);
GetDlgItemText(IDC_CUSTOMERID, strCustomerID);
UpdateData(FALSE);
}
else
{
AfxMessageBox(_T("Customer not found. Please try again."),
MB_OK|MB_ICONINFORMATION);
SetDlgItemText(IDC_PRODUCTID, "");
SetDlgItemText(IDC_PRODUCTNAME, "");
UpdateData(FALSE);
}
}
}
164
GetDlgItemText(IDC_CUSTOMERID, strCustomerID);
if(strCustomerID.IsEmpty())
{
AfxMessageBox(_T("Please Select Customer Id."));
GetDlgItem(IDC_CUSTOMERID)->SetFocus();
bTest = FALSE;
}
}
if(bTest)
{
TRY
{
CRecCustomerComplain Rec(&db);
if(Rec.Open(CRecordset::snapshot))
{
// To Begin a Transaction With the Connected Data Source.
db.BeginTrans();
165
AfxMessageBox(_T("Record Source is not Open. Please try again."), MB_OK
| MB_ICONERROR);
// Click CANCEL Button then CLOSE the DATABASE Connection and Interface
void CAddNewComplain :: OnCancel()
{
db.Close();
CDialog::OnCancel();
}
BEGIN_MESSAGE_MAP(CAddNewComplain, CDialog)
//{{AFX_MSG_MAP(CAddNewComplain)
ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
ON_CBN_SELCHANGE(IDC_PRODUCTID, OnSelChangeProductID)
ON_EN_KILLFOCUS(IDC_CUSTOMERID, OnSelChangeCustomerID)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
166
// THIS FILE IS USED FOR PENDING COMPLAIN
// PendingComplain.h : Interface of the CPendingComplain class
//{{AFX_DATA (CPendingComplain)
CString strComplainID;
int nComplainID;
CString strProductID;
CString strProductName;
CString strCustomerID;
CString strCustomerName;
UINT nComplex;
CTime tComplainDate;
CString strComplainDate;
CString strDescription;
CString strTechnician;
CTime tActionDate;
CString strAmount;
int nAmount;
CString strActionTaken;
//}}AFX_DATA
public:
CPendingComplain(CWnd* pParent = NULL);
void InitiatVariables();
protected:
//{{AFX_VIRTUAL (CPendingComplain)
virtual BOOL OnInitDialog();
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL
//{{AFX_MSG (CPendingComplain)
afx_msg void OnRefresh();
afx_msg void OnOK();
afx_msg void OnCancel();
afx_msg void OnSelChangeCustomerID();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
167
// PendingComplain.cpp : Implementation of the CPendingComplain class
#include"StdAfx.h"
#include"PendingComplain.h"
#include"RecCustomerComplain.h"
#include"RecCustomerMaster.h"
#include"RecProductMaster.h"
168
}
Rec.Close();
GetDlgItem(IDC_TECHNICIAN)->SetFocus();
}
else
{
AfxMessageBox(_T("Complain(s) are not present."),
MB_OK|MB_ICONINFORMATION);
db.Close();
CDialog::OnCancel();
}
}
return TRUE;
}
//{{AFX_DATA_MAP(CPendingComplain)
DDX_CBIndex(pDX, IDC_COMPLAINID, nComplainID);
DDX_Text(pDX, IDC_PRODUCTID, strProductID);
DDX_Text(pDX, IDC_PRODUCTNAME, strProductName);
DDX_Text(pDX, IDC_CUSTOMERID, strCustomerID);
DDX_Text(pDX, IDC_CUSTOMERNAME, strCustomerName);
DDX_Text(pDX, IDC_COMPLEX, nComplex);
DDX_Text(pDX, IDC_COMPLAINDATE, strComplainDate);
DDX_Text(pDX, IDC_DESCRIPTION, strDescription);
DDX_Text(pDX, IDC_TECHNICIAN, strTechnician);
DDV_MaxChars(pDX, strTechnician, 30);
DDX_DateTimeCtrl(pDX, IDC_ACTIONDATE, tActionDate);
DDX_Text(pDX, IDC_AMOUNT, nAmount);
DDV_MinMaxInt(pDX, nAmount, 150, 99999);
DDX_Text(pDX, IDC_ACTIONTAKEN, strActionTaken);
DDV_MaxChars(pDX, strActionTaken, 50);
//}}AFX_DATA_MAP
}
169
{
strProductID = _T(Rec.m_PRODUCT_ID);
strCustomerID = _T(Rec.m_CUSTOMER_ID);
nComplex = _T(Rec.m_COMPLAIN_COMPLEXITY);
strComplainDate = Rec.m_COMPLAINTEGER_DATE.Format(_T("%d/%m/%Y"));
strDescription = _T(Rec.m_COMPLAIN_DESCRIPTION);
Rec.Close();
170
if(strTechnician.IsEmpty())
{
AfxMessageBox(_T("Please Enter Technician Name."));
GetDlgItem(IDC_TECHNICIAN)->SetFocus();
bTest = FALSE;
}
if(bTest)
{
strSQL = _T("");
CString strTempCID = _T("");
GetDlgItemText(IDC_COMPLAINID, strTempCID);
// Click CANCEL Button then CLOSE the DATABASE Connection and Interface
void CPendingComplain :: OnCancel()
{
db.Close();
CDialog::OnCancel();
171
}
BEGIN_MESSAGE_MAP(CPendingComplain, CDialog)
//{{AFX_MSG_MAP(CPendingComplain)
ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
ON_CBN_SELCHANGE(IDC_COMPLAINID, OnSelChangeCustomerID)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
172
// THIS FILE IS USED FOR VIW ALL COMPLAIN
// ViewComplain.h : Interface of the CViewComplain class
public:
CViewComplain(CWnd* pParent = NULL);
void GridFormating();
protected:
//{{AFX_VIRTUAL (CViewComplain)
virtual afx_msg void OnCancel();
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
//{{AFX_MAP (CViewComplain)
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MAP
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"ViewComplain.h"
#include"RecCustomerComplain.h"
RECT rc;
GetClientRect(&rc);
InflateRect(&rc, 0, -50);
173
rc.top = 0;
CRecCustomerComplain CCRec(&db);
TRY
{
strSQL = _T("SELECT * FROM CUSTOMER_COMPLAIN ORDER BY
TO_NUMBER(SUBSTR(COMPLAIN_ID, 3))");
CCRec.Open(CRecordset::snapshot, strSQL);
if(!CCRec.IsEOF())
{
int nRW = 0;
CString strRW, strComplainDate, strActionDate, strPayment, strComplex;
174
VSGrid->PutTextMatrix(nRW, 6, _bstr_t(strComplainDate));
if(CCRec.m_ACTION_TAKEN == "PENDING")
{
strActionDate = _T("");
VSGrid->PutTextMatrix(nRW, 8, _bstr_t(""));
strPayment = _T("0");
}
else
{
strActionDate =
CCRec.m_DATE_OF_ACTION.Format(_T("%d/%m/%Y"));
VSGrid->PutTextMatrix(nRW, 8, _bstr_t(CCRec.m_TECHNICIAN));
strPayment.Format(_T("%f"), CCRec.m_PAYMENT_RECIEVED);
}
VSGrid->PutTextMatrix(nRW, 7, _bstr_t(strActionDate));
VSGrid->PutTextMatrix(nRW, 9, _bstr_t(CCRec.m_ACTION_TAKEN));
VSGrid->PutTextMatrix(nRW, 10, _bstr_t(strPayment));
}
}
else
{
AfxMessageBox(_T("Record(s) are not present."), MB_OK |
MB_ICONINFORMATION);
CCRec.Close();
CDialog::OnCancel();
}
}
CATCH_ALL(e)
{
CCRec.Close();
AfxMessageBox(_T("Unable to Open Record Source."), MB_OK | MB_ICONERROR);
}
END_CATCH_ALL
175
db.Close();
CDialog::OnCancel();
}
BEGIN_MESSAGE_MAP(CViewComplain, CDialog)
//{{AFX_MSG_MAP(CViewComplain)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
176
// THIS FILE IS A RECORD SOURCE OF CUSTOMER_COMPLAIN
// RecCustomerComplain.h : Interface of the CRecCustomerComplain class
public:
CRecCustomerComplain(CDatabase* pDatabase = NULL);
public:
//{{AFX_VIRTUAL (CRecCustomerComplain)
virtual CString GetDefaultConnect();
virtual CString GetDefaultSQL();
virtual void DoFieldExchange(CFieldExchange* pFX);
//}}AFX_VIRTUAL
};
#include"StdAfx.h"
#include"RecCustomerComplain.h"
IMPLEMENT_DYNAMIC(CRecCustomerComplain, CRecordset)
177
//}}AFX_FIELD_INIT
m_nFields = 10;
m_nDefaultType = snapshot;
}
// To Exchange Data (IN BOTH DIRECTION) Between the Record Source Data Members
// and the Corresponding Record on the Data Variable.
void CRecCustomerComplain :: DoFieldExchange(CFieldExchange* pFX)
{
pFX->SetFieldType(CFieldExchange::outputColumn);
//{{AFX_FIELD_MAP (CUSTOMER_COMPLAIN)
RFX_Text(pFX, _T("[COMPLAIN_ID]"), m_COMPLAIN_ID);
RFX_Text(pFX, _T("[PRODUCT_ID]"), m_PRODUCT_ID);
RFX_Text(pFX, _T("[CUSTOMER_ID]"), m_CUSTOMER_ID);
RFX_Text(pFX, _T("[COMPLAIN_DESCRIPTION]"), m_COMPLAIN_DESCRIPTION);
RFX_Int(pFX, _T("[COMPLAIN_COMPLEXITY]"), m_COMPLAIN_COMPLEXITY);
RFX_Date(pFX, _T("[COMPLAINTEGER_DATE]"), m_COMPLAINTEGER_DATE);
RFX_Date(pFX, _T("[DATE_OF_ACTION]"), m_DATE_OF_ACTION);
RFX_Text(pFX, _T("[TECHNICIAN]"), m_TECHNICIAN);
RFX_Text(pFX, _T("[ACTION_TAKEN]"), m_ACTION_TAKEN);
RFX_Double(pFX, _T("[PAYMENT_RECIEVED]"), m_PAYMENT_RECIEVED);
//}}AFX_FIELD_MAP
}
178
// THIS FILE IS USED FOR ADD NEW ORDER
// AddNewOrder.h : Interface of the CAddNewOrder
//{{AFX_INCLUDES()
#include "vsflexgrid.h"
//}}AFX_INCLUDES
//{{AFX_DATA (CAddNewOrder)
CString strBillNo;
CString strProductID;
CString strCustomerID;
CString strCustomerName;
CString strSalesmanID;
CString strSalesmanName;
double fGrandTotal;
CTime tBillDate;
CVSFlexGrid Grid;
//}}AFX_DATA
public:
CAddNewOrder(CWnd* pParent = NULL);
void InitiatVariables();
POINT MouseToScreen(HWND hWnd, float X, float Y);
void AddRow();
void DeleteRow();
void GridFormat();
protected:
//{{AFX_VIRTUAL (CAddNewOrder)
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL
//{{AFX_MSG (CAddNewOrder)
virtual BOOL OnInitDialog();
afx_msg void OnRefresh();
virtual void OnOK();
virtual void OnCancel();
afx_msg void OnSelchangeSalesmanID();
afx_msg void OnSelchangeCustomerID();
//}}AFX_MSG
179
//{{AFX_EVENTSINK_MAP (CAddNewOrder)
afx_msg void OnMouseDownGrid(short Button, short Shift, float X, float Y);
afx_msg void OnAfterEditGrid(long Row, long Col);
//}}AFX_EVENTSINK_MAP
DECLARE_EVENTSINK_MAP()
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"AddNewOrder.h"
#include"RecCustomerBill.h"
#include"RecCustomerMaster.h"
#include"RecSalesmanMaster.h"
#include"RecProductMaster.h"
#include"RecProductDiscount.h"
#include"RecProductInventory.h"
//{{AFX_DATA_INIT(CAddNewOrder)
strCustomerID = _T("");
strCustomerName = _T("");
strSalesmanID = _T("");
strSalesmanName = _T("");
tBillDate = CTime::GetCurrentTime();
fGrandTotal = 0.0;
//}}AFX_DATA_INIT
180
void CAddNewOrder :: DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP (CAddNewOrder)
DDX_Text(pDX, IDC_BILLNO, strBillNo);
DDX_CBString(pDX, IDC_CUSTOMERID, strCustomerID);
DDX_Text(pDX, IDC_CUSTOMERNAME, strCustomerName);
DDX_CBString(pDX, IDC_SALESMANID, strSalesmanID);
DDX_Text(pDX, IDC_SALESMANNAME, strSalesmanName);
DDX_DateTimeCtrl(pDX, IDC_BILLDATE, tBillDate);
DDX_Control(pDX, IDC_ORDERGRID, Grid);
DDX_Text(pDX, IDC_GRANDTOTAL, fGrandTotal);
//}}AFX_DATA_MAP
}
181
AfxMessageBox(_T("Unable to Open Record Source."), MB_OK | MB_ICONERROR);
}
END_CATCH_ALL
182
// UPDATE Information in PRODUCT_INVENTORY Record Source
for(Row = 1; Row <= (Grid.GetRows()-1); Row++)
{
PIRec.m_strFilter = "PRODUCT_ID = '" + strProductID + "'";
PIRec.Open(CRecordset::snapshot);
PIRec.Edit();
int nStock = 0;
sscanf(Grid.GetTextMatrix(Row, 3), "%d", &nStock);
PIRec.m_PRODUCT_STOCK = PIRec.m_PRODUCT_STOCK - nStock;
PIRec.Update();
PIRec.Close();
}
db.CommitTrans();
AfxMessageBox(_T("Succesfull Save."), MB_OK | MB_ICONINFORMATION);
}
CATCH_ALL(e)
{
db.Rollback();
CBRec.Close();
PIRec.Close();
AfxMessageBox(_T("Unable to Save Information."), MB_OK | MB_ICONERROR);
}
END_CATCH_ALL
}
183
}
CATCH_ALL(e)
{
SMRec.Close();
AfxMessageBox(_T("Unable to Open Record Source. Please try again."), MB_OK | MB_ICONERROR);
}
END_CATCH_ALL
}
// Click RIGHT MOUSE Button Then Display Popup Menu and Select Option
void CAddNewOrder :: OnMouseDownGrid(short Button, short Shift, float X, float Y)
{
if (Button != 2)
return;
// Build Menu
CMenu MyMenu;
MyMenu.CreatePopupMenu();
LPTSTR arrItems[] = { "Add New", "Delete", "Save", "Refresh", NULL };
for (int i = 0; arrItems[i]; i++)
MyMenu.AppendMenu(0, 1000 + i, arrItems[i]);
184
if (option > 0)
{
switch(option)
{
case 1000:
AddRow();
break;
case 1001:
DeleteRow();
break;
case 1002:
OnOK();
break;
case 1003:
OnRefresh();
break;
}
}
}
185
// Find Maximum Number of Items
PIRec.m_strFilter = "PRODUCT_ID = '" + strProductID + "'";
PIRec.Open(CRecordset::snapshot);
MaxStock = PIRec.m_PRODUCT_STOCK;
PIRec.Close();
if(Grid.GetTextMatrix(Row, 3) == "")
fQty = 0;
else
sscanf(Grid.GetTextMatrix(Row, 3), "%f", &fQty);
186
if(Grid.GetTextMatrix(Row, 5) == "")
fDiscount = 0;
else
sscanf(Grid.GetTextMatrix(Row, 5), "%f", &fDiscount);
187
// Convert MOUSE Coordinate to Screen Coordinate
POINT CAddNewOrder :: MouseToScreen(HWND hWnd, float X, float Y)
{
// Get Screen Resolution
static POINT logPix = {0,0};
if (logPix.x == 0)
{
HDC hdc = ::GetDC(NULL);
logPix.x = GetDeviceCaps(hdc, LOGPIXELSX);
logPix.y = GetDeviceCaps(hdc, LOGPIXELSY);
::ReleaseDC(NULL, hdc);
}
BEGIN_EVENTSINK_MAP(CAddNewOrder, CDialog)
//{{AFX_EVENTSINK_MAP(CAddNewOrder)
ON_EVENT(CAddNewOrder, IDC_ORDERGRID, -605 /* MouseDown */, OnMouseDownGrid, VTS_I2
VTS_I2 VTS_R4 VTS_R4)
ON_EVENT(CAddNewOrder, IDC_ORDERGRID, 24 /* AfterEdit */, OnAfterEditGrid, VTS_I4 VTS_I4)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
BEGIN_MESSAGE_MAP(CAddNewOrder, CDialog)
//{{AFX_MSG_MAP(CAddNewOrder)
ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
ON_CBN_SELCHANGE(IDC_SALESMANID, OnSelchangeSalesmanID)
188
ON_CBN_SELCHANGE(IDC_CUSTOMERID, OnSelchangeCustomerID)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
189
THIS FILE IS A RECORD SOURCE OF CUSTOMER_BILL
// RecCustomerBill.h : Interface of the CRecCustomerBill class
public:
// Variable of the CUSTOMER_BILL Data Source Fields
//{{AFX_FIELD (CUSTOMER_BILL)
CString m_BILL_NO;
CString m_CUSTOMER_ID;
CString m_SALESMAN_ID;
CTime m_BILL_DATE;
double m_TOTAL;
//}}AFX_FIELD
public:
CRecCustomerBill(CDatabase* pDatabase = NULL);
//{{AFX_VIRTUAL(CRecCustomerBill)
virtual CString GetDefaultConnect();
virtual CString GetDefaultSQL();
virtual void DoFieldExchange(CFieldExchange* pFX);
//}}AFX_VIRTUAL
};
#include"StdAfx.h"
#include"RecCustomerBill.h"
IMPLEMENT_DYNAMIC(CRecCustomerBill, CRecordset)
m_nFields = 5;
m_nDefaultType = snapshot;
}
190
// Default Connection String
CString CRecCustomerBill::GetDefaultConnect()
{
return _T("ODBC;DSN=crm;UID=crm;PWD=crm;");
}
// To Exchange Data (IN BOTH DIRECTION) Between the Record Source Data Members
// and the Corresponding Record on the Data Variable.
void CRecCustomerBill::DoFieldExchange(CFieldExchange* pFX)
{
pFX->SetFieldType(CFieldExchange::outputColumn);
//{{AFX_FIELD_MAP(CRecCustomerBill)
RFX_Text(pFX, _T("[BILL_NO]"), m_BILL_NO);
RFX_Date(pFX, _T("[BILL_DATE]"), m_BILL_DATE);
RFX_Text(pFX, _T("[CUSTOMER_ID]"), m_CUSTOMER_ID);
RFX_Text(pFX, _T("[SALESMAN_ID]"), m_SALESMAN_ID);
RFX_Double(pFX, _T("[TOTAL]"), m_TOTAL);
//}}AFX_FIELD_MAP
}
191
THIS FILE IS USED FOR ADD NEW SALESMAN
// AddNewSalesman.h : Interface of the CAddNewSalesman class
//{{AFX_DATA (CAddNewSalesman)
CString strSalesmanID;
CString strSalesmanName;
CString strAddress;
CString strCity;
CString strPhone;
CString strMobile;
CString strEMail;
CTime tDateOfBirth;
CTime tDateOfJoin;
CString strManager;
CString strDesignation;
//}}AFX_DATA
public:
CAddNewSalesman(CWnd* pParent = NULL);
void InitiatVariables();
protected:
//{{AFX_VIRTUAL (CAddNewSalesman)
virtual void OnOK();
virtual void OnCancel();
virtual BOOL OnInitDialog();
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL
//{{AFX_MSG (CAddNewSalesman)
afx_msg void OnRefersh();
afx_msg void OnSelchangeDesignation();
afx_msg void OnDropdownDesignation();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"AddNewSalesman.h"
#include"RecSalesmanMaster.h"
192
// Constructer of the CAddNewSalesman to Initiate the Variables
CAddNewSalesman :: CAddNewSalesman(CWnd* pParent) : CDialog(CAddNewSalesman::IDD, pParent)
{
InitiatVariables();
}
//{{AFX_DATA_MAP(CAddNewSalesman)
DDX_Text(pDX, IDC_SALESMANID, strSalesmanID);
DDX_Text(pDX, IDC_SALESMANNAME, strSalesmanName);
DDV_MaxChars(pDX, strSalesmanName, 25);
DDX_Text(pDX, IDC_ADDRESS, strAddress);
DDV_MaxChars(pDX, strAddress, 30);
193
DDX_Text(pDX, IDC_CITY, strCity);
DDV_MaxChars(pDX, strCity, 15);
DDX_Text(pDX, IDC_PHONE, strPhone);
DDV_MaxChars(pDX, strPhone, 12);
DDX_Text(pDX, IDC_MOBILE, strMobile);
DDV_MaxChars(pDX, strMobile, 12);
DDX_DateTimeCtrl(pDX, IDC_DATEOFBIRTH, tDateOfBirth);
DDX_DateTimeCtrl(pDX, IDC_DATEOFJOIN, tDateOfJoin);
DDX_Text(pDX, IDC_EMAIL, strEMail);
DDV_MaxChars(pDX, strEMail, 40);
DDX_Text(pDX, IDC_MANAGER, strManager);
DDV_MaxChars(pDX, strManager, 20);
//}}AFX_DATA_MAP
}
194
else if(strDesignation.IsEmpty())
{
AfxMessageBox(_T("Please Enter Designation."), MB_OK |
MB_ICONINFORMATION);
GetDlgItem(IDC_DESIGNATION)->SetFocus();
bTest = FALSE;
}
if(bTest)
{
// ERROR Handling in VISUAL C++
TRY
{
db.BeginTrans();
CRecSalesmanMaster SMRec(&db);
if(SMRec.Open(CRecordset::snapshot))
{
SMRec.AddNew();
195
END_CATCH_ALL
}
}
}
BEGIN_MESSAGE_MAP(CAddNewSalesman, CDialog)
//{{AFX_MSG_MAP (CAddNewSalesman)
ON_BN_CLICKED(IDC_REFERSH, OnRefersh)
ON_CBN_SELCHANGE(IDC_DESIGNATION, OnSelchangeDesignation)
ON_CBN_DROPDOWN(IDC_DESIGNATION, OnDropdownDesignation)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
196
// THIS FILE IS USED FOR UPDATE SALESMAN INFORMATION
// UpdateSalesman.h : Interface of the CUpdateSalesman class
//{{AFX_INCLUDES()
#include "vsflexgrid.h"
//}}AFX_INCLUDES
//{{AFX_DATA(CUpdateSalesman)
CDateTimeCtrl m_Date;
CVSFlexGrid m_Grid;
//}}AFX_DATA
public:
CUpdateSalesman(CWnd* pParent = NULL); // standard constructor
void PopulateValue();
protected:
BOOL m_bDropped;
CString strLastValue;
protected:
//{{AFX_VIRTUAL (CUpdateSalesman)
virtual void OnOK();
virtual void OnCancel();
virtual BOOL OnInitDialog();
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
//{{AFX_MSG (CUpdateSalesman)
afx_msg void OnDelete();
197
//}}AFX_MSG
DECLARE_EVENTSINK_MAP()
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"UpdateSalesman.h"
#include"RecSalesmanMaster.h"
198
m_Grid.SetTextMatrix(nSeq, 10, _T(SMRec.m_SALESMAN_DESIGNATION));
m_Grid.SetTextMatrix(nSeq, 11, _T(SMRec.m_SALESMAN_MANAGER));
m_Grid.SetTextMatrix(nSeq, 12, _T("No"));
}
SMRec.Close();
}
else
{
AfxMessageBox(_T("Record(s) Not Present."), MB_OK | MB_ICONINFORMATION);
SMRec.Close();
db.Close();
CDialog::OnCancel();
}
}
CATCH_ALL(e)
{
SMRec.Close();
AfxMessageBox(_T("Unable to Open Record Source"), MB_OK | MB_ICONERROR);
}
END_CATCH_ALL
}
//{{AFX_DATA_MAP(CUpdateSalesman)
DDX_Control(pDX, IDC_DATE, m_Date);
DDX_Control(pDX, IDC_SALESMANGRID, m_Grid);
//}}AFX_DATA_MAP
}
199
return TRUE;
}
200
// Press SAVE Button Then Save Modified Records
void CUpdateSalesman :: OnOK()
{
int nRow;
BOOL bFlag = FALSE;
CRecSalesmanMaster SMRec(&db);
for(nRow = 1; nRow <= (m_Grid.GetRows()-1); nRow++)
{
TRY
{
if(m_Grid.GetTextMatrix(nRow, 12) == "Yes")
{
if(!bFlag)
{
if(AfxMessageBox(_T("Do you want to Update Record"), MB_YESNO
| MB_ICONQUESTION) == IDYES)
bFlag = TRUE;
else
break;
}
db.BeginTrans();
SMRec.m_strFilter = "SALESMAN_ID = '" + m_Grid.GetTextMatrix(nRow, 1) +
"'";
SMRec.Open(CRecordset::snapshot);
SMRec.Edit();
SMRec.m_SALESMAN_NAME = m_Grid.GetTextMatrix(nRow, 2);
SMRec.m_SALESMAN_ADDRESS = m_Grid.GetTextMatrix(nRow, 3);
SMRec.m_SALESMAN_CITY = m_Grid.GetTextMatrix(nRow, 4);
SMRec.m_SALESMAN_PHONE = m_Grid.GetTextMatrix(nRow, 5);
SMRec.m_SALESMAN_MOBILE = m_Grid.GetTextMatrix(nRow, 6);
SMRec.m_SALESMAN_EMAIL = m_Grid.GetTextMatrix(nRow, 7);
SMRec.m_SALESMAN_DOB = m_Grid.GetTextMatrix(nRow, 8);
SMRec.m_SALESMAN_DATE_OF_JOIN = m_Grid.GetTextMatrix(nRow, 9);
SMRec.m_SALESMAN_DESIGNATION = m_Grid.GetTextMatrix(nRow, 10);
SMRec.m_SALESMAN_MANAGER = m_Grid.GetTextMatrix(nRow,
11);
m_Grid.SetTextMatrix(nRow, 12, _T("No"));
SMRec.Update();
SMRec.Close();
db.CommitTrans();
}
}
CATCH_ALL(e)
{
SMRec.Close();
db.Rollback();
AfxMessageBox(_T("Unable to Update Information."), MB_OK | MB_ICONERROR);
}
END_CATCH_ALL
}
if(bFlag)
201
AfxMessageBox(_T("Salesman Information Update."), MB_OK | MB_ICONINFORMATION);
else
PopulateValue();
}
m_Date.SetParent((CWnd*)&m_Grid);
m_Date.MoveWindow(x, y, nWidth, nHeight, FALSE);
202
// show and activate date picker control
m_Date.ShowWindow(SW_SHOW);
m_Date.SetFocus();
// DONE
*pResult = 0;
}
203
if(strLastValue != m_Grid.GetTextMatrix(Row, Col))
m_Grid.SetTextMatrix(Row, 12, _T("Yes"));
m_Grid.AutoSize(Col, _variant_t(Col), vtMissing, _variant_t(200));
}
BEGIN_MESSAGE_MAP(CUpdateSalesman, CDialog)
//{{AFX_MSG_MAP (CUpdateSalesman)
ON_COMMAND(IDC_DELETE, OnDelete)
ON_NOTIFY(NM_KILLFOCUS, IDC_DATE, OnKillfocusDate)
ON_NOTIFY(DTN_CLOSEUP, IDC_DATE, OnCloseupDate)
ON_NOTIFY(DTN_DROPDOWN, IDC_DATE, OnDropdownDate)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BEGIN_EVENTSINK_MAP(CUpdateSalesman, CDialog)
//{{AFX_EVENTSINK_MAP (CUpdateSalesman)
ON_EVENT(CUpdateSalesman, IDC_SALESMANGRID, -600 /* Click */, OnClickGrid, VTS_NONE)
ON_EVENT(CUpdateSalesman, IDC_SALESMANGRID, 24 /* AfterEdit */, OnAfterEditGrid, VTS_I4
VTS_I4)
ON_EVENT(CUpdateSalesman, IDC_SALESMANGRID, 21 /* BeforeEdit */, OnBeforeEditGrid, VTS_I4
VTS_I4 VTS_PBOOL)
204
// THIS FILE IS USED FOR VIEW ALL SALESMAN INFORMATION
// ViewSalesman.h : Interface of the CViewSalesman class
public:
CViewSalesman(CWnd* pParent = NULL);
void GridFormating();
protected:
//{{AFX_VIRTUAL (CViewSalesman)
virtual afx_msg void OnCancel();
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
//{{AFX_MAP (CViewSalesman)
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MAP
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"ViewSalesman.h"
#include"RecSalesmanMaster.h"
RECT rc;
GetClientRect(&rc);
InflateRect(&rc, 0, -50);
205
rc.top = 0;
CRecSalesmanMaster SMRec(&db);
TRY
{
strSQL = _T("SELECT * FROM SALESMAN_MASTER ORDER BY TO_NUMBER(SUBSTR(SALESMAN_ID, 3))");
SMRec.Open(CRecordset::snapshot, strSQL);
if(!SMRec.IsEOF())
{
int nRW = 0;
CString strRW, strDOB, strDOJ;
206
strDOJ = SMRec.m_SALESMAN_DATE_OF_JOIN.Format(_T("%d/%m/%Y"));
VSGrid->PutTextMatrix(nRW, 9, _bstr_t(strDOJ));
VSGrid->PutTextMatrix(nRW, 10,
_bstr_t(SMRec.m_SALESMAN_MANAGER));
VSGrid->PutTextMatrix(nRW, 11,
_bstr_t(SMRec.m_SALESMAN_DESIGNATION));
}
}
else
{
AfxMessageBox(_T("Record(s) are not present."), MB_OK |
MB_ICONINFORMATION);
SMRec.Close();
CDialog::OnCancel();
}
}
CATCH_ALL(e)
{
SMRec.Close();
AfxMessageBox(_T("Unable to Open Record Source."), MB_OK | MB_ICONERROR);
}
END_CATCH_ALL
207
InflateRect(&rc, 0, - 50);
rc.top = 0;
CWnd *wndGrid = GetDlgItem(IDC_GRID);
wndGrid->MoveWindow(&rc);
BEGIN_MESSAGE_MAP(CViewSalesman, CDialog)
//{{AFX_MSG_MAP(CViewSalesman)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
208
// THIS FILE IS A RECORD SOURCE OF THE SALESMAN_MASTER
// RecSalesmanMaster.h : Interface of the CRecSalesmanMaster class
public:
// Variable of the SALESMAN_MASTER Data Source Fields
//{{AFX_FIELD (SALESMAN_MASTER)
CString m_SALESMAN_ID;
CString m_SALESMAN_NAME;
CString m_SALESMAN_ADDRESS;
CString m_SALESMAN_CITY;
CString m_SALESMAN_PHONE;
CString m_SALESMAN_MOBILE;
CString m_SALESMAN_EMAIL;
CTime m_SALESMAN_DOB;
CTime m_SALESMAN_DATE_OF_JOIN;
CString m_SALESMAN_MANAGER;
CString m_SALESMAN_DESIGNATION;
//}}AFX_FIELD
public:
CRecSalesmanMaster(CDatabase* pDatabase = NULL);
//{{AFX_VIRTUAL (CRecSalesmanMaster)
virtual CString GetDefaultConnect();
virtual CString GetDefaultSQL();
virtual void DoFieldExchange(CFieldExchange* pFX);
//}}AFX_VIRTUAL
};
#include"StdAfx.h"
#include"RecSalesmanMaster.h"
IMPLEMENT_DYNAMIC(CRecSalesmanMaster, CRecordset)
209
//}}AFX_FIELD_INIT
m_nFields = 11;
m_nDefaultType = snapshot;
}
// To Exchange Data (IN BOTH DIRECTION) Between the Record Source Data Members
// and the Corresponding Record on the Data Variable.
void CRecSalesmanMaster::DoFieldExchange(CFieldExchange* pFX)
{
pFX->SetFieldType(CFieldExchange::outputColumn);
//{{AFX_FIELD_MAP(SALESMAN_MASTER)
RFX_Text(pFX, _T("[SALESMAN_ID]"), m_SALESMAN_ID);
RFX_Text(pFX, _T("[SALESMAN_NAME]"), m_SALESMAN_NAME);
RFX_Text(pFX, _T("[SALESMAN_ADDRESS]"), m_SALESMAN_ADDRESS);
RFX_Text(pFX, _T("[SALESMAN_CITY]"), m_SALESMAN_CITY);
RFX_Text(pFX, _T("[SALESMAN_PHONE]"), m_SALESMAN_PHONE);
RFX_Text(pFX, _T("[SALESMAN_MOBILE]"), m_SALESMAN_MOBILE);
RFX_Text(pFX, _T("[SALESMAN_EMAIL]"), m_SALESMAN_EMAIL);
RFX_Date(pFX, _T("[SALESMAN_DOB]"), m_SALESMAN_DOB);
RFX_Text(pFX, _T("[SALESMAN_DESIGNATION]"), m_SALESMAN_DESIGNATION);
RFX_Date(pFX, _T("[SALESMAN_DATE_OF_JOIN]"), m_SALESMAN_DATE_OF_JOIN);
RFX_Text(pFX, _T("[SALESMAN_MANAGER]"), m_SALESMAN_MANAGER);
//}}AFX_FIELD_MAP
}
210
// THIS FILE IS USED FOR QUOTA ASSIGNMENT
// QuotaManager.h : Interface of the CQuotaManager class
//{{AFX_DATA( CQuotaManager)
CString strProductID;
CString strProductName;
CString strSalesmanID;
CString strSalesmanName;
UINT nPresentQuota;
int nQuota;
//}}AFX_DATA
public:
CQuotaManager(CWnd* pParent = NULL);
void InitiatVariables();
void FindQuota();
protected:
//{{AFX_VIRTUAL(CQuotaManager)
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
//{{AFX_MSG(CQuotaManager)
virtual BOOL OnInitDialog();
virtual void OnOK();
virtual void OnCancel();
afx_msg void OnRefresh();
afx_msg void OnSelchangeProductid();
afx_msg void OnSelchangeSalesmanid();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"QuotaManager.h"
#include"RecSalesmanQuota.h"
#include"RecProductMaster.h"
#include"RecSalesmanMaster.h"
211
// Constructer of the CQuotaManager to Initiate the Variables
CQuotaManager :: CQuotaManager(CWnd* pParent) : CDialog(CQuotaManager::IDD, pParent)
{
InitiatVariables();
}
//{{AFX_DATA_MAP(CQuotaManager)
DDX_CBString(pDX, IDC_PRODUCTID, strProductID);
DDX_Text(pDX, IDC_PRODUCTNAME, strProductName);
DDX_CBString(pDX, IDC_SALESMANID, strSalesmanID);
DDX_Text(pDX, IDC_SALESMANNAME, strSalesmanName);
DDX_Text(pDX, IDC_PRESENTQUOTA, nPresentQuota);
DDX_Text(pDX, IDC_QUOTA, nQuota);
DDV_MinMaxUInt(pDX, nQuota, 1, 9999);
//}}AFX_DATA_MAP
}
212
SMRec.Open(CRecordset::snapshot, strSQL);
for(SMRec.MoveFirst(); !SMRec.IsEOF(); SMRec.MoveNext())
cmbSalesmanID.AddString (_T(SMRec.m_SALESMAN_ID));
cmbSalesmanID.Detach ();
SMRec.Close();
}
CATCH_ALL(e)
{
SMRec.Close();
PMRec.Close();
AfxMessageBox(_T("Unable to Open Record Source."), MB_OK | MB_ICONERROR);
}
END_CATCH_ALL
return TRUE;
}
213
AfxMessageBox(_T("Succesfull Save."), MB_OK | MB_ICONINFORMATION);
InitiatVariables();
UpdateData(FALSE);
}
CATCH_ALL(e)
{
SQRec.Close();
db.Rollback();
AfxMessageBox(_T("Unable to Add Information"), MB_OK | MB_ICONERROR);
}
END_CATCH_ALL
}
}
214
// READ Currentaly Selected SALESMAN From ComboBox
void CQuotaManager :: OnSelchangeSalesmanid()
{
GetDlgItemText(IDC_SALESMANID, strSalesmanID);
CRecSalesmanMaster SMRec(&db);
SMRec.m_strFilter = "SALESMAN_ID = '" + strSalesmanID + "'";
TRY
{
SMRec.Open(CRecordset::snapshot);
strSalesmanName = _T(SMRec.m_SALESMAN_NAME);
SMRec.Close();
UpdateData(FALSE);
GetDlgItem(IDC_PRODUCTID)->SetFocus();
}
CATCH_ALL(e)
{
SMRec.Close();
AfxMessageBox(_T("Unable to Open Record Source. Please try again."), MB_OK | MB_ICONERROR);
}
END_CATCH_ALL
}
}
else
nPresentQuota = SQRec.m_SALESMAN_QUOTA;
SQRec.Close();
GetDlgItem(IDC_QUOTA)->SetFocus();
215
UpdateData(FALSE);
}
}
BEGIN_MESSAGE_MAP(CQuotaManager, CDialog)
//{{AFX_MSG_MAP(CQuotaManager)
ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
ON_CBN_SELCHANGE(IDC_PRODUCTID, OnSelchangeProductid)
ON_CBN_SELCHANGE(IDC_SALESMANID, OnSelchangeSalesmanid)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
216
// THIS FILE IS A RECORD SOURCE OF THE SALESMAN_QUOTA_ASSIGN
// RecSalesmanQuota.h : Interface of the CRecSalesmanQuota class
public:
// Variable of the SALESMAN_MASTER Data Source Fields
//{{AFX_FIELD (SALESMAN_QUOTA_ASSIGNED)
CString m_SALESMAN_ID;
CString m_PRODUCT_ID;
int m_SALESMAN_QUOTA;
//}}AFX_FIELD
public:
CRecSalesmanQuota(CDatabase* pDatabase = NULL);
//{{AFX_VIRTUAL(CRecCustomerBill)
virtual CString GetDefaultConnect();
virtual CString GetDefaultSQL();
virtual void DoFieldExchange(CFieldExchange* pFX);
//}}AFX_VIRTUAL
};
#include"StdAfx.h"
#include"RecSalesmanQuota.h"
IMPLEMENT_DYNAMIC(CRecSalesmanQuota, CRecordset)
m_nFields = 3;
m_nDefaultType = snapshot;
}
217
// Used to Default SQL for Recordset
CString CRecSalesmanQuota::GetDefaultSQL()
{
return _T("[CRM].[SALESMAN_QUOTA_ASSIGNED]");
}
// To Exchange Data (IN BOTH DIRECTION) Between the Record Source Data Members
// and the Corresponding Record on the Data Variable.
void CRecSalesmanQuota::DoFieldExchange(CFieldExchange* pFX)
{
pFX->SetFieldType(CFieldExchange::outputColumn);
//{{AFX_FIELD_MAP(SALESMAN_QUOTA_ASSIGNED)
RFX_Text(pFX, _T("[SALESMAN_ID]"), m_SALESMAN_ID);
RFX_Text(pFX, _T("[PRODUCT_ID]"), m_PRODUCT_ID);
RFX_Int(pFX, _T("[SALESMAN_QUOTA]"), m_SALESMAN_QUOTA);
//}}AFX_FIELD_MAP
}
218
// THIS FILE IS USED FOR UPDATE STOCK
// UpdateStock.h : Interface of the CUpdateStock class
//{{AFX_DATA (CUpdateStock)
enum { IDD = IDD_UPDATESTOCK };
CString strProductID;
CTime tDate;
CString strDate;
UINT nLevel;
UINT nStock;
//}}AFX_DATA
public:
CUpdateStock(CWnd* pParent = NULL); // standard constructor
protected:
//{{AFX_VIRTUAL (CUpdateStock)
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
//{{AFX_MSG (CUpdateStock)
virtual BOOL OnInitDialog();
virtual void OnOK();
virtual void OnCancel();
afx_msg void OnDropdownCombo();
afx_msg void OnSelchangeCombo();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"RecProductMaster.h"
#include"RecProductInventory.h"
#include"UpdateStock.h"
219
nLevel = 0;
nStock = 0;
//}}AFX_DATA_INIT
}
//{{AFX_DATA_MAP (CUpdateStock)
DDX_Text(pDX, IDC_DATE, strDate);
DDX_Text(pDX, IDC_LEVEL, nLevel);
DDX_Text(pDX, IDC_STOCK, nStock);
DDV_MinMaxUInt(pDX, nStock, 1, 9999);
//}}AFX_DATA_MAP
}
BOOL CUpdateStock::OnInitDialog()
{
CDialog::OnInitDialog();
return TRUE;
}
void CUpdateStock::OnOK()
{
BOOL bTest = TRUE;
220
strDate = tDate.Format(_T("%d/%m/%Y"));
PIRec.Update();
PIRec.Close();
AfxMessageBox(_T("Record Succesfull Updated."), MB_OK |
MB_ICONINFORMATION);
db.CommitTrans();
UpdateData(FALSE);
}
CATCH_ALL(e)
{
// IF Any Error Process ROLLBACK
db.Rollback();
AfxMessageBox(_T("Unable to Modify Record Source."), MB_OK |
MB_ICONERROR);
}
END_CATCH_ALL
}
}
}
221
CRecProductInventory PIRec(&db);
TRY
{
PIRec.m_strFilter = "PRODUCT_ID = '" + strProductID + "' ";
PIRec.Open(CRecordset::snapshot);
strDate = PIRec.m_PRODUCT_LAST_UPDATE.Format(_T("%d/%m/%Y"));
nLevel = PIRec.m_PRODUCT_REORDER_LEVEL;
nStock = PIRec.m_PRODUCT_STOCK;
PIRec.Close();
UpdateData(FALSE);
}
CATCH_ALL(e)
{
AfxMessageBox(_T("Unable to Open Record Source."), MB_OK | MB_ICONERROR);
PIRec.Close();
}
END_CATCH_ALL
}
BEGIN_MESSAGE_MAP(CUpdateStock, CDialog)
//{{AFX_MSG_MAP (CUpdateStock)
ON_CBN_DROPDOWN(IDC_PRODUCTID, OnDropdownCombo)
ON_CBN_SELCHANGE(IDC_PRODUCTID, OnSelchangeCombo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
222
// THIS FILE IS USED FOR VIEW ALL STOCK INFORMATION
// ViewStock.h : Interface of the CViewStock class
public:
CViewStock(CWnd* pParent = NULL);
void GridFormating();
protected:
//{{AFX_VIRTUAL (CViewStock)
virtual afx_msg void OnCancel();
virtual BOOL OnInitDialog();
//}}AFX_VIRTUAL
//{{AFX_MAP (CViewStock)
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MAP
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"ViewStock.h"
#include"RecProductMaster.h"
#include"RecProductInventory.h"
RECT rc;
GetClientRect(&rc);
223
InflateRect(&rc, 0, -50);
rc.top = 0;
CRecProductMaster PMRec(&db);
CRecProductInventory PIRec(&db);
TRY
{
strSQL = _T("SELECT * FROM PRODUCT_INVENTORY ORDER BY
TO_NUMBER(SUBSTR(PRODUCT_ID, 3))");
PIRec.Open(CRecordset::snapshot, strSQL);
if(!PIRec.IsEOF())
{
int nRW = 0;
CString strRW, strDate;
VSGrid->PutTextMatrix(nRW, 3,
_bstr_t(PIRec.m_PRODUCT_REORDER_LEVEL));
VSGrid->PutTextMatrix(nRW, 4, _bstr_t(PIRec.m_PRODUCT_STOCK));
224
strDate = PIRec.m_PRODUCT_LAST_UPDATE.Format(_T("%d/%m/%Y"));
VSGrid->PutTextMatrix(nRW, 5, _bstr_t(strDate));
}
}
else
{
AfxMessageBox(_T("Record(s) are not present."), MB_OK |
MB_ICONINFORMATION);
PIRec.Close();
CDialog::OnCancel();
}
}
CATCH_ALL(e)
{
PIRec.Close();
AfxMessageBox(_T("Unable to Open Record Source."), MB_OK | MB_ICONERROR);
}
END_CATCH_ALL
225
wndButton->MoveWindow(&rc);
GridFormating();
}
BEGIN_MESSAGE_MAP(CViewStock, CDialog)
//{{AFX_MSG_MAP(CViewStock)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
226
// THIS FILE IS RECORD SOURCE OF THE PRODUCT_INVENTORY
// RecProductInventory.h : Interface of the CRecProductInventory class
public:
CRecProductInventory(CDatabase* pDatabase = NULL);
public:
//{{AFX_VIRTUAL (CRecProductInventory)
virtual CString GetDefaultConnect();
virtual CString GetDefaultSQL();
virtual void DoFieldExchange(CFieldExchange* pFX);
//}}AFX_VIRTUAL
};
#include"StdAfx.h"
#include"RecProductInventory.h"
IMPLEMENT_DYNAMIC(CRecProductInventory, CRecordset)
m_nFields = 4;
m_nDefaultType = snapshot;
}
227
}
// To Exchange Data (IN BOTH DIRECTION) Between the Record Source Data Members
// and the Corresponding Record on the Data Variable.
void CRecProductInventory::DoFieldExchange(CFieldExchange* pFX)
{
pFX->SetFieldType(CFieldExchange::outputColumn);
//{{AFX_FIELD_MAP(CRecProductInventory)
RFX_Text(pFX, _T("[PRODUCT_ID]"), m_PRODUCT_ID);
RFX_Int(pFX, _T("[PRODUCT_STOCK]"), m_PRODUCT_STOCK);
RFX_Int(pFX, _T("[PRODUCT_REORDER_LEVEL]"), m_PRODUCT_REORDER_LEVEL);
RFX_Date(pFX, _T("[PRODUCT_LAST_UPDATE]"), m_PRODUCT_LAST_UPDATE);
//}}AFX_FIELD_MAP
}
228
// THIS FILE IS A RECORD SOURCE OF THE PRODUCT_DISCOUNT
// RecProductDiscount.h : Interface of the CRecProductDiscount class
public:
CRecProductDiscount(CDatabase* pDatabase = NULL);
public:
//{{AFX_VIRTUAL(CRecProductDiscount)
virtual CString GetDefaultConnect();
virtual CString GetDefaultSQL();
virtual void DoFieldExchange(CFieldExchange* pFX);
//}}AFX_VIRTUAL
};
#include"StdAfx.h"
#include"CRMProject.h"
#include"RecProductDiscount.h"
IMPLEMENT_DYNAMIC(CRecProductDiscount, CRecordset)
m_nFields = 5;
m_nDefaultType = snapshot;
}
229
// Default connection string
CString CRecProductDiscount :: GetDefaultConnect()
{
return _T("ODBC;DSN=crm;UID=crm;PWD=crm;");
}
// To Exchange Data (IN BOTH DIRECTION) Between the Record Source Data Members
// and the Corresponding Record on the Data Variable.
void CRecProductDiscount :: DoFieldExchange(CFieldExchange* pFX)
{
pFX->SetFieldType(CFieldExchange::outputColumn);
//{{AFX_FIELD_MAP (PRODUCT_DISCOUNT)
RFX_Text(pFX, _T("[PRODUCT_ID]"), m_PRODUCT_ID);
RFX_Int(pFX, _T("[PRODUCT_PURCHASE_PRICE]"), m_PRODUCT_PURCHASE_PRICE);
RFX_Int(pFX, _T("[PRODUCT_MRP]"), m_PRODUCT_MRP);
RFX_Int(pFX, _T("[PRODUCT_MAX_DISCOUNT]"), m_PRODUCT_MAX_DISCOUNT);
RFX_Int(pFX, _T("[PRODUCT_MIN_DISCOUNT]"), m_PRODUCT_MIN_DISCOUNT);
//}}AFX_FIELD_MAP
}
230
// THIS FILE DISPLAY ALL CRYSTAL RECORDS
// ReportViewer.h : Interface of the CReportViewer class
//{{AFX_INCLUDES()
#include"CrystalReportViewer10.h"
//}}AFX_INCLUDES
public:
CReportViewer(CString strFileName, CString strReportName, CWnd* pParent = NULL);
void HandleError(_com_error &e);
void ResizeViewer(CRect crRect);
protected:
//{{AFX_VIRTUAL (CReportViewer)
virtual BOOL OnInitDialog();
virtual void DoDataExchange(CDataExchange* pDX);
//}}AFX_VIRTUAL
//{{AFX_MSG (CReportViewer)
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"ReportViewer.h"
231
{
// Create instance of Application object
m_Application.CreateInstance("CrystalRuntime.Application.10");
}
catch(_com_error& e)
{
// if errors occur, handle and display errors
HandleError(e);
}
// initialise the m_Report variable to NULL
m_Report = NULL;
}
BOOL CReportViewer::OnInitDialog()
{
CDialog::OnInitDialog();
// A dummy variant
VariantInit (&dummy);
CString strPath;
char lpPath[BUFFER_LENGTH];
CRect rect;
dummy.vt = VT_EMPTY;
::GetCurrentDirectory(BUFFER_LENGTH, lpPath);
strPath.Format(_T("%s"), lpPath);
_bstr_t ReportPath(strPath);
_variant_t vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
return TRUE;
}
232
//{{AFX_DATA_MAP(CReportViewer)
DDX_Control(pDX, IDC_VIEWER, m_Viewer);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CReportViewer, CDialog)
//{{AFX_MSG_MAP(CReportViewer)
ON_WM_SIZE()
233
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
234
// THIS FILE IS USED FOR DISPLAY CLOCK ON STATUS BAR
// StatusBar.h : Interface of the CMyStatusBar class
private:
CString m_strClockFormat;
public:
CMyStatusBar();
~CMyStatusBar();
//{{AFX_MSG
afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );
afx_msg void OnDestroy();
afx_msg void OnUpdateIndicatorTime(CCmdUI* pCmdUI);
afx_msg void OnTimer(UINT n);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#include"StdAfx.h"
#include"StatusBar.h"
IMPLEMENT_DYNCREATE(CMyStatusBar, CStatusBar)
235
return 0;
}
void CMyStatusBar::OnDestroy()
{
KillTimer(ID_PANE_FOUR);
// ProgressDestroy();
CStatusBar::OnDestroy();
}
BEGIN_MESSAGE_MAP(CMyStatusBar, CStatusBar)
ON_WM_CREATE()
ON_WM_DESTROY()
// ON_WM_TIMER()
ON_UPDATE_COMMAND_UI(ID_PANE_FOUR, OnUpdateIndicatorTime )
END_MESSAGE_MAP()
236
// THIS FILE DISPLAY SPLASH SCREEN
// SplashWnd.h : Interface of CSplashWnd Class
//{{AFX_MSG(CSplashWnd)
virtual void PostNcDestroy();
afx_msg void OnPaint();
//}}AFX_MSG
public:
// Constructs a CSplashWnd object.
CSplashWnd();
virtual ~CSplashWnd();
DECLARE_MESSAGE_MAP()
};
#include "stdafx.h"
#include "SplashWnd.h"
CSplashWnd* CSplashWnd::m_pSplashWnd;
// This Member Function is Called to Create and Display the Splash Screen Window.
BOOL CSplashWnd::ShowSplashScreen(UINT uBitmapID, CWnd* pParentWnd /*= NULL*/)
{
ASSERT(uBitmapID);
237
if (m_pSplashWnd != NULL)
{
return FALSE;
}
if (!m_pSplashWnd->m_bitmap.LoadBitmap(uBitmapID)) {
return FALSE;
}
BITMAP bm;
m_pSplashWnd->m_bitmap.GetBitmap(&bm);
CString strWndClass = AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW));
if (!m_pSplashWnd->CreateEx(0, strWndClass, NULL, WS_POPUP | WS_VISIBLE,
0, 0, bm.bmWidth, bm.bmHeight, pParentWnd->GetSafeHwnd(), NULL))
{
TRACE0("Failed to create splash screen.\n");
delete m_pSplashWnd;
return FALSE;
}
return TRUE;
}
// This Member Function is Used to Destroy the Splash Window Once the Timer Has Run Out.
void CSplashWnd::HideSplashScreen()
{
// Destroy the window, and update the mainframe.
DestroyWindow();
AfxGetMainWnd()->UpdateWindow();
}
void CSplashWnd::OnPaint()
{
CPaintDC dc(this);
CDC dcImage;
if (dcImage.CreateCompatibleDC(&dc))
{
BITMAP bm;
m_bitmap.GetBitmap(&bm);
CBitmap* pOldBitmap = dcImage.SelectObject(&m_bitmap);
dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &dcImage, 0, 0, SRCCOPY);
dcImage.SelectObject(pOldBitmap);
}
}
238
void CSplashWnd::PostNcDestroy()
{
delete this;
}
BEGIN_MESSAGE_MAP(CSplashWnd, CWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()
239
// MyValidation.h : Some Validation Functions
240
// THis Fuction Is Check Given String Has a NUMBER or Not
BOOL isNumber(CString str)
{
int i;
char ch;
for(i=0; i<=str.GetLength(); i++)
{
ch=str.GetAt(i);
if(ch=='0' || ch=='1' || ch=='2' || ch=='3' || ch=='4' ||
ch=='5' || ch=='6' || ch=='7' || ch=='8' || ch=='9')
{
}
else
return FALSE;
}
return TRUE;
}
241
// Stdafx.h : Include File for Standard System Include Files,
#include"Resource.h"
#include"MyValidation.h"
#import"vsFlex8l.ocx" no_namespace
#import"craxdrt.dll" no_namespace
242