请大神求救!把下面的ASP.NET代码逐行注释一下。 5
protectedvoidPage_Load(objectsender,EventArgse){if(Session["username"]!=null)//判断用户是否...
protectedvoid Page_Load(object sender, EventArgs e)
{
if(Session["username"] != null) //判断用户是否登录
{
if(!Page.IsPostBack)//若登录,加载页面
{
BindProvince();
BindCity();
BindArea();
}
string username =Session["username"].ToString();//获取登录用户的用户名
Users u = newUsersManager().SelectByUserName(username);
Label2.Text = u.Id;
}
else
{ //当前用户没有登录的时候,转到登陆页面让用户先登录再发布房源信息
Response.Write("<ScriptLanguage=JavaScript>alert('请先登录!');</Script>");
Response.Redirect("Login.aspx");
}
}
protectedvoid btnpublish_Click(object sender, EventArgs e)//发布房源
{
stringtitle = txtTitle.Text.Trim();
stringaddress = txtAddress.Text.Trim();
stringprovince = ddlProvince.SelectedItem.Text;
stringcity = ddlCity.SelectedItem.Text;
stringregion = ddlArea.SelectedItem.Text;
stringrentway = RadioButtonList1.Text;
stringroom = txtRoom.Text.Trim();
stringhall = txtHall.Text.Trim();
stringtoilet = txtToilet.Text.Trim();
stringstorey = txtStorey.Text.Trim();
stringstoreyall = txtStoreyAll.Text.Trim();
stringhousetype = dropHtype.Text;
stringdecoration = dropHDecoration.Text;
stringaspect = dropHaspect.Text;
stringarea = txtArea.Text.Trim();
stringrental = txtRent.Text.Trim();
stringmethod = dropMethod.Text;
stringstatus = Label1.Text.Trim();
stringuserid = Label2.Text.Trim();
stringallocation = "";//获取CheckBoxList选中的房源配置信息
for (int i= 0; i < CheckBoxList1.Items.Count; i++)
{
if(CheckBoxList1.Items[i].Selected)
{
allocation+= CheckBoxList1.Items[i].Value + " ";
}
}
string filepath =this.FileUpload1.PostedFile.FileName; //图片
stringpicture = filepath.Substring(filepath.LastIndexOf("\\") + 1);
if(Path.GetExtension(filepath) == ".jpg" || Path.GetExtension(filepath)== ".png" || Path.GetExtension(filepath) == ".tmp" ||Path.GetExtension(filepath) == ".gif")
{
stringsavefile = Server.MapPath("~/") + "picture\\" + picture;
if(File.Exists(savefile))
{
savefile = Server.MapPath("~/") + "picture\\" +System.DateTime.Now.ToString().Replace(":","-").Replace("/", "-") + "data" +Path.GetExtension(filepath);
}
this.FileUpload1.PostedFile.SaveAs(savefile);
}
else{Response.Write("<script>alert('只能上传jpg、tmp、gif、png格式的图片');</script>");
}
Model.HouseInfo hi =new Model.HouseInfo(title, address, province, city, region, rentway, room,hall, toilet, storey, storeyall, housetype, decoration, aspect, area, rental,method, allocation, picture, status, userid);
bool b1 =new BLL.HouseInfoManager().Insert(hi);
stringtelephone = this.txtPhone.Text.Trim();
stringlinkman = this.txtLinkman.Text.Trim();
Model.Linkway lk = newModel.Linkway(userid,linkman,telephone);
bool b2 =new BLL.LinkwayManager().InsertLinkway(lk);
Response.Redirect("HomePageSkip.aspx");
} 展开
{
if(Session["username"] != null) //判断用户是否登录
{
if(!Page.IsPostBack)//若登录,加载页面
{
BindProvince();
BindCity();
BindArea();
}
string username =Session["username"].ToString();//获取登录用户的用户名
Users u = newUsersManager().SelectByUserName(username);
Label2.Text = u.Id;
}
else
{ //当前用户没有登录的时候,转到登陆页面让用户先登录再发布房源信息
Response.Write("<ScriptLanguage=JavaScript>alert('请先登录!');</Script>");
Response.Redirect("Login.aspx");
}
}
protectedvoid btnpublish_Click(object sender, EventArgs e)//发布房源
{
stringtitle = txtTitle.Text.Trim();
stringaddress = txtAddress.Text.Trim();
stringprovince = ddlProvince.SelectedItem.Text;
stringcity = ddlCity.SelectedItem.Text;
stringregion = ddlArea.SelectedItem.Text;
stringrentway = RadioButtonList1.Text;
stringroom = txtRoom.Text.Trim();
stringhall = txtHall.Text.Trim();
stringtoilet = txtToilet.Text.Trim();
stringstorey = txtStorey.Text.Trim();
stringstoreyall = txtStoreyAll.Text.Trim();
stringhousetype = dropHtype.Text;
stringdecoration = dropHDecoration.Text;
stringaspect = dropHaspect.Text;
stringarea = txtArea.Text.Trim();
stringrental = txtRent.Text.Trim();
stringmethod = dropMethod.Text;
stringstatus = Label1.Text.Trim();
stringuserid = Label2.Text.Trim();
stringallocation = "";//获取CheckBoxList选中的房源配置信息
for (int i= 0; i < CheckBoxList1.Items.Count; i++)
{
if(CheckBoxList1.Items[i].Selected)
{
allocation+= CheckBoxList1.Items[i].Value + " ";
}
}
string filepath =this.FileUpload1.PostedFile.FileName; //图片
stringpicture = filepath.Substring(filepath.LastIndexOf("\\") + 1);
if(Path.GetExtension(filepath) == ".jpg" || Path.GetExtension(filepath)== ".png" || Path.GetExtension(filepath) == ".tmp" ||Path.GetExtension(filepath) == ".gif")
{
stringsavefile = Server.MapPath("~/") + "picture\\" + picture;
if(File.Exists(savefile))
{
savefile = Server.MapPath("~/") + "picture\\" +System.DateTime.Now.ToString().Replace(":","-").Replace("/", "-") + "data" +Path.GetExtension(filepath);
}
this.FileUpload1.PostedFile.SaveAs(savefile);
}
else{Response.Write("<script>alert('只能上传jpg、tmp、gif、png格式的图片');</script>");
}
Model.HouseInfo hi =new Model.HouseInfo(title, address, province, city, region, rentway, room,hall, toilet, storey, storeyall, housetype, decoration, aspect, area, rental,method, allocation, picture, status, userid);
bool b1 =new BLL.HouseInfoManager().Insert(hi);
stringtelephone = this.txtPhone.Text.Trim();
stringlinkman = this.txtLinkman.Text.Trim();
Model.Linkway lk = newModel.Linkway(userid,linkman,telephone);
bool b2 =new BLL.LinkwayManager().InsertLinkway(lk);
Response.Redirect("HomePageSkip.aspx");
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询