Exemple #1
0
        public ActionResult btnLogin_Click(FormCollection formvalues)
        {
            if (formvalues["tbxOldPwd"] != null && formvalues["tbxNewPwd"] != null)
            {
                //修改账号密码
                string UserID = Session["UserID"].ToString();
                string oldPwd = formvalues["tbxOldPwd"].ToString();
                string newPwd = formvalues["tbxNewPwd"].ToString();

                var accountList = from T_Account in db.T_Account where ((T_Account.Psd == oldPwd) && (T_Account.ID == UserID)) select T_Account;
                if (accountList.Any())
                {
                    //修改密码
                    T_Account account = accountList.ToList().First();
                    account.Psd = newPwd;
                    db.SaveChanges();
                    ShowNotify("密码更新成功!");
                }
                else
                {
                    //密码错误
                    ShowNotify("密码错误!");
                    //清空输入框
                }
            }
            if (formvalues["tbxPwd"] != null && formvalues["tbxST_Num"] != null)
            {
                //初始化学生密码
                string UserID  = Session["UserID"].ToString();
                string UserPwd = formvalues["tbxPwd"].ToString();
                string ST_NUM  = formvalues["tbxST_Num"].ToString();

                var accountlist = from T_Account in db.T_Account where ((T_Account.Psd == UserPwd) && (T_Account.ID == UserID)) select T_Account;
                if (accountlist.Any())
                {
                    //密码正确
                    T_Account account = db.T_Account.Find(ST_NUM);
                    if (account != null)
                    {
                        //此账号存在
                        account.Psd = ST_NUM.Substring(ST_NUM.Length - 6, 6);
                        db.SaveChanges();
                        ShowNotify("密码初始化成功,为学号后六位!");
                    }
                    else
                    {
                        //此账号不存在
                        ShowNotify("该学生账号不存在,请重新核对!");
                    }
                }
                else
                {
                    //密码错误
                }
            }
            return(UIHelper.Result());
        }
Exemple #2
0
        public ApiBaseResult Revoke(string leavelistID, string access_token)
        {
            ApiBaseResult result = Check(access_token);

            if (result == null)
            {
                result = new ApiBaseResult();

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

                #region 获取数据

                string UserID = access_token.Substring(0, access_token.IndexOf("_"));

                var list = from T_LeaveList in db.T_LeaveList where ((T_LeaveList.StudentID == UserID) && (T_LeaveList.ID == leavelistID)) select T_LeaveList;//注意,不能删除其他人的请假记录

                if (list.Any())
                {
                    T_LeaveList ll = db.T_LeaveList.Find(leavelistID);
                    if (ll.StateBack == "0" && ll.StateLeave == "0")
                    {
                        db.T_LeaveList.Remove(ll);
                        db.SaveChanges();
                        result.result   = "success";
                        result.messages = "撤回成功!";
                    }
                    else
                    {
                        result.result   = "error";
                        result.messages = "非待审核状态,不能撤回!";
                    }
                }
                else
                {
                    result.result   = "error";
                    result.messages = "该条请假记录不存在!";
                }

                #endregion

                return(result);
            }
            else
            {
                return(result);
            }
        }
Exemple #3
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);
            }
        }
        public ActionResult btnNight_Click(FormCollection form)
        {
            string     teacherid = Session["UserID"].ToString();
            T_Deadline t_deadline;
            string     date     = form["dpNight"];
            string     time     = form["tpNight"];
            string     datetime = date + " " + time + ":00";
            DateTime   d_time   = Convert.ToDateTime(datetime);

            var night = from d in db.T_Deadline
                        where d.TypeID == type_night && d.TeacherID == teacherid
                        select d;

            if (night.Count() > 0)
            {
                t_deadline                 = night.First();
                t_deadline.Time            = d_time;
                db.Entry(t_deadline).State = EntityState.Modified;
            }
            else
            {
                t_deadline           = new T_Deadline();
                t_deadline.Time      = d_time;
                t_deadline.TypeID    = type_night;
                t_deadline.TeacherID = teacherid;

                db.T_Deadline.Add(t_deadline);
            }
            db.SaveChanges();

            Alert alert = new Alert();

            alert.Message     = "截止时间设置成功!";
            alert.EnableClose = false;
            alert.Show();

            return(UIHelper.Result());
        }
        protected bool UpdateTime(string TeacherID)
        {
            bool flag = false;

            var timelist = from T_Batch in db.T_Batch where (T_Batch.TeacherID == TeacherID) select T_Batch;

            if (timelist.Any())
            {
                foreach (T_Batch batch in timelist.ToList())
                {
                    DateTime _lastTime = batch.Datetime;
                    if (DateTime.Now > _lastTime)
                    {
                        //晚点名已过期
                        T_Batch newBatch = db.T_Batch.Find(batch.ID);
                        string  time     = _lastTime.ToString("yyyy-MM-dd HH:mm:ss").Substring(10, 9);

                        int weeknow = Convert.ToInt32(DateTime.Now.DayOfWeek);
                        weeknow = (weeknow == 0 ? 7 : weeknow);
                        int    daydiff = (7 - weeknow);
                        string LastDay = "";
                        if (daydiff == 0)
                        {
                            LastDay = DateTime.Now.AddDays(7).ToString("yyyy-MM-dd");
                        }
                        else
                        {
                            LastDay = DateTime.Now.AddDays(daydiff).ToString("yyyy-MM-dd");
                        }
                        string newTime = LastDay + time;

                        newBatch.Datetime = Convert.ToDateTime(newTime);
                        db.SaveChanges();
                        flag = true;
                    }
                }
                //db.SaveChanges();
                ShowNotify("已完成晚点名时间更新!");
            }
            else
            {
                //无数据
                ShowNotify("无晚点名数据!");
            }
            return(flag);
        }
        /// <summary>
        /// 将发送的短信内容保存至数据库
        /// </summary>
        /// <param name="ST_NUM"></param>
        /// <param name="LV_Num"></param>
        /// <param name="ST_Tel"></param>
        /// <param name="MessageType"></param>
        /// <returns></returns>
        private static bool SaveMessageList(string ST_Num, string LV_Num, string ST_Tel, string MessageType)
        {
            T_SendList LL = new T_SendList();

            LL.LV_Num      = LV_Num;
            LL.ST_Num      = ST_Num;
            LL.MessageType = MessageType;
            LL.ST_Tel      = ST_Tel;
            LL.timeString  = DateTime.Now;
            db.T_SendList.Add(LL);
            try
            {
                db.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public ApiBaseResult Authorize([FromBody] User_Login user_login_info)
        {
            ApiBaseResult result = new ApiBaseResult();

            string UserID  = "";
            string UserPSd = "";
            string YiBanID = "";

            #region 检查参数是否正确

            if (user_login_info == null)
            {
                //参数错误
                result.result   = "error";
                result.messages = "未接收到合法参数!";
                return(result);
            }
            else
            {
                //存在合法参数正确
                try
                {
                    UserID  = user_login_info.UserID;
                    UserPSd = user_login_info.UserPsd;
                    YiBanID = user_login_info.YiBanID;
                    if (UserID == null || UserPSd == null || YiBanID == null)
                    {
                        result.result   = "error";
                        result.messages = "参数格式错误或缺少参数!";
                        return(result);
                    }
                }
                catch
                {
                    result.result   = "error";
                    result.messages = "参数格式错误或缺少参数!";
                    return(result);
                }
            }

            #endregion

            #region 账号绑定

            var accountList = from T_Account in db.T_Account where (T_Account.YiBanID == YiBanID) select T_Account;
            if (accountList.Any())
            {
                //此账号已绑定
                result.result   = "error";
                result.messages = "此账号已绑定!";
            }
            else
            {
                //此账号尚未绑定
                T_Account account = db.T_Account.Find(UserID);
                if (account != null)
                {
                    if (account.Psd == UserPSd)
                    {
                        //验证通过
                        string GuidString   = Guid.NewGuid().ToString();
                        string access_token = UserID + "_" + GuidString;
                        account.YiBanID        = YiBanID;
                        account.YB_AccessToken = GuidString;
                        db.SaveChanges();

                        AccessToken authorizeModel = new AccessToken();
                        authorizeModel.access_token = access_token;
                        result.result = "success";
                        result.data   = authorizeModel;
                    }
                    else
                    {
                        //用户密码错误
                        result.result   = "error";
                        result.messages = "账号密码错误!";
                    }
                }
                else
                {
                    //此用户ID不存在
                    result.result   = "error";
                    result.messages = "此用户ID不存在!";
                }
            }

            #endregion

            return(result);
        }
        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
            }
        }
