Beispiel #1
0
        public ActionResult AlarmEditSaveChange(ALarmEditViewModel model)
        {
            using (ANDONEntities entities = new ANDONEntities())
            {
                bool result = false;
                try
                {
                    Alarm_edit alarm = entities.Alarm_edit.Where(t => t.ID == model.ID).FirstOrDefault();
                    alarm.Start_time         = model.Start_time;
                    alarm.End_time           = model.End_time;
                    alarm.Reason             = model.Reason;
                    alarm.Responsible        = model.Responsible;
                    alarm.Division_of_respon = model.Division_of_respon;
                    UserModel user = GetCurrentUser();
                    alarm.Recorder = user.UName + "(" + user.UID + ")";

                    DateTime startTime, endTime;
                    if (model.Start_time.HasValue && model.End_time.HasValue)
                    {
                        startTime = model.Start_time.Value;
                        endTime   = model.End_time.Value;
                        TimeSpan ts = endTime - startTime;
                        alarm.Duration = ts.TotalSeconds.ToString();
                    }
                    entities.SaveChanges();
                    result = true;
                }
                catch (Exception e)
                {
                }

                return(Json(result));
            }
        }
Beispiel #2
0
        public ActionResult DeleteAlarmEidt(int ID)
        {
            bool result = false;

            using (ANDONEntities entities = new ANDONEntities())
            {
                Alarm_edit a = entities.Alarm_edit.Find(ID);
                a.Delete_flag = true;
                entities.SaveChanges();
                result = true;
            }
            return(Json(result));
        }
Beispiel #3
0
 public ActionResult Login(UserModel model)
 {
     using (ANDONEntities entities = new ANDONEntities())
     {
         string   pwd  = Untils.MD5Encrypt(model.PWD);
         user_log user = entities.user_log.Where(t => t.UID == model.UID && t.PWD == pwd).FirstOrDefault();
         if (user != null)
         {
             user.LogInTime = DateTime.Now;
             entities.SaveChanges();
             Mapper.CreateMap <user_log, UserModel>();       // 配置
             model = Mapper.Map <user_log, UserModel>(user); // 使用AutoMapper自动映射
             SessionHelper.Add("adminInfo", model, 120);
             return(Json(true));
         }
         else
         {
             return(Json(false));
         }
     }
 }
 public ActionResult ModifyNotice(Notice model)
 {
     using (ANDONEntities entities = new ANDONEntities())
     {
         bool result = false;
         try
         {
             var entity = entities.Notice.Find(model.ID);
             entity.Message = model.Message;
             entities.SaveChanges();
             result = true;
         }
         catch
         {
             result = false;
         }
         return(Json(new
         {
             result
         }
                     , JsonRequestBehavior.AllowGet));
     }
 }
        public ActionResult UpdateSchedule(List <DateScheduleViewModel> list)
        {
            bool result = false;

            using (ANDONEntities entities = new ANDONEntities())
            {
                ShiftSet s1 = new ShiftSet
                {
                    shift = "1",
                    _1    = list[0].Day.StartTime.Split(':')[0],
                    _2    = list[0].Day.StartTime.Split(':')[1],
                    _3    = list[0].Day.EndTime.Split(':')[0],
                    _4    = list[0].Day.EndTime.Split(':')[1],
                    _5    = list[1].Day.StartTime.Split(':')[0],
                    _6    = list[1].Day.StartTime.Split(':')[1],
                    _7    = list[1].Day.EndTime.Split(':')[0],
                    _8    = list[1].Day.EndTime.Split(':')[1],
                    _9    = list[2].Day.StartTime.Split(':')[0],
                    _10   = list[2].Day.StartTime.Split(':')[1],
                    _11   = list[2].Day.EndTime.Split(':')[0],
                    _12   = list[2].Day.EndTime.Split(':')[1],
                    _13   = list[3].Day.StartTime.Split(':')[0],
                    _14   = list[3].Day.StartTime.Split(':')[1],
                    _15   = list[3].Day.EndTime.Split(':')[0],
                    _16   = list[3].Day.EndTime.Split(':')[1],
                    _17   = list[4].Day.StartTime.Split(':')[0],
                    _18   = list[4].Day.StartTime.Split(':')[1],
                    _19   = list[4].Day.EndTime.Split(':')[0],
                    _20   = list[4].Day.EndTime.Split(':')[1],
                };
                ShiftSet s2 = new ShiftSet
                {
                    shift = "2",
                    _1    = list[0].Night.StartTime.Split(':')[0],
                    _2    = list[0].Night.StartTime.Split(':')[1],
                    _3    = list[0].Night.EndTime.Split(':')[0],
                    _4    = list[0].Night.EndTime.Split(':')[1],
                    _5    = list[1].Night.StartTime.Split(':')[0],
                    _6    = list[1].Night.StartTime.Split(':')[1],
                    _7    = list[1].Night.EndTime.Split(':')[0],
                    _8    = list[1].Night.EndTime.Split(':')[1],
                    _9    = list[2].Night.StartTime.Split(':')[0],
                    _10   = list[2].Night.StartTime.Split(':')[1],
                    _11   = list[2].Night.EndTime.Split(':')[0],
                    _12   = list[2].Night.EndTime.Split(':')[1],
                    _13   = list[3].Night.StartTime.Split(':')[0],
                    _14   = list[3].Night.StartTime.Split(':')[1],
                    _15   = list[3].Night.EndTime.Split(':')[0],
                    _16   = list[3].Night.EndTime.Split(':')[1],
                    _17   = list[4].Night.StartTime.Split(':')[0],
                    _18   = list[4].Night.StartTime.Split(':')[1],
                    _19   = list[4].Night.EndTime.Split(':')[0],
                    _20   = list[4].Night.EndTime.Split(':')[1],
                };

                List <ShiftSet> sets = new List <ShiftSet> {
                    s1, s2
                };
                foreach (ShiftSet set in sets)
                {
                    string sql = string.Format(@"UPDATE [dbo].[shift_set]
   SET [1] = '{0}'
      ,[2] = '{1}'
      ,[3] = '{2}'
      ,[4] = '{3}'
      ,[5] = '{4}'
      ,[6] = '{5}'
      ,[7] = '{6}'
      ,[8] = '{7}'
      ,[9] = '{8}'
      ,[10] = '{9}'
      ,[11] = '{10}'
      ,[12] = '{11}'
      ,[13] = '{12}'
      ,[14] = '{13}'
      ,[15] = '{14}'
      ,[16] = '{15}'
      ,[17] = '{16}'
      ,[18] = '{17}'
      ,[19] = '{18}'
      ,[20] = '{19}'
 WHERE [shift]='{20}'", set._1, set._2, set._3, set._4, set._5, set._6, set._7, set._8, set._9, set._10, set._11, set._12, set._13, set._14, set._15, set._16, set._17, set._18, set._19, set._20, set.shift);
                    entities.Database.ExecuteSqlCommand(sql);
                }
                entities.SaveChanges();
                result = true;
            }
            return(Json(result));
        }