protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { UserIdentity identity = this.Page.User.Identity as UserIdentity; if (identity != null) { user = identity.Name + identity._domain; } Exam.Entity.tb_UserEntity list = Exam.BLL.tb_UserBLL.GetInstance().GetModelByNameSchoolId(identity.Name, identity._schoolID); name = list.RealName; mail = list.Mail; phone = list.Phone; roleid = list.RoleId.ToString(); if (list.RoleId == 1) { schoolid = list.SchoolId.ToString(); yuming = Jnwf.Utils.Config.ConfigurationUtil.GetAppSettingValue("yuming"); yumingks = Jnwf.Utils.Config.ConfigurationUtil.GetAppSettingValue("yumingks"); yumingyd = Jnwf.Utils.Config.ConfigurationUtil.GetAppSettingValue("yumingyd"); } Exam.Entity.tb_SchoolEntity lists = Exam.BLL.tb_SchoolBLL.GetInstance().GetAdminSingle(identity._schoolID); schoolname = lists.Name; schoollinkman = lists.Linkman; schooltime = lists.Addtime.ToString("yyyy-MM-dd"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { UserIdentity identity = User.Identity as UserIdentity; //string[] tarr = identity._domain.Split('.'); //domain = tarr[0].TrimStart('@'); if (schoolid > 0) { Exam.Entity.tb_SchoolEntity model = Exam.BLL.tb_SchoolBLL.GetInstance().GetAdminSingle(schoolid); school = model.Name.ToString(); if (model != null) { domain = model.Domain; domain1 = model.Domain; string[] tarr = domain1.Split('.'); domain1 = tarr[0].TrimStart('@'); } } if (identity != null) { UserId = identity.UserID; iddomain = identity._domain; schoolId = identity._schoolID; idname = identity.Name; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (schoolid > 0) { Exam.Entity.tb_SchoolEntity model = Exam.BLL.tb_SchoolBLL.GetInstance().GetAdminSingle(schoolid); //school = model.SchoolId.ToString(); if (model != null) { domain = model.Domain; } } } }
//删除学校 public void delschool(int schoolId) { try { Exam.Entity.tb_SchoolEntity model = Exam.BLL.tb_SchoolBLL.GetInstance().GetAdminSingle(schoolId); if (model != null) { model.Status = 0; } Exam.BLL.tb_SchoolBLL.GetInstance().Update(model); Response.Write("1"); } catch (Exception ex) { Jnwf.Utils.Log.Logger.Log4Net.Error("data.aspx.cs,delagent,ex:" + ex.Message + "|" + ex.StackTrace); Response.Write("error"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { if (UserId != 0) { Exam.Entity.tb_UserEntity model = Exam.BLL.tb_UserBLL.GetInstance().GetAdminSingle(UserId); Exam.Entity.tb_SchoolEntity tmodel = Exam.BLL.tb_SchoolBLL.GetInstance().GetAdminSingle(model.SchoolId); if (model.Status == 0) { model.Status = 1; Exam.BLL.tb_UserBLL.GetInstance().Update(model); Response.Write("审核通过"); string body = Jnwf.Utils.Config.ConfigurationUtil.GetAppSettingValue("body"); body = string.Format(body, "<p><b>", tmodel.Name, "</b></p><p>", "<br/>", "admin@" + tmodel.Domain + "<br/>", model.Pwd + "<br/><p>", model.SchoolId + "</p>", "</p>"); Jnwf.Utils.Mail.MailHelper.SendEmail( Jnwf.Utils.Config.ConfigurationUtil.GetAppSettingValue("smtpServer"), Jnwf.Utils.Config.ConfigurationUtil.GetAppSettingValue("smtpUser"), Jnwf.Utils.Config.ConfigurationUtil.GetAppSettingValue("smtpPass"), model.Mail, "欢迎加入快去读", body, true, null); } else { Response.Write("用户" + UserId + "已申请"); } } else { Response.Write("UserId为null"); } } catch (Exception ex) { Response.Write(ex.Message); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { IList <tb_UserEntity> agentList = tb_UserBLL.GetInstance().GetAgentList(); tb_UserEntity userModel = new tb_UserEntity(); userModel.UserId = 0; userModel.Name = "选择代理商"; agentList.Insert(0, userModel); if (agentList != null && agentList.Count > 0) { dllagent.DataSource = agentList; dllagent.DataTextField = "name"; dllagent.DataValueField = "userid"; dllagent.DataBind(); } //省 IList <tb_LocationEntity> list = Exam.BLL.tb_LocationBLL.GetInstance().GetProvinceByCache(); this.ddlprovince.DataSource = list; this.ddlprovince.DataTextField = "LocationName"; this.ddlprovince.DataValueField = "LocationId"; this.ddlprovince.DataBind(); if (identity != null) { if (schoolId > 0) { Exam.Entity.tb_SchoolEntity model = Exam.BLL.tb_SchoolBLL.GetInstance().GetAdminSingle(schoolId); if (model != null) { string str = model.Domain; string[] arr = str.Split('.'); this.txtname.Text = model.Name; this.txtdomain.Text = arr[0]; this.txtdomain.Enabled = false; this.ddldomain.SelectedItem.Text = arr[1]; this.ddldomain.Enabled = false; this.txtrealname.Text = model.Linkman; this.txtphone.Text = model.Phone; this.ddlstatus.SelectedValue = model.Status.ToString(); this.txtemail.Text = model.Mail; DataSet ds = Exam.BLL.tb_LocationBLL.GetInstance().GetLocationInfo(model.LocationId); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { //城市 if (int.Parse(ds.Tables[0].Rows[0]["ProvinceID"].ToString()) == 0) { for (int i = 0; i < ddlprovince.Items.Count; i++) { if (ddlprovince.Items[i].Value == ds.Tables[0].Rows[0]["CityID"].ToString()) { ddlprovince.Items[i].Selected = true; IList <tb_LocationEntity> tlist = Exam.BLL.tb_LocationBLL.GetInstance().GetCityByCache(int.Parse(ds.Tables[0].Rows[0]["CityID"].ToString())); this.ddlcity.DataSource = tlist; this.ddlcity.DataTextField = "LocationName"; this.ddlcity.DataValueField = "LocationId"; this.ddlcity.DataBind(); } } //城市选中 for (int k = 0; k < ddlcity.Items.Count; k++) { if (ddlcity.Items[k].Value == ds.Tables[0].Rows[0]["LocationId"].ToString()) { ddlcity.Items[k].Selected = true; } } } else if (int.Parse(ds.Tables[0].Rows[0]["ProvinceID"].ToString()) > 0) { for (int i = 0; i < ddlprovince.Items.Count; i++) { if (ddlprovince.Items[i].Value == ds.Tables[0].Rows[0]["ProvinceID"].ToString()) { //省选中 ddlprovince.Items[i].Selected = true; //市赋值 IList <tb_LocationEntity> tlist = Exam.BLL.tb_LocationBLL.GetInstance().GetCityByCache(int.Parse(ds.Tables[0].Rows[0]["ProvinceID"].ToString())); if (tlist != null) { this.ddlcity.DataSource = tlist; this.ddlcity.DataTextField = "LocationName"; this.ddlcity.DataValueField = "LocationId"; this.ddlcity.DataBind(); } } } for (int y = 0; y < ddlcity.Items.Count; y++) { if (ddlcity.Items[y].Value == ds.Tables[0].Rows[0]["CityID"].ToString()) { //市选中 ddlcity.Items[y].Selected = true; //区赋值 IList <tb_LocationEntity> templist = Exam.BLL.tb_LocationBLL.GetInstance().GetEurozoneList(int.Parse(ddlcity.Value)); if (templist != null) { this.ddleurozone.DataSource = templist; this.ddleurozone.DataTextField = "LocationName"; this.ddleurozone.DataValueField = "LocationId"; this.ddleurozone.DataBind(); } } } for (int k = 0; k < ddleurozone.Items.Count; k++) { //区选择 if (ddleurozone.Items[k].Value == ds.Tables[0].Rows[0]["LocationId"].ToString()) { ddleurozone.Items[k].Selected = true; } } } } } } } } }
protected void btnSave_Click(object sender, EventArgs e) { try { string domain = SqlInject(this.txtdomain.Text.Trim()); string domain2 = ddldomain.SelectedValue; string realname = SqlInject(this.txtrealname.Text.Trim()); string name = SqlInject(this.txtname.Text.Trim()); string phone = SqlInject(txtphone.Text.Trim()); string status = ddlstatus.SelectedValue; string mail = SqlInject(this.txtemail.Text.Trim()); int agentId = int.Parse(SqlInject(this.dllagent.SelectedValue.ToString())); if (identity != null) { //添加 if (schoolId == 0) { Exam.Entity.tb_SchoolEntity model = Exam.BLL.tb_SchoolBLL.GetInstance().GetModel("@" + domain + ddldomain.SelectedValue); if (model != null) { MessageBox.ShowMsg(this, "域名已存在!"); return; } else { RandomCode r = new RandomCode(); r.IncludeSpecial = false; r.MaximumLength = 6; string pwd = r.Create(); int locationid = 0; if (ddleurozone.Value == "0") { int.TryParse(ddlcity.Value, out locationid); } else { int.TryParse(ddleurozone.Value, out locationid); } string body = Jnwf.Utils.Config.ConfigurationUtil.GetAppSettingValue("body"); int rows = 0; if (identity._roleID == 4) { if (agentId == 0) { rows = Exam.BLL.tb_SchoolBLL.GetInstance().InsertSchool("@" + domain + ddldomain.SelectedValue, name, locationid, realname, male.Checked ? 1 : 0, phone, mail, pwd, 0, 1); } else { rows = Exam.BLL.tb_SchoolBLL.GetInstance().InsertSchool("@" + domain + ddldomain.SelectedValue, name, locationid, realname, male.Checked ? 1 : 0, phone, mail, pwd, agentId, 1); } Exam.Entity.tb_SchoolEntity tmodel = Exam.BLL.tb_SchoolBLL.GetInstance().GetModel("@" + domain + ddldomain.SelectedValue); body = string.Format(body, "<p><b>", name, "</b></p><p>", "<br/>", "admin@" + domain + domain2 + "<br/>", pwd + "<br/><p>", tmodel.SchoolId + "</p>", "</p>"); if (rows > 0) { Jnwf.Utils.Mail.MailHelper.SendEmail( Jnwf.Utils.Config.ConfigurationUtil.GetAppSettingValue("smtpServer"), Jnwf.Utils.Config.ConfigurationUtil.GetAppSettingValue("smtpUser"), Jnwf.Utils.Config.ConfigurationUtil.GetAppSettingValue("smtpPass"), mail, "欢迎加入快去读", body, true, null); MessageBox.ShowAndRedirect(this, "添加成功!", "listschool.aspx"); } } //代理商 else if (identity._roleID == 5) { Exam.BLL.tb_SchoolBLL.GetInstance().InsertSchool("@" + domain + ddldomain.SelectedValue, name, locationid, realname, male.Checked ? 1 : 0, phone, mail, pwd, identity.UserID, 0); } } } //修改 else { Exam.Entity.tb_SchoolEntity model = Exam.BLL.tb_SchoolBLL.GetInstance().GetAdminSingle(schoolId); if (model != null) { if (selecteurozone.Text != "0") { model.LocationId = int.Parse(ddleurozone.Value); } else if (selectcity.Text != "0") { model.LocationId = int.Parse(ddlcity.Value); } model.Name = name; model.Linkman = txtrealname.Text; model.Mail = mail; model.Phone = txtphone.Text; model.Status = int.Parse(status); model.Updatetime = DateTime.Now; Exam.BLL.tb_SchoolBLL.GetInstance().Update(model); } Response.Redirect("listschool.aspx"); } } } catch (Exception ex) { Jnwf.Utils.Log.Logger.Log4Net.Error("AddSchool.aspx.cs,btnSave_Click,ex:" + ex.Message + "|" + ex.StackTrace); //throw; } }
protected void btnSave_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtyuming.Text.Trim())) { MessageBox.ShowMsg(this, "域名不能为空"); return; } if (string.IsNullOrEmpty(txtname.Text.Trim())) { MessageBox.ShowMsg(this, "学校名称不能为空"); return; } if (string.IsNullOrEmpty(txtrealname.Text.Trim())) { MessageBox.ShowMsg(this, "姓名不能为空"); return; } if (string.IsNullOrEmpty(txtphone.Text.Trim())) { MessageBox.ShowMsg(this, "电话不能为空"); return; } if (string.IsNullOrEmpty(txtmail.Text.Trim())) { MessageBox.ShowMsg(this, "邮箱不能为空"); return; } Exam.Entity.tb_SchoolEntity model = Exam.BLL.tb_SchoolBLL.GetInstance().GetModel("@" + txtyuming.Text.Trim() + ddldomain.SelectedValue); if (model == null) { RandomCode r = new RandomCode(); r.IncludeSpecial = false; r.MaximumLength = 6; string pwd = r.Create(); int locationid = 0; //if (ddleurozone.SelectedValue =="0") //{ // int.TryParse(ddlcity.SelectedValue,out locationid); //} //else //{ // int.TryParse(ddleurozone.SelectedValue, out locationid); //} int rows = Exam.BLL.tb_SchoolBLL.GetInstance().InsertSchool("@" + txtyuming.Text.Trim() + ddldomain.SelectedValue, txtname.Text.Trim(), locationid, txtrealname.Text.Trim(), male.Checked ? 1 : 0, txtphone.Text.Trim(), txtmail.Text.Trim(), pwd, 0); /*model = new Exam.Entity.tb_SchoolEntity(); * model.Name = txtname.Text.Trim(); * model.Domain = "@" + txtyuming.Text.Trim(); * model.LocationId = 0; * model.Linkman = txtrealname.Text.Trim(); * model.Phone = txtphone.Text.Trim(); * model.Tel = ""; * model.Mail = txtmail.Text.Trim(); * model.Addtime = DateTime.Now; * model.Updatetime = DateTime.Now; * model.Begintime = DateTime.Now; * model.Endtime = DateTime.Now.AddYears(1); * * int row = Exam.BLL.tb_SchoolBLL.GetInstance().Insert(model); * * Exam.Entity.tb_UserEntity user = new Exam.Entity.tb_UserEntity(); * user.SchoolId = row; * user.DepartmentId = 0; * user.RoleId = 1; * user.Name = "admin"; * user.Pwd = "admin"; * user.RealName = txtrealname.Text.Trim(); * user.Sex = male.Checked ? 1 : 0; * user.Position = "管理员"; * user.Mail = txtmail.Text.Trim(); * user.IdentityCard = ""; * user.Phone = txtphone.Text.Trim(); * user.Description = ""; * user.Status = 1; * user.Addtime = DateTime.Now; * * Exam.BLL.tb_UserBLL.GetInstance().Insert(user); */ MessageBox.ShowMsg(this, "添加成功,请等待管理员审核"); //SendWelcome(txtrealname.Text.Trim(), txtmail.Text.Trim(),"admin",pwd); } else { MessageBox.ShowMsg(this, "注册域名重复"); return; } } catch (Exception ex) { MessageBox.ShowMsg(this, ex.Message); } }