public void classstatus(int id) { Exam.Entity.tb_DepartmentEntity model = Exam.BLL.tb_DepartmentBLL.GetInstance().GetAdminSingle(id); try { if (model != null) { if (model.Status == 1) { model.Status = 0; Exam.BLL.tb_DepartmentBLL.GetInstance().Update(model); Response.Write("1"); } else { model.Status = 1; Exam.BLL.tb_DepartmentBLL.GetInstance().Update(model); Response.Write("1"); } } } catch (Exception ex) { Jnwf.Utils.Log.Logger.Log4Net.Error("data.aspx.cs,classstatus,ex:" + ex.Message + "|" + ex.StackTrace); Response.Write("error"); } }
//添加 public void AddMenu(int departmentid, string name) { try { Exam.Entity.tb_DepartmentEntity model = new Exam.Entity.tb_DepartmentEntity(); UserIdentity identity = User.Identity as UserIdentity; if (identity != null) { model.SchoolId = identity._schoolID; model.RoleId = 0; model.ParentId = departmentid; model.Name = name; model.Description = name; model.Status = 1; model.Addtime = DateTime.Now; model.Updatetime = DateTime.Now; Exam.BLL.tb_DepartmentBLL.GetInstance().Insert(model); Response.Write("1"); } } catch (Exception ex) { Jnwf.Utils.Log.Logger.Log4Net.Error("data.aspx.cs,AddMenu,ex:" + ex.Message + "|" + ex.StackTrace); Response.Write("error"); } }
protected void btnSave_Click(object sender, EventArgs e) { UserIdentity identity = User.Identity as UserIdentity; //所属学校 Exam.Entity.tb_DepartmentEntity model = Exam.BLL.tb_DepartmentBLL.GetInstance().Get_DepartmentEntityBySchoold(identity._schoolID); //年级 IList <Exam.Entity.tb_DepartmentEntity> list = Exam.BLL.tb_DepartmentBLL.GetInstance().Gettb_DepartmentParentIdListNowStatus(163); try { if (list.Count > 0 && list != null) { for (int i = 0; i < rptResultsList.Items.Count; i++) { DropDownList drp = rptResultsList.Items[i].FindControl("ddlstatus") as DropDownList; //判断是否改动 if (list[i].Status != int.Parse(drp.SelectedValue)) { //具体年级 Exam.Entity.tb_DepartmentEntity tmodel = Exam.BLL.tb_DepartmentBLL.GetInstance().GetAdminSingle(list[i].DepartmentId); if (tmodel != null) { //班级 IList <Exam.Entity.tb_DepartmentEntity> tlist = Exam.BLL.tb_DepartmentBLL.GetInstance().Gettb_DepartmentParentIdListNowStatus(tmodel.DepartmentId); if (tlist.Count > 0 && tlist != null) { //班级循环 for (int k = 0; k < tlist.Count; k++) { //具体班级 Exam.Entity.tb_DepartmentEntity tempmodel = Exam.BLL.tb_DepartmentBLL.GetInstance().GetAdminSingle(tlist[k].DepartmentId); if (tempmodel != null) { tempmodel.Status = int.Parse(drp.SelectedValue); Exam.BLL.tb_DepartmentBLL.GetInstance().Update(tempmodel); } } } tmodel.Status = int.Parse(drp.SelectedValue); Exam.BLL.tb_DepartmentBLL.GetInstance().Update(tmodel); } } } } Datainfo(); } catch (Exception ex) { Jnwf.Utils.Log.Logger.Log4Net.Error("data.aspx.cs,btnSave_Click,ex:" + ex.Message + "|" + ex.StackTrace); } }
//修改 public void EndMenu(int departmentid, string name) { try { Exam.Entity.tb_DepartmentEntity model = Exam.BLL.tb_DepartmentBLL.GetInstance().GetAdminSingle(departmentid); if (model != null) { model.Name = name; Exam.BLL.tb_DepartmentBLL.GetInstance().Update(model); Response.Write("1"); } } catch (Exception ex) { Jnwf.Utils.Log.Logger.Log4Net.Error("data.aspx.cs,EndMenu,ex:" + ex.Message + "|" + ex.StackTrace); Response.Write("error"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (identity != null) { txtdomain.Text = identity._domain; txtdomain.Enabled = false; if (UserId > 0) { radselect2.Checked = true; txtname.Enabled = false; tb_UserEntity model = tb_UserBLL.GetInstance().GetAdminSingle(UserId); this.txtname.Text = model.Name; this.txtrealname.Text = model.RealName; this.ddlstatus.SelectedValue = model.Status.ToString(); this.txtposition.Text = model.Position; this.txtemail.Text = model.Mail; this.txtphone.Text = model.Phone; this.txtnotice.Text = model.Description; this.ddlrole.SelectedValue = model.RoleId.ToString(); if (model.Sex == 1) { male.Checked = true; } else { female.Checked = true; } Exam.Entity.tb_DepartmentEntity temp = Exam.BLL.tb_DepartmentBLL.GetInstance().GetAdminSingle(model.DepartmentId); if (temp != null) { Exam.Entity.tb_DepartmentEntity ttemp = Exam.BLL.tb_DepartmentBLL.GetInstance().GetAdminSingle(temp.ParentId); if (ttemp != null) { labdepartment.Text = ttemp.Name + temp.Name; } } hiddepartmentId.Text = model.DepartmentId.ToString(); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { UserIdentity identity = User.Identity as UserIdentity; if (identity != null) { Exam.Entity.tb_DepartmentEntity model = Exam.BLL.tb_DepartmentBLL.GetInstance().Get_DepartmentEntityBySchoold(identity._schoolID); IList <Exam.Entity.tb_DepartmentEntity> list = Exam.BLL.tb_DepartmentBLL.GetInstance().Gettb_DepartmentParentIdList(model.DepartmentId); if (list.Count > 0 && list != null) { listClass.DataSource = list; listClass.DataTextField = "name"; listClass.DataValueField = "DepartmentId"; listClass.DataBind(); } } } }
public void Datainfo() { UserIdentity identity = User.Identity as UserIdentity; Exam.Entity.tb_DepartmentEntity model = Exam.BLL.tb_DepartmentBLL.GetInstance().Get_DepartmentEntityBySchoold(identity._schoolID); IList <Exam.Entity.tb_DepartmentEntity> list = Exam.BLL.tb_DepartmentBLL.GetInstance().Gettb_DepartmentParentIdListNowStatus(model.DepartmentId); if (list.Count > 0 && list != null) { rptResultsList.DataSource = list; rptResultsList.DataBind(); for (int i = 0; i < rptResultsList.Items.Count; i++) { DropDownList dll = (DropDownList)rptResultsList.Items[i].FindControl("ddlstatus"); if (list[i].Status == 0) { dll.SelectedValue = "0"; } } } }
protected void btnSave_Click(object sender, EventArgs e) { try { string name = SqlInject(this.txtname.Text.Trim()); //用户名 string pwd = ""; string realname = SqlInject(this.txtrealname.Text.Trim()); //姓名 int sex = 0; //性别 if (this.male.Checked) { sex = 1; } else if (this.female.Checked) { sex = 0; } string status = SqlInject(ddlstatus.SelectedValue); //状态 string position = SqlInject(this.txtposition.Text.Trim()); //职位 string mail = SqlInject(this.txtemail.Text.Trim()); //邮箱 string phone = SqlInject(this.txtphone.Text.Trim()); //电话 string notice = SqlInject(this.txtnotice.Text.Trim()); //备注 int departmentId = 0; //部门 if (hiddepartmentId.Text != "") { departmentId = int.Parse(SqlInject(hiddepartmentId.Text)); } if (identity != null) { //添加 if (UserId == 0) { pwd = SqlInject(this.txtpassword.Text.Trim()); Exam.Entity.tb_UserEntity temp = Exam.BLL.tb_UserBLL.GetInstance().GetModelByNameSchoolId(name, identity._schoolID); if (temp != null) { MessageBox.ShowMsg(this, "登入名已存在!"); return; } Exam.Entity.tb_DepartmentEntity department = null; if (departmentId > 0) { department = Exam.BLL.tb_DepartmentBLL.GetInstance().GetAdminSingle(departmentId); } else { department = Exam.BLL.tb_DepartmentBLL.GetInstance().Get_DepartmentEntityBySchoold(identity.SchoolID); } tb_UserEntity model = new tb_UserEntity(); model.SchoolId = identity._schoolID; model.DepartmentId = departmentId;//部门id //path if (department != null) { if (department.RoleId == 1) { model.Path = "/" + department.DepartmentId + "/"; } else if (department.RoleId == 2) { model.Path = "/" + department.ParentId + "/" + department.DepartmentId + "/"; } else { Exam.Entity.tb_DepartmentEntity tempdepartment = Exam.BLL.tb_DepartmentBLL.GetInstance().GetAdminSingle(department.ParentId); if (tempdepartment != null) { model.Path = "/" + tempdepartment.ParentId + "/" + department.ParentId + "/" + department.DepartmentId + "/"; } else { model.Path = ""; } } } else { model.Path = ""; } model.Name = name; model.Pwd = pwd; model.RealName = realname; model.Sex = sex; model.Position = position; model.Mail = mail; model.IdentityCard = ""; model.Phone = phone; model.Description = notice; model.Status = int.Parse(status); model.Addtime = DateTime.Now; model.RoleId = int.Parse(SqlInject(ddlrole.SelectedValue)); int num = tb_UserBLL.GetInstance().Insert(model); if (num > 0) { MessageBox.ShowAndRedirect(this, "添加成功!", "listname.aspx"); } else { MessageBox.ShowMsg(this, "保存失败!"); labdepartment.Text = SqlInject(hidname.Text.Trim()); } } //修改 else { if (radselect.Checked) { pwd = SqlInject(this.txtpassword.Text.Trim()); if (pwd == "") { MessageBox.ShowMsg(this, "密码不能为空!"); return; } if (txtpasswordSafe.Text.Trim() != pwd) { MessageBox.ShowMsg(this, "两次密码不同!"); return; } } Exam.Entity.tb_DepartmentEntity department = null; if (departmentId > 0) { department = Exam.BLL.tb_DepartmentBLL.GetInstance().GetAdminSingle(departmentId); } else { department = Exam.BLL.tb_DepartmentBLL.GetInstance().Get_DepartmentEntityBySchoold(identity.SchoolID); } tb_UserEntity model = tb_UserBLL.GetInstance().GetAdminSingle(UserId); //model.Name = name; if (radselect.Checked) { model.Pwd = pwd; } model.RealName = realname; model.Sex = sex; model.Position = position; model.Mail = mail; model.Phone = phone; model.Description = notice; model.DepartmentId = departmentId; if (department != null) { if (department.RoleId == 1) { model.Path = "/" + department.DepartmentId + "/"; } else if (department.RoleId == 2) { model.Path = "/" + department.ParentId + "/" + department.DepartmentId + "/"; } else { Exam.Entity.tb_DepartmentEntity tempdepartment = Exam.BLL.tb_DepartmentBLL.GetInstance().GetAdminSingle(department.ParentId); if (tempdepartment != null) { model.Path = "/" + tempdepartment.ParentId + "/" + department.ParentId + "/" + department.DepartmentId + "/"; } else { model.Path = ""; } } } else { model.Path = ""; } model.RoleId = int.Parse(ddlrole.SelectedValue); model.Pwd = pwd; tb_UserBLL.GetInstance().Update(model); Response.Redirect("listname.aspx"); } } } catch (Exception ex) { } }
protected void Button1_Click(object sender, EventArgs e) { try { bool flage = false; string strName = uploadInput.FileName; int i = strName.LastIndexOf("."); //获取。的索引顺序号,在这里。代表图片名字与后缀的间隔 string kzm = strName.Substring(i); //获取文件扩展名的另一种方法 string fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower(); string path = Request.PhysicalApplicationPath; path += @"userinfo\"; string strPath = path + Guid.NewGuid().ToString() + kzm; if (uploadInput.HasFile) { String[] allowedExtensions = { ".xls", ".xlsx" }; for (int j = 0; j < allowedExtensions.Length; j++) { if (kzm == allowedExtensions[j]) { flage = true; } } } if (flage) { // 判定该路径是否存在 if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } uploadInput.PostedFile.SaveAs(strPath);//将图片存储到服务器上 DataSet ds = BasePage.ToDataTable(strPath); Exam.Entity.tb_DepartmentEntity tmodel = Exam.BLL.tb_DepartmentBLL.GetInstance().Get_DepartmentEntityBySchoold(schoolId); if (tmodel != null) { if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { //Jnwf.Utils.Log.Logger.Log4Net.Error("importname,ds:y"); List <Exam.Entity.tb_UserEntity> list = new List <Exam.Entity.tb_UserEntity>(); int schoolidnum = schoolId + 10000; DataSet tds = Exam.BLL.tb_DepartmentBLL.GetInstance().GetYearClassName(schoolId, 3); foreach (DataRow dr in ds.Tables[0].Rows) { int classid = 0; int parentid = 0; Exam.Entity.tb_UserEntity model = Exam.BLL.tb_UserBLL.GetInstance().GetModel(dr); model.SchoolId = schoolId; if (model != null && model.Pwd != "" && model.RealName != "") { //学生 if (model.RoleId == 3) { string className = model.Description; if (model.Description != "") { //班级总人数 int num = Exam.BLL.tb_UserBLL.GetInstance().GetPeopleNumber(className, schoolId); //一年级2班 int index = className.IndexOf('级'); //班级名 string classStr = className.Substring(index + 1, className.Length - 2 - index); if (classStr.Length == 1) { classStr = "0" + classStr;//班级序号02 } //年级名 int tyearname = className.IndexOf('年'); string yearStr = className.Substring(0, tyearname); string[] str = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二" }; int yearnum = 0; string yearnum2 = ""; foreach (string year in str) { yearnum++; if (yearnum < 10) { if (yearStr.Equals(year)) { yearnum2 = "0" + yearnum.ToString();//年级序号01 continue; } } else { if (yearStr.Equals(year)) { yearnum2 = yearnum.ToString();//年级序号01 continue; } } } string numend = "000" + (num + 1).ToString(); numend = numend.Substring(numend.Length - 3, 3); string name = schoolidnum.ToString() + yearnum2 + classStr + numend; model.Name = name; //用户名 foreach (DataRow row in tds.Tables[0].Rows) ///遍历所有的行 { if (row["name"].ToString().Equals(className)) { classid = int.Parse(row["DepartmentId"].ToString()); parentid = int.Parse(row["parentid"].ToString()); continue; } } model.DepartmentId = classid;//所属班级id model.Path = "/" + tmodel.DepartmentId + "/" + parentid + "/" + classid + "/"; model.Addtime = DateTime.Now; Exam.BLL.tb_UserBLL.GetInstance().Insert(model); } } //教师管理员 else { int jsnum = Exam.BLL.tb_UserBLL.GetInstance().GetTeacherAdminNumber(schoolId); string numstr = "0000000" + (jsnum + 1).ToString(); numstr = schoolidnum + numstr.Substring(numstr.Length - 7, 7); model.DepartmentId = 0; model.Path = "/" + tmodel.DepartmentId + "/"; model.Name = numstr; model.Addtime = DateTime.Now; Exam.BLL.tb_UserBLL.GetInstance().Insert(model); } } } MessageBox.ShowMsg(this, "保存成功!"); } } } } catch (Exception ex) { Jnwf.Utils.Log.Logger.Log4Net.Error("importname,ex:" + ex.Message + "|" + ex.StackTrace); } }
//添加代理商 public void addagent(string name, string pwd, string realname, int sex, int role, int status, string position, string email, string phone, string ontice, int userid) { int schoolid = int.Parse(Jnwf.Utils.Config.ConfigurationUtil.GetAppSettingValue("agentid")); int departmentId = 0; UserIdentity identity = User.Identity as UserIdentity; if (identity != null) { //添加 if (userid == 0) { Exam.Entity.tb_DepartmentEntity department = null; if (departmentId > 0) { department = Exam.BLL.tb_DepartmentBLL.GetInstance().GetAdminSingle(departmentId); } else { department = Exam.BLL.tb_DepartmentBLL.GetInstance().Get_DepartmentEntityBySchoold(identity.SchoolID); } Exam.Entity.tb_UserEntity model = new Exam.Entity.tb_UserEntity(); model.SchoolId = schoolid; model.DepartmentId = departmentId; if (department != null) { if (department.RoleId == 1) { model.Path = "/" + department.DepartmentId + "/"; } else if (department.RoleId == 2) { model.Path = "/" + department.ParentId + "/" + department.DepartmentId + "/"; } else { Exam.Entity.tb_DepartmentEntity tempdepartment = Exam.BLL.tb_DepartmentBLL.GetInstance().GetAdminSingle(department.ParentId); if (tempdepartment != null) { model.Path = "/" + tempdepartment.ParentId + "/" + department.ParentId + "/" + department.DepartmentId + "/"; } else { model.Path = ""; } } } else { model.Path = ""; } model.Name = name; model.Pwd = pwd; model.RealName = realname; model.Sex = sex; model.Position = position; model.Mail = email; model.Phone = phone; if (!ontice.Equals("0")) { model.Description = ontice; } model.Status = status; model.Addtime = DateTime.Now; model.RoleId = role; Exam.BLL.tb_UserBLL.GetInstance().Insert(model); MessageBox.ShowAndRedirect(this, "添加成功!", "listagent.aspx"); Response.Write("1"); } else { Exam.Entity.tb_UserEntity model = Exam.BLL.tb_UserBLL.GetInstance().GetAdminSingle(userid); if (model != null) { if (!pwd.Equals("0")) { model.Pwd = pwd; } model.RealName = realname; model.Sex = sex; model.RoleId = role; model.Status = status; model.Position = position; model.Mail = email; model.Phone = phone; model.Description = ontice; Exam.BLL.tb_UserBLL.GetInstance().Update(model); Response.Write("2"); } } } }