Ejemplo n.º 1
0
        /// <summary>
        /// 修改个人的lock锁
        /// </summary>
        /// <param name="operation">状态修改的目标值这里为char类型,只传一个字符就可以例如‘1’</param>
        /// <param name="date">日期</param>
        /// <param name="username">个人id</param>
        public bool ModifyInfor(char operation, int date, string username)
        {
            Student student = new Student();
            bool    flag    = false;
            Help    h       = new Help();

            using (var context = new LSSDataContext())
            {
                using (var transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        if (h.IsStudentId(username))
                        {
                            student = context.Student.FirstOrDefault(x => x.Sid == username);
                        }
                        else
                        {
                            student = context.Student.FirstOrDefault(x => x.Semail == username);
                        }
                        if (student != null)
                        {
                            char[] old = { student.Slock.ElementAt(0), student.Slock.ElementAt(1) };
                            if (date == 0)
                            {
                                old[0] = operation;           //修改第一天的状态
                            }
                            else
                            {
                                old[1] = operation; //修改第二天的状态
                            }
                            string str = new string(old);
                            student.Slock = str;
                            context.Update(student);
                            context.SaveChanges();
                            transaction.Commit();
                            flag = true;
                        }
                    }
                    catch (Exception)
                    {
                        transaction.Rollback();
                        return(false);
                    }
                    return(flag);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改学生得信誉积分,每次修改减1
        /// </summary>
        /// <param name="sid">学生学号</param>
        /// <returns></returns>
        public bool DuctGlory(string sid)
        {
            bool flag = false;

            using (var dbContext = new LSSDataContext())
            {
                Student student = new Student();
                student = dbContext.Student.FirstOrDefault(x => x.Sid == sid);
                if (student != null)
                {
                    student.Svalue = student.Svalue + 1;
                    dbContext.Update(student);
                    dbContext.SaveChanges();
                    flag = true;
                }
            }
            return(flag);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 修改下次打卡时间
        /// </summary>
        /// <param name="oid">订单id</param>
        /// <param name="v">打卡时间的string类型</param>
        public bool ChangeClockTime(string oid, string v)
        {
            bool flag = false;

            using (var dbContext = new LSSDataContext())
            {
                Order order = new Order();
                order = dbContext.Order.FirstOrDefault(x => x.Oid == oid);
                if (order != null)
                {
                    DateTime ka2 = Convert.ToDateTime(v);
                    order.Octime = ka2;
                    dbContext.Update(order);
                    flag = true;
                }
            }
            return(flag);
        }