protected void dosubmit(object sender, CommandEventArgs e) { wgiAdUnionSystem.BLL.wgi_sitehost bll = new wgiAdUnionSystem.BLL.wgi_sitehost(); string username = ""; if (e.CommandArgument.ToString() == "add") { username = this.txtusername.Text; if (bll.GetListByUsername(username).Tables[0].Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('用户名已被使用');", true); return; } } string password = this.txtpassword.Text; string email = this.txtemail.Text; string mobile = this.txtmobile.Text; string accountname = this.txtaccountname.Text; string accountno = this.txtaccountno.Text; string bank = this.txtbank.Text; string branch = this.txtbranch.Text; int usertype = 1;//usertype是个人/网站/博客等,因为已经在usersite里面可以多重定义,所以改为用户在系统里的类型,如网站主,广告主 string contact = this.txtcontact.Text; string qq = this.txtqq.Text; string idcard = this.txtidcard.Text; string address = this.txtaddress.Text; string zipcode = this.txtzipcode.Text; string tel = this.txttel.Text; decimal balance = Convert.ToDecimal(0.00); DateTime regdate = DateTime.Now; string regip = CommonData.GetIp(this.Page); //DateTime lastdate = DateTime.Now; //string lastip = ""; int status = 1;//0表示尚未审核通过,暂时默认网站主注册即通过 if (e.CommandArgument.ToString() == "add") { wgiAdUnionSystem.Model.wgi_sitehost model = new wgiAdUnionSystem.Model.wgi_sitehost(); model.username = username; model.password = password; model.email = email; model.mobile = mobile; model.contact = contact; model.qq = qq; model.idcard = idcard; model.address = address; model.zipcode = zipcode; model.tel = tel; //银行账户信息允许管理员添加,却不允许管理员更改 model.accountname = accountname; model.accountno = accountno; model.bank = bank; model.branch = branch; //账号状态信息自动读取,不允许编辑 //model.balance = balance; //model.lastdate = lastdate; //model.lastip = lastip; model.regdate = regdate; model.regip = regip; model.usertype = usertype; model.status = status; try { bll.Add(model); ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('添加成功');top.location=top.location;", true); } catch (Exception) { ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('内部错误');", true); } } else if (e.CommandArgument.ToString() == "edit") { try { int userid = int.Parse(this.hiduid.Value); wgiAdUnionSystem.Model.wgi_sitehost model = bll.GetModel(userid); model.password = password; model.email = email; model.mobile = mobile; model.contact = contact; model.qq = qq; model.idcard = idcard; model.address = address; model.zipcode = zipcode; model.tel = tel; if (ddlstatus.Visible = true) model.status = int.Parse(ddlstatus.Text); bll.Update(model); ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('修改成功');top.location=top.location;", true); } catch (Exception) { ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('内部错误');", true); } } }
protected void btnAdd_Click(object sender, EventArgs e) { string username = this.txtusername.Text; wgiAdUnionSystem.BLL.wgi_sitehost bll = new wgiAdUnionSystem.BLL.wgi_sitehost(); if (bll.GetListByUsername(username).Tables[0].Rows.Count > 0) { ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('用户名已被使用');", true); return; } #region 服务器验证 string strErr = ""; if (this.txtusername.Text == "") { strErr += "username不能为空!\\n"; } if (this.txtpassword.Text == "") { strErr += "password不能为空!\\n"; } if (this.txtpassword.Text != this.txtpwd2.Text) { strErr += "password不能为空!\\n"; } if (this.txtemail.Text == "") { strErr += "email不能为空!\\n"; } if (this.txtmobile.Text == "" && this.txttel.Text == "") { strErr += "电话、手机至少选填一项!\\n"; } if (this.txtaccountname.Text == "") { strErr += "accountname不能为空!\\n"; } if (this.txtaccountno.Text == "") { strErr += "accountno不能为空!\\n"; } if (this.txtbank.Text == "") { strErr += "bank不能为空!\\n"; } if (this.txtbranch.Text == "") { strErr += "branch不能为空!\\n"; } //if (!PageValidate.IsNumber(txtusertype.Text)) //{ // strErr += "usertype不是数字!\\n"; //} if (this.txtcontact.Text == "") { strErr += "contact不能为空!\\n"; } //if (this.txtqq.Text == "") //{ // strErr += "qq不能为空!\\n"; //} if (this.txtidcard.Text == "") { strErr += "idcard不能为空!\\n"; } //if (this.txtaddress.Text == "") //{ // strErr += "address不能为空!\\n"; //} //if (this.txtzipcode.Text == "") //{ // strErr += "zipcode不能为空!\\n"; //} //if (!PageValidate.IsNumber(txtstatus.Text)) //{ // strErr += "status不是数字!\\n"; //} if (strErr != "") { MessageBox.Show(this, strErr); return; } #endregion string password = this.txtpassword.Text; string email = this.txtemail.Text; string mobile = this.txtmobile.Text; string accountname = this.txtaccountname.Text; string accountno = this.txtaccountno.Text; string bank = this.txtbank.Text; string branch = this.txtbranch.Text; int usertype = 1;//usertype是个人/网站/博客等 string contact = this.txtcontact.Text; string qq = this.txtqq.Text; string idcard = this.txtidcard.Text; string address = this.txtaddress.Text; string zipcode = this.txtzipcode.Text; string tel = this.txttel.Text; decimal balance = Convert.ToDecimal(0.00); DateTime regdate = DateTime.Now; string regip = CommonData.GetIp(this.Page); //DateTime lastdate = DateTime.Now; //string lastip = ""; int status = 1;//0表示尚未审核通过,暂时默认网站主注册即通过 wgiAdUnionSystem.Model.wgi_sitehost model = new wgiAdUnionSystem.Model.wgi_sitehost(); model.username = username; model.password = password; model.email = email; model.mobile = mobile; model.accountname = accountname; model.accountno = accountno; model.bank = bank; model.branch = branch; model.usertype = usertype; model.contact = contact; model.qq = qq; model.idcard = idcard; model.address = address; model.zipcode = zipcode; model.tel = tel; model.balance = balance; model.regdate = regdate; model.regip = regip; //model.lastdate = lastdate; //model.lastip = lastip; model.status = status; try { bll.Add(model); Response.Redirect("regSuccess.aspx"); } catch (Exception) { ScriptManager.RegisterClientScriptBlock(this, GetType(), DateTime.Now.ToString(), "alert('内部错误');", true); } }