protected void btnAdd_Click(object sender, EventArgs e) { if (txtName.Text == string.Empty) { Response.Write("<script language=javascript>alert('版主名不能为空!')</script>"); } else { host.HostName = txtName.Text; host = HostManager.FindHostByHostName(host); if (host.HostName != null) { Response.Write("<script language=javascript>alert('该版主已经存在!')</script>"); txtName.Text = string.Empty; txtName.Focus(); } else { try { module.ModuleName = ddlModule.SelectedValue; host.ModuleID = ModuleManager.findModuleByName(module).ModuleID; } catch { Response.Write("<script language=javascript>alert('请先填写版块信息!')</script>"); return; } host.HostPwd = txtPwd.Text; host.TName = txtTName.Text; if (ddlSex.SelectedIndex == 0) { host.Sex = true; } if (ddlSex.SelectedIndex == 1) { host.Sex = false; } host.Birthday = DateTime.Parse(txtBirthday.Text); host.Tel = txtTel.Text; host.Mobile = txtMobile.Text; try { host.QQ = Int32.Parse(txtQQ.Text); } catch { txtQQ.Text = string.Empty; Response.Write("<script language=javascript>alert('QQ号码输入错误!')</script>"); return; } images.PhotoID = ddlPhoto.SelectedValue; host.Photo = ImageManager.findImageByPhotoID(images).Photo; host.Email = txtEmail.Text; host.FAddress = txtHAddress.Text; host.RAddress = txtRAddress.Text; host.Index = txtIndex.Text; HostManager.addHost(host); Response.Write("<script language=javascript>alert('版主添加成功!')</script>"); txtName.Text = txtPwd.Text = txtSPwd.Text = txtTName.Text = txtBirthday.Text = txtTel.Text = txtMobile.Text = txtQQ.Text = txtEmail.Text = txtHAddress.Text = txtRAddress.Text = txtIndex.Text = string.Empty; } } }