-
Notifications
You must be signed in to change notification settings - Fork 0
/
Edit Agent .cs
101 lines (82 loc) · 4.15 KB
/
Edit 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
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 Edit_Agent : Form
{
public Edit_Agent()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
SelectedAgent select_agent = new SelectedAgent();
select_agent.Show();
}
private void button3_Click(object sender, EventArgs e)
{
updateAgent(AgentIDbox.Text, FirstNameBox.Text, LastNamebox.Text, Adressbox.Text, citybox.Text, statecombobox.Text, zipbox.Text, phonebox.Text,
emailbox.Text, dateTimePicker1, dateTimePicker2, StatusBox.Text);
}
public void updateAgent(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 updateAgent = SqlConnectionCommand.getCommand();
updateAgent.CommandText = "USE SRDB UPDATE AGENT SET " +
"First_name = @strFirst_name, Last_name = @strLast_name, Street = @strStreet, City = @strCity, State = @strState, Zip = @strZip, A_phone = @strA_phone," +
" A_email = @strA_email, Start_Date = @strDate, DOB = @strDOB, Status = @strstatus WHERE Agent_id = @strAgent_id";
//addproperty.Parameters.AddWithValue("@strproperty", comboboxtype.SelectedText);
updateAgent.Parameters.AddWithValue("@strAgent_id", AgentID);
updateAgent.Parameters.AddWithValue("@strFirst_name", Fname);
updateAgent.Parameters.AddWithValue("@strLast_name", Lname);
updateAgent.Parameters.AddWithValue("@strStreet", Address);
updateAgent.Parameters.AddWithValue("@strCity", city);
updateAgent.Parameters.AddWithValue("@strState", state);
updateAgent.Parameters.AddWithValue("@strZip", zip);
updateAgent.Parameters.AddWithValue("@strA_phone", phone);
updateAgent.Parameters.AddWithValue("@strA_email", Email);
updateAgent.Parameters.AddWithValue("@strDate", StartDate.Value);
updateAgent.Parameters.AddWithValue("@strDOB", DOB.Value);
updateAgent.Parameters.AddWithValue("@strstatus", Status);
// MessageBox.Show(updateAgent.CommandText.ToString());
try
{
updateAgent.ExecuteNonQuery();
MessageBox.Show("Successfully Updated" + " " + AgentID + " " + Fname,
"Added as an Agent", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Hide();
ViewAgents view_agent = new ViewAgents();
view_agent.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 button2_Click(object sender, EventArgs e)
{
this.Hide();
HomePage home_page = new HomePage();
home_page.Show();
}
private void statecombobox_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void StatusBox_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}