Beispiel #1
0
        private int DeleteTblSupplierFabric(TblSupplierFabric row)
        {
            using (var context = new WorkFlowManagerDBEntities())
            {
                var oldRow = (from e in context.TblSupplierFabrics
                              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;
                    var saveRow = new TblSupplierFabric();
                    saveRow.InjectFrom(SelectedMainRow);
                    Client.UpdateOrInsertTblSupplierFabricAsync(saveRow, save, MainRowList.IndexOf(SelectedMainRow));
                }
            }
        }
        public SearchExternalFabricViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                Client = new CRUD_ManagerServiceClient();

                MainRowList     = new SortableCollectionView <TblSupplierFabric>();
                SelectedMainRow = new TblSupplierFabric();

                Client.GetTblSupplierFabricCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        MainRowList.Add(row);
                    }

                    Loading   = false;
                    FullCount = sv.fullCount;
                };

                GetMaindata();
            }
        }
Beispiel #4
0
 private TblSupplierFabric UpdateOrInsertTblSupplierFabric(TblSupplierFabric newRow, bool save, int index, out int outindex)
 {
     outindex = index;
     using (var context = new WorkFlowManagerDBEntities())
     {
         if (save)
         {
             context.TblSupplierFabrics.AddObject(newRow);
         }
         else
         {
             var oldRow = (from e in context.TblSupplierFabrics
                           where e.Iserial == newRow.Iserial
                           select e).SingleOrDefault();
             if (oldRow != null)
             {
                 GenericUpdate(oldRow, newRow, context);
             }
         }
         context.SaveChanges();
         return(newRow);
     }
 }