-
Notifications
You must be signed in to change notification settings - Fork 0
/
kredicek.cs
178 lines (137 loc) · 5.58 KB
/
kredicek.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Data.Sql;
namespace bankmanagementapp
{
public partial class kredicek : Form
{
string accno;
SqlConnection con = new SqlConnection();
SqlCommand com = new SqlCommand();
SqlCommand com1 = new SqlCommand();
SqlDataAdapter adapter = new SqlDataAdapter();
public kredicek(string value)
{
InitializeComponent();
this.TopMost = true;
this.StartPosition = FormStartPosition.CenterScreen;
this.TopMost = true;
this.StartPosition = FormStartPosition.CenterScreen;
labelonay.Visible = false;
labelret.Visible = false;
button_WOC5.Visible = false;
accno = value;
maas();
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void txtKredimiktari_Enter(object sender, EventArgs e)
{
if (txtKredimiktari.Text.Equals(@"KREDİ TUTARI"))
{
txtKredimiktari.Text = "";
}
}
public void maas()
{
con = new SqlConnection(@"Data Source");
con.Open();
com = new SqlCommand("SELECT salary FROM customerinfo where customerno=@customerno", con);
com.Parameters.AddWithValue("@customerno", accno);
SqlDataReader da = com.ExecuteReader();
while (da.Read())
{
txtMaas.Text = da.GetValue(0).ToString();
}
con.Close();
}
private void comboBox1_Leave(object sender, EventArgs e)
{
if (txtKredimiktari.Text.Equals(@""))
{
MessageBox.Show("KREDİ MİKTARİ ALANI BOS BIRAKILAMAZ", "HATA", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
int kredimiktari = Convert.ToInt32(txtKredimiktari.Text);
int aysayisi = Convert.ToInt32(comboBox1.SelectedItem);
int aylikodeme = kredimiktari / aysayisi;
txtAylikodeme.Text = aylikodeme.ToString();
if (aylikodeme*2 < Convert.ToInt32(txtMaas.Text))
{
labelonay.Visible = true;
labelret.Visible = false;
button_WOC5.Visible = true;
}
else
{
labelret.Visible = true;
labelonay.Visible = false;
button_WOC5.Visible = false;
}
}
}
private void txtKredimiktari_Leave(object sender, EventArgs e)
{
}
private void btnonayla_Click(object sender, EventArgs e)
{
}
private void button_WOC5_Click(object sender, EventArgs e)
{
string islemadi = "kredi cekme";
string now = DateTime.Now.ToString("MM/dd/yyyy");
con = new SqlConnection(@"Data Source");
con.Open();
com = new SqlCommand("SELECT balance FROM balances where customerno=@customerno", con);
com.Parameters.AddWithValue("@customerno", accno);
SqlDataReader da = com.ExecuteReader();
string[] bakiye = new string[1];
while (da.Read())
{
bakiye[0] = da.GetValue(0).ToString();
}
da.Close();
long kredimiktari = Convert.ToInt64(txtKredimiktari.Text);
long totalmoney = Convert.ToInt64(bakiye[0]) + kredimiktari;
con = new SqlConnection(@"Data Source");
con.Open();
com1 = new SqlCommand("UPDATE balances SET balance=@balance WHERE customerno=@customerno", con);
com1.Parameters.AddWithValue("@balance", totalmoney);
com1.Parameters.AddWithValue("@customerno", accno);
int result1 = com1.ExecuteNonQuery();
if (result1 < 0)
{
MessageBox.Show("KREDİ CEKME İSLEMİ GERCEKLESTİRİLEMEDİ", "HATA", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
MessageBox.Show("KREDİ CEKME İSLEMİ BASARIYLA GERCEKLESTIRILDI");
com2 = new SqlCommand("INSERT INTO accountactions (customerno,actionname,actionamount,actiondate) VALUES(@customerno,@actionname,@amount,@date)", con);
com2.Parameters.AddWithValue("@customerno", accno);
com2.Parameters.AddWithValue("@actionname", islemadi);
com2.Parameters.AddWithValue("@amount", kredimiktari);
com2.Parameters.AddWithValue("@date", now);
com2.ExecuteNonQuery();
com3 = new SqlCommand("INSERT INTO creditinfos (customerno,creditamount,monthlypayment,date) VALUES(@customerno,@amount,@payment,@date)", con);
com3.Parameters.AddWithValue("@customerno", accno);
com3.Parameters.AddWithValue("@amount", kredimiktari);
com3.Parameters.AddWithValue("@payment", Convert.ToInt64(txtAylikodeme.Text));
com3.Parameters.AddWithValue("@date", now);
com3.ExecuteNonQuery();
}
con.Close();
}
}
}