Пример #1
0
    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");
        }
    }
Пример #2
0
 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);
                 //Agents.Model.wx_UsersEntity model = Agents.BLL.wx_UsersBLL.GetInstance().GetAdminSingle(UserId);
                 if (model.Status == 0)
                 {
                     Response.Write("用户" + UserId + "已拒绝");
                 }
             }
             else
             {
                 Response.Write("UserId为null");
             }
         }
         catch (Exception ex)
         {
             Response.Write(ex.Message);
         }
     }
 }
Пример #3
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            UserIdentity identity = this.Page.User.Identity as UserIdentity;
            if (identity != null)
            {
                Exam.Entity.tb_UserEntity list = Exam.BLL.tb_UserBLL.GetInstance().GetModelByNameSchoolId(identity.Name, identity._schoolID);
                if (list != null)
                {
                    pass = list.Pwd;

                    if (pass != this.txtpass.Text.Trim())
                    {
                        MessageBox.ShowMsg(this, "原始密码不正确!");
                        return;
                    }
                    string newpass = "";
                    newpass = this.txtnewpass.Text.Trim();
                    if (newpass == "")
                    {
                        MessageBox.ShowMsg(this, "新密码不能为空!");
                        return;
                    }
                    if (txtpasswordSafe.Text.Trim() != newpass)
                    {
                        MessageBox.ShowMsg(this, "两次密码不同!");
                        return;
                    }
                    int           userid = list.UserId;
                    tb_UserEntity model  = tb_UserBLL.GetInstance().GetAdminSingle(userid);
                    if (model != null)
                    {
                        model.Pwd     = newpass;
                        model.Addtime = DateTime.Now;
                        tb_UserBLL.GetInstance().Update(model);
                        MessageBox.ShowAndRedirect(this, "修改成功!", "Center.aspx");
                    }
                    else
                    {
                        MessageBox.ShowAndRedirect(this, "修改失败!", "Center.aspx");
                    }
                }
            }
        }
        catch (Exception ex)
        {
            throw;
        }
    }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         user = idName + iddomain;
         Exam.Entity.tb_UserEntity list = Exam.BLL.tb_UserBLL.GetInstance().GetModelByNameSchoolId(idName, schoolId);
         if (list != null)
         {
             name        = list.RealName;
             position    = list.Position;
             sex         = list.Sex == 0 ? "女" : "男";
             phone       = list.Phone;
             mail        = list.Mail;
             description = list.Description;
         }
     }
 }
Пример #5
0
 public void DeleteUser(int userid)
 {
     try
     {
         Exam.Entity.tb_UserEntity model = Exam.BLL.tb_UserBLL.GetInstance().GetAdminSingle(userid);
         if (model != null)
         {
             model.Status = 0;
             Exam.BLL.tb_UserBLL.GetInstance().Update(model);
         }
     }
     catch (Exception ex)
     {
         Jnwf.Utils.Log.Logger.Log4Net.Error("data.aspx.cs,DeleteUser,ex:" + ex.Message + "|" + ex.StackTrace);
         Response.Write("error");
     }
 }
Пример #6
0
 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);
         }
     }
 }
Пример #7
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)
        {
        }
    }
Пример #8
0
    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);
        }
    }
Пример #9
0
    //添加代理商
    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");
                }
            }
        }
    }