-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNew_Branch_Dialog.cpp
87 lines (66 loc) · 2.3 KB
/
New_Branch_Dialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// New_Branch_Dialog.cpp : implementation file
//
#include "pch.h"
#include "Falcon.h"
#include "afxdialogex.h"
#include "New_Branch_Dialog.h"
#include "GlobalsManager.h"
#include "Weekly_Bulletin.h"
// New_Branch_Dialog dialog
IMPLEMENT_DYNAMIC(New_Branch_Dialog, CDialogEx)
New_Branch_Dialog::New_Branch_Dialog(CFalconDlg* pParentDlg, CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_DIALOG_BRANCH, pParent), m_pFalconDlg(pParentDlg)
{
}
New_Branch_Dialog::~New_Branch_Dialog()
{
}
void New_Branch_Dialog::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT_BRANCH_NAME, Branch_Name_Box);
DDX_Control(pDX, IDC_EDIT_BRANCH_LOAD, Branch_Load_Box);
}
BEGIN_MESSAGE_MAP(New_Branch_Dialog, CDialogEx)
ON_BN_CLICKED(IDOK, &New_Branch_Dialog::OnBnClickedOk)
END_MESSAGE_MAP()
// New_Branch_Dialog message handlers
//Perform action when the user clicks "OK".
void New_Branch_Dialog::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
CreateBulletinBranch();
CDialogEx::OnOK();
}
//Creates a branch for bulletin.
void New_Branch_Dialog::CreateBulletinBranch()
{
//Update this function further to help user to do operations.
UpdateData(TRUE);
//Declare a pointer of "GlobalsManager.cpp".
GlobalsManager *pGlobal = GlobalsManager::Instance();
//Declare variables to store the values from control files
CString Branch_Name;
CString Branch_Load;
Load SelectedLoad;
//Retrieve variables from control variables
Branch_Name_Box.GetWindowTextW(Branch_Name);
Branch_Load_Box.GetWindowTextW(Branch_Load);
//Determine the load based on the users answer (Available values: NoLoad, LessLoad, NormalLoad and HighLoad)
if (Branch_Load == "No Load") {
SelectedLoad = NoLoad;
} else if (Branch_Load == "Less Load") {
SelectedLoad = LessLoad;
} else if (Branch_Load == "Normal Load") {
SelectedLoad = NormalLoad;
}
else if (Branch_Load == "High Load") {
SelectedLoad = HighLoad;
}
//Create a branch based on instances
pGlobal->globalVariablesInstance.bulletin.addBranch(Branch_Name, SelectedLoad);
//Save the result to the Bulletin_Display variable
m_pFalconDlg->Bulletin_Display = pGlobal->globalVariablesInstance.bulletin.printBulletin();
// Save the bulletin to a file
m_pFalconDlg->C_Bulletin_Display.SetWindowTextW(m_pFalconDlg->Bulletin_Display);
}