Exemplo n.º 1
0
        private TblEmpWeeklyDayOff UpdateOrInsertTblEmpWeeklyDayOff(TblEmpWeeklyDayOff 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.TblEmpWeeklyDayOffs.AddObject(newRow);
                }
                else
                {
                    var oldRow = (from e in context.TblEmpWeeklyDayOffs
                                  where e.Iserial == newRow.Iserial
                                  select e).SingleOrDefault();
                    if (oldRow != null)
                    {
                        GenericUpdate(oldRow, newRow, context);
                    }
                }
                context.SaveChanges();

                return(newRow);
            }
        }
Exemplo 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;
                    if (save)
                    {
                        if (AllowAdd != true)
                        {
                            MessageBox.Show(strings.AllowAddMsg);
                            return;
                        }
                    }
                    else
                    {
                        if (AllowUpdate != true)
                        {
                            MessageBox.Show(strings.AllowUpdateMsg);
                            return;
                        }
                    }
                    var saveRow = new TblEmpWeeklyDayOff();

                    saveRow.InjectFrom(SelectedMainRow);
                    Client.UpdateOrInsertTblEmpWeeklyDayOffAsync(saveRow, save, 0, LoggedUserInfo.Iserial);
                }
            }
        }
Exemplo n.º 3
0
        private int DeleteTblEmpWeeklyDayOff(TblEmpWeeklyDayOff row)
        {
            using (var context = new TimeAttEntities())
            {
                var oldRow = (from e in context.TblEmpWeeklyDayOffs
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row.Iserial);
        }