public void UpdateIDCardPath(string stuid, string side, string path)
        {
            var t = db.Queryable <T_Student>().Where(it => it.Id == stuid).First();

            if (t == null)
            {
                return;
            }
            JObject j;

            if (string.IsNullOrEmpty(t.UploadIDCardPath))
            {
                j = new JObject();
            }
            else
            {
                j = JObject.Parse(t.UploadIDCardPath);
            }
            j[side] = path;
            var data = new T_Student()
            {
                Id = stuid, UploadIDCardPath = JsonConvert.SerializeObject(j)
            };

            db.Updateable(data).UpdateColumns(it => new { it.UploadIDCardPath }).ExecuteCommand();
        }
        public void UpdateHeader(string stuid, string path)
        {
            var data = new T_Student()
            {
                Id = stuid, HeaderUrl = path
            };

            db.Updateable(data).UpdateColumns(it => new { it.HeaderUrl }).ExecuteCommand();
        }
Example #3
0
 public static CompleteInfo_M ToViewModel(T_Student Student)
 {
     return(new CompleteInfo_M()
     {
         StuCellphone = Student.StuCellphone,
         StuEMail = Student.StuEMail,
         StuQQ = Student.StuQQ,
         StuSex = Student.StuSex,
         StuBirthday = Student.StuBirthday,
         StuPhoto = Student.MainPhoto,
         StuResume = Student.StuResume
     });
 }
Example #4
0
        public ActionResult Registration(T_Student model)
        {
            StudentContext eb = new StudentContext();

            if (eb.T_Student.Any(x => x.UserName == model.UserName))
            {
                TempData["Success"] = "UserName Already Available!";
                return(View());
            }
            model.RoleId    = 2;//bydefault selected as student
            model.IsAdmin   = false;
            model.IsTeacher = false;
            eb.T_Student.Add(model);
            eb.SaveChanges();
            TempData["Success"] = "Added Successfully!";
            return(View());
        }
Example #5
0
        public ApiBaseResult ChangeInfo([FromBody] ChangeInfoModel changeInfo)
        {
            ApiBaseResult result;

            if (changeInfo != null)
            {
                if (!changeInfo.CheckInfo())
                {
                    result          = new ApiBaseResult();
                    result.result   = "error";
                    result.messages = "参数格式错误或缺少参数!";
                    return(result);
                }
            }
            else
            {
                result          = new ApiBaseResult();
                result.result   = "error";
                result.messages = "参数格式错误或缺少参数!";
                return(result);
            }

            result = Check(changeInfo.access_token);
            if (result == null)
            {
                result = new ApiBaseResult();

                string    StudentID = changeInfo.access_token.Substring(0, changeInfo.access_token.IndexOf("_"));
                T_Student student   = db.T_Student.Find(StudentID);
                student.Tel        = changeInfo.ST_Tel;
                student.QQ         = changeInfo.ST_QQ;
                student.Email      = changeInfo.ST_Email;
                student.ContactOne = changeInfo.ST_Guardian + "-" + changeInfo.ST_GuardianName;
                student.OneTel     = changeInfo.ST_GuardianTel;
                db.SaveChanges();

                result.result = "success";

                return(result);
            }
            else
            {
                return(result);
            }
        }
Example #6
0
 public ActionResult Login(T_Student student)
 {
     using (StudentContext eb = new StudentContext())
     {
         var stu = eb.T_Student.Where(x => x.UserName == student.UserName && x.Password == student.Password).FirstOrDefault();
         if (stu != null)
         {
             Session["UserName"] = student.UserName.ToString();
             Session["Password"] = student.Password.ToString();
             menus = GetMenusBasedOnUser();
             return(RedirectToAction("LoggedIn"));
         }
         else
         {
             TempData["Success"] = "Login Failed";
             return(RedirectToAction("Login"));
         }
     }
     return(View());
 }
Example #7
0
        private void ucBtnExt2_BtnClick(object sender, EventArgs e)
        {
            //选择一名学生
            FrmSelectStudent selectStu = new FrmSelectStudent();

            Select_Students += selectStu.SelectStudents;
            selectStu.ShowDialog();
            var rows = Select_Students(sender, e);

            //将每行逐条插入
            if (rows.Count == 0)
            {
                return;
            }
            stu = rows[0].DataBoundItem as T_Student;
            if (stu == null)
            {
                return;
            }
            LoadScreenControlData();
        }
Example #8
0
 public ActionResult AddTeacher(T_Student s)
 {
     if (Session["UserName"] == null)
     {
         return(RedirectToAction("Login"));
     }
     if (eb.T_Student.Any(x => x.UserName == s.UserName))
     {
         TempData["Success"] = "User Already Exists!";
     }
     else
     {
         s.IsTeacher = true;
         s.RoleId    = 3;
         eb.T_Student.Add(s);
         eb.SaveChanges();
         TempData["Success"] = "Saved Successfully!";
         ViewBag.Menus       = GetMenusBasedOnUser();
     }
     return(View());
 }
