Example #1
0
        private int DeleteTblEmployeeBehalf(TblEmployeeBehalf row)
        {
            using (var context = new TimeAttEntities())
            {
                var oldRow = (from e in context.TblEmployeeBehalves
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.Iserial);
        }
Example #2
0
        public void SaveMainRowExc()
        {
            if (SelectedMainRows != null)
            {
                var valiationCollection = new List <ValidationResult>();

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

                if (isvalid)
                {
                    var save = SelectedMainRow.Iserial == 0;

                    var saveRow = new TblEmployeeBehalf();
                    saveRow.InjectFrom(SelectedMainRow);
                    if (save)
                    {
                        if (AllowAdd)
                        {
                            Loading = true;
                            Client.UpdateOrInsertTblEmployeeBehalfAsync(saveRow, save, MainRowList.IndexOf(SelectedMainRow));
                        }
                        else
                        {
                            MessageBox.Show(strings.AllowAddMsg);
                        }
                    }
                    else
                    {
                        if (AllowUpdate)
                        {
                            Loading = true;
                            Client.UpdateOrInsertTblEmployeeBehalfAsync(saveRow, save, MainRowList.IndexOf(SelectedMainRow));
                        }
                        else
                        {
                            MessageBox.Show(strings.AllowUpdateMsg);
                        }
                    }
                }
            }
        }
Example #3
0
 private TblEmployeeBehalf UpdateOrInsertTblEmployeeBehalf(TblEmployeeBehalf newRow, bool save, int index, out int outindex)
 {
     outindex = index;
     using (var context = new TimeAttEntities())
     {
         if (save)
         {
             context.TblEmployeeBehalves.AddObject(newRow);
         }
         else
         {
             var oldRow = (from e in context.TblEmployeeBehalves
                           where e.Iserial == newRow.Iserial
                           select e).SingleOrDefault();
             if (oldRow != null)
             {
                 GenericUpdate(oldRow, newRow, context);
             }
         }
         context.SaveChanges();
         return(newRow);
     }
 }