-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateProperty.cs
More file actions
96 lines (79 loc) · 3.95 KB
/
UpdateProperty.cs
File metadata and controls
96 lines (79 loc) · 3.95 KB
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
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 UpdateProperty : Form
{
public UpdateProperty()
{
InitializeComponent();
}
private void ZipCode_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Update_Click(object sender, EventArgs e)
{
Update_Property(comboPno.Text, pnobox.Text, Address.Text, citybox.Text, statebox.Text, zipbox.Text, countybox.Text, combostatus.Text,
float.Parse(areabox.Text), float.Parse(pricebox.Text), float.Parse(taxbox.Text), yearbuiltbox.Text, onerssnbox.Text);
}
public void Update_Property(string type, string Pno, string Address, string city, string state, string zip, string county, string status,
float Area, float price, float tax, string Date, string ownerssn)
{
{
SqlCommand Update_Property = SqlConnectionCommand.getCommand();
Update_Property.CommandText = "USE srdb UPDATE PROPERTY SET " +
"Type = @strtype, Date = @strDate, price = @floatprice, status = @strstatus, Tax = @floatTax, Address = @strAddress, city = @strcity, state = @strstate, zip = @strzip," +
" county = @strcounty, Area = @floatArea, ownerssn = @strOwnerssn WHERE PNO = @strPno";
//addproperty.Parameters.AddWithValue("@strproperty", comboboxtype.SelectedText);
Update_Property.Parameters.AddWithValue("@strPno", Pno);
Update_Property.Parameters.AddWithValue("@strtype", type);
Update_Property.Parameters.AddWithValue("@strstatus", status);
Update_Property.Parameters.AddWithValue("@strAddress", Address);
Update_Property.Parameters.AddWithValue("@strCity", city);
Update_Property.Parameters.AddWithValue("@strstate", state);
Update_Property.Parameters.AddWithValue("@strzip", zip);
Update_Property.Parameters.AddWithValue("@strcounty", county);
Update_Property.Parameters.AddWithValue("@floatarea", Area);
Update_Property.Parameters.AddWithValue("@floatprice", price);
Update_Property.Parameters.AddWithValue("@floatTax", tax);
Update_Property.Parameters.AddWithValue("@strDate", Date);
Update_Property.Parameters.AddWithValue("@strOwnerssn", ownerssn);
// MessageBox.Show(Update_Property.CommandText.ToString());
try
{
Update_Property.ExecuteNonQuery();
MessageBox.Show("Successfully Updated" + " " + Pno + " " + type,
"Updated property", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.Hide();
ViewProps view_props = new ViewProps();
view_props.Show();
}
catch (Exception ex)
{
//MessageBox.Show(" Please Enter a Different PNO Number ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show("Faild to Update a property: " + ex.Message, "Update Property Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
}//end
}
}
private void comboPno_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void Backbutton_Click(object sender, EventArgs e)
{
this.Hide();
ViewProps view_props = new ViewProps();
view_props.Show();
}
}
}