Example #9
0
        /// <summary>
        /// 根据t_sql,进行查询返回查询到的所有数据
        /// </summary>
        /// <param name="t_sql"></param>
        /// <param name="cmdType"></param>
        /// <param name="pars"></param>
        /// <returns></returns>
        public List <T_Student> LoadStudents(string t_sql, CommandType cmdType, params SqlParameter[] pars)
        {
            List <T_Student> stu = null;

            using (SqlDataReader reader = new SqlHelper().ExecuteReader(t_sql, cmdType, pars)) {
                if (reader.HasRows)
                {
                    stu = new List <T_Student>();
                    while (reader.Read())
                    {
                        T_Student temp = new T_Student();
                        temp.StuID        = reader.GetInt32(0);
                        temp.StuName      = reader.GetString(1);
                        temp.StuBirthday  = reader.GetDateTime(2).ToString("yyyy-MM-dd");
                        temp.StuSex_filed = reader.GetBoolean(3);
                        temp.ClassID      = reader.GetInt32(4);
                        stu.Add(temp);
                    }
                }
            }
            return(stu);
        }
Example #10
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="curIndex"></param>
        /// <param name="dataLength"></param>
        /// <param name="classid"></param>
        /// <returns></returns>
        public List <T_Student> LoadStudents(int curIndex, int dataLength, int classid)
        {
            string t_sql = "SelectStudent_Pagiation";

            SqlParameter[] pars = new SqlParameter[] {
                new SqlParameter("@curIndex", System.Data.SqlDbType.Int)
                {
                    Value = curIndex
                },
                new SqlParameter("@pagiation", System.Data.SqlDbType.Int)
                {
                    Value = dataLength
                },
                new SqlParameter("@classid", System.Data.SqlDbType.Int)
                {
                    Value = classid
                },
            };
            SqlHelper        helper = new SqlHelper();
            List <T_Student> stu    = null;

            using (SqlDataReader reader = helper.ExecuteReader(t_sql, System.Data.CommandType.StoredProcedure, pars)) {
                if (reader.HasRows)
                {
                    stu = new List <T_Student>();
                    while (reader.Read())
                    {
                        T_Student temp = new T_Student();
                        temp.StuID        = reader.GetInt32(0);
                        temp.StuName      = reader.GetString(1);
                        temp.StuBirthday  = reader.GetDateTime(2).ToString("yyyy-MM-dd");
                        temp.StuSex_filed = reader.GetBoolean(3);
                        temp.ClassID      = reader.GetInt32(4);
                        stu.Add(temp);
                    }
                }
            }
            return(stu);
        }
        private void FrmStudentManaChildModifyData_Load(object sender, EventArgs e)
        {
            copy             = new T_Student();
            txtBirthDay.Text = t_stu.StuBirthday;
            txtStuID.Text    = t_stu.StuID.ToString();
            txtStuName.Text  = t_stu.StuName;
            txtClassID.Text  = t_stu.ClassID.ToString();

            copy.StuBirthday  = t_stu.StuBirthday;
            copy.StuID        = t_stu.StuID;
            copy.StuName      = t_stu.StuName;
            copy.StuSex_filed = t_stu.StuSex_filed;
            copy.ClassID      = t_stu.ClassID;
            //true:男;false:女
            if (t_stu.StuSex_filed)
            {
                ucRidMan.Checked = true;
            }
            else
            {
                ucRdiWoman.Checked = true;
            }
            txtNameValidate.SetVerificationCustomRegex(txtStuName, @"^[\u4E00-\u9FFF]{2,10}$");
            txtNameValidate.SetVerificationErrorMsg(txtStuName, "非法输入");
            txtNameValidate.SetVerificationRequired(txtStuName, true);
            txtNameValidate.SetVerificationModel(txtStuName, VerificationModel.Custom);

            txtBirthDayValidate.SetVerificationCustomRegex(txtBirthDay, @"^(?!0000)[0-9]{4}-((0{0,1}[1-9]|1[0-2])-(0{0,1}[1-9]|1[0-9]|2[0-8])|(0{0,1}[13-9]|1[0-2])-(29|30)|(0{0,1}[13578]|1[02])-31)$");
            txtBirthDayValidate.SetVerificationErrorMsg(txtBirthDay, "非法输入");
            txtBirthDayValidate.SetVerificationRequired(txtBirthDay, true);
            txtBirthDayValidate.SetVerificationModel(txtBirthDay, VerificationModel.Custom);

            txtClassIDValidate.SetVerificationCustomRegex(txtClassID, @"^\d{4,}$");
            txtClassIDValidate.SetVerificationErrorMsg(txtClassID, "非法输入");
            txtClassIDValidate.SetVerificationRequired(txtClassID, true);
            txtClassIDValidate.SetVerificationModel(txtClassID, VerificationModel.Custom);
        }
 public FrmStudentManaChildModifyData(T_Student stu) : this()
 {
     t_stu = stu;
 }
