-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmEnterAmount.cs
152 lines (131 loc) · 4.92 KB
/
frmEnterAmount.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ATMApp.BL;
namespace ATMApp
{
public partial class frmEnterAmount : Form
{
//clCommonBL objBL = new clCommonBL();
CommunicationRef.CommunicationService objService = new CommunicationRef.CommunicationService();
public static class EnterAmt
{
public static string BankID;
}
public frmEnterAmount()
{
InitializeComponent();
}
private void imgClear_Click(object sender, EventArgs e)
{
txtAmount.Clear();
}
private void frmEnterAmount_Load(object sender, EventArgs e)
{
DataSet dsBankWithBranch = objService.GetBankWithBranch(ATMApp.frmCustomLogin.ClassValue.BankID, ATMApp.frmCustomLogin.ClassValue.CustomerId, ATMApp.frmCustomLogin.ClassValue.AtmPin);
if (dsBankWithBranch.Tables[0].Rows.Count > 0)
{
DataRow dr = dsBankWithBranch.Tables[0].NewRow();
dr[0] = 0;
dr[1] = "---Select Bank---";
dsBankWithBranch.Tables[0].Rows.InsertAt(dr, 0);
ddlBank.DataSource = dsBankWithBranch.Tables[0];
ddlBank.ValueMember = "BankID";
ddlBank.DisplayMember = "name";
}
}
private void imgOK_Click(object sender, EventArgs e)
{
if (txtAmount.Text == String.Empty)
{
MessageBox.Show("Please enter the amount");
return;
}
if (ddlBank.SelectedIndex == 0)
{
MessageBox.Show("Please select Bank");
return;
}
if (Convert.ToInt32(txtAmount.Text) > 40000)
{
MessageBox.Show("Transaction limit is 40000. Cannot proceed with the current amount");
return;
}
//This will prevent the user entering amount like 0 / 50 etc
if (txtAmount.Text.Length <= 2)
{
MessageBox.Show("Invalid Amount");
return;
}
//This will prevent the user entering amount like 1050 / 150 etc
int length = txtAmount.Text.Length;
if (Convert.ToInt32(txtAmount.Text.Substring(length - 2)) == 50)
{
MessageBox.Show("Please Enter the amount in multiples of 100");
return;
}
int ReturnCode = objService.DeductAmount(ddlBank.SelectedValue.ToString(), Convert.ToInt32(ATMApp.frmCustomLogin.ClassValue.CustomerId), Convert.ToDecimal(txtAmount.Text));
EnterAmt.BankID = ddlBank.SelectedValue.ToString();
if (ReturnCode == 1)
{
if (ATMApp.frmCustomLogin.ClassValue.BankID != ddlBank.SelectedValue.ToString())
{
ATMApp.frmCustomLogin.ClassValue.OtherBankTransactionInd++;
}
CallCompletionScreen();
}
else
{
MessageBox.Show("There is no sufficient balance in your Account");
return;
}
}
private void lblGoBack_Click(object sender, EventArgs e)
{
CallOptionScreen();
}
private void CallOptionScreen()
{
this.Hide();
frmOptions updatepin = new frmOptions();
updatepin.ShowDialog();
this.Close();
}
private void CallCompletionScreen()
{
this.Hide();
frmCompleted updatepin = new frmCompleted();
updatepin.ShowDialog();
this.Close();
}
private void txtAmount_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar))
{
e.Handled = true;
}
}
private void ddlBank_SelectedIndexChanged(object sender, EventArgs e)
{
DataSet dsAccountNumberWithBranch = null;
CommunicationRef.CommunicationService objService = new CommunicationRef.CommunicationService();
dsAccountNumberWithBranch = objService.GetAccountNumberForBank(ddlBank.SelectedValue.ToString(), Convert.ToInt32(ATMApp.frmCustomLogin.ClassValue.CustomerId));
if (dsAccountNumberWithBranch.Tables[0] != null)
{
if (dsAccountNumberWithBranch.Tables[0].Rows.Count > 0)
{
lblBalance.Text = dsAccountNumberWithBranch.Tables[0].Rows[0]["totalavailablebalance"].ToString();
}
}
}
private void frmEnterAmount_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
}
}
}