Esempio n. 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if(t==null) t = Teacher.GetTeacherByID(UserID,out dc);
     if (!IsPostBack)
     {
        
         SetTheProfile();
     }
 }
Esempio n. 2
0
 public static bool InsertTeacher(TeacherInfo teacher)
 {
     ExamDbDataContext dc = DataAccess.CreateDBContext();
     if(dc.TeacherInfo.Any(p=>p.LoginName==teacher.LoginName))return false;
     dc.TeacherInfo.InsertOnSubmit(teacher);
     dc.SubmitChanges();
     return true;       
    
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         t = Teacher.GetTeacherByID(UserID);
        //Response.Write("userid=" + UserID);
         ShowProfile();
        
     }
 }
        private void GetInfoByControls(TeacherInfo t)
        {
            t.LoginName = txtLoginName.Text;
            t.TeacherName = txtRealName.Text;

            if (string.IsNullOrEmpty(txtPassword.Text) == false)
            {
                string pwdEncode = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "SHA1");

                t.Password = pwdEncode;
            }
            // t.Major = txtMajor.Text;
            t.Sex = bool.Parse(ddlSex.SelectedValue);
            if (ddlMajors.SelectedValue != "0")
                t.MajorID = int.Parse(ddlMajors.SelectedValue);
            t.IsMajorManager = chkManager.Checked;
            //t.ProfessionalTitle = txtProfessionTitle.Text;
            //t.Position = txtPosition.Text;
            //t.OfficePhoneNum = txtOfficePhone.Text;
            //t.Email = txtEmail.Text;
            //t.MotherSchool = txtGraduatefrom.Text;
            //t.EduLeve = txtDegree.Text;
            //t.CellPhoneNum = txtCellNum.Text;
            //t.ResearchField = txtResearchField.Text;
            //t.QQNum = txtQQ.Text;
            //t.IsInSchool = chkInSchool.Checked;
            //t.PersonalDesc = txtProfileDesc.Text;
            //t.IsFullProfile = true;
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (btnSubmit.Text == "添加")
            {
                //这里插入新教师 
                TeacherInfo newTeacher = new TeacherInfo();

                GetInfoByControls(newTeacher);
                if (Session["IsSuperAdmin"] != null)
                {
                    int deptID = int.Parse(ddlSelectDepts.SelectedValue);
                    if (deptID == 0)
                    {
                        lblError.Text = "请选择系别!";
                        lblError.Visible = true;
                        return;
                    }
                    else newTeacher.DepartmentID = deptID;
                }
                else newTeacher.DepartmentID = DeptID;


                if (Teacher.InsertTeacher(newTeacher) == true)
                    this.ClientScript.RegisterStartupScript(this.GetType(), "Hint", "<script>alert('成功添加教师信息')</script>");
                else
                    this.ClientScript.RegisterStartupScript(this.GetType(), "Hint", "<script>alert('登陆名已经存在,请换一个名称')</script>");
            }
            else
            {
                int tID = 0;
                if (Session["teacherId"] != null)
                {
                    tID = int.Parse(Session["teacherId"].ToString());
                }
                //不能获取教师id
                else
                {
                    return;
                }

                ExamDbDataContext dc;
                TeacherInfo t = Teacher.GetTeacherByID(tID, out dc);

                if (t == null)
                {
                    Response.Write("updating fail,t is null");
                    return;
                }
                GetInfoByControls(t);
                Teacher.UpdateTeacher(t, dc);

                this.ClientScript.RegisterStartupScript(this.GetType(), "Hint", "<script>alert('成功修改教师信息')</script>");
                Session["teacherId"] = null;
            }
            BindGrid();
            GridView1.Visible = true;
            panelModify.Visible = false;

        }
Esempio n. 6
0
 /// <summary>
 /// 更新教师实体信息
 /// </summary>
 /// <param name="s">需要更新的教师实体</param>
 public static void UpdateTeacher(TeacherInfo t,  ExamDbDataContext dc)
 {
    AttachInfo<TeacherInfo>(dc.TeacherInfo, t);
     dc.SubmitChanges();
 }
Esempio n. 7
0
 /// <summary>
 /// 更新教师实体信息
 /// </summary>
 /// <param name="s">需要更新的教师实体</param>
 public static void UpdateTeacher(TeacherInfo t)
 {
     ExamDbDataContext dc = DataAccess.CreateDBContext();
     AttachInfo<TeacherInfo>(dc.TeacherInfo, t);
     dc.SubmitChanges();            
 }
Esempio n. 8
0
        /// <summary>
        /// 将excel文件中的数据转换成教师实体集合
        /// </summary>
        /// <param name="filePath">excel文件的物理路径</param>
        /// <returns></returns>
        private static IList<TeacherInfo> ChangeExcelToTeachers(string filePath)
        {

            IList<TeacherInfo> teachers = new List<TeacherInfo>();
            string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";
            if (filePath.EndsWith("xlsx")) strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\"";

            string deptName = "";
            OleDbConnection myConn = new OleDbConnection(strConn);
            string strCom = " SELECT * FROM [Sheet1$]";
            OleDbCommand cmd = new OleDbCommand(strCom, myConn);
            myConn.Open();
            OleDbDataReader dr = cmd.ExecuteReader();
            string defaultPwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("123456", "SHA1");
            try
            {

                while (dr.Read())
                {
                    if (dr["姓名"] == null || dr["职称"] == null || dr["系别"] == null)
                        continue;
                    TeacherInfo t = new TeacherInfo();
                    t.TeacherName = dr["姓名"].ToString();

                    t.LoginName = dr["教工号"].ToString();

                    t.Password = defaultPwd;

                    t.ProfessionalTitle = dr["职称"].ToString();
                    //t.Position = dr["职务"].ToString();

                    deptName = dr["系别"].ToString();

                    t.DepartmentID = ReturnID(deptDic, deptName);

                    if (t.DepartmentID == 0)
                        throw new Exception("系别名称中有错,请按照提示填写!");

                    //else
                    //    t.DepartmentID = 10002;

                    if (dr["性别"].ToString().Equals("男"))
                        t.Sex = false;
                    else t.Sex = true;
                  
                    //t.MotherSchool = dr["毕业院校"].ToString();
                    //t.Major = dr["专业"].ToString();
                    t.ResearchField = dr["研究领域"].ToString();
      
                    t.TeacherNum = dr["教工号"].ToString();

                    teachers.Add(t);
                    //    HttpContext.Current.Response.Write("一条记录<br>");

                }
            }
            catch (Exception e)
            {
                HttpContext.Current.Response.Write("错误信息:" + e.Message);
                teachers = null;
            }
            finally
            {
                dr.Close();
                myConn.Close();

            }
            return teachers;
        }
Esempio n. 9
0
		private void detach_TeacherInfo(TeacherInfo entity)
		{
			this.SendPropertyChanging();
			entity.MajorInfo = null;
		}
Esempio n. 10
0
		private void attach_TeacherInfo(TeacherInfo entity)
		{
			this.SendPropertyChanging();
			entity.MajorInfo = this;
		}