-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm3.cs
124 lines (98 loc) · 3.81 KB
/
Form3.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
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 Group_11___COSC_31112
{
public partial class addNewAcc : Form
{
public addNewAcc()
{
InitializeComponent();
}
private void newAccountToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Hide();
Home form2 = new Home();
form2.Show();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void addNewAcc_Load(object sender, EventArgs e)
{
string connectionString = "Data Source=(localdb)\\Local;Initial Catalog=projectDatabase;Integrated Security=True";
using (SqlConnection connection = new SqlConnection(connectionString))
{
/*try
{
Data
}
catch(Exception e1)
{
MessageBox.Show("Error 1 in Acc")
}*/
}
}
private void subNewAcc_Click(object sender, EventArgs e)
{
try
{
string accName = txtAccName.Text;
string accDec = txtAccDesc.Text;
string accCat = cmbAccCat.SelectedItem.ToString();
string connectionString = "Data Source=(localdb)\\Local;Initial Catalog=projectDatabase;Integrated Security=True";
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
string sqlAccaddQuery = "INSERT INTO Account (Account_name,Account_catagory,Expence,Income,Balance) VALUES(@Account_name, @Account_catagory, @Expence, @Income, @Balance)";
using (SqlCommand com = new SqlCommand(sqlAccaddQuery, connection))
{
com.Parameters.AddWithValue("@Account_name", accName);
com.Parameters.AddWithValue("@Account_catagory", accCat);
com.Parameters.AddWithValue("@Expence", 0);
com.Parameters.AddWithValue("@Income", 0);
com.Parameters.AddWithValue("@Balance", 0);
com.ExecuteNonQuery();
MessageBox.Show("Data inserted successfully!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
txtAccDesc.Text = string.Empty;
txtAccName.Text = string.Empty;
cmbAccCat.SelectedItem = null;
}
}
}
catch(Exception ex)
{
MessageBox.Show("Please Fill all before submit", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void newSubtaskToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Hide();
frmAddNewSubT form4 = new frmAddNewSubT();
form4.Show();
}
private void deToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Hide();
deleteAcc form5 = new deleteAcc();
form5.Close();
}
private void deleteSubtaskToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Hide();
Form6 form6 = new Form6();
form6.Show();
}
private void btnAddNewAcc_Click(object sender, EventArgs e)
{
this.Refresh();
}
}
}