Example #13
0
        public ActionResult EditUserInfo(string ST_Tel, string ST_QQ, string ST_Email, string ST_ContactName, string ST_ContactRelation, string ST_ContactTel)
        {
            string    ST_Num  = Session["UserID"].ToString();
            T_Student student = db.T_Student.Find(ST_Num);

            if (student.ContactOne == "" || student.ContactOne == null || student.OneTel == "" || student.OneTel == null)
            {
                #region 登陆之后自动跳转,完善个人信息,联系人方式等信息为空
                //缺少验证处理

                if (ST_Tel == "" && ST_QQ == "" && ST_Email == "" && ST_ContactName == "" && ST_ContactRelation == "" && ST_ContactTel == "")
                {
                    LoadData(ST_Num);
                    ShowNotify("未做任何修改!");
                    return(View("Index"));
                }
                if (ST_Tel != "")
                {
                    student.Tel = ST_Tel.ToString();
                }
                if (ST_QQ != "")
                {
                    student.QQ = ST_QQ.ToString();
                }
                if (ST_Email != "")
                {
                    student.Email = ST_Email.ToString();
                }
                if (ST_ContactName != "")
                {
                    //此处需要判断原数据是否为null
                    if (student.ContactOne != null && student.ContactOne.ToString() != "")
                    {
                        student.ContactOne = student.ContactOne.ToString().Substring(0, 3) + ST_ContactName.ToString();
                    }
                    else
                    {
                        student.ContactOne = ST_ContactName.ToString();
                    }
                }
                if (ST_ContactRelation != "")
                {
                    if (ST_ContactRelation != "父亲" && ST_ContactRelation != "母亲" && ST_ContactRelation != "其他")
                    {
                        LoadData(ST_Num);
                        ShowNotify("联系人关系类型为父亲、母亲或其他,请重新填写!");
                        return(View("Index"));
                    }
                    else
                    {
                        //检查是否包含“-”字符
                        if (student.ContactOne.Contains("-"))
                        {
                            //联系人信息已存在
                            student.ContactOne = ST_ContactRelation.ToString() + "-" + student.ContactOne.ToString().Substring(3, student.ContactOne.ToString().Length - 3);
                        }
                        else
                        {
                            //联系人信息不存在
                            student.ContactOne = ST_ContactRelation.ToString() + "-" + student.ContactOne.ToString();
                        }
                    }
                }
                if (ST_ContactTel != "")
                {
                    student.OneTel = ST_ContactTel.ToString();
                }
                db.SaveChanges();
                LoadData(ST_Num);
                ViewBag.Changed = true;
                ShowNotify("修改成功");
                //return View("Index");
                return(RedirectToAction("Index", "Home", new { area = "" }));

                #endregion
            }
            else
            {
                #region 修改个人信息,联系人方式等信息为空
                //缺少验证处理

                if (ST_Tel == "" && ST_QQ == "" && ST_Email == "" && ST_ContactName == "" && ST_ContactRelation == "" && ST_ContactTel == "")
                {
                    LoadData(ST_Num);
                    ShowNotify("未做任何修改!");
                    return(View("Index"));
                }
                if (ST_Tel != "")
                {
                    student.Tel = ST_Tel.ToString();
                }
                if (ST_QQ != "")
                {
                    student.QQ = ST_QQ.ToString();
                }
                if (ST_Email != "")
                {
                    student.Email = ST_Email.ToString();
                }
                if (ST_ContactName != "")
                {
                    //此处需要判断原数据是否为null
                    if (student.ContactOne != null && student.ContactOne.ToString() != "")
                    {
                        student.ContactOne = student.ContactOne.ToString().Substring(0, 3) + ST_ContactName.ToString();
                    }
                    else
                    {
                        student.ContactOne = ST_ContactName.ToString();
                    }
                }
                if (ST_ContactRelation != "")
                {
                    if (ST_ContactRelation != "父亲" && ST_ContactRelation != "母亲" && ST_ContactRelation != "其他")
                    {
                        LoadData(ST_Num);
                        ShowNotify("联系人关系类型为父亲、母亲或其他,请重新填写!");
                        return(View("Index"));
                    }
                    else
                    {
                        //检查是否包含“-”字符
                        if (student.ContactOne.Contains("-"))
                        {
                            //联系人信息已存在
                            student.ContactOne = ST_ContactRelation.ToString() + "-" + student.ContactOne.ToString().Substring(3, student.ContactOne.ToString().Length - 3);
                        }
                        else
                        {
                            //联系人信息不存在
                            student.ContactOne = ST_ContactRelation.ToString() + "-" + student.ContactOne.ToString();
                        }
                    }
                }
                if (ST_ContactTel != "")
                {
                    student.OneTel = ST_ContactTel.ToString();
                }
                db.SaveChanges();
                LoadData(ST_Num);
                ViewBag.Changed = true;
                ShowNotify("修改成功");
                return(View("Index"));

                #endregion
            }
        }
Example #14
0
        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"));
            }
        }