Ejemplo n.º 1
0
        private int DeleteTblPeriodLock(TblPeriodLock row)
        {
            using (var context = new TimeAttEntities())
            {
                var oldRow = (from e in context.TblPeriodLocks
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.Iserial);
        }
Ejemplo n.º 2
0
        public void SaveMainRow()
        {
            if (SelectedMainRow != null)
            {
                var valiationCollection = new List <ValidationResult>();

                var isvalid = Validator.TryValidateObject(SelectedMainRow, new ValidationContext(SelectedMainRow, null, null), valiationCollection, true);

                if (isvalid)
                {
                    var save    = SelectedMainRow.Iserial == 0;
                    var saveRow = new TblPeriodLock();
                    saveRow.InjectFrom(SelectedMainRow);
                    AttService.UpdateOrInsertTblPeriodLockAsync(saveRow, save, MainRowList.IndexOf(SelectedMainRow));
                }
            }
        }
Ejemplo n.º 3
0
 private TblPeriodLock UpdateOrInsertTblPeriodLock(TblPeriodLock newRow, bool save, int index, out int outindex)
 {
     outindex = index;
     using (var context = new TimeAttEntities())
     {
         if (save)
         {
             context.TblPeriodLocks.AddObject(newRow);
         }
         else
         {
             var oldRow = (from e in context.TblPeriodLocks
                           where e.Iserial == newRow.Iserial
                           select e).SingleOrDefault();
             if (oldRow != null)
             {
                 Operations.SharedOperation.GenericUpdate(oldRow, newRow, context);
             }
         }
         context.SaveChanges();
         return(newRow);
     }
 }