📄 houseleaseform.aspx.cs
字号:
//文件名:HouseLeaseForm.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class HouseManage_HouseLeaseForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string MyForbidString = Session["MyForbid"].ToString();
if (MyForbidString.IndexOf("B2") > 1)
{
Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
}
if (!IsPostBack)
{
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyHouseDBConnectionString"].ConnectionString;
string MySQL = "Select * From 房源参数 Where 自编号='CQ001'";
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
DataTable MyHouseTable = new DataTable();
SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyAdapter.Fill(MyHouseTable);
string MyName = "城区";
string MyValue = MyHouseTable.Rows[0][MyName].ToString();
String[] MyDistData = MyValue.Split(new char[1] { '、' });
//设置所在城区列表项
foreach (String MyString in MyDistData)
{
this.DropDownList1.Items.Add(MyString);
}
MyName = "类型";
MyValue = MyHouseTable.Rows[0][MyName].ToString();
String[] MyTypeData = MyValue.Split(new char[1] { '、' });
foreach (String MyString in MyTypeData)
{
this.DropDownList3.Items.Add(MyString);
}
MyName = "朝向";
MyValue = MyHouseTable.Rows[0][MyName].ToString();
String[] MyDireData = MyValue.Split(new char[1] { '、' });
foreach (String MyString in MyDireData)
{
this.DropDownList2.Items.Add(MyString);
}
MyName = "结构";
MyValue = MyHouseTable.Rows[0][MyName].ToString();
String[] MyStruData = MyValue.Split(new char[1] { '、' });
foreach (String MyString in MyStruData)
{
this.DropDownList4.Items.Add(MyString);
}
MyName = "装修";
MyValue = MyHouseTable.Rows[0][MyName].ToString();
String[] MyDecoData = MyValue.Split(new char[1] { '、' });
foreach (String MyString in MyDecoData)
{
this.DropDownList5.Items.Add(MyString);
}
MyName = "付佣";
MyValue = MyHouseTable.Rows[0][MyName].ToString();
String[] MyFeeData = MyValue.Split(new char[1] { '、' });
foreach (String MyString in MyFeeData)
{
this.DropDownList7.Items.Add(MyString);
}
MyName = "委托";
MyValue = MyHouseTable.Rows[0][MyName].ToString();
String[] MyDeleData = MyValue.Split(new char[1] { '、' });
foreach (String MyString in MyDeleData)
{
this.DropDownList8.Items.Add(MyString);
}
MyName = "来源";
MyValue = MyHouseTable.Rows[0][MyName].ToString();
String[] MySourceData = MyValue.Split(new char[1] { '、' });
foreach (String MyString in MySourceData)
{
this.DropDownList9.Items.Add(MyString);
}
MyName = "状态";
MyValue = MyHouseTable.Rows[0][MyName].ToString();
String[] MyStatusData = MyValue.Split(new char[1] { '、' });
foreach (String MyString in MyStatusData)
{
this.DropDownList11.Items.Add(MyString);
}
MySQL = "Select * From 职员信息";
DataTable MyPersonnelTable = new DataTable();
MyAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyAdapter.Fill(MyPersonnelTable);
MyName = "职员姓名";
MyValue = MyPersonnelTable.Rows[0][MyName].ToString();
foreach (DataRow MyRow in MyPersonnelTable.Rows)
{
this.DropDownList10.Items.Add(MyRow[MyName].ToString());
}
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{//新增出租房源信息
this.SqlDataSource1.Insert();
}
protected void Button3_Click(object sender, EventArgs e)
{//修改出租房源信息
this.SqlDataSource1.Update();
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{//弹出删除操作确认对话框
if (e.Row.RowType == DataControlRowType.DataRow)
{
Button MyButton = (Button)e.Row.FindControl("Button1");
MyButton.OnClientClick = "return confirm('是否确认删除当前选择的记录?')";
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{//在控件中显示选择的记录
this.TextBox2.Text = this.GridView1.SelectedRow.Cells[2].Text.ToString();
this.DropDownList1.SelectedValue = this.GridView1.SelectedRow.Cells[3].Text.ToString();
this.TextBox4.Text = this.GridView1.SelectedRow.Cells[4].Text.ToString();
this.TextBox5.Text = this.GridView1.SelectedRow.Cells[5].Text.ToString();
this.TextBox6.Text = this.GridView1.SelectedRow.Cells[6].Text.ToString();
this.CheckBox1.Checked = (Convert.ToInt16(this.GridView1.SelectedRow.Cells[7].Text.ToString()) == 1) ? true : false;
this.TextBox8.Text = this.GridView1.SelectedRow.Cells[8].Text.ToString();
this.TextBox9.Text = this.GridView1.SelectedRow.Cells[9].Text.ToString();
this.TextBox10.Text = this.GridView1.SelectedRow.Cells[10].Text.ToString();
this.TextBox11.Text = this.GridView1.SelectedRow.Cells[11].Text.ToString();
this.TextBox12.Text = this.GridView1.SelectedRow.Cells[12].Text.ToString();
this.DropDownList2.SelectedValue = this.GridView1.SelectedRow.Cells[13].Text.ToString();
this.TextBox14.Text = this.GridView1.SelectedRow.Cells[14].Text.ToString();
this.DropDownList3.SelectedValue = this.GridView1.SelectedRow.Cells[15].Text.ToString();
this.DropDownList4.SelectedValue = this.GridView1.SelectedRow.Cells[16].Text.ToString();
this.TextBox17.Text = this.GridView1.SelectedRow.Cells[17].Text.ToString();
this.TextBox18.Text = this.GridView1.SelectedRow.Cells[18].Text.ToString();
this.DropDownList5.SelectedValue = this.GridView1.SelectedRow.Cells[19].Text.ToString();
this.TextBox20.Text = this.GridView1.SelectedRow.Cells[20].Text.ToString();
this.DropDownList6.SelectedValue = this.GridView1.SelectedRow.Cells[21].Text.ToString();
this.TextBox22.Text = this.GridView1.SelectedRow.Cells[22].Text.ToString();
this.TextBox23.Text = this.GridView1.SelectedRow.Cells[23].Text.ToString();
this.TextBox24.Text = this.GridView1.SelectedRow.Cells[24].Text.ToString();
this.TextBox25.Text = this.GridView1.SelectedRow.Cells[25].Text.ToString();
this.TextBox26.Text = this.GridView1.SelectedRow.Cells[26].Text.ToString();
this.TextBox27.Text = this.GridView1.SelectedRow.Cells[27].Text.ToString();
this.TextBox28.Text = this.GridView1.SelectedRow.Cells[28].Text.ToString();
this.TextBox29.Text = this.GridView1.SelectedRow.Cells[29].Text.ToString();
this.TextBox30.Text = this.GridView1.SelectedRow.Cells[30].Text.ToString();
this.DropDownList7.SelectedValue = this.GridView1.SelectedRow.Cells[31].Text.ToString();
this.TextBox32.Text = this.GridView1.SelectedRow.Cells[32].Text.ToString();
this.TextBox33.Text = this.GridView1.SelectedRow.Cells[33].Text.ToString();
this.TextBox34.Text = this.GridView1.SelectedRow.Cells[34].Text.ToString();
this.TextBox35.Text = this.GridView1.SelectedRow.Cells[35].Text.ToString();
this.DropDownList8.SelectedValue = this.GridView1.SelectedRow.Cells[36].Text.ToString();
this.TextBox37.Text = this.GridView1.SelectedRow.Cells[37].Text.ToString();
this.TextBox38.Text = this.GridView1.SelectedRow.Cells[38].Text.ToString();
this.DropDownList9.SelectedValue = this.GridView1.SelectedRow.Cells[39].Text.ToString();
this.CheckBox2.Checked = (Convert.ToInt16(this.GridView1.SelectedRow.Cells[40].Text.ToString()) == 1) ? true : false;
this.CheckBox3.Checked = (Convert.ToInt16(this.GridView1.SelectedRow.Cells[41].Text.ToString()) == 1) ? true : false;
this.CheckBox4.Checked = (Convert.ToInt16(this.GridView1.SelectedRow.Cells[42].Text.ToString()) == 1) ? true : false;
this.TextBox43.Text = this.GridView1.SelectedRow.Cells[43].Text.ToString();
this.DropDownList10.SelectedValue = this.GridView1.SelectedRow.Cells[44].Text.ToString();
this.DropDownList11.SelectedValue = this.GridView1.SelectedRow.Cells[45].Text.ToString();
this.TextBox46.Text = this.GridView1.SelectedRow.Cells[46].Text.ToString();
}
protected void Button4_Click(object sender, EventArgs e)
{//打印出租房源信息
Server.Transfer("~/HouseManage/HouseLeasePrint.aspx");
}
public string MyPrint房屋位置
{//设置要传递到打印页的数据
get
{
return "房屋位置:" + this.DropDownList1.SelectedValue + this.TextBox4.Text+" 楼盘名称:"+this.TextBox5.Text;
}
}
public string MyPrint付租情况
{//设置要传递到打印页的数据
get
{
return "付租方式:" + this.DropDownList6.SelectedValue + " 出租价格:" +this.TextBox22.Text+"元";
}
}
public string MyPrint建筑面积
{//设置要传递到打印页的数据
get
{
return "建面(m2):" + this.TextBox17.Text + " 套面(m2):" + this.TextBox18.Text + " 装修:" +this.DropDownList5.SelectedValue;
}
}
public string MyPrint房型物管费
{//设置要传递到打印页的数据
get
{
return "房型:" + this.TextBox8.Text + "房" + this.TextBox9.Text + "厅" + this.TextBox10.Text + "厨" + this.TextBox11.Text + "卫" + this.TextBox12.Text + "阳台" + " 物管费:" + this.TextBox14.Text+"元/年";
}
}
public string MyPrint家电家私
{//设置要传递到打印页的数据
get
{
return "家私:" + this.TextBox24.Text + " 家电:" + this.TextBox25.Text;
}
}
public string MyPrint配套设施
{//设置要传递到打印页的数据
get
{
return "配套设施:" + this.TextBox26.Text;
}
}
public string MyPrint房源编号
{//设置要传递到打印页的数据
get
{
return "房源编号:" + this.TextBox2.Text;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -