Exemplo n.º 1
0
        private EmpLeavingTransaction UpdateOrInsertEmpLeavingTransaction(EmpLeavingTransaction newRow, bool save, int index, int user, out int outindex)
        {
            outindex = index;
            using (var context = new TimeAttEntities())
            {
                if (save)
                {
                    newRow.CreationBy   = user;
                    newRow.CreationDate = DateTime.Now;
                    context.EmpLeavingTransactions.AddObject(newRow);
                }
                else
                {
                    var oldRow = (from e in context.EmpLeavingTransactions
                                  where e.Iserial == newRow.Iserial
                                  select e).SingleOrDefault();
                    if (oldRow != null)
                    {
                        GenericUpdate(oldRow, newRow, context);
                    }
                }
                context.SaveChanges();

                return(newRow);
            }
        }
Exemplo n.º 2
0
        private int DeleteEmpLeavingTransaction(EmpLeavingTransaction row)
        {
            using (var context = new TimeAttEntities())
            {
                var oldRow = (from e in context.EmpLeavingTransactions
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.Iserial);
        }
        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;
                    if (save)
                    {
                        if (AllowAdd != true)
                        {
                            return;
                        }
                    }
                    else
                    {
                        if (AllowUpdate != true)
                        {
                            return;
                        }
                    }
                    if (!Loading)
                    {
                        var saveRow = new EmpLeavingTransaction();

                        saveRow.InjectFrom(SelectedMainRow);
                        Loading = true;
                        Client.UpdateOrInsertEmpLeavingTransactionAsync(saveRow, save, 0, LoggedUserInfo.Iserial);
                    }
                }
            }
        }