-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddBuyerSeller.cs
165 lines (133 loc) · 5.87 KB
/
AddBuyerSeller.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RealEstateDB
{
public partial class AddBuyerSeller : Form
{
// SSNTextBox.Text =
public AddBuyerSeller()
{
InitializeComponent();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
HomePage Home_page = new HomePage();
Home_page.Show();
}
private void AddBuyerSeller_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
int i;
long j;
if (string.IsNullOrWhiteSpace(Fname.Text))
{
MessageBox.Show("Please enter a first name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (string.IsNullOrWhiteSpace(Lname.Text))
{
MessageBox.Show("Please enter a last name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (SSNText.TextLength != 9 || !int.TryParse(SSNText.Text, out i))
{
MessageBox.Show("Please enter a 9 digit SSN ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (string.IsNullOrWhiteSpace(StrAdd.Text))
{
MessageBox.Show("Please enter a street address", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (string.IsNullOrWhiteSpace(City.Text))
{
MessageBox.Show("Please enter a city", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (State.SelectedItem == null)
{
MessageBox.Show("Please select a state", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (Zip.TextLength != 5 || !int.TryParse(Zip.Text, out i))
{
MessageBox.Show("Please enter a 5 digit Zip Code ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (Type.SelectedItem == null)
{
MessageBox.Show("Please Specify if this person is a seller or buyer ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (Phone.TextLength != 10 || !long.TryParse(Phone.Text, out j))
{
MessageBox.Show("Please enter a 10 digit phone", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if (string.IsNullOrWhiteSpace(Email.Text))
{
MessageBox.Show("Please enter an e-mail", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
addBUYERSELLER(Type.SelectedItem.ToString(), SSNText.Text, Fname.Text, Mname.Text, Lname.Text, Email.Text,
Phone.Text, StrAdd.Text, City.Text, State.SelectedItem.ToString(), Zip.Text);
}
}
public void addBUYERSELLER(string atype, string aSSN, string afname, string amname, string alname, string aemail, string aphone,
string astreetAdd, string acity, string aBS_State, string azip)
{
{
float zero = 0;
string status = "Active";
SqlCommand addbs = SqlConnectionCommand.getCommand();
addbs.CommandText = "USE SRDB INSERT INTO BUYERSELLER Values " +
"(@strtype, @strSSN, @strfname, @strmname, @strlname, @stremail, @strphone, @strstreetAdd, @strcity, @strState, @strzip, @floatProfit, @strstatus)";
addbs.Parameters.AddWithValue("@strtype", atype);
addbs.Parameters.AddWithValue("@strSSN", aSSN);
addbs.Parameters.AddWithValue("@strfname", afname);
addbs.Parameters.AddWithValue("@strmname", amname);
addbs.Parameters.AddWithValue("@strlname", alname);
addbs.Parameters.AddWithValue("@stremail", aemail);
addbs.Parameters.AddWithValue("@strphone", aphone);
addbs.Parameters.AddWithValue("@strstreetAdd", astreetAdd);
addbs.Parameters.AddWithValue("@strcity", acity);
addbs.Parameters.AddWithValue("@strState", aBS_State);
addbs.Parameters.AddWithValue("@strzip", azip);
addbs.Parameters.AddWithValue("@floatProfit", zero);
addbs.Parameters.AddWithValue("@strstatus", status);
try
{
addbs.ExecuteNonQuery();
MessageBox.Show("Successfully added");
this.Hide();
ViewBuyerSeller BS_Page = new ViewBuyerSeller();
BS_Page.Show();
}
catch (Exception ex)
{
// MessageBox.Show(ex.ToString());
MessageBox.Show("The SSN entered already exists, Please enter another SSN.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void SSNText_TextChanged(object sender, EventArgs e)
{
}
private void Fname_TextChanged(object sender, EventArgs e)
{
}
private void City_TextChanged(object sender, EventArgs e)
{
}
private void Type_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}