温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:Asp.net房产中介管理系统源码及常用文档
当前文件路径:HouseManage/HouseManage/HouseSaleForm.aspx.cs

1//文件名:HouseSaleForm.aspx.cs 2
using System; 3
using System.Data; 4
using System.Configuration; 5
using System.Collections; 6
using System.Web; 7
using System.Web.Security; 8
using System.Web.UI; 9
using System.Web.UI.WebControls; 10
using System.Web.UI.WebControls.WebParts; 11
using System.Web.UI.HtmlControls; 12
13
using System.Data.SqlClient; 14
public partial class HouseManage_HouseSaleForm : System.Web.UI.Page 15
{ 16
protected void Page_Load(object sender, EventArgs e) 17
{ 18
string MyForbidString = Session["MyForbid"].ToString(); 19
if (MyForbidString.IndexOf("B1") > 1) 20
{ 21
Server.Transfer("~/SystemManage/AllErrorHelp.aspx"); 22
} 23
if (!IsPostBack) 24
{ 25
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyHouseDBConnectionString"].ConnectionString; 26
string MySQL = "Select * From 房源参数 Where 自编号='CQ001'"; 27
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString); 28
MyConnection.Open(); 29
DataTable MyHouseTable = new DataTable(); 30
SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnection); 31
MyAdapter.Fill(MyHouseTable); 32
string MyName = "城区"; 33
string MyValue = MyHouseTable.Rows[0][MyName].ToString(); 34
String[] MyDistData = MyValue.Split(new char[1] { '、' }); 35
//设置所在城区列表项 36
foreach (String MyString in MyDistData) 37
{ 38
this.DropDownList1.Items.Add(MyString); 39
} 40
MyName = "类型"; 41
MyValue = MyHouseTable.Rows[0][MyName].ToString(); 42
String[] MyTypeData = MyValue.Split(new char[1] { '、' }); 43
foreach (String MyString in MyTypeData) 44
{ 45
this.DropDownList3.Items.Add(MyString); 46
} 47
MyName = "朝向"; 48
MyValue = MyHouseTable.Rows[0][MyName].ToString(); 49
String[] MyDireData = MyValue.Split(new char[1] { '、' }); 50
foreach (String MyString in MyDireData) 51
{ 52
this.DropDownList2.Items.Add(MyString); 53
} 54
55
MyName = "用途"; 56
MyValue = MyHouseTable.Rows[0][MyName].ToString(); 57
String[] MyUseData = MyValue.Split(new char[1] { '、' }); 58
foreach (String MyString in MyUseData) 59
{ 60
this.DropDownList6.Items.Add(MyString); 61
} 62
MyName = "土地"; 63
MyValue = MyHouseTable.Rows[0][MyName].ToString(); 64
String[] MyFieldData = MyValue.Split(new char[1] { '、' }); 65
foreach (String MyString in MyFieldData) 66
{ 67
this.DropDownList4.Items.Add(MyString); 68
} 69
MyName = "产权"; 70
MyValue = MyHouseTable.Rows[0][MyName].ToString(); 71
String[] MyPreData = MyValue.Split(new char[1] { '、' }); 72
foreach (String MyString in MyPreData) 73
{ 74
this.DropDownList5.Items.Add(MyString); 75
} 76
MyName = "结构"; 77
MyValue = MyHouseTable.Rows[0][MyName].ToString(); 78
String[] MyStruData = MyValue.Split(new char[1] { '、' }); 79
foreach (String MyString in MyStruData) 80
{ 81
this.DropDownList7.Items.Add(MyString); 82
} 83
MyName = "装修"; 84
MyValue = MyHouseTable.Rows[0][MyName].ToString(); 85
String[] MyDecoData = MyValue.Split(new char[1] { '、' }); 86
foreach (String MyString in MyDecoData) 87
{ 88
this.DropDownList8.Items.Add(MyString); 89
} 90
MyName = "证件"; 91
MyValue = MyHouseTable.Rows[0][MyName].ToString(); 92
String[] MyCertData = MyValue.Split(new char[1] { '、' }); 93
foreach (String MyString in MyCertData) 94
{ 95
this.DropDownList9.Items.Add(MyString); 96
} 97
MyName = "付款"; 98
MyValue = MyHouseTable.Rows[0][MyName].ToString(); 99
String[] MyPayData = MyValue.Split(new char[1] { '、' }); 100
foreach (String MyString in MyPayData) 101
{ 102
this.DropDownList10.Items.Add(MyString); 103
} 104
MyName = "货币"; 105
MyValue = MyHouseTable.Rows[0][MyName].ToString(); 106
String[] MyMoneyData = MyValue.Split(new char[1] { '、' }); 107
foreach (String MyString in MyMoneyData) 108
{ 109
this.DropDownList11.Items.Add(MyString); 110
} 111
MyName = "付佣"; 112
MyValue = MyHouseTable.Rows[0][MyName].ToString(); 113
String[] MyFeeData = MyValue.Split(new char[1] { '、' }); 114
foreach (String MyString in MyFeeData) 115
{ 116
this.DropDownList12.Items.Add(MyString); 117
} 118
MyName = "委托"; 119
MyValue = MyHouseTable.Rows[0][MyName].ToString(); 120
String[] MyDeleData = MyValue.Split(new char[1] { '、' }); 121
foreach (String MyString in MyDeleData) 122
{ 123
this.DropDownList13.Items.Add(MyString); 124
} 125
MyName = "来源"; 126
MyValue = MyHouseTable.Rows[0][MyName].ToString(); 127
String[] MySourceData = MyValue.Split(new char[1] { '、' }); 128
foreach (String MyString in MySourceData) 129
{ 130
this.DropDownList14.Items.Add(MyString); 131
} 132
MyName = "状态"; 133
MyValue = MyHouseTable.Rows[0][MyName].ToString(); 134
String[] MyStatusData = MyValue.Split(new char[1] { '、' }); 135
foreach (String MyString in MyStatusData) 136
{ 137
this.DropDownList16.Items.Add(MyString); 138
} 139
MySQL = "Select * From 职员信息"; 140
DataTable MyPersonnelTable = new DataTable(); 141
MyAdapter = new SqlDataAdapter(MySQL, MyConnection); 142
MyAdapter.Fill(MyPersonnelTable); 143
MyName = "职员姓名"; 144
MyValue = MyPersonnelTable.Rows[0][MyName].ToString(); 145
foreach (DataRow MyRow in MyPersonnelTable.Rows) 146
{ 147
this.DropDownList15.Items.Add(MyRow[MyName].ToString()); 148
} 149
if (MyConnection.State == ConnectionState.Open) 150
{ 151
MyConnection.Close(); 152
} 153
} 154
} 155
protected void Button2_Click(object sender, EventArgs e) 156
{//新增出售房源信息 157
this.SqlDataSource1.Insert(); 158
} 159
protected void Button3_Click(object sender, EventArgs e) 160
{//修改出售房源信息 161
this.SqlDataSource1.Update(); 162
} 163
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) 164
{//弹出删除操作确认对话框 165
if (e.Row.RowType == DataControlRowType.DataRow) 166
{ 167
Button MyButton = (Button)e.Row.FindControl("Button1"); 168
MyButton.OnClientClick = "return confirm('是否确认删除当前选择的记录?')"; 169
} 170
} 171
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) 172
{//在控件中显示选择的记录 173
this.TextBox2.Text = this.GridView1.SelectedRow.Cells[2].Text.ToString(); 174
this.DropDownList1.SelectedValue= this.GridView1.SelectedRow.Cells[3].Text.ToString(); 175
this.TextBox4.Text = this.GridView1.SelectedRow.Cells[4].Text.ToString(); 176
this.TextBox5.Text = this.GridView1.SelectedRow.Cells[5].Text.ToString(); 177
this.TextBox6.Text = this.GridView1.SelectedRow.Cells[6].Text.ToString(); 178
this.TextBox7.Text = this.GridView1.SelectedRow.Cells[7].Text.ToString(); 179
this.TextBox8.Text = this.GridView1.SelectedRow.Cells[8].Text.ToString(); 180
this.TextBox9.Text = this.GridView1.SelectedRow.Cells[9].Text.ToString(); 181
this.TextBox10.Text = this.GridView1.SelectedRow.Cells[10].Text.ToString(); 182
this.TextBox11.Text = this.GridView1.SelectedRow.Cells[11].Text.ToString(); 183
this.CheckBox1.Checked = (Convert.ToInt16(this.GridView1.SelectedRow.Cells[12].Text.ToString()) == 1) ? true : false; 184
this.TextBox13.Text = this.GridView1.SelectedRow.Cells[13].Text.ToString(); 185
this.TextBox14.Text = this.GridView1.SelectedRow.Cells[14].Text.ToString(); 186
this.TextBox15.Text = this.GridView1.SelectedRow.Cells[15].Text.ToString(); 187
this.TextBox16.Text = this.GridView1.SelectedRow.Cells[16].Text.ToString(); 188
this.TextBox17.Text = this.GridView1.SelectedRow.Cells[17].Text.ToString(); 189
this.DropDownList2.SelectedValue= this.GridView1.SelectedRow.Cells[18].Text.ToString(); 190
this.TextBox19.Text = this.GridView1.SelectedRow.Cells[19].Text.ToString(); 191
this.DropDownList3.SelectedValue= this.GridView1.SelectedRow.Cells[20].Text.ToString(); 192
this.TextBox21.Text = this.GridView1.SelectedRow.Cells[21].Text.ToString(); 193
this.DropDownList4.SelectedValue= this.GridView1.SelectedRow.Cells[22].Text.ToString(); 194
this.DropDownList5.SelectedValue= this.GridView1.SelectedRow.Cells[23].Text.ToString(); 195
this.DropDownList6.SelectedValue= this.GridView1.SelectedRow.Cells[24].Text.ToString(); 196
this.DropDownList7.SelectedValue= this.GridView1.SelectedRow.Cells[25].Text.ToString(); 197
this.TextBox26.Text = this.GridView1.SelectedRow.Cells[26].Text.ToString(); 198
this.TextBox27.Text = this.GridView1.SelectedRow.Cells[27].Text.ToString(); 199
this.DropDownList8.SelectedValue= this.GridView1.SelectedRow.Cells[28].Text.ToString(); 200
this.TextBox29.Text = this.GridView1.SelectedRow.Cells[29].Text.ToString(); 201
this.TextBox30.Text = this.GridView1.SelectedRow.Cells[30].Text.ToString(); 202
this.TextBox31.Text = this.GridView1.SelectedRow.Cells[31].Text.ToString(); 203
////单价 204
////this.TextBox32.Text = this.GridView1.SelectedRow.Cells[32].Text.ToString(); 205
this.TextBox32.Text = this.GridView1.SelectedRow.Cells[33].Text.ToString(); 206
this.TextBox33.Text = this.GridView1.SelectedRow.Cells[34].Text.ToString(); 207
this.TextBox34.Text = this.GridView1.SelectedRow.Cells[35].Text.ToString(); 208
this.TextBox35.Text = this.GridView1.SelectedRow.Cells[36].Text.ToString(); 209
this.DropDownList9.SelectedValue= this.GridView1.SelectedRow.Cells[37].Text.ToString(); 210
this.TextBox37.Text = this.GridView1.SelectedRow.Cells[38].Text.ToString(); 211
this.TextBox38.Text = this.GridView1.SelectedRow.Cells[39].Text.ToString(); 212
this.TextBox39.Text = this.GridView1.SelectedRow.Cells[40].Text.ToString(); 213
this.TextBox40.Text = this.GridView1.SelectedRow.Cells[41].Text.ToString(); 214
this.DropDownList10.SelectedValue= this.GridView1.SelectedRow.Cells[42].Text.ToString(); 215
this.DropDownList11.SelectedValue= this.GridView1.SelectedRow.Cells[43].Text.ToString(); 216
this.DropDownList12.SelectedValue= this.GridView1.SelectedRow.Cells[44].Text.ToString(); 217
this.TextBox44.Text = this.GridView1.SelectedRow.Cells[45].Text.ToString(); 218
this.TextBox45.Text = this.GridView1.SelectedRow.Cells[46].Text.ToString(); 219
this.TextBox46.Text = this.GridView1.SelectedRow.Cells[47].Text.ToString(); 220
this.TextBox47.Text = this.GridView1.SelectedRow.Cells[48].Text.ToString(); 221
this.DropDownList13.SelectedValue= this.GridView1.SelectedRow.Cells[49].Text.ToString(); 222
this.TextBox49.Text = this.GridView1.SelectedRow.Cells[50].Text.ToString(); 223
this.TextBox50.Text = this.GridView1.SelectedRow.Cells[51].Text.ToString(); 224
this.DropDownList14.SelectedValue= this.GridView1.SelectedRow.Cells[52].Text.ToString(); 225
this.CheckBox2.Checked =(Convert.ToInt16(this.GridView1.SelectedRow.Cells[53].Text.ToString()) == 1) ? true : false; 226
this.CheckBox3.Checked = (Convert.ToInt16(this.GridView1.SelectedRow.Cells[54].Text.ToString()) == 1) ? true : false; 227
this.CheckBox4.Checked = (Convert.ToInt16(this.GridView1.SelectedRow.Cells[55].Text.ToString()) == 1) ?





}