-
Notifications
You must be signed in to change notification settings - Fork 0
/
Add an Agent.cs
120 lines (94 loc) · 4.28 KB
/
Add an Agent.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
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;
namespace RealEstateDB
{
public partial class Add_an_Agent : Form
{
public Add_an_Agent()
{
InitializeComponent();
}
private void Add_an_Agent_Load(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
private void Addnewagentbutton_Click(object sender, EventArgs e)
{
SearchAgent(AgentIDbox.Text, Firstnamebox.Text, LastNamebox.Text, AddressBox.Text, Citybox.Text, combostate.SelectedItem.ToString(), zipbox.Text, phonebox.Text,
emailbox.Text, DOB, StartDate, statuscombobox.SelectedItem.ToString());
}
public void SearchAgent(string AgentID, string Fname, string Lname, string Address, string city, string state, string zip, string phone,
string Email, DateTimePicker DOB, DateTimePicker StartDate, string status)
{
{
SqlCommand SearchAgent = SqlConnectionCommand.getCommand();
SearchAgent.CommandText = "USE SRDB INSERT INTO AGENT Values" +
"(@strAgent_id, @strFirst_name, @strLast_name, @strStreet, @strCity, @strState, @strZip, @strA_phone," +
" @strA_email, @strDate, @strDOB, @strstatus)";
//addproperty.Parameters.AddWithValue("@strproperty", comboboxtype.SelectedText);
SearchAgent.Parameters.AddWithValue("@strstatus", status);
SearchAgent.Parameters.AddWithValue("@strAgent_id", AgentID);
SearchAgent.Parameters.AddWithValue("@strFirst_name", Fname);
SearchAgent.Parameters.AddWithValue("@strLast_name", Lname);
SearchAgent.Parameters.AddWithValue("@strStreet", Address);
SearchAgent.Parameters.AddWithValue("@strCity", city);
SearchAgent.Parameters.AddWithValue("@strState", state);
SearchAgent.Parameters.AddWithValue("@strZip", zip);
SearchAgent.Parameters.AddWithValue("@strA_phone", phone);
SearchAgent.Parameters.AddWithValue("@strA_email", Email);
SearchAgent.Parameters.AddWithValue("@strDate", StartDate.Value);
SearchAgent.Parameters.AddWithValue("@strDOB", DOB.Value);
// MessageBox.Show(SearchAgent.CommandText.ToString());
try
{
SearchAgent.ExecuteNonQuery();
MessageBox.Show("Successfully added" + " " + AgentID + " " + Fname,
"Added as an Agent", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Hide();
ViewAgents Home_page = new ViewAgents();
Home_page.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
// MessageBox.Show(" Please Enter a Different Agent Number ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
// MessageBox.Show("Faild to Add a property: " + ex.Message, "Add Property Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
}//end
}
}
private void homebutton_Click(object sender, EventArgs e)
{
this.Hide();
HomePage Home_page = new HomePage();
Home_page.Show();
}
private void Backbutton_Click(object sender, EventArgs e)
{
this.Hide();
ViewAgents Home_page = new ViewAgents();
Home_page.Show();
}
private void phonebox_TextChanged(object sender, EventArgs e)
{
}
private void DOBbox_TextChanged(object sender, EventArgs e)
{
}
private void DOB_ValueChanged(object sender, EventArgs e)
{
}
private void statuscombobox_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}