-
Notifications
You must be signed in to change notification settings - Fork 1
/
ChargeRules.cs
156 lines (140 loc) · 6.96 KB
/
ChargeRules.cs
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.ServiceModel;
using DevExpress.XtraBars.Docking2010.Views.WindowsUI;
namespace SBFA
{
public partial class ChargeRules : DevExpress.XtraEditors.XtraForm
{
int currentTypeId = 0;
long currentId = 0;
public ChargeRules()
{
InitializeComponent();
}
private void ChargeRules_Load(object sender, EventArgs e)
{
try
{
Globals.SetDataTypePickList(cmbDataType, "fee");
Globals.SetDataTypePickList(cmbEvalDataType);
Globals.SetValueExecutionPickList(cmbExecutiontype);
}
catch
{
ShowErrorMessage("There has been an error pre-loading lists");
}
}
private void btnSave_Click(object sender, EventArgs e)
{
try
{
SBFAApi agent = new SBFAApi();
using (new OperationContextScope(agent.context))
{
try
{
long save = agent.operation.SaveFeeRule(currentTypeId, txtName.Text, cmbDataType.SelectedValue.ToString(), cmbField.SelectedValue.ToString(), cmbExecutiontype.SelectedValue.ToString(), txtValue.Text, cmbEvalField.SelectedValue.ToString(), cmbEvalDataType.SelectedValue.ToString(), cmbEvaluationType.SelectedValue.ToString(), txtEvalValue.Text, txtEvalValueMax.Text, chkActive.Checked);
if (save > 0)
{
currentId = save;
string[] row = { save.ToString(), txtName.Text, cmbDataType.SelectedText, cmbField.SelectedText, cmbExecutiontype.SelectedText, txtValue.Text, cmbEvalField.SelectedText, cmbEvalDataType.SelectedText, cmbEvaluationType.SelectedText, txtEvalValue.Text, txtEvalValueMax.Text, ((chkActive.Checked) ? "Yes" : "No") };
var listViewItem = new ListViewItem(row);
lstRules.Items.Add(listViewItem);
}
}
catch { }
}
}
catch
{
ShowErrorMessage("Failed to save your Rule, Please make sure all fields are valid");
}
}
private void treeFees_AfterSelect(object sender, TreeViewEventArgs e)
{
SBFAApi agent = new SBFAApi();
using (new OperationContextScope(agent.context))
{
if (treeFees.SelectedNode.Text.ToLower() != "fees")
{
currentTypeId = int.Parse(treeFees.SelectedNode.Name.Split('_')[0]);
Globals.SetFieldsPickList(cmbField, treeFees.SelectedNode.Name.Split('_')[1]);
Globals.SetFieldsPickList(cmbEvalField, treeFees.SelectedNode.Name.Split('_')[1]);
lstRules.Items.Clear();
sbfa.FeeRules[] response = agent.operation.GetFeeRulesList(treeFees.SelectedNode.Name.Split('_')[1]);
foreach (sbfa.FeeRules rule in response)
{
string[] row = { rule.Id.ToString(), rule.RuleName, rule.RuleType, rule.RuleField, rule.RuleExecutionType, rule.RuleExecutionValue, rule.RuleEvaluationField, rule.RuleEvaluationDataType, rule.RuleEvaluationType, rule.RuleEvaluationValue, rule.RuleEvaluationMaxValue, ((rule.Active) ? "Yes" : "No") };
var listViewItem = new ListViewItem(row);
lstRules.Items.Add(listViewItem);
}
}
}
}
private void lstRules_SelectedIndexChanged(object sender, EventArgs e)
{
SBFAApi agent = new SBFAApi();
using (new OperationContextScope(agent.context))
{
try
{
currentId = long.Parse(lstRules.SelectedItems[0].SubItems[0].Text);
sbfa.FeeRules response = agent.operation.GetFeeRule(currentId);
Globals.SetPickListValue(cmbField, response.RuleField);
chkActive.Checked = response.Active;
txtName.Text = response.RuleName;
Globals.SetPickListValue(cmbDataType, response.RuleType);
Globals.SetPickListValue(cmbExecutiontype, response.RuleExecutionType);
txtValue.Text = response.RuleExecutionValue;
Globals.SetPickListValue(cmbEvalField, response.RuleEvaluationField);
Globals.SetPickListValue(cmbEvalDataType, response.RuleEvaluationDataType);
Globals.SetPickListValue(cmbEvaluationType, response.RuleEvaluationType);
txtEvalValue.Text = response.RuleEvaluationValue;
txtEvalValueMax.Text = response.RuleEvaluationMaxValue;
}
catch { }
}
}
private void cmbEvalDataType_SelectedIndexChanged(object sender, EventArgs e)
{
Globals.SetEvaluationPickList(cmbEvaluationType, cmbEvalDataType.SelectedValue.ToString());
}
public void ShowSuccessMessage(string message)
{
FlyoutAction action = new FlyoutAction() { Caption = "Success!", Description = message };
FlyoutCommand command1 = new FlyoutCommand() { Text = "OK", Result = System.Windows.Forms.DialogResult.Yes };
action.Commands.Add(command1);
FlyoutProperties properties = new FlyoutProperties();
properties.ButtonSize = new Size(100, 40);
properties.Style = FlyoutStyle.MessageBox;
properties.Appearance.BackColor = Color.Green;
properties.Appearance.ForeColor = Color.White;
DevExpress.XtraBars.Docking2010.Customization.FlyoutDialog.Show(this, action, properties);
if (DevExpress.XtraBars.Docking2010.Customization.FlyoutDialog.Show(this, action, properties) == DialogResult.Yes)
{
this.Close();
}
}
public void ShowErrorMessage(string message)
{
FlyoutAction action = new FlyoutAction() { Caption = "Charges!", Description = message };
FlyoutCommand command1 = new FlyoutCommand() { Text = "OK", Result = System.Windows.Forms.DialogResult.Yes };
action.Commands.Add(command1);
FlyoutProperties properties = new FlyoutProperties();
properties.ButtonSize = new Size(100, 40);
properties.Style = FlyoutStyle.MessageBox;
properties.Appearance.BackColor = Color.Red;
properties.Appearance.ForeColor = Color.White;
DevExpress.XtraBars.Docking2010.Customization.FlyoutDialog.Show(this, action, properties);
}
}
}