Exemplo n.º 1
0
    /// <summary>
    /// 新增和修改教师信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ButtonOK_Click(object sender, EventArgs e)
    {
        TbTeacher teacher = new TbTeacher();
        TbUser    user    = new TbUser();

        user.Zt        = int.Parse(userrole.SelectedValue);
        user.Xh        = "";
        teacher.LsName = teachername.Text.Trim();
        user.YhName    = teacheruser.Text.Trim();                                                                            //用户名(账号)
        user.YhPwd     = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(teacherpwd.Text, "MD5"); //密码
        teacher.ZyID   = int.Parse(this.teacherzy.SelectedValue);                                                            //专业
        teacher.Remark = textRemark.Text.Trim();
        if (this.hidTeacherID.Value != "")                                                                                   /*用户编号不为空,即为修改时*/
        {
            teacher.YhID = int.Parse(this.hidTeacherID.Value);
            user.YhID    = teacher.YhID;
            TbUserManager.UpdateUserRoleByYhID(user);
            TbTeacherManager.UpdateTeacherInfoByYhID(teacher);
            this.hidTeacherID.Value = "";
        }
        else
        {
            int yhid = TbUserManager.InsertTeacherUser(user.YhName, user.Xh, user.YhPwd, user.Zt);/*新增教师用户信息,返回其用户编号*/
            if (yhid > 0)
            {
                int Result = TbTeacherManager.InsertTeacherInfo(yhid, teacher.LsName, teacher.ZyID, teacher.Remark);
            }
        }
        teacherzy.Items.Clear();
        GetSpeciality();
        GetPageInfo();
        teachername.Text = "";
        teacherpwd.Text  = "";
        teacheruser.Text = "";
    }
Exemplo n.º 2
0
        /// <summary>
        /// 修改教师信息
        /// </summary>
        /// <param name="teacher">修改后的教师信息</param>
        /// <returns></returns>
        public int UpdateTeacherInfoByYhID(TbTeacher teacher)
        {
            string sql = "update tbTeacher set LsName=@name,ZyID=@zyid,Remark=@remark where YhID=@Yhid";

            SqlParameter[] paras = new SqlParameter[]
            {
                new SqlParameter("@name", teacher.LsName),
                new SqlParameter("@zyid", teacher.ZyID),
                new SqlParameter("@remark", teacher.Remark),
                new SqlParameter("@Yhid", teacher.YhID)
            };
            return(DBHelper.ExecuteCommand(sql, paras));
        }
Exemplo n.º 3
0
    /// <summary>
    /// 根据教师编号LsID查询对应的详细信息
    /// </summary>
    /// <param name="LsID"></param>
    private void GetTeacher(int YhID)
    {
        TbTeacher teacher = TbTeacherManager.GetTeacherInfoByLsID(YhID);
        TbUser    user    = TbUserManager.GetUserInfoByYhID(YhID);
        string    role    = "";

        if (user.Zt == 1)
        {
            role = "管理员";
        }
        else
        {
            role = "教师";
        }
        TbSpeciality speciality = TbSpecialityManager.GetSpecialByID(teacher.ZyID);
        string       message    = teacher.YhID + "|" + teacher.LsName + "|" + user.YhName + "|" + user.YhPwd + "|" + role + "|" + speciality.ZyName + "|" + teacher.Remark;

        Response.Write(message);
    }
Exemplo n.º 4
0
        /// <summary>
        /// 根据教师的用户编号获取教师的详细信息
        /// </summary>
        /// <param name="YhID">用户编号</param>
        /// <returns></returns>
        public TbTeacher GetTeacherInfoByLsID(int Yhid)
        {
            TbTeacher teacher = null;
            string    sql     = "select * from tbTeacher where YhID=@Yhid";

            SqlParameter[] paras  = new SqlParameter[] { new SqlParameter("@YhId", Yhid) };
            SqlDataReader  reader = DBHelper.GetReader(sql, paras);

            if (reader.Read())
            {
                teacher        = new TbTeacher();
                teacher.YhID   = Yhid;
                teacher.LsID   = int.Parse(reader["LsID"].ToString());
                teacher.LsName = reader["LsName"].ToString();
                teacher.ZyID   = int.Parse(reader["ZyID"].ToString());
                teacher.Remark = reader["Remark"].ToString();
                reader.Close();
            }
            return(teacher);
        }
Exemplo n.º 5
0
 /// <summary>
 /// 修改教师信息
 /// </summary>
 /// <param name="teacher">修改后的教师信息</param>
 /// <returns></returns>
 public static int UpdateTeacherInfoByYhID(TbTeacher teacher)
 {
     return(tbteacherservice.UpdateTeacherInfoByYhID(teacher));
 }