-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipedgas.cs
88 lines (77 loc) · 2.92 KB
/
pipedgas.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
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 System.Data.OleDb;
namespace EWALLET
{
public partial class pipedgas : Form
{
int bal=0;
public static string Email = "";
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\DOT.NET Practical\EWALLET.mdb");
public pipedgas()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "" || comboBox1.Text == "")
{
MessageBox.Show("Some Data is Missing");
}
else
{
// fetch current bal
con.Open();
String query = "select * from EWALLET where Email = '"
+ login.Email + "'";
OleDbCommand cmd = new OleDbCommand(query, con);
OleDbDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
bal = Convert.ToInt32(dr["wbalance"].ToString());
}
con.Close();
// add operation
if (bal < Convert.ToInt32(textBox2.Text))
{
MessageBox.Show("Insuffient Balance");
}
else
{
bal -= Convert.ToInt32(textBox2.Text);
// update bal
con.Open();
OleDbCommand cmd1 = new OleDbCommand();
cmd1.Connection = con;
cmd1.CommandType = CommandType.Text;
cmd1.CommandText = "UPDATE EWALLET SET wbalance = '" + bal + "' WHERE Email = '" + login.Email + "' ";
cmd1.ExecuteNonQuery();
con.Close();
con.Open();
OleDbCommand cmd2 = con.CreateCommand();
cmd2.CommandType = CommandType.Text;
cmd2.CommandText = "Insert into Transcation values('"
+ login.Email + "','"
+ comboBox1.Text + "','"
+ textBox1.Text + "','"
+ textBox2.Text + "')";
cmd2.ExecuteNonQuery();
con.Close();
MessageBox.Show("Your Piped Gas Bill Has Paid Successfully");
}
}
}
private void pictureBox3_Click(object sender, EventArgs e)
{
seemore s = new seemore();
s.Show();
this.Hide();
}
}
}