public List <T_Base_Student> GetStuListByView(string where, int startIndex, int endIndex) { DataSet ds = GetListByPageByView(where, "id", startIndex, endIndex); List <T_Base_Student> lst = new List <T_Base_Student>(); foreach (DataRow dr in ds.Tables[0].Rows) { //lst.Add(DataRowToModel(dr)); T_Base_Student student = new T_Base_Student(); student = GetModel((int)dr["Id"]); T_Base_Class cla = new T_Base_Class(); cla.Name = Convert.ToString(dr["className"]); student.Class = cla; lst.Add(student); } return(lst); }
public ActionResult StudentEdit(int id) { //if (!User.Identity.IsAuthenticated) //{ // return Redirect("/Login/Login/Index"); //} DALT_Base_Student db = new DALT_Base_Student(); T_Base_Student student = db.GetStudent(id); ViewBag.item = student; if (student == null) { return(Content("资料不存在!")); } return(View()); }
public List <T_Base_Student> GetStudentList(int pageSize, int pageIndex, string where) { SqlConnection co = new SqlConnection(); co.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["dataConnection"]; co.Open(); SqlCommand cm = new SqlCommand(); cm.Connection = co; cm.CommandText = "select top " + pageSize + " * from V_Class_Student where " + where + " and id not in(select top " + (pageIndex - 1) * pageSize + " id from V_Class_Student where " + where + ")"; SqlDataReader dr = cm.ExecuteReader(); List <T_Base_Student> lst = new List <T_Base_Student>(); while (dr.Read()) { #region 模式转换 T_Base_Student student = new T_Base_Student(); T_Base_Class cla = new T_Base_Class(); student.Id = Convert.ToInt32(dr["Id"]); student.StuId = Convert.ToString(dr["StuId"]); student.Name = Convert.ToString(dr["Name"]); student.Sex = Convert.ToInt32(dr["Sex"]); student.PassWord = Convert.ToString(dr["PassWord"]); student.Phone = Convert.ToString(dr["Phone"]); student.IsBGB = Convert.ToInt32(dr["IsBGB"]); student.IsKDB = Convert.ToInt32(dr["IsKDB"]); student.ClassId = Convert.ToInt32(dr["ClassId"]); cla.Name = Convert.ToString(dr["className"]); student.Class = cla; #endregion lst.Add(student); } co.Close(); dr.Close(); return(lst); }
public void AddSave(T_Base_Student student) { DALT_Base_Student dal = new DALT_Base_Student(); string pwd = MD5Class.UserMd5(student.StuId); student.ClassId = Convert.ToInt32(Request.Form["Class.Id"]); student.PassWord = pwd; int res = dal.Add(student); if (res != 0) { string tmp = "{\"statusCode\":\"200\",\"message\":\"插入成功\",\"navTabId\":\"StudentList\",\"rel\":\"StudentList\",\"callbackType\":\"closeCurrent\",\"forwardUrl\":\"\"}"; Response.Write(tmp); } else { string tmp = "{\"statusCode\":\"300\",\"message\":\"插入失败\",\"navTabId\":\"StudentList\",\"rel\":\"StudentList\",\"callbackType\":\"closeCurrent\",\"forwardUrl\":\"\"}"; Response.Write(tmp); } }
public void Reset(int id) { DALT_Base_Student db = new DALT_Base_Student(); T_Base_Student student = db.GetStudent(id); string pwd = MD5Class.UserMd5(student.StuId); student.PassWord = pwd; bool res = db.Update(student); if (res) { string tmp = "{\"statusCode\":\"200\",\"message\":\"重置密码成功\",\"navTabId\":\"StudentList\",\"rel\":\"StudentList\",\"callbackType\":\"\",\"forwardUrl\":\"\"}"; Response.Write(tmp); } else { string tmp = "{\"statusCode\":\"300\",\"message\":\"重置密码失败\",\"navTabId\":\"StudentList\",\"rel\":\"StudentList\",\"callbackType\":\"\",\"forwardUrl\":\"\"}"; Response.Write(tmp); } }
public T_Base_Student GetStudent(int Id) { SqlConnection co = new SqlConnection(); co.ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["dataConnection"]; co.Open(); SqlCommand cm = new SqlCommand(); cm.CommandText = "select * from V_Class_Student where Id=@Id"; cm.Parameters.AddWithValue("@Id", Id); cm.Connection = co; SqlDataReader dr = cm.ExecuteReader(); T_Base_Student student = null; T_Base_Class cla = null; while (dr.Read()) { #region 模式转换 student = new T_Base_Student(); cla = new T_Base_Class(); cla.Name = Convert.ToString(dr["className"]); student.Id = Convert.ToInt32(dr["Id"]); student.StuId = Convert.ToString(dr["StuId"]); student.Name = Convert.ToString(dr["Name"]); student.Sex = Convert.ToInt32(dr["Sex"]); student.PassWord = Convert.ToString(dr["PassWord"]); student.Phone = Convert.ToString(dr["Phone"]); student.IsBGB = Convert.ToInt32(dr["IsBGB"]); student.IsKDB = Convert.ToInt32(dr["IsKDB"]); student.ClassId = Convert.ToInt32(dr["ClassId"]); student.Class = cla; #endregion } dr.Close(); co.Close(); return(student); }
public void EditSave(T_Base_Student student) { DALT_Base_Student db = new DALT_Base_Student(); T_Base_Student student2 = db.GetStudent(student.Id); student.PassWord = student2.PassWord; student.ClassId = Convert.ToInt32(Request.Form["Class.Id"]); bool res = db.Update(student); if (res) { string tmp = "{\"statusCode\":\"200\",\"message\":\"修改成功\",\"navTabId\":\"StudentList\",\"rel\":\"StudentList\",\"callbackType\":\"closeCurrent\",\"forwardUrl\":\"\"}"; Response.Write(tmp); } else { string tmp = "{\"statusCode\":\"300\",\"message\":\"修改失败\",\"navTabId\":\"StudentList\",\"rel\":\"StudentList\",\"callbackType\":\"closeCurrent\",\"forwardUrl\":\"\"}"; Response.Write(tmp); } }