/// <summary> /// 得到教师实体对象,除密码 /// </summary> /// <param name="TeaAccount">教师账号</param> /// <returns>教师实体</returns> public Teacher getModel(String TeaAccount) { DataSet ds = dao.GetTeacher(TeaAccount); Teacher teacher = new Teacher(); College college = new College(); RSACryptoService rsa = new RSACryptoService(); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["teaAccount"].ToString() != "") { teacher.TeaAccount = ds.Tables[0].Rows[0]["teaAccount"].ToString(); } //if (ds.Tables[0].Rows[0]["teaPwd"].ToString() != "") //{ // teacher.TeaPwd = ds.Tables[0].Rows[0]["teaPwd"].ToString(); //} if (ds.Tables[0].Rows[0]["teaName"].ToString() != "") { teacher.TeaName = ds.Tables[0].Rows[0]["teaName"].ToString(); } if (ds.Tables[0].Rows[0]["sex"].ToString() != "") { teacher.Sex = ds.Tables[0].Rows[0]["sex"].ToString(); } if (ds.Tables[0].Rows[0]["phone"].ToString() != "") { teacher.Phone = ds.Tables[0].Rows[0]["phone"].ToString(); } if (ds.Tables[0].Rows[0]["Email"].ToString() != "") { teacher.Email = ds.Tables[0].Rows[0]["Email"].ToString(); } if (ds.Tables[0].Rows[0]["teaType"].ToString() != "") { teacher.TeaType = int.Parse(ds.Tables[0].Rows[0]["teaType"].ToString()); } if (ds.Tables[0].Rows[0]["collegeId"].ToString() != "") { college.ColID = int.Parse(ds.Tables[0].Rows[0]["collegeId"].ToString()); } if (ds.Tables[0].Rows[0]["collegeName"].ToString() != "") { college.ColName = ds.Tables[0].Rows[0]["collegeName"].ToString(); } if (college != null) { teacher.college = college; } } else { } return(teacher); }
//教师信息去重 private static DataTable DeduplicationByTea(DataTable dt1, int collegeId) { RSACryptoService rSA = new RSACryptoService(); string pwd = "000000"; DataColumn dcPwd = new DataColumn("teaPwd", typeof(string)); dcPwd.DefaultValue = rSA.Encrypt(pwd); dt1.Columns.Add(dcPwd); DataColumn dcCol = new DataColumn("collegeId", typeof(int)); dcCol.DefaultValue = collegeId; dt1.Columns.Add(dcCol); DataColumn dcteaType = new DataColumn("teaType", typeof(int)); dcteaType.DefaultValue = 1; dt1.Columns.Add(dcteaType); DataTable deDuplication = new DataTable(); deDuplication.Columns.Add("teaAccount", typeof(string)); deDuplication.Columns.Add("teaPwd", typeof(string)); deDuplication.Columns.Add("teaName", typeof(string)); deDuplication.Columns.Add("sex", typeof(string)); deDuplication.Columns.Add("phone", typeof(string)); deDuplication.Columns.Add("Email", typeof(string)); deDuplication.Columns.Add("collegeId", typeof(int)); deDuplication.Columns.Add("teaType", typeof(int)); TeacherBll teacherBll = new TeacherBll(); DataTable dt2 = teacherBll.SelectTeaAcount().Tables[0]; if (dt1 != null) { DataRowCollection count = dt1.Rows; foreach (DataRow row in count)//遍历excel数据集 { try { string teaAccount = row[0].ToString(); DataRow[] rows = dt2.Select(string.Format("teaAccount='{0}'", teaAccount)); if (rows.Length == 0)//判断如果DataRow.Length为0,即该行excel数据不存在于表A中,就插入到dt3 { deDuplication.Rows.Add(row[0], row[5], row[1], row[2], row[3], row[4], row[6], row[7]); } } catch (Exception ex) { throw ex; } } } return(deDuplication); }
/// <summary> /// 登录操作 /// </summary> /// <param name="stuAccount"></param> /// <param name="pwd"></param> /// <returns></returns> public Student Login(string stuAccount, string pwd) { DataSet dds = dao.Select(stuAccount); //string stuPwd = ds.Tables[0].Rows[0]["stuPwd"].ToString(); if (dds != null && dds.Tables[0].Rows.Count == 1) { DataRow row = dds.Tables[0].Rows[0]; RSACryptoService rsa = new RSACryptoService(); if (row["stuAccount"].ToString() == stuAccount && rsa.Decrypt(row["stuPwd"].ToString()) == pwd) { Student student = new Student(); Profession profession = new Profession(); College college = new College(); DataSet ds = dao.GetStudent(stuAccount); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["stuAccount"].ToString() != "") { student.StuAccount = ds.Tables[0].Rows[0]["stuAccount"].ToString(); } if (ds.Tables[0].Rows[0]["stuPwd"].ToString() != "") { student.StuPwd = rsa.Decrypt(ds.Tables[0].Rows[0]["stuPwd"].ToString()); } if (ds.Tables[0].Rows[0]["realName"].ToString() != "") { student.RealName = ds.Tables[0].Rows[0]["realName"].ToString(); } if (ds.Tables[0].Rows[0]["sex"].ToString() != "") { student.Sex = ds.Tables[0].Rows[0]["sex"].ToString(); } if (ds.Tables[0].Rows[0]["phone"].ToString() != "") { student.Phone = ds.Tables[0].Rows[0]["phone"].ToString(); } if (ds.Tables[0].Rows[0]["Email"].ToString() != "") { student.Email = ds.Tables[0].Rows[0]["Email"].ToString(); } if (ds.Tables[0].Rows[0]["proId"].ToString() != "") { profession.ProId = int.Parse(ds.Tables[0].Rows[0]["proId"].ToString()); } if (ds.Tables[0].Rows[0]["proName"].ToString() != "") { profession.ProName = ds.Tables[0].Rows[0]["proName"].ToString(); } if (ds.Tables[0].Rows[0]["collegeId"].ToString() != "") { college.ColID = int.Parse(ds.Tables[0].Rows[0]["collegeId"].ToString()); } if (ds.Tables[0].Rows[0]["collegeName"].ToString() != "") { college.ColName = ds.Tables[0].Rows[0]["collegeName"].ToString(); } if (profession != null) { student.profession = profession; } if (college != null) { student.college = college; } } //填充属性 return(student); } } return(null); }
/// <summary> /// 教师登录 /// </summary> /// <param name="teaAccount"></param> /// <param name="pwd"></param> /// <returns></returns> public Teacher Login(string teaAccount, string pwd) { DataSet dataSet = dao.Select(teaAccount); if (dataSet != null && dataSet.Tables[0].Rows.Count == 1) { DataRow row = dataSet.Tables[0].Rows[0]; DataSet ds = dao.GetTeacher(row["teaAccount"].ToString()); RSACryptoService rsa = new RSACryptoService(); if (row["teaAccount"].ToString() == teaAccount && rsa.Decrypt(row["teaPwd"].ToString()) == pwd) { Teacher teacher = new Teacher(); College college = new College(); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["teaAccount"].ToString() != "") { teacher.TeaAccount = ds.Tables[0].Rows[0]["teaAccount"].ToString(); } if (ds.Tables[0].Rows[0]["teaPwd"].ToString() != "") { teacher.TeaPwd = rsa.Decrypt(ds.Tables[0].Rows[0]["teaPwd"].ToString()); } if (ds.Tables[0].Rows[0]["teaName"].ToString() != "") { teacher.TeaName = ds.Tables[0].Rows[0]["teaName"].ToString(); } if (ds.Tables[0].Rows[0]["sex"].ToString() != "") { teacher.Sex = ds.Tables[0].Rows[0]["sex"].ToString(); } if (ds.Tables[0].Rows[0]["phone"].ToString() != "") { teacher.Phone = ds.Tables[0].Rows[0]["phone"].ToString(); } if (ds.Tables[0].Rows[0]["Email"].ToString() != "") { teacher.Email = ds.Tables[0].Rows[0]["Email"].ToString(); } if (ds.Tables[0].Rows[0]["teaType"].ToString() != "") { teacher.TeaType = int.Parse(ds.Tables[0].Rows[0]["teaType"].ToString()); } if (ds.Tables[0].Rows[0]["collegeId"].ToString() != "") { college.ColID = int.Parse(ds.Tables[0].Rows[0]["collegeId"].ToString()); } if (ds.Tables[0].Rows[0]["collegeName"].ToString() != "") { college.ColName = ds.Tables[0].Rows[0]["collegeName"].ToString(); } if (college != null) { teacher.college = college; } } else { } return(teacher); } } return(null); }
/// <summary> /// 得到学生实体对象 /// </summary> /// <param name="TeaAccount">学生账号</param> /// <returns>学生实体</returns> public Student GetModel(String stuAccount) { Student student = new Student(); Profession profession = new Profession(); College college = new College(); DataSet ds = dao.GetStudent(stuAccount); RSACryptoService rsa = new RSACryptoService(); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["stuAccount"].ToString() != "") { student.StuAccount = ds.Tables[0].Rows[0]["stuAccount"].ToString(); } if (ds.Tables[0].Rows[0]["stuPwd"].ToString() != "") { student.StuPwd = rsa.Decrypt(ds.Tables[0].Rows[0]["stuPwd"].ToString()); } if (ds.Tables[0].Rows[0]["realName"].ToString() != "") { student.RealName = ds.Tables[0].Rows[0]["realName"].ToString(); } if (ds.Tables[0].Rows[0]["sex"].ToString() != "") { student.Sex = ds.Tables[0].Rows[0]["sex"].ToString(); } if (ds.Tables[0].Rows[0]["phone"].ToString() != "") { student.Phone = ds.Tables[0].Rows[0]["phone"].ToString(); } if (ds.Tables[0].Rows[0]["Email"].ToString() != "") { student.Email = ds.Tables[0].Rows[0]["Email"].ToString(); } if (ds.Tables[0].Rows[0]["proId"].ToString() != "") { profession.ProId = int.Parse(ds.Tables[0].Rows[0]["proId"].ToString()); } if (ds.Tables[0].Rows[0]["proName"].ToString() != "") { profession.ProName = ds.Tables[0].Rows[0]["proName"].ToString(); } if (ds.Tables[0].Rows[0]["collegeId"].ToString() != "") { college.ColID = int.Parse(ds.Tables[0].Rows[0]["collegeId"].ToString()); } if (ds.Tables[0].Rows[0]["collegeName"].ToString() != "") { college.ColName = ds.Tables[0].Rows[0]["collegeName"].ToString(); } if (profession != null) { student.profession = profession; } if (college != null) { student.college = college; } } return(student); }