Пример #1
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 (AllowUpdate != true)
                    {
                        MessageBox.Show(strings.AllowAddMsg);
                        return;
                    }
                    var saveRow = new TblSalesOrderColorTheme();
                    saveRow.InjectFrom(SelectedMainRow);

                    saveRow.TblBrand           = Brand;
                    saveRow.TblLkpBrandSection = BrandSection;
                    saveRow.TblLkpSeason       = Season;
                    Client.UpdateOrInsertTblSalesOrderColorThemeAsync(saveRow, save, MainRowList.IndexOf(SelectedMainRow));
                }
            }
        }
Пример #2
0
        private TblSalesOrderColorTheme DeleteTblSalesOrderColorTheme(TblSalesOrderColorTheme row)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var oldRow = (from e in context.TblSalesOrderColorThemes
                              where e.Iserial == row.Iserial
                              select e).SingleOrDefault();
                if (oldRow != null)
                {
                    context.DeleteObject(oldRow);
                }

                context.SaveChanges();
            }
            return(row);
        }
Пример #3
0
        private TblSalesOrderColorTheme UpdateOrInsertTblSalesOrderColorTheme(TblSalesOrderColorTheme newRow, bool save, int index, out int outindex)
        {
            outindex = index;
            using (var context = new WorkFlowManagerDBEntities())
            {
                if (save)
                {
                    context.TblSalesOrderColorThemes.AddObject(newRow);
                }
                else
                {
                    var oldRow = (from e in context.TblSalesOrderColorThemes
                                  where e.Iserial == newRow.Iserial
                                  select e).SingleOrDefault();
                    if (oldRow != null)
                    {
                        GenericUpdate(oldRow, newRow, context);
                    }
                }
                context.SaveChanges();
            }

            return(newRow);
        }