-
Notifications
You must be signed in to change notification settings - Fork 0
/
Transfer.cs
59 lines (54 loc) · 2.01 KB
/
Transfer.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Transfer : Form
{
public Transfer()
{
InitializeComponent();
}
SqlConnection con = new SqlConnection("Data Source=DESKTOP-U0A9B3M;Initial Catalog=bank;Integrated Security=True");
private void button2_Click(object sender, EventArgs e)
{
this.Hide();
Form2 f = new Form2();
f.Show();
}
private void button1_Click(object sender, EventArgs e)
{
if (Convert.ToInt32(Form1.Totalammount) > Convert.ToInt32(textBox1.Text))
{
con.Open();
int tammount = Convert.ToInt32(Form1.Totalammount) - Convert.ToInt32(textBox1.Text);
SqlCommand s = new SqlCommand("insert into Transactioninfo(AccountID,Ammount,Transaction_Type) values(@id,@ammount,@type)", con);
s.Parameters.AddWithValue("@id", Form1.accountid);
s.Parameters.AddWithValue("@ammount", textBox1.Text);
s.Parameters.AddWithValue("@type", "Transfer");
s.ExecuteNonQuery();
con.Close();
con.Open();
SqlCommand a = new SqlCommand("update currentammount set Total_Ammount=@upammount where AccountID=@idd", con);
a.Parameters.AddWithValue("@upammount", tammount);
a.Parameters.AddWithValue("@idd", Form1.accountid);
a.ExecuteNonQuery();
con.Close();
MessageBox.Show("Ammount Have been Transfered");
}
else {
MessageBox.Show("Your Balance is Less to Transfer");
}
}
private void Transfer_Load(object sender, EventArgs e)
{
}
}
}