Exemple #9
0
        public ActionResult btnSubmit_Click(FormCollection form, JArray first, JArray second, JArray third)
        {
            string teacherid  = Session["UserID"].ToString();
            string date       = form["dpDate"];
            string time_one   = form["tpFirst"];
            string time_two   = form["tpSecond"];
            string time_three = form["tpThird"];

            DateTime dt_one   = Convert.ToDateTime(date + " " + time_one + ":00");
            DateTime dt_two   = Convert.ToDateTime(date + " " + time_two + ":00");
            DateTime dt_three = Convert.ToDateTime(date + " " + time_three + ":00");

            T_Batch batch;
            T_Class t_class;
            Guid    id;

            #region 清除该辅导员管理的班级的批次信息
            var classes = from c in db.T_Class
                          where c.TeacherID == teacherid
                          select c;
            foreach (var item in classes)
            {
                item.Batch           = null;
                db.Entry(item).State = EntityState.Modified;
            }
            db.SaveChanges();
            #endregion

            #region 第一批
            if ((time_one != null) && (first.Count > 0))
            {
                batch = new T_Batch();

                var batch_id = from b in db.T_Batch
                               where b.Batch == 1 && b.TeacherID == teacherid
                               select b.ID;

                //辅导员是否设置过晚点名通知
                if (batch_id.Count() == 0)
                {
                    batch.ID        = Guid.NewGuid();
                    batch.Batch     = 1;
                    batch.TeacherID = teacherid;
                    batch.Datetime  = dt_one;
                    db.T_Batch.Add(batch);
                }
                else
                {
                    id                    = batch_id.ToList().First();
                    batch                 = db.T_Batch.Find(id);
                    batch.Datetime        = dt_one;
                    db.Entry(batch).State = EntityState.Modified;
                }
                db.SaveChanges();

                batch_id = from b in db.T_Batch
                           where b.Batch == 1 && b.TeacherID == teacherid
                           select b.ID;
                id = batch_id.ToList().First();
                foreach (JObject item in first)
                {
                    t_class                 = db.T_Class.Find(item["ID"].ToString());
                    t_class.Batch           = id;
                    db.Entry(t_class).State = EntityState.Modified;
                }
                db.SaveChanges();
            }
            #endregion

            #region 第二批
            if ((time_two != null) && (second.Count > 0))
            {
                batch = new T_Batch();
                var batch_id = from b in db.T_Batch
                               where b.Batch == 2 && b.TeacherID == teacherid
                               select b.ID;

                //辅导员是否设置过晚点名通知
                if (batch_id.Count() == 0)
                {
                    batch.ID        = Guid.NewGuid();
                    batch.Batch     = 2;
                    batch.TeacherID = teacherid;
                    batch.Datetime  = dt_two;
                    db.T_Batch.Add(batch);
                }
                else
                {
                    id                    = batch_id.ToList().First();
                    batch                 = db.T_Batch.Find(id);
                    batch.Datetime        = dt_two;
                    db.Entry(batch).State = EntityState.Modified;
                }
                try
                {
                    db.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                }


                batch_id = from b in db.T_Batch
                           where b.Batch == 2 && b.TeacherID == teacherid
                           select b.ID;
                id = batch_id.ToList().First();
                foreach (JObject item in second)
                {
                    t_class                 = db.T_Class.Find(item["ID"].ToString());
                    t_class.Batch           = id;
                    db.Entry(t_class).State = EntityState.Modified;
                }
                db.SaveChanges();
            }
            #endregion

            #region 第三批
            if ((time_three != null) && (third.Count > 0))
            {
                batch = new T_Batch();
                var batch_id = from b in db.T_Batch
                               where b.Batch == 3 && b.TeacherID == teacherid
                               select b.ID;

                //辅导员是否设置过晚点名通知
                if (batch_id.Count() == 0)
                {
                    batch.ID        = Guid.NewGuid();
                    batch.Batch     = 3;
                    batch.TeacherID = teacherid;
                    batch.Datetime  = dt_three;
                    db.T_Batch.Add(batch);
                }
                else
                {
                    id                    = batch_id.ToList().First();
                    batch                 = db.T_Batch.Find(id);
                    batch.Datetime        = dt_three;
                    db.Entry(batch).State = EntityState.Modified;
                }
                db.SaveChanges();

                batch_id = from b in db.T_Batch
                           where b.Batch == 3 && b.TeacherID == teacherid
                           select b.ID;
                id = batch_id.ToList().First();
                foreach (JObject item in third)
                {
                    t_class                 = db.T_Class.Find(item["ID"].ToString());
                    t_class.Batch           = id;
                    db.Entry(t_class).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }
            #endregion

            Alert alert = new Alert();
            alert.Message     = "晚点名通知设置成功";
            alert.EnableClose = false;
            alert.Show();
            return(UIHelper.Result());
        }