public ResponseMessage <object> TeacherTestTrans_D() { dynamic result; var teacher = new T_Teacher() { F_TeacherName = $"Test_{ (DateTime.Now.Ticks - 621356256000000000) / 10000}" }; var bl = _SqlDB.ExecuteWithTransaction((conn, trans) => { var r = conn.Execute($"INSERT INTO T_Teacher (F_TeacherName) VALUES(@F_TeacherName);", teacher, trans, null, null); r += conn.Execute("delete from T_Teacher where f_id=@id", new { id = 1 }, trans, null, null); return(r); }); if (bl) { result = CreateResult.For(); } else { result = CreateResult.For("00001", "新增出现错误"); } return(result); }
public ResponseMessage <object> InsertTeacher_D() { dynamic result; var teacher = new T_Teacher() { F_TeacherName = $"Test_{ (DateTime.Now.Ticks - 621356256000000000) / 10000}" }; var n = _SqlDB.Excute($"INSERT INTO T_Teacher (F_TeacherName) VALUES(@F_TeacherName)", teacher); if (n > 0) { result = CreateResult.For(); } else { result = CreateResult.For("00001", "新增出现错误"); } return(result); }
public void setBatch() { string teacherid = ""; try { if (Session["RoleID"].ToString() == "3")//辅导员 { teacherid = Session["UserID"].ToString(); T_Teacher teacher = db.T_Teacher.Find(teacherid); string teacher_name = teacher.Name.ToString(); string teacher_grade = teacher.Grade.ToString() + "级"; ViewBag.lblTName = teacher_name.ToString(); ViewBag.lblTGrade = teacher_grade.ToString(); } else if (Session["RoleID"].ToString() == "1")//学生 { string ST_Num = Session["UserID"].ToString(); var student = from vw_Student in db.vw_Student where vw_Student.ST_Num == ST_Num select vw_Student; teacherid = student.ToList().First().ST_TeacherID.ToString(); T_Teacher teacher = db.T_Teacher.Find(teacherid); string teacher_name = teacher.Name.ToString(); string teacher_grade = teacher.Grade.ToString() + "级"; ViewBag.lblTName = teacher_name.ToString(); ViewBag.lblTGrade = teacher_grade.ToString(); } } catch { ViewBag.lblTName = "未设定"; ViewBag.lblTGrade = "未设定"; } if (teacherid != "") { ViewBag.IsTeacherIDExist = "1"; try { for (int i = 1; i <= 3; i++) { var classes = from c in db.vw_ClassBatch where c.TeacherID == teacherid && c.Batch == i select c; StringBuilder str_class = new StringBuilder(); string time; if (classes.Count() > 0) { foreach (var item in classes) { str_class.Append(item.ClassName.ToString()); str_class.Append(";"); } time = classes.First().Datetime.ToString(); } else { str_class.Append("无"); time = "无"; } switch (i) { case 1: { ViewBag.lblTimeFirst = time; ViewBag.lblClassFirst = str_class.ToString(); break; } case 2: { ViewBag.lblTimeSecond = time; ViewBag.lblClassSecond = str_class.ToString(); break; } case 3: { ViewBag.lblTimeThird = time; ViewBag.lblClassThird = str_class.ToString(); break; } default: break; } } string deadline_time = "辅导员尚未设定"; //此处TypeID = 2 代表晚点名请假截止时间、TypeID = 1 代表节假日请假截止时间 var deadline = from d in db.T_Deadline where d.TeacherID == teacherid && d.TypeID == 2 select d.Time; if (deadline.Count() > 0) { deadline_time = deadline.First().ToString(); } ViewBag.lblDeadlineNight = deadline_time; } catch { ViewBag.lblTimeFirst = "未设定晚点名批次"; ViewBag.lblClassFirst = "未设定晚点名时间"; ViewBag.lblTimeSecond = "未设定晚点名批次"; ViewBag.lblClassSecond = "未设定晚点名时间"; ViewBag.lblTimeThird = "未设定晚点名批次"; ViewBag.lblClassThird = "未设定晚点名时间"; ViewBag.lblDeadlineNight = "未设定截止时间"; } } else { //学生端口 尚未绑定辅导员 ViewBag.IsTeacherIDExist = "0"; } }
/// <summary> /// 初始化晚点名设置 /// </summary> public void LoadData() { string teacherid = Session["UserID"].ToString(); int batch_num = 0; int i = 0; string[][] selected = new string[3][]; ViewBag.selected_first = ""; ViewBag.selected_second = ""; ViewBag.selected_thrid = ""; ViewBag.tpFirst = ""; ViewBag.tpSecond = ""; ViewBag.tpThird = ""; ViewBag.dpDate = ""; T_Teacher teacher = db.T_Teacher.Find(teacherid); string teacher_name = teacher.Name.ToString(); string teacher_grade = teacher.Grade.ToString() + "级"; ViewBag.lblNameAGrade = "辅导员:" + teacher_name + " " + "年级:" + teacher_grade; var batch = from b in db.T_Batch where b.TeacherID == teacherid orderby b.Batch select new { b.ID, b.Datetime }; if (batch.Count() > 0) { Guid batch_id; string time; ViewBag.dpDate = batch.First().Datetime; foreach (var item in batch) { i = 0; batch_id = item.ID; time = item.Datetime.ToString("yyyy-MM-dd HH:mm").Substring(11, 5); var list = db.T_Class.Where(c => c.Batch == batch_id).Where(b => b.TeacherID == teacherid).Select(b => b.ID); selected[batch_num] = new string[list.Count()]; foreach (var classes in list) { selected[batch_num][i] = classes.ToString(); i++; } switch (batch_num) { case 0: { ViewBag.selected_first = selected[batch_num]; ViewBag.tpFirst = time; break; } case 1: { ViewBag.selected_second = selected[batch_num]; ViewBag.tpSecond = time; break; } case 2: { ViewBag.selected_thrid = selected[batch_num]; ViewBag.tpThird = time; break; } default: break; } batch_num++; } } }
public ActionResult login(string txbAccount, string txbAccountPass) { var user = from T_Account in db.T_Account where (T_Account.ID == txbAccount.ToString().Trim()) && (T_Account.Psd == txbAccountPass.ToString().Trim()) select T_Account; if (user.Any() && user.Count() == 1) { #region 登录成功、将用户信息写入Session //从数据集中提取 Session["UserID"] = user.First().ID; Session["UserPsd"] = user.First().Psd; Session["RoleID"] = user.First().RoleID; //从表单中提取 //Session["UserID"] = tbxUserName.ToString().Trim(); //Session["UserPsd"] = tbxPassword.ToString().Trim(); #endregion #region 检查学生是否完善个人信息、辅导员的信息是否更新 if (Session["RoleID"].ToString() == "1")//学生 { T_Student student = db.T_Student.Find(Session["UserID"].ToString()); if (student.ContactOne == "" || student.ContactOne == null || student.OneTel == "" || student.OneTel == null)//信息不完善 { //FineUI登陆成功提示框、完善个人信息 ShowNotify("成功登陆!请完善个人信息", MessageBoxIcon.Success); return(RedirectToAction("Index", "UserInfo", new { area = "UserInfo" })); //此处需要以Areas的ID作为参数才能实现从Controller到Areas中的Controller的跳转 } else//信息已完善 { //FineUI登陆成功提示框 ShowNotify("成功登录!", MessageBoxIcon.Success); return(RedirectToAction("Index", "Home")); } } else if (Session["RoleID"].ToString() == "3")//辅导员 { string UserID = Session["UserID"].ToString(); var TeacherInfo = from T_Teacher in db.T_Teacher where (T_Teacher.ID == UserID) select T_Teacher; T_Teacher teacher = TeacherInfo.ToList().First(); Session["Grade"] = teacher.Grade; //辅导员登录-更新晚点名时间 if (UpdateTime(Session["UserID"].ToString())) { //更新了时间 return(RedirectToAction("Index", "Home", new { updatetime = "true" })); } else { //未更新时间 return(RedirectToAction("Index", "Home")); } } else if (Session["RoleID"].ToString() == "2") { //FineUI登陆成功提示框 ShowNotify("成功登录!", MessageBoxIcon.Success); return(RedirectToAction("Index", "Home")); } else { //未知错误 return(null); } #endregion } else if (!user.Any()) { //FineUI登录失败提示框 //ShowNotify("用户名或密码错误!", MessageBoxIcon.Error); alertInfo("登录提示", "用户名或密码错误!", "Information"); return(RedirectToAction("Index", "Account")); } else { alertInfo("登录提示", "用户名或密码错误!", "Information"); return(RedirectToAction("Index", "Account")